From 9b185c20d76b10b08bf403680aa9fc6433ffc073 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 11 Jan 2023 14:51:02 -0800 Subject: [PATCH 001/582] first commit moving ecosim_pk to my fork --- src/pks/ecosim_pk/BGCEngine.cc | 630 +++++++++++++++ src/pks/ecosim_pk/BGCEngine.hh | 173 +++++ src/pks/ecosim_pk/CMakeLists.txt | 64 ++ src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 729 ++++++++++++++++++ src/pks/ecosim_pk/Ecosim_ATS_interface.hh | 147 ++++ src/pks/ecosim_pk/ats_ecosim_registration.hh | 19 + .../ecosim_pk/ats_ecosim_registration.hh.in | 19 + 7 files changed, 1781 insertions(+) create mode 100644 src/pks/ecosim_pk/BGCEngine.cc create mode 100644 src/pks/ecosim_pk/BGCEngine.hh create mode 100644 src/pks/ecosim_pk/CMakeLists.txt create mode 100644 src/pks/ecosim_pk/EcoSIM_ATS_interface.cc create mode 100644 src/pks/ecosim_pk/Ecosim_ATS_interface.hh create mode 100644 src/pks/ecosim_pk/ats_ecosim_registration.hh create mode 100644 src/pks/ecosim_pk/ats_ecosim_registration.hh.in diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc new file mode 100644 index 000000000..67fca6d60 --- /dev/null +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -0,0 +1,630 @@ +/* + Alquimia + + Copyright 2010-201x held jointly by LANS/LANL, LBNL, and PNNL. + Amanzi is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Jeffrey Johnson + Sergi Molins + + This implements the Alquimia chemistry engine. +*/ + +#include +#include +#include +#include +#include "ChemistryEngine.hh" +#include "errors.hh" +#include "exceptions.hh" + +// Support for manipulating floating point exception handling. +#ifdef _GNU_SOURCE +#define AMANZI_USE_FENV +#include +#endif + +namespace Amanzi { +namespace EcoSIM { + +namespace { + +//Here are the major function that the engine will need + +void CopyEcoSIMState(EcoSIMState* dest, EcoSIMState* src) +{ + dest->water_density = src->water_density; + dest->porosity = src->porosity; + dest->temperature = src->temperature; + dest->aqueous_pressure = src->aqueous_pressure; + memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); + memcpy(dest->total_immobile.data, src->total_immobile.data, sizeof(double) * src->total_immobile.size); + memcpy(dest->mineral_volume_fraction.data, src->mineral_volume_fraction.data, sizeof(double) * src->mineral_volume_fraction.size); + memcpy(dest->mineral_specific_surface_area.data, src->mineral_specific_surface_area.data, sizeof(double) * src->mineral_specific_surface_area.size); + memcpy(dest->surface_site_density.data, src->surface_site_density.data, sizeof(double) * src->surface_site_density.size); + memcpy(dest->cation_exchange_capacity.data, src->cation_exchange_capacity.data, sizeof(double) * src->cation_exchange_capacity.size); +} + +// These functions are going into the next release of Alquimia. +void CopyEcoSIMProperties(EcoSIMProperties* dest, EcoSIMProperties* src) +{ + dest->volume = src->saturation; + dest->saturation = src->saturation; + memcpy(dest->aqueous_kinetic_rate_cnst.data, src->aqueous_kinetic_rate_cnst.data, sizeof(double) * src->aqueous_kinetic_rate_cnst.size); + memcpy(dest->mineral_rate_cnst.data, src->mineral_rate_cnst.data, sizeof(double) * src->mineral_rate_cnst.size); + memcpy(dest->isotherm_kd.data, src->isotherm_kd.data, sizeof(double) * src->isotherm_kd.size); + memcpy(dest->freundlich_n.data, src->freundlich_n.data, sizeof(double) * src->freundlich_n.size); + memcpy(dest->langmuir_b.data, src->langmuir_b.data, sizeof(double) * src->langmuir_b.size); +} + +void CopyEcoSIMAuxiliaryData(EcoSIMAuxiliaryData* dest, EcoSIMAuxiliaryData* src) +{ + memcpy(dest->aux_ints.data, src->aux_ints.data, sizeof(int) * src->aux_ints.size); + memcpy(dest->aux_doubles.data, src->aux_doubles.data, sizeof(double) * src->aux_doubles.size); +} + +} // namespace + + +BGCEngine::BGCEngine(const std::string& engineName, + const std::string& inputFile) : + bgc_engine_name_(engineName), + bgc_engine_inputfile_(inputFile) +{ + Errors::Message msg; + + // NOTE: Alquimia now has a "hands-off" mode in which Alquimia relies on + // NOTE: reaction properties from the engine as opposed to the ones provided + // NOTE: in Amanzi's input file. As stop-gap solution hands-off is indicated + // NOTE: by the + sign at end of engine name + bool hands_off = false; + if (bgc_engine_name_ == "EcoSIM") hands_off = true; + + if (bgc_engine_name_ != "EcoSIM") + { + msg << "BGCEngine: Unsupported bgc engine: '" << bgc_engine_name_ << "'\n"; + msg << " Only option for now is 'EcoSIM'.\n"; + Exceptions::amanzi_throw(msg); + } + + // All alquimia function calls require a status object. + // AllocateAlquimiaEngineStatus is in the alquimia code in alquimia_memory.c + // The Allocate engine status function creates an object called "status" + // and fills an element called message with calloc. This is maybe just + // for error handling so I think it can be ignored + //AllocateAlquimiaEngineStatus(&chem_status_); + + //CreateAlquimiaInterface - in alquimia code in alquimia_interface.c + //This points the code to the processes for the two geochemistry codes + // PFloTran and CrunchFlow and points the Chemistry engine functions to + // Their corresponding functions in the drivers depending on which + // of the geochemsitry codes. I think to start we can simply just point this + // code directly to the EcoSIM dirver functions for the following processes: + // Setup, Shutdown, ProcessCondition, ReactionStepOperatorSplit (advance), + // GetAquxiliaryOutput (not neccesary for now), + // GetProblemMetaData (not neccesary) + // Thefore, for now I don't think we need this + /*CreateAlquimiaInterface(chem_engine_name_.c_str(), &chem_, &chem_status_); + if (chem_status_.error != 0) + { + std::cout << chem_status_.message << std::endl; + msg << "ChemistryEngine: Could not create an interface to Alquimia."; + Exceptions::amanzi_throw(msg); + }*/ + + + //This calls the Setup function that we pointed the code to within alquimia + + chem_.Setup(chem_engine_inputfile_.c_str(), + hands_off, + &engine_state_, + &sizes_, + &functionality_, + &chem_status_); + if (chem_status_.error != 0) + { + std::cout << chem_status_.message << std::endl; + PrintAlquimiaSizes(&sizes_, stdout); + msg << "Error in creation of ChemistryEngine."; + Exceptions::amanzi_throw(msg); + } + + // Allocate storage for additional Alquimia data. + AllocateAlquimiaProblemMetaData(&sizes_, &chem_metadata_); + + // Get the problem metadata (species and mineral names, etc). + chem_.GetProblemMetaData(&engine_state_, + &chem_metadata_, + &chem_status_); + if (chem_status_.error != 0) + { + std::cout << chem_status_.message << std::endl; + PrintAlquimiaProblemMetaData(&chem_metadata_, stdout); + msg << "Error in ChemistryEngine::Initialize"; + Exceptions::amanzi_throw(msg); + } +} + +ChemistryEngine::~ChemistryEngine() +{ + chem_.Shutdown(&engine_state_, &chem_status_); + FreeAlquimiaProblemMetaData(&chem_metadata_); + + // Delete the various geochemical conditions. + for (GeochemicalConditionMap::iterator + iter = chem_conditions_.begin(); iter != chem_conditions_.end(); ++iter) + { + FreeAlquimiaGeochemicalCondition(&iter->second->condition); + FreeAlquimiaState(&iter->second->chem_state); + FreeAlquimiaProperties(&iter->second->mat_props); + FreeAlquimiaAuxiliaryData(&iter->second->aux_data); + delete iter->second; + } + + FreeAlquimiaEngineStatus(&chem_status_); +} + +void ChemistryEngine::InitState(AlquimiaProperties& mat_props, + AlquimiaState& chem_state, + AlquimiaAuxiliaryData& aux_data, + AlquimiaAuxiliaryOutputData& aux_output) +{ + AllocateAlquimiaProperties(&sizes_, &mat_props); + AllocateAlquimiaState(&sizes_, &chem_state); + AllocateAlquimiaAuxiliaryData(&sizes_, &aux_data); + AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); + + // Make sure the auxiliary ints/doubles are zeroed out. + std::fill(aux_data.aux_ints.data, aux_data.aux_ints.data + aux_data.aux_ints.size, 0); + std::fill(aux_data.aux_doubles.data, aux_data.aux_doubles.data + aux_data.aux_doubles.size, 0.0); +} + +void ChemistryEngine::FreeState(AlquimiaProperties& mat_props, + AlquimiaState& chem_state, + AlquimiaAuxiliaryData& aux_data, + AlquimiaAuxiliaryOutputData& aux_output) +{ + FreeAlquimiaProperties(&mat_props); + FreeAlquimiaState(&chem_state); + FreeAlquimiaAuxiliaryData(&aux_data); + FreeAlquimiaAuxiliaryOutputData(&aux_output); +} + +bool ChemistryEngine::Advance(const double delta_time, + const AlquimiaProperties& mat_props, + AlquimiaState& chem_state, + AlquimiaAuxiliaryData& aux_data, + AlquimiaAuxiliaryOutputData& aux_output, + int& num_iterations) +{ +#ifdef AMANZI_USE_FENV + // Disable divide-by-zero floating point exceptions. + int fpe_mask = fedisableexcept(FE_DIVBYZERO); +#endif + + // Advance the chemical reaction all operator-split-like. + chem_.ReactionStepOperatorSplit(&engine_state_, + delta_time, + &(const_cast(mat_props)), + &chem_state, + &aux_data, + &chem_status_); + +#ifdef AMANZI_USE_FENV + // Re-enable pre-existing floating point exceptions. + feclearexcept(fpe_mask); + fpe_mask = feenableexcept(fpe_mask); +#endif + + // Retrieve auxiliary output. + chem_.GetAuxiliaryOutput(&engine_state_, + &(const_cast(mat_props)), + &chem_state, + &aux_data, + &aux_output, + &chem_status_); + + // Did we succeed? + if (chem_status_.error != kAlquimiaNoError) + return false; + + // Did we converge? + if (!chem_status_.converged) + return false; + + // Write down the (maximum) number of Newton iterations. + num_iterations = chem_status_.num_newton_iterations; + return true; +} + +void ChemistryEngine::CreateCondition(const std::string& condition_name) +{ + // NOTE: a condition with zero aqueous/mineral constraints is assumed to be defined in + // NOTE: the backend engine's input file. + GeochemicalConditionData* condition = new GeochemicalConditionData(); + condition->processed = false; + int num_aq = 0, num_min = 0; + AllocateAlquimiaProperties(&sizes_, &condition->mat_props); + AllocateAlquimiaGeochemicalCondition(kAlquimiaMaxStringLength, num_aq, num_min, &condition->condition); + AllocateAlquimiaState(&sizes_, &condition->chem_state); + AllocateAlquimiaAuxiliaryData(&sizes_, &condition->aux_data); + std::strcpy(condition->condition.name, condition_name.c_str()); + + // Add this to the conditions map. + chem_conditions_[condition_name] = condition; +} + + +/* Mineral constraints will be discontinued in Alquimia -- see Sergi + +void ChemistryEngine::AddMineralConstraint(const std::string& condition_name, + const std::string& mineral_name, + double volume_fraction, + double specific_surface_area) +{ + assert(condition_name.length() > 0); + assert(volume_fraction >= 0.0); + assert(specific_surface_area >= 0.0); + + GeochemicalConditionMap::iterator iter = chem_conditions_.find(condition_name); + if (iter != chem_conditions_.end()) + { + AlquimiaGeochemicalCondition* condition = &iter->second->condition; + + // Do we have an existing constraint? + int index = -1; + for (int i = 0; i < condition->mineral_constraints.size; ++i) + { + if (!std::strcmp(condition->mineral_constraints.data[i].mineral_name, mineral_name.c_str())) + { + // Overwrite the old constraint. + index = i; + free(condition->mineral_constraints.data[index].mineral_name); + } + } + if (index == -1) + { + // New constraint! + index = condition->mineral_constraints.size; + condition->mineral_constraints.size++; + condition->mineral_constraints.data = (AlquimiaMineralConstraint*)realloc(condition->mineral_constraints.data, sizeof(AlquimiaMineralConstraint) * (index+1)); + } + + // Add the mineral constraint. + condition->mineral_constraints.data[index].mineral_name = strdup(mineral_name.c_str()); + condition->mineral_constraints.data[index].volume_fraction = volume_fraction; + condition->mineral_constraints.data[index].specific_surface_area = specific_surface_area; + } + else + { + Errors::Message msg; + msg << "ChemistryEngine::AddMineralConstraint: no condition named '" << condition_name << "'."; + Exceptions::amanzi_throw(msg); + } +} +Mineral constraints will be discontinued in Alquimia -- see Sergi */ + + +void ChemistryEngine::AddAqueousConstraint(const std::string& condition_name, + const std::string& primary_species_name, + const std::string& constraint_type, + const std::string& associated_species) +{ + assert(condition_name.length() > 0); + assert(primary_species_name.length() > 0); + assert((constraint_type == "total_aqueous") || (constraint_type == "charge") || + (constraint_type == "free") || (constraint_type == "mineral") || + (constraint_type == "gas") || (constraint_type == "pH")); + + GeochemicalConditionMap::iterator iter = chem_conditions_.find(condition_name); + if (iter != chem_conditions_.end()) + { + AlquimiaGeochemicalCondition* condition = &iter->second->condition; + + /* Mineral constraints will be discontinued from Alquimia in the near future -- see Sergi + + // Is there a mineral constraint for the associated species? + if (!associated_species.empty()) + { + bool found_mineral = false; + for (int i = 0; i < condition->mineral_constraints.size; ++i) + { + if (!std::strcmp(condition->mineral_constraints.data[i].mineral_name, associated_species.c_str())) + found_mineral = true; + } + if (!found_mineral) + { + Errors::Message msg; + msg << "ChemistryEngine::AddAqueousConstraint: the condition '" << condition_name << "' does not have a mineral constraint for '" << associated_species << "'."; + Exceptions::amanzi_throw(msg); + } + } + + Mineral constraints will be discontinued from Alquimia in the near future -- see Sergi */ + + // Do we have an existing constraint? + int index = -1; + for (int i = 0; i < condition->aqueous_constraints.size; ++i) + { + if (!std::strcmp(condition->aqueous_constraints.data[i].primary_species_name, primary_species_name.c_str())) + { + // Overwrite the old constraint. + index = i; + free(condition->aqueous_constraints.data[index].primary_species_name); + free(condition->aqueous_constraints.data[index].constraint_type); + if (condition->aqueous_constraints.data[index].associated_species != NULL) + free(condition->aqueous_constraints.data[index].associated_species); + } + } + if (index == -1) + { + // New constraint! + index = condition->aqueous_constraints.size; + condition->aqueous_constraints.size++; + condition->aqueous_constraints.data = (AlquimiaAqueousConstraint*)realloc(condition->aqueous_constraints.data, sizeof(AlquimiaAqueousConstraint) * (index+1)); + } + + // Add the aqueous constraint. + condition->aqueous_constraints.data[index].primary_species_name = strdup(primary_species_name.c_str()); + condition->aqueous_constraints.data[index].constraint_type = strdup(constraint_type.c_str()); + if (!associated_species.empty()) + condition->aqueous_constraints.data[index].associated_species = strdup(associated_species.c_str()); + else + condition->aqueous_constraints.data[index].associated_species = NULL; + } + else + { + Errors::Message msg; + msg << "ChemistryEngine::AddAqueousConstraint: no condition named '" << condition_name << "'."; + Exceptions::amanzi_throw(msg); + } +} + +void ChemistryEngine::EnforceCondition(const std::string& condition_name, + const double time, + const AlquimiaProperties& mat_props, + AlquimiaState& chem_state, + AlquimiaAuxiliaryData& aux_data, + AlquimiaAuxiliaryOutputData& aux_output) +{ + Errors::Message msg; + + // Retrieve the chemical condition for the given name. + GeochemicalConditionMap::iterator iter = chem_conditions_.find(condition_name); + if (iter == chem_conditions_.end()) + { + CreateCondition(condition_name); + iter = chem_conditions_.find(condition_name); + } + +#ifdef AMANZI_USE_FENV + // Disable divide-by-zero floating point exceptions. + int fpe_mask = fedisableexcept(FE_DIVBYZERO); +#endif + + AlquimiaGeochemicalCondition* condition = &iter->second->condition; + AlquimiaProperties& nc_mat_props = const_cast(mat_props); + if (!iter->second->processed) + { + // Copy the given state data into place for this condition. + CopyAlquimiaProperties(&iter->second->mat_props, &nc_mat_props); + CopyAlquimiaState(&iter->second->chem_state, &chem_state); + CopyAlquimiaAuxiliaryData(&iter->second->aux_data, &aux_data); + + // Process the condition on the given array at the given time. + // FIXME: Time is ignored for the moment. + chem_.ProcessCondition(&engine_state_, condition, &iter->second->mat_props, + &iter->second->chem_state, &iter->second->aux_data, &chem_status_); + iter->second->processed = true; + } + + // Copy the constraint's data into place. + // Here, condition names are used but Alquimia properties are + // given as "Material" zones in Amanzi's inputthus disconnecting them + // from "Initial" conditions (i.e. condition names) + // For the sake of performance, we avoid here to re-process conditions + // but we need to retain materical properties as provided in Amanzi inputs + // CopyAlquimiaProperties(&nc_mat_props, &iter->second->mat_props); + CopyAlquimiaState(&chem_state, &iter->second->chem_state); + CopyAlquimiaAuxiliaryData(&aux_data, &iter->second->aux_data); + +#ifdef AMANZI_USE_FENV + // Re-enable pre-existing floating point exceptions. + feclearexcept(fpe_mask); + fpe_mask = feenableexcept(fpe_mask); +#endif + +// FIXME: Figure out a neutral parallel-friendly way to report errors. + assert(chem_status_.error == 0); + +#if 0 + if (chem_status_.error != 0) + ierr = -1; + + // figure out if any of the processes threw an error, if so all processes will re-throw + int recv = 0; + mesh_->get_comm()->MaxAll(&ierr, &recv, 1); + if (recv != 0) + { + msg << "Error in enforcement of chemical condition '" << condition_name << "'"; + Exceptions::amanzi_throw(msg); + } +#endif +} + +const std::string& ChemistryEngine::Name() const +{ + return chem_engine_name_; +} + +bool ChemistryEngine::IsThreadSafe() const +{ + Errors::Message msg; + + if (not chem_initialized_) + { + msg << "ChemistryEngine: Cannot query before initialization!"; + Exceptions::amanzi_throw(msg); + } + + return functionality_.thread_safe; +} + +int ChemistryEngine::NumPrimarySpecies() const +{ + return sizes_.num_primary; +} + +int ChemistryEngine::NumAqueousComplexes() const +{ + return sizes_.num_aqueous_complexes; +} + +int ChemistryEngine::NumSorbedSpecies() const +{ + return sizes_.num_sorbed; +} + +void ChemistryEngine::GetPrimarySpeciesNames(std::vector& species_names) const +{ + const AlquimiaProblemMetaData* metadata = &chem_metadata_; + int N = metadata->primary_names.size; + species_names.resize(N); + for (int i = 0; i < N; ++i) + species_names[i] = std::string(metadata->primary_names.data[i]); +} + +int ChemistryEngine::NumMinerals() const +{ + return sizes_.num_minerals; +} + +void ChemistryEngine::GetMineralNames(std::vector& mineral_names) const +{ + const AlquimiaProblemMetaData* metadata = &chem_metadata_; + int N = metadata->mineral_names.size; + mineral_names.resize(N); + for (int i = 0; i < N; ++i) + mineral_names[i] = std::string(metadata->mineral_names.data[i]); +} + +int ChemistryEngine::NumSurfaceSites() const +{ + return sizes_.num_surface_sites; +} + +void ChemistryEngine::GetSurfaceSiteNames(std::vector& site_names) const +{ + const AlquimiaProblemMetaData* metadata = &chem_metadata_; + int N = metadata->surface_site_names.size; + site_names.resize(N); + for (int i = 0; i < N; ++i) + site_names[i] = std::string(metadata->surface_site_names.data[i]); +} + +int ChemistryEngine::NumIonExchangeSites() const +{ + return sizes_.num_ion_exchange_sites; +} + +void ChemistryEngine::GetIonExchangeNames(std::vector& ion_exchange_names) const +{ + const AlquimiaProblemMetaData* metadata = &chem_metadata_; + int N = metadata->ion_exchange_names.size; + ion_exchange_names.resize(N); + for (int i = 0; i < N; ++i) + ion_exchange_names[i] = std::string(metadata->ion_exchange_names.data[i]); +} + +int ChemistryEngine::NumIsothermSpecies() const +{ + return sizes_.num_isotherm_species; +} + +void ChemistryEngine::GetIsothermSpeciesNames(std::vector& species_names) const +{ + const AlquimiaProblemMetaData* metadata = &chem_metadata_; + int N = metadata->isotherm_species_names.size; + species_names.resize(N); + for (int i = 0; i < N; ++i) + species_names[i] = std::string(metadata->isotherm_species_names.data[i]); +} + +int ChemistryEngine::NumFreeIonSpecies() const +{ + return sizes_.num_primary; +} + +void ChemistryEngine::GetAuxiliaryOutputNames(std::vector& aux_names, + std::vector>& subfield_names) const +{ + aux_names.clear(); + subfield_names.clear(); + aux_names.emplace_back("pH"); + subfield_names.emplace_back(std::vector{"0"}); + + const AlquimiaProblemMetaData* metadata = &chem_metadata_; + + // Mineral data -- one per mineral. + int N = metadata->mineral_names.size; + if (N > 0) { + std::vector mineral_names; + for (int i = 0; i < N; ++i) { + mineral_names.emplace_back(metadata->mineral_names.data[i]); + } + aux_names.emplace_back("mineral_saturation_index"); + subfield_names.emplace_back(mineral_names); + aux_names.emplace_back("mineral_reaction_rate"); + subfield_names.emplace_back(std::move(mineral_names)); + } + + // Auxiliary data per primary species. + N = metadata->primary_names.size; + if (N > 0) { + std::vector primary_names; + for (int i = 0; i < N; ++i) { + primary_names.emplace_back(metadata->primary_names.data[i]); + } + aux_names.emplace_back("primary_free_ion_concentration"); + subfield_names.emplace_back(primary_names); + aux_names.emplace_back("primary_activity_coeff"); + subfield_names.emplace_back(std::move(primary_names)); + } + + // Secondary auxiliary data. + N = this->NumAqueousComplexes(); + if (N > 0) { + std::vector secondary_names; + for (int i = 0; i < N; ++i) { + secondary_names.emplace_back(std::to_string(i)); + } + aux_names.emplace_back("secondary_free_ion_concentration"); + subfield_names.emplace_back(secondary_names); + aux_names.emplace_back("secondary_activity_coeff"); + subfield_names.emplace_back(std::move(secondary_names)); + } +} + +int ChemistryEngine::NumAqueousKinetics() const +{ + return sizes_.num_aqueous_kinetics; +} + +void ChemistryEngine::GetAqueousKineticNames(std::vector& kinetics_names) const +{ + const AlquimiaProblemMetaData* metadata = &chem_metadata_; + int N = metadata->aqueous_kinetic_names.size; + kinetics_names.resize(N); + for (int i = 0; i < N; ++i) + kinetics_names[i] = std::string(metadata->aqueous_kinetic_names.data[i]); +} + +const AlquimiaSizes& ChemistryEngine::Sizes() const +{ + return sizes_; +} + +} // namespace +} // namespace diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh new file mode 100644 index 000000000..3b6feca92 --- /dev/null +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -0,0 +1,173 @@ +/* + Alqumia + + Copyright 2010-201x held jointly by LANS/LANL, LBNL, and PNNL. + Amanzi is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Author: Jeffrey Johnson + + This is a point of contact for the chemistry engine exposed by Alquimia + to the rest of Amanzi--it provides the ability to enforce geochemical + conditions and to integrate reactions given a chemical configuration. +*/ + +#ifndef AMANZI_CHEMISTRY_ENGINE_HH_ +#define AMANZI_CHEMISTRY_ENGINE_HH_ + +#include +#include +#include + +#include "alquimia/alquimia_memory.h" +#include "alquimia/alquimia_util.h" +#include "alquimia/alquimia_constants.h" +#include "alquimia/alquimia_containers.h" +#include "alquimia/alquimia_interface.h" + +namespace Amanzi { +namespace AmanziChemistry { + + +struct GeochemicalConditionData +{ + bool processed; + AlquimiaProperties mat_props; + AlquimiaGeochemicalCondition condition; + AlquimiaState chem_state; + AlquimiaAuxiliaryData aux_data; +}; + +typedef std::map GeochemicalConditionMap; + +class ChemistryEngine { + + public: + + // Constructs a chemistry engine using the given engine (backend) name and input file. + ChemistryEngine(const std::string& engineName, const std::string& inputFile); + + // Destructor. + ~ChemistryEngine(); + + // Returns the name of the backend that does the chemistry. + const std::string& Name() const; + + // Returns true if the chemistry engine is thread-safe, false if not. + bool IsThreadSafe() const; + + // These query methods return metadata for the chemical configuration represented + // within the chemistry engine. + int NumPrimarySpecies() const; + int NumAqueousComplexes() const; + int NumSorbedSpecies() const; + void GetPrimarySpeciesNames(std::vector& species_names) const; + int NumMinerals() const; + void GetMineralNames(std::vector& mineral_names) const; + int NumSurfaceSites() const; + void GetSurfaceSiteNames(std::vector& site_names) const; + int NumIonExchangeSites() const; + void GetIonExchangeNames(std::vector& ion_exchange_names) const; + int NumIsothermSpecies() const; + void GetIsothermSpeciesNames(std::vector& species_names) const; + int NumFreeIonSpecies() const; + void GetAuxiliaryOutputNames(std::vector& aux_names, + std::vector>& subfield_names) const; + int NumAqueousKinetics() const; + void GetAqueousKineticNames(std::vector& kinetics_names) const; + + // Returns a reference to a "sizes" object that can be queried to find the sizes of the various + // arrays representing the geochemical state within the engine. + const AlquimiaSizes& Sizes() const; + + // Initializes the data structures that hold the chemical state information. + void InitState(AlquimiaProperties& mat_props, + AlquimiaState& chem_state, + AlquimiaAuxiliaryData& aux_data, + AlquimiaAuxiliaryOutputData& aux_output); + + // Frees the data structures that hold the chemical state information. + void FreeState(AlquimiaProperties& mat_props, + AlquimiaState& chem_state, + AlquimiaAuxiliaryData& aux_data, + AlquimiaAuxiliaryOutputData& aux_output); + + // Creates a geochemical condition with the given name within the chemistry engine, using the + // data in the given containers. + void CreateCondition(const std::string& condition_name); + + /* Mineral constraints will be discontinued in Alquimia -- see Sergi + // Adds a mineral constraint to the geochemical condition with the given name. If another + // constraint with the same mineral name exists for this condition, it is replaced by + // this one. + void AddMineralConstraint(const std::string& condition_name, + const std::string& mineral_name, + double volume_fraction, + double specific_surface_area); + Mineral constraints will be discontinued in Alquimia -- see Sergi */ + + // Adds an aqueous constraint to the geochemical condition with the given name. If another + // constraint involving the same primary species exists for this condition, it is replaced by + // this one. + // The constraint type may be "total_aqueous", "total_sorb", "free", "mineral", "gas", + // "pH", or "charge". + // The associated (mineral) species must be the name of a mineral mentioned + // in a mineral constraint that has been previously added to this condition + // using AddMineralConstraint(). + void AddAqueousConstraint(const std::string& condition_name, + const std::string& primary_species_name, + const std::string& constraint_type, + const std::string& associated_species); + + // Enforces the geochemical condition with the given name on the chemical configuration + // represented by the given array of concentrations at the given time. The order of the + // concentrations in the array matches that of the species names returned by GetSpeciesNames. + void EnforceCondition(const std::string& condition_name, + const double time, + const AlquimiaProperties& mat_props, + AlquimiaState& chem_state, + AlquimiaAuxiliaryData& aux_data, + AlquimiaAuxiliaryOutputData& aux_output); + + // Advances the species represented by the given array of concentrations, replacing old values + // with new values. The order of the concentrations in the array matches that of the species names + // returned by GetSpeciesNames. Returns true if the advance is successful, + // false if it fails. + bool Advance(const double delta_time, + const AlquimiaProperties& mat_props, + AlquimiaState& chem_state, + AlquimiaAuxiliaryData& aux_data, + AlquimiaAuxiliaryOutputData& aux_output, + int& num_iterations); + + private: + + // Alquimia data structures. + bool chem_initialized_; + void* engine_state_; + AlquimiaEngineFunctionality functionality_; + AlquimiaSizes sizes_; + AlquimiaInterface chem_; + AlquimiaEngineStatus chem_status_; + AlquimiaProblemMetaData chem_metadata_; + + // Mapping of geochemical condition names to geochemical conditions (and flags indicating + // whether they have been processed). + GeochemicalConditionMap chem_conditions_; + + // Back-end engine name and input file. + std::string chem_engine_name_; + std::string chem_engine_inputfile_; + + // forbidden. + ChemistryEngine(); + ChemistryEngine(const ChemistryEngine&); + ChemistryEngine& operator=(const ChemistryEngine&); + +}; + +} // namespace +} // namespace + +#endif diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt new file mode 100644 index 000000000..b2bf0be7d --- /dev/null +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -0,0 +1,64 @@ +# -*- mode: cmake -*- + +add_subdirectory(constitutive_relations) + +include_directories(${ATS_SOURCE_DIR}/src/pks) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/root_storage) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/flux_uptake) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/atm_flux) + +# ATS EcoSIM pk + +set(ats_ecosim_src_files + Ecosim_interface_test.cc + constitutive_relations/flux_uptake/eco_fort_test.F90 + ) + +set(ats_ecosim_inc_files + Ecosim_interface_test.hh + constitutive_relations/flux_uptake/eco_fort_test.F90 + constitutive_relations/flux_uptake/eco_fort_test_interface_private.hh + ) + +set(ats_ecosim_link_libs + ${Teuchos_LIBRARIES} + ${Epetra_LIBRARIES} + error_handling + atk + mesh + data_structures + whetstone + operators + solvers + time_integration + state + pks + chemistry_pk + ats_pks + ats_eos + ats_operators + ecosim_relations + ) + + +add_amanzi_library(ats_ecosim + SOURCE ${ats_ecosim_src_files} + HEADERS ${ats_ecosim_inc_files} + LINK_LIBS ${ats_ecosim_link_libs}) + +#================================================ +# register evaluators/factories/pks + +register_evaluator_with_factory( + HEADERFILE Ecosim_interface_test_reg.hh + LISTNAME ATS_ECOSIM_REG +) + +#Do I need this? +#seems like you don't need the file, it's auto-generated +generate_evaluators_registration_header( + HEADERFILE ats_ecosim_registration.hh + LISTNAME ATS_ECOSIM_REG + INSTALL True +) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc new file mode 100644 index 000000000..dc53d3c09 --- /dev/null +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -0,0 +1,729 @@ +/* -*- mode: c++; indent-tabs-mode: nil -*- */ + +/*-------------------------------------------------------------------------- + ATS + + License: see $ATS_DIR/COPYRIGHT + Author: Andrew Graus + + + --------------------------------------------------------------------------*/ + +#include "Ecosim_ATS_interface.hh" +#include "pk_helpers.hh" + +namespace Amanzi { +namespace EcoSIM { + +EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, + const Teuchos::RCP& global_list, + const Teuchos::RCP& S, + const Teuchos::RCP& solution): + PK_Physical_Default(pk_tree, global_list, S, solution), + PK(pk_tree, global_list, S, solution) + { + domain_ = plist_->get("domain name", "domain"); + + // obtain key of fields + // What fields will we need to pass to EcoSIM, presumably fields relating to + // transport, flow, and energy + // What do we need for EcoSIM? Based on the variables doc it is: + // grid position (X,Y,Z) - can we just pass Z and assume X and Y are 0? + // soil texture - not sure where this is + // bulk density - not sure + // Elevation + // Aspect in geometric format + // soil texture (sand, clay, silt) + // water table depth + + // transport + tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); + + //Flow + poro_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); + saturation_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); + fluid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); + ice_den_key_ = Keys::readKey(plist_, domain, "ice mass density", "mass_density_ice"); + mass_den_key_ = Keys::readKey(plist_, domain, "mass density", mass_key); + rhos_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); + + //energy + T_key_ = Keys::readKey(plist_, domain_name, "temperature", "temperature"); + conductivity_key_ = = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); + + //Other + cv_key_ = Keys::readKey(plist_, domain_name, "cell volume", "cell_volume"); + min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); + ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); + + // parameters + // initial timestep + dt_ = plist_->get("initial time step", 1.); + //Heat capacity looks like the default units are molar heat capacity + c_m = plist_.get("heat capacity [J mol^-1 K^-1]"); + //They also sometimes use a version of heat capacity that is just this + //quantity times 1e-6: + //ka_ = 1.e-6 * plist_.get("heat capacity [J kg^-1 K^-1]"); + //Unclear what we need + + // Here is where Alquimia initializes the Chemistry engine which handles differences between + // CrunchFlow and PFlotran and eventually runs either code to advance the Chemistry + // We will probably need something like this eventually if we add in other BGC codes but it + // is very complex and we can almost certainly do something simpler to start out with to just get + // EcoSIM running. + // + // For now I'm changing the syntax from chem_engine to bgc_engine but I'll probably end up + // either cutting this out or commenting it out. + + if (!plist_->isParameter("engine")) { + Errors::Message msg; + msg << "No 'engine' parameter found in the parameter list for 'BGC'.\n"; + Exceptions::amanzi_throw(msg); + } + if (!plist_->isParameter("engine input file")) { + Errors::Message msg; + msg << "No 'engine input file' parameter found in the parameter list for 'BGC'.\n"; + Exceptions::amanzi_throw(msg); + } + std::string engine_name = plist_->get("engine"); + std::string engine_inputfile = plist_->get("engine input file"); + bgc_engine_ = Teuchos::rcp(new EcoSIM::BGCEngine(engine_name, engine_inputfile)); + //When creating the engine there are a few functions in ChemistryEngine that + //are called AllocateAlquimiaEngineStatus, CreateAlquimiaInterface, and chem_.Setup + //these are functions in the Alquimia standalone code + // + // AllocateAlquimiaEngineStatus - is in alquimia_memory.c does some simple memory + // Calculation I think. + // + // CreateAlquimiaInterface - in alquimia_interface.c, this makes the main + // decision between Pflotran and CrunchFlow, then allocates to the interface + // called chem_ where to find the processes the interface will need including + // Setup, Shutdown, ProcessCondition, ReactionStepOperatorSplit, GetAuxiliaryOutput + // GetProblemMetaData + // + // Basically it goes Alquimia PK -> ChemistryEngine -> Alquimia Interface -> + // CrunchFlow/PFloTran. We don't have to stick to this and probably just simplify to: + // EcoSIM_PK -> BGCEngine -> EcoSIM driver + + // grab the component names + // This is a small function in ChemistryEngine that simply looks at the metadata + // finds the number of primary species and fills a vector with the names of those + //species + comp_names_.clear(); + bgc_engine_->GetPrimarySpeciesNames(comp_names_); + + number_aqueous_components_ = comp_names_.size(); + number_free_ion_ = number_aqueous_components_; + number_total_sorbed_ = number_aqueous_components_; + + } + +/* ******************************************************************* +* Destroy ansilary data structures. +******************************************************************* */ +//Going to need this eventually to clear the strutures +//the various data structures were named for alquimia i.e. +//alq_mat_props_, alq_state, ect. changed to just bgc +EcoSIM::~EcoSIM() + { + if (bgc_initialized_) + bgc_engine_->FreeState(bgc_props_, bgc_state_, bgc_aux_data_); + } + + +// now the PK setup +void EcoSIM::Setup() { + std::cout << "beginning Ecosim setup\n"; + PK_Physical_Default::Setup(); + //I actually don't think we have much to do here. In BGC_simple they set up + //The arrays for the PFTs and the carbon pools but we're not going to setup + //variables in this way. Other than that it sets the required variables. It + //seems like these are things that are "owned" by this PK so the auxiliary data + //Leaving in the alquimia code for this. It seems to set the auxiliary data up + //in several different ways. Still need to understand what is going on here. + // + //To further confuse things the chemistry engine function called Setup occurs + //When the engine is created in the constructor NOT called in the PK setup + + // Set up auxiliary chemistry data using the ChemistryEngine. + + /*This is for setting up the Auxiliary Output data which I'm not sure we need + chem_engine_->GetAuxiliaryOutputNames(aux_names_, aux_subfield_names_); + for (size_t i = 0; i < aux_names_.size(); ++i) { + aux_names_[i] = Keys::getKey(domain_, aux_names_[i]); + + if (!S_->HasRecord(aux_names_[i])) { + S_->Require(aux_names_[i], tag_next_, passwd_, aux_subfield_names_[i]) + .SetMesh(mesh_)->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, aux_subfield_names_[i].size()); + } + } + */ + + //This is for the Auxiliary Data which we will need + if (plist_->isParameter("auxiliary data")) { + auto names = plist_->get >("auxiliary data"); + + for (auto it = names.begin(); it != names.end(); ++it) { + Key aux_field_name = Keys::getKey(domain_, *it); + if (!S_->HasRecord(aux_field_name)) { + S_->Require(aux_field_name, tag_next_, passwd_) + .SetMesh(mesh_)->SetGhosted(false)->SetComponent("cell", AmanziMesh::CELL, 1); + } + } + } + + // Setup more auxiliary data + if (!S_->HasRecord(alquimia_aux_data_key_, tag_next_)) { + int num_aux_data = chem_engine_->Sizes().num_aux_integers + chem_engine_->Sizes().num_aux_doubles; + S_->Require(alquimia_aux_data_key_, tag_next_, passwd_) + .SetMesh(mesh_)->SetGhosted(false)->SetComponent("cell", AmanziMesh::CELL, num_aux_data); + + S_->GetRecordW(alquimia_aux_data_key_, tag_next_, passwd_).set_io_vis(false); + } + + std::cout << "\nEnd setup\n"; +} + +// -- Initialize owned (dependent) variables. +void EcoSIM::Initialize() { + std::cout << "\nBegin Initialize\n"; + //PK_Physical_Default::Initialize(S); + PK_Physical_Default::Initialize(); + + //Now we have to initalize the variables (i.e. give them initial values) + //In our PK it will only be done for variables owned by the PK so the aux_names + //Keeping an example of how it's done generically here: + //S_->GetW("co2_decomposition", tag_next_, name_).PutScalar(0.); + //S_->GetRecordW("co2_decomposition", tag_next_, name_).set_initialized(); + + //In alquimia they initialize the axuiliary data via a function called InitializeCVField + //which can be found in Amanzi/src/PKs/PK_Physical.cc: + + // initialize fields as soon as possible + for (size_t i = 0; i < aux_names_.size(); ++i) { + InitializeCVField(S_, *vo_, aux_names_[i], tag_next_, passwd_, 0.0); + } + + //Now we call the engine's init state function which allocates the data + bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_); + //This function calls four separate functions from the interface: + // AllocateAlquimiaProperties - Allocates the properties which are things + // chemistry doesn't change + // AllocateAlquimiaState - Allocates properties of things chemistry CAN change + // AllocateAqluimiaAuxiliaryData - Allocates variables Alquimia needs to carry + // over between runs but ATS doesn't need + // AllocateAlquimiaAuxiliaryOutputData - Allocates variables that ATS will eventually + // output (probably don't need for now) + + // Ensure dependencies are filled + // I think this is everything from ATS that needs to be updated + S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(fluid_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(saturation_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(mass_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(rhos_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + + // init root carbon + // I think we can basically make use of the FieldToColumn_ function to take + // all of the properties we need (water, heat, ect) and pass them to each + // column + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_depth = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); + const Epetra_Vector& temp = *(*S_->Get("temperature", tag_next_) + .ViewComponent("cell",false))(0); + + int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + + //This is the main set up code in alquimia it loops over times and chemical conditions + //I don't know that we need the two initial loops. I'm just including them because we might + + if (fabs(initial_conditions_time_ - S_->get_time()) < 1e-8 * (1.0 + fabs(S_->get_time()))) { + for (auto it = chem_initial_conditions_.begin(); it != chem_initial_conditions_.end(); ++it) { + std::string region = it->first; + std::string condition = it->second; + + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "enforcing geochemical condition \"" << condition + << "\" in region \"" << region << "\"\n"; + } + for (int col=0; col!=num_cols_; ++col) { + FieldToColumn_(col, temp, col_temp.ptr()); + ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); + + //We're going to need to write an InitializeSingleColumn code + //ierr = InitializeSingleCell(cell, condition); + + ierr = InitializeSingleColumn(col, condition); + //In Alquimia this function simply calls CopyToAlquimia, then + //Calls the chemistry engine and enforces condition, then copies + //From Alquimia to Amanzi + // + //The copy to alquimia function takes the cell index, because it + //is assigning things cell by cell in state. For colums this will + //be a bit trickier I THINK we could use the FieldToColumn_ function + //To do this, but I think I will actually need to figure out a test + //for this before I actually code it up + } + } + } + + // verbose message + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << vo_->color("green") << "Initialization of PK was successful, T=" + << S_->get_time() << vo_->reset() << std::endl << std::endl; + } +} + +void EcoSIM::CommitStep(double t_old, double t_new, const Tag& tag) { + std::cout << "\nRunning commit\n"; + + // I don't know that we will have much to do here. In SimpleBGC they just copy + // Data to the pfts, which we won't be doing. In Alquimia they just save the time + // As below. + + saved_time_ = t_new; + + std::cout << "\nEnd commit\n"; +} + +bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { + double dt = t_new - t_old; + current_time_ = saved_time_ + dt; + + // If we are given a dt that is less than the one we wanted, we don't record it. + // This is in alquimia but I'm not quite sure why + //if (dt < dt_next_) { + // dt_prev_ = dt_next_; + //} else { + // dt_prev_ = dt; + //} + + std::cout << "\nBegin Advance\n"; + Teuchos::OSTab out = vo_->getOSTab(); + if (vo_->os_OK(Teuchos::VERB_HIGH)) + *vo_->os() << "----------------------------------------------------------------" << std::endl + << "Advancing: t0 = " << S_->get_time(tag_current_) + << " t1 = " << S_->get_time(tag_next_) << " h = " << dt << std::endl + << "----------------------------------------------------------------" << std::endl; + + // Ensure dependencies are filled + // Fix this from DEFAULT, see amanzi/amanzi#646 --etc + // Update all dependencies again + S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(fluid_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(saturation_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(mass_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(rhos_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + + //--------------------------------------------------------------------------- + //BGCSimple Advance + //--------------------------------------------------------------------------- + // Copy the PFT from old to new, in case we failed the previous attempt at + // this timestep. This is hackery to get around the fact that PFTs are not + // (but should be) in state. + AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + + // grab the required fields + Epetra_MultiVector& sc_pools = *S_->GetW(key_, tag_next_, name_) + .ViewComponent("cell",false); + Epetra_MultiVector& co2_decomp = *S_->GetW("co2_decomposition", tag_next_, name_) + .ViewComponent("cell",false); + Epetra_MultiVector& trans = *S_->GetW(trans_key_, tag_next_, name_) + .ViewComponent("cell",false); + + S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& temp = *S_->Get("temperature", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("pressure", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& pres = *S_->Get("pressure", tag_next_) + .ViewComponent("cell",false); + + // note that this is used as the column area, which is maybe not always + // right. Likely correct for soil carbon calculations and incorrect for + // surface vegetation calculations (where the subsurface's face area is more + // correct?) + S_->GetEvaluator("surface-cell_volume", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& scv = *S_->Get("surface-cell_volume", tag_next_) + .ViewComponent("cell", false); + + + // loop over columns and apply the model + for (AmanziMesh::Entity_ID col=0; col!=num_cols_; ++col) { + // update the various soil arrays + FieldToColumn_(col, *temp(0), temp_c.ptr()); + FieldToColumn_(col, *pres(0), pres_c.ptr()); + ColDepthDz_(col, depth_c.ptr(), dz_c.ptr()); + + auto& col_iter = mesh_->cells_of_column(col); + ncells_per_col_ = col_iter.size(); + + //Copy to EcoSIM structures + + // call the model + // This will be where we call the main function which advances ecosim + //BGCAdvance(S_->get_time(tag_current_), dt, scv[0][col], cryoturbation_coef_, met, + // *temp_c, *pres_c, *depth_c, *dz_c, + // pfts_[col], soil_carbon_pools_[col], + // co2_decomp_c, trans_c, sw_c); + + AdvanceSingleColumn(dt, col); + + //Copy back to Amanzi + + } // end loop over columns + + // mark primaries as changed + changedEvaluatorPrimary(trans_key_, tag_next_, *S_); + changedEvaluatorPrimary(shaded_sw_key_, tag_next_, *S_); + changedEvaluatorPrimary(total_lai_key_, tag_next_, *S_); + return false; + + // Compute the next time step. + // * will we need to do this? * + ComputeNextTimeStep(); + + return failed; + + std::cout << "\nEnd Advance\n"; +} + +//--------------------------------------------------------------------------- +//Here are the BGCSimple helper functions +//--------------------------------------------------------------------------- + +// helper function for pushing field to column +void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + Teuchos::Ptr col_vec, bool copy) +{ + if (col_vec == Teuchos::null) { + col_vec = Teuchos::ptr(new Epetra_SerialDenseVector(ncells_per_col_)); + } + + auto& col_iter = mesh_->cells_of_column(col); + for (std::size_t i=0; i!=col_iter.size(); ++i) { + (*col_vec)[i] = vec[col_iter[i]]; + } +} + +// helper function for pushing field to column +void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + double* col_vec, int ncol) +{ + auto& col_iter = mesh_->cells_of_column(col); + for (std::size_t i=0; i!=col_iter.size(); ++i) { + col_vec[i] = vec[col_iter[i]]; + } +} + + +// helper function for collecting column dz and depth +void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, + Teuchos::Ptr depth, + Teuchos::Ptr dz) { + AmanziMesh::Entity_ID f_above = mesh_surf_->entity_get_parent(AmanziMesh::CELL, col); + auto& col_iter = mesh_->cells_of_column(col); + ncells_per_col_ = col_iter.size(); + + AmanziGeometry::Point surf_centroid = mesh_->face_centroid(f_above); + AmanziGeometry::Point neg_z(3); + neg_z.set(0.,0.,-1); + + for (std::size_t i=0; i!=col_iter.size(); ++i) { + // depth centroid + (*depth)[i] = surf_centroid[2] - mesh_->cell_centroid(col_iter[i])[2]; + + // dz + // -- find face_below + AmanziMesh::Entity_ID_List faces; + std::vector dirs; + mesh_->cell_get_faces_and_dirs(col_iter[i], &faces, &dirs); + + // -- mimics implementation of build_columns() in Mesh + double mindp = 999.0; + AmanziMesh::Entity_ID f_below = -1; + for (std::size_t j=0; j!=faces.size(); ++j) { + AmanziGeometry::Point normal = mesh_->face_normal(faces[j]); + if (dirs[j] == -1) normal *= -1; + normal /= AmanziGeometry::norm(normal); + + double dp = -normal * neg_z; + if (dp < mindp) { + mindp = dp; + f_below = faces[j]; + } + } + + // -- fill the val + (*dz)[i] = mesh_->face_centroid(f_above)[2] - mesh_->face_centroid(f_below)[2]; + AMANZI_ASSERT( (*dz)[i] > 0. ); + f_above = f_below; + } +} + +//--------------------------------------------------------------------------- +//Alquimia Helper functions +//--------------------------------------------------------------------------- +void EcoSIM::CopyToEcoSIM(int col, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data) +{ + CopyToEcoSIM(col, props, state, aux_data); +} + +void EcoSIM::CopyToEcoSIM(int col, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data) +{ + //NOTE: I Have not touched this yet as it will depend on what we have to + //Transfer + // + //Fill state with ATS variables that are going to be changed by EcoSIM + const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); + const auto& fluid_density = *S_->Get(fluid_den_key_, water_tag).ViewComponent("cell", true); + const auto& water_saturation = *S_->Get(saturation_key_, water_tag).ViewComponent("cell", true); + const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); + const auto& ice_density = *S_->Get(ice_den_key_, water_tag).ViewComponent("cell", true); + const auto& mass_density = *S_->Get(mass_den_key_, water_tag).ViewComponent("cell", true); + const auto& rock_density = *S_->Get(rhos_key_, water_tag).ViewComponent("cell", true); + const auto& Temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", true); + const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); + const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); + + state.water_density = fluid_density[0][cell]; + state.porosity = porosity[0][cell]; + + //We are probably going to need to do something like this that loops over + //All transport components to give them over to EcoSIM + for (int i = 0; i < number_aqueous_components_; i++) { + state.total_mobile.data[i] = (*aqueous_components)[i][cell]; + + if (using_sorption_) { + const auto& sorbed = *S_->Get(total_sorbed_key_, tag_next_).ViewComponent("cell"); + state.total_immobile.data[i] = sorbed[i][cell]; + } + } + + // minerals + assert(state.mineral_volume_fraction.size == number_minerals_); + assert(state.mineral_specific_surface_area.size == number_minerals_); + assert(mat_props.mineral_rate_cnst.size == number_minerals_); + + if (number_minerals_ > 0) { + const auto& mineral_vf = *S_->Get(min_vol_frac_key_, tag_next_).ViewComponent("cell"); + const auto& mineral_ssa = *S_->Get(min_ssa_key_, tag_next_).ViewComponent("cell"); + const auto& mineral_rate = *S_->Get(mineral_rate_constant_key_, tag_next_).ViewComponent("cell"); + for (unsigned int i = 0; i < number_minerals_; ++i) { + state.mineral_volume_fraction.data[i] = mineral_vf[i][cell]; + mat_props.mineral_rate_cnst.data[i] = mineral_rate[i][cell]; + state.mineral_specific_surface_area.data[i] = mineral_ssa[i][cell]; + } + } + + // ion exchange + assert(state.cation_exchange_capacity.size == number_ion_exchange_sites_); + if (number_ion_exchange_sites_ > 0) { + const auto& ion_exchange = *S_->Get(ion_exchange_sites_key_, tag_next_).ViewComponent("cell"); + for (int i = 0; i < number_ion_exchange_sites_; i++) { + state.cation_exchange_capacity.data[i] = ion_exchange[i][cell]; + } + } + + // surface complexation + if (number_sorption_sites_ > 0) { + const auto& sorption_sites = *S_->Get(sorp_sites_key_, tag_next_).ViewComponent("cell"); + + assert(number_sorption_sites_ == state.surface_site_density.size); + for (int i = 0; i < number_sorption_sites_; ++i) { + // FIXME: Need site density names, too? + state.surface_site_density.data[i] = sorption_sites[i][cell]; + // TODO(bandre): need to save surface complexation free site conc here! + } + } + + // Auxiliary data -- block copy. + if (S_->HasRecord(alquimia_aux_data_key_, tag_next_)) { + aux_data_ = S_->GetW(alquimia_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); + int num_aux_ints = chem_engine_->Sizes().num_aux_integers; + int num_aux_doubles = chem_engine_->Sizes().num_aux_doubles; + + for (int i = 0; i < num_aux_ints; i++) { + double* cell_aux_ints = (*aux_data_)[i]; + aux_data.aux_ints.data[i] = (int)cell_aux_ints[cell]; + } + for (int i = 0; i < num_aux_doubles; i++) { + double* cell_aux_doubles = (*aux_data_)[i + num_aux_ints]; + aux_data.aux_doubles.data[i] = cell_aux_doubles[cell]; + } + } + + mat_props.volume = mesh_->cell_volume(cell); + mat_props.saturation = water_saturation[0][cell]; + + // sorption isotherms + if (using_sorption_isotherms_) { + const auto& isotherm_kd = *S_->Get(isotherm_kd_key_, tag_next_).ViewComponent("cell"); + const auto& isotherm_freundlich_n = *S_->Get(isotherm_freundlich_n_key_, tag_next_).ViewComponent("cell"); + const auto& isotherm_langmuir_b = *S_->Get(isotherm_langmuir_b_key_, tag_next_).ViewComponent("cell"); + + for (unsigned int i = 0; i < number_aqueous_components_; ++i) { + mat_props.isotherm_kd.data[i] = isotherm_kd[i][cell]; + mat_props.freundlich_n.data[i] = isotherm_freundlich_n[i][cell]; + mat_props.langmuir_b.data[i] = isotherm_langmuir_b[i][cell]; + } + } + + // first order reaction rate cnst + if (number_aqueous_kinetics_ > 0) { + const auto& aqueous_kinetics_rate = *S_->Get(first_order_decay_constant_key_, tag_next_).ViewComponent("cell"); + for (unsigned int i = 0; i < number_aqueous_kinetics_; ++i) { + mat_props.aqueous_kinetic_rate_cnst.data[i] = aqueous_kinetics_rate[i][cell]; + } + } +} + +void EcoSIM::CopyEcoSIMStateToAmanzi( + const int cell, + const BGCProperties& props, + const BGCState& state, + const BGCAuxiliaryData& aux_data) +{ + CopyFromEcoSIM(cell, props, state, aux_data); +} + +void EcoSIM::CopyFromEcoSIM(const int cell, + const BGCProperties& props, + const BGCState& state, + const BGCAuxiliaryData& aux_data) +{ + // If the chemistry has modified the porosity and/or density, it needs to + // be updated here. + // (this->water_density())[cell] = state.water_density; + // (this->porosity())[cell] = state.porosity; + + for (int i = 0; i < number_aqueous_components_; ++i) { + (*aqueous_components)[i][cell] = state.total_mobile.data[i]; + + if (using_sorption_) { + auto& sorbed = *S_->GetW(total_sorbed_key_, tag_next_, passwd_).ViewComponent("cell"); + sorbed[i][cell] = state.total_immobile.data[i]; + } + } + + //Here is where the auxiliary data is filled need to try to change this to columns + //This may not be trivial + if (S_->HasRecord(alquimia_aux_data_key_, tag_next_)) { + aux_data_ = S_->GetW(alquimia_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); + + int num_aux_ints = chem_engine_->Sizes().num_aux_integers; + int num_aux_doubles = chem_engine_->Sizes().num_aux_doubles; + + for (int i = 0; i < num_aux_ints; i++) { + double* cell_aux_ints = (*aux_data_)[i]; + cell_aux_ints[cell] = (double)aux_data.aux_ints.data[i]; + } + for (int i = 0; i < num_aux_doubles; i++) { + double* cell_aux_doubles = (*aux_data_)[i + num_aux_ints]; + cell_aux_doubles[cell] = aux_data.aux_doubles.data[i]; + } + } + + + // Here is where constants are saved as properties (things that won't be + //changed by EcoSIM) + if (using_sorption_isotherms_) { + auto& isotherm_kd = *S_->GetW(isotherm_kd_key_, tag_next_, passwd_).ViewComponent("cell"); + auto& isotherm_freundlich_n = *S_->GetW(isotherm_freundlich_n_key_, tag_next_, passwd_).ViewComponent("cell"); + auto& isotherm_langmuir_b = *S_->GetW(isotherm_langmuir_b_key_, tag_next_, passwd_).ViewComponent("cell"); + + for (unsigned int i = 0; i < number_aqueous_components_; ++i) { + isotherm_kd[i][cell] = mat_props.isotherm_kd.data[i]; + isotherm_freundlich_n[i][cell] = mat_props.freundlich_n.data[i]; + isotherm_langmuir_b[i][cell] = mat_props.langmuir_b.data[i]; + } + } +} + +/* ******************************************************************* +* This helper performs initialization on a single cell within Amanzi's state. +* It returns an error code that indicates success (0) or failure (1). +******************************************************************* */ +int EcoSIM::InitializeSingleColumn(int col, const std::string& condition) +{ + // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but + // should use the same tag as transport. See #673 + CopyToAlquimia(col, bgc_props_, bgc_state_, bgc_aux_data_); + + bgc_engine_->EnforceCondition(condition, current_time_, bgc_props_, + bgc_state_, bgc_aux_data_); + + CopyAlquimiaStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_); + + + // ETC: hacking to get consistent solution -- if there is no water + // (e.g. surface system, we still need to call EnforceCondition() as it also + // gets aux data set up correctly. But the concentrations need to be + // overwritten as 0 to get expected output. Therefore we manually overwrite + // this now. Previously this happened due to a bug in ATS's reactive + // transport coupler -- happy accidents. + if (alq_mat_props_.saturation <= saturation_tolerance_) + for (int i=0; i!=aqueous_components_->NumVectors(); ++i) (*aqueous_components_)[i][cell] = 0.; + return 0; +} + +/* ******************************************************************* +* This helper advances the solution on a single cell within Amanzi's state. +* It returns the number of iterations taken to obtain the advanced solution, +* or -1 if an error occurred. +******************************************************************* */ +int EcoSIM::AdvanceSingleColumn(double dt, int col) +{ + // Copy the state and property information from Amanzi's state within + // this cell to Alquimia. + // + // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but + // should use the same tag as transport. See #673 + CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_); + + int num_iterations = 0; + + //Think a bit about what to do with this + if (ecosim_mat_props_.saturation > saturation_tolerance_) { + bool success = bgc_engine_->Advance(dt, bgc_props_, bgc_state_, + bgc_aux_data_, num_iterations); + if (not success) { + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "no convergence in cell: " << mesh_->cell_map(false).GID(cell) << std::endl; + } + return -1; + } + } + + // Move the information back into Amanzi's state, updating the given total concentration vector. + CopyEcoSIMStateToAmanzi(col, + bgc_props_, bgc_state_, bgc_aux_data_); + + return num_iterations; +} + +} // namespace EcoSIM +} // namespace Amanzi diff --git a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh new file mode 100644 index 000000000..8048e261b --- /dev/null +++ b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh @@ -0,0 +1,147 @@ +/* -*- mode: c++; indent-tabs-mode: nil -*- */ + +/*-------------------------------------------------------------------------- + ATS + + License: see $ATS_DIR/COPYRIGHT + Author: Andrew Graus + + The idea here is to begin writing the EcoSIM ATS interface with a simple + program. To start we are going to try to do a few things: + + 1) Initalize a PK called EcoSIM_ATS + 2) Have that PK take in the water content + 3) modify the water content in a simple way to mock roots (take away water) + 4) modify it so it will take in tracers (how roots take in nutrients) + + --------------------------------------------------------------------------*/ +//Eventually add if statement here (probably tied to something at compile time +// +//#ifndef PKS_BGC_SIMPLE_HH_ +//#define PKS_BGC_SIMPLE_HH_ + +#ifndef PKS_ECOSIM_HH_ +#define PKS_ECOSIM_HH_ + +#include "Teuchos_ParameterList.hpp" +#include "Teuchos_RCP.hpp" +#include "Epetra_SerialDenseVector.h" + +#include "VerboseObject.hh" +#include "TreeVector.hh" + +#include "BGCEngine.hh" +#include "PK_Factory.hh" +#include "pk_physical_default.hh" + +namespace Amanzi { +namespace EcoSIM { + +class EcoSIM : public PK_Physical_Default { + + public: + + //Unclear if the constructor is neccessary + EcoSIM(Teuchos::ParameterList& pk_tree, + const Teuchos::RCP& plist, + const Teuchos::RCP& S, + const Teuchos::RCP& solution); + + // Virtual destructor + virtual ~EcoSIM() override {} + + // is a PK + // -- Setup data + //virtual void Setup(const Teuchos::Ptr&S); + virtual void Setup() override; + + // -- initalize owned (dependent) variables + //virtual void Initialize(const Teuchos::Ptr& S); + virtual void Initialize() override; + + // --provide timestep size + virtual double get_dt() override { + return dt_; + } + + virtual void set_dt(double dt) override { + dt_ = dt; + } + + // -- commit the model + //virtual void CommitStep(double t_old, double t_new, const Teuchos::RCP& S); + virtual void CommitStep(double t_old, double t_new, const Tag& tag) override; + + // -- Update diagnostics for vis. + //virtual void CalculateDiagnostics(const Teuchos::RCP& S) {} + //virtual void CalculateDiagnostics(const Tag& tag) override; + + // -- advance the model + virtual bool AdvanceStep(double t_old, double t_new, bool reinit) override; + + virtual std::string name(){return "EcoSIM for ATS";}; + + void CopyToEcoSIM(int col, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data); + + private: + + //Helper functions from Alquimia + void CopyToEcoSIM(int col, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data); + + void CopyFromEcoSIM(const int cell, + const BGCProperties& props, + const BGCState& state, + const BGCAuxiliaryData& aux_data); + + int InitializeSingleColumn(int col, const std::string& condition); + + int AdvanceSingleColumn(double dt, int col); + + void CopyEcoSIMStateToAmanzi( + const int cell, + const BGCProperties& props, + const BGCState& state, + const BGCAuxiliaryData& aux_data); + + void ComputeNextTimeStep(); + + protected: + double dt_; + Teuchos::RCP mesh_surf_; //might need this? + //Key domain_surf_; + + //The helper functions from BGC are protected not private (unclear why) + //I don't think I need this here, probably in the engine + void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + Teuchos::Ptr col_vec, bool copy); + + void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + double* col_vec, int ncol); + void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, + Teuchos::Ptr depth, + Teuchos::Ptr dz) + + //evaluator for transpiration; + //I don't think I need this anymore + //Teuchos::RCP p_root_eval_; + + // keys + Key wc_key_; + Key wc_root_key_; + Key trans_key_; + Key p_root_key_; + private: + //factory registration + static RegisteredPKFactory reg_; +}; + +} // namespace EcoSIM +} // namespace Amanzi + +#endif diff --git a/src/pks/ecosim_pk/ats_ecosim_registration.hh b/src/pks/ecosim_pk/ats_ecosim_registration.hh new file mode 100644 index 000000000..21e62d006 --- /dev/null +++ b/src/pks/ecosim_pk/ats_ecosim_registration.hh @@ -0,0 +1,19 @@ +/* -*- mode: c++; indent-tabs-mode: nil -*- */ +/* ------------------------------------------------------------------------- + * ATS + * + * License: see $ATS_DIR/COPYRIGHT + * Author: Ethan Coon + * + * ------------------------------------------------------------------------- */ + +#include "Ecosim_interface_test.hh" + +namespace Amanzi { +namespace EcoSIM { + +RegisteredPKFactory EcoSIM::reg_("EcoSIM for ATS"); + + +} // namespace +} // namespace diff --git a/src/pks/ecosim_pk/ats_ecosim_registration.hh.in b/src/pks/ecosim_pk/ats_ecosim_registration.hh.in new file mode 100644 index 000000000..21e62d006 --- /dev/null +++ b/src/pks/ecosim_pk/ats_ecosim_registration.hh.in @@ -0,0 +1,19 @@ +/* -*- mode: c++; indent-tabs-mode: nil -*- */ +/* ------------------------------------------------------------------------- + * ATS + * + * License: see $ATS_DIR/COPYRIGHT + * Author: Ethan Coon + * + * ------------------------------------------------------------------------- */ + +#include "Ecosim_interface_test.hh" + +namespace Amanzi { +namespace EcoSIM { + +RegisteredPKFactory EcoSIM::reg_("EcoSIM for ATS"); + + +} // namespace +} // namespace From 991309971f60918190fb1fcf13382b6a01495c9c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 11 Jan 2023 14:53:06 -0800 Subject: [PATCH 002/582] updated version of BGCEngine --- src/pks/ecosim_pk/BGCEngine.cc | 131 ++++----------------------------- 1 file changed, 16 insertions(+), 115 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 67fca6d60..521e0df76 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -116,7 +116,7 @@ BGCEngine::BGCEngine(const std::string& engineName, //This calls the Setup function that we pointed the code to within alquimia - + /* chem_.Setup(chem_engine_inputfile_.c_str(), hands_off, &engine_state_, @@ -130,20 +130,14 @@ BGCEngine::BGCEngine(const std::string& engineName, msg << "Error in creation of ChemistryEngine."; Exceptions::amanzi_throw(msg); } + */ + //We don't need the chem interface call + //Place the call to the EcoSIM setup driver here: + EcoSIMSetup(); // Allocate storage for additional Alquimia data. - AllocateAlquimiaProblemMetaData(&sizes_, &chem_metadata_); - - // Get the problem metadata (species and mineral names, etc). - chem_.GetProblemMetaData(&engine_state_, - &chem_metadata_, - &chem_status_); - if (chem_status_.error != 0) - { - std::cout << chem_status_.message << std::endl; - PrintAlquimiaProblemMetaData(&chem_metadata_, stdout); - msg << "Error in ChemistryEngine::Initialize"; - Exceptions::amanzi_throw(msg); + // Below this sets up Alquimia metadata I don't think we + //need this } } @@ -199,46 +193,25 @@ bool ChemistryEngine::Advance(const double delta_time, AlquimiaAuxiliaryOutputData& aux_output, int& num_iterations) { -#ifdef AMANZI_USE_FENV - // Disable divide-by-zero floating point exceptions. - int fpe_mask = fedisableexcept(FE_DIVBYZERO); -#endif // Advance the chemical reaction all operator-split-like. - chem_.ReactionStepOperatorSplit(&engine_state_, + /*chem_.ReactionStepOperatorSplit(&engine_state_, delta_time, &(const_cast(mat_props)), &chem_state, &aux_data, &chem_status_); + */ + //This is alquimia's advance function which we won't need + //calling EcoSIM advance driver + EcoSIMAdvance(); -#ifdef AMANZI_USE_FENV - // Re-enable pre-existing floating point exceptions. - feclearexcept(fpe_mask); - fpe_mask = feenableexcept(fpe_mask); -#endif - - // Retrieve auxiliary output. - chem_.GetAuxiliaryOutput(&engine_state_, - &(const_cast(mat_props)), - &chem_state, - &aux_data, - &aux_output, - &chem_status_); - - // Did we succeed? - if (chem_status_.error != kAlquimiaNoError) - return false; - - // Did we converge? - if (!chem_status_.converged) - return false; - - // Write down the (maximum) number of Newton iterations. - num_iterations = chem_status_.num_newton_iterations; - return true; } +//Here is where alquimai has the set condition functions. +//Is this the equivalent to setting ICs for the runs? + + void ChemistryEngine::CreateCondition(const std::string& condition_name) { // NOTE: a condition with zero aqueous/mineral constraints is assumed to be defined in @@ -256,57 +229,6 @@ void ChemistryEngine::CreateCondition(const std::string& condition_name) chem_conditions_[condition_name] = condition; } - -/* Mineral constraints will be discontinued in Alquimia -- see Sergi - -void ChemistryEngine::AddMineralConstraint(const std::string& condition_name, - const std::string& mineral_name, - double volume_fraction, - double specific_surface_area) -{ - assert(condition_name.length() > 0); - assert(volume_fraction >= 0.0); - assert(specific_surface_area >= 0.0); - - GeochemicalConditionMap::iterator iter = chem_conditions_.find(condition_name); - if (iter != chem_conditions_.end()) - { - AlquimiaGeochemicalCondition* condition = &iter->second->condition; - - // Do we have an existing constraint? - int index = -1; - for (int i = 0; i < condition->mineral_constraints.size; ++i) - { - if (!std::strcmp(condition->mineral_constraints.data[i].mineral_name, mineral_name.c_str())) - { - // Overwrite the old constraint. - index = i; - free(condition->mineral_constraints.data[index].mineral_name); - } - } - if (index == -1) - { - // New constraint! - index = condition->mineral_constraints.size; - condition->mineral_constraints.size++; - condition->mineral_constraints.data = (AlquimiaMineralConstraint*)realloc(condition->mineral_constraints.data, sizeof(AlquimiaMineralConstraint) * (index+1)); - } - - // Add the mineral constraint. - condition->mineral_constraints.data[index].mineral_name = strdup(mineral_name.c_str()); - condition->mineral_constraints.data[index].volume_fraction = volume_fraction; - condition->mineral_constraints.data[index].specific_surface_area = specific_surface_area; - } - else - { - Errors::Message msg; - msg << "ChemistryEngine::AddMineralConstraint: no condition named '" << condition_name << "'."; - Exceptions::amanzi_throw(msg); - } -} -Mineral constraints will be discontinued in Alquimia -- see Sergi */ - - void ChemistryEngine::AddAqueousConstraint(const std::string& condition_name, const std::string& primary_species_name, const std::string& constraint_type, @@ -323,27 +245,6 @@ void ChemistryEngine::AddAqueousConstraint(const std::string& condition_name, { AlquimiaGeochemicalCondition* condition = &iter->second->condition; - /* Mineral constraints will be discontinued from Alquimia in the near future -- see Sergi - - // Is there a mineral constraint for the associated species? - if (!associated_species.empty()) - { - bool found_mineral = false; - for (int i = 0; i < condition->mineral_constraints.size; ++i) - { - if (!std::strcmp(condition->mineral_constraints.data[i].mineral_name, associated_species.c_str())) - found_mineral = true; - } - if (!found_mineral) - { - Errors::Message msg; - msg << "ChemistryEngine::AddAqueousConstraint: the condition '" << condition_name << "' does not have a mineral constraint for '" << associated_species << "'."; - Exceptions::amanzi_throw(msg); - } - } - - Mineral constraints will be discontinued from Alquimia in the near future -- see Sergi */ - // Do we have an existing constraint? int index = -1; for (int i = 0; i < condition->aqueous_constraints.size; ++i) From 861fd28b9bb4e77316022e9eb4a7d0ddec628bb5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 19 Jan 2023 13:36:45 -0800 Subject: [PATCH 003/582] More modifications to engine and interface addition of memory functions --- src/pks/ecosim_pk/BGCEngine.cc | 60 +-- src/pks/ecosim_pk/BGCEngine.hh | 79 ++-- src/pks/ecosim_pk/BGC_memory.c | 513 ++++++++++++++++++++++ src/pks/ecosim_pk/BGC_memory.h | 112 +++++ src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 104 +---- 5 files changed, 713 insertions(+), 155 deletions(-) create mode 100644 src/pks/ecosim_pk/BGC_memory.c create mode 100644 src/pks/ecosim_pk/BGC_memory.h diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 521e0df76..ae0557eb5 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -16,7 +16,7 @@ #include #include #include -#include "ChemistryEngine.hh" +#include "BGCEngine.hh" #include "errors.hh" #include "exceptions.hh" @@ -35,6 +35,7 @@ namespace { void CopyEcoSIMState(EcoSIMState* dest, EcoSIMState* src) { + //NEED TO EDIT STILL dest->water_density = src->water_density; dest->porosity = src->porosity; dest->temperature = src->temperature; @@ -50,6 +51,7 @@ void CopyEcoSIMState(EcoSIMState* dest, EcoSIMState* src) // These functions are going into the next release of Alquimia. void CopyEcoSIMProperties(EcoSIMProperties* dest, EcoSIMProperties* src) { + //NEED TO EDIT STILL dest->volume = src->saturation; dest->saturation = src->saturation; memcpy(dest->aqueous_kinetic_rate_cnst.data, src->aqueous_kinetic_rate_cnst.data, sizeof(double) * src->aqueous_kinetic_rate_cnst.size); @@ -141,56 +143,54 @@ BGCEngine::BGCEngine(const std::string& engineName, } } -ChemistryEngine::~ChemistryEngine() +BGCEngine::~BGCEngine() { - chem_.Shutdown(&engine_state_, &chem_status_); - FreeAlquimiaProblemMetaData(&chem_metadata_); + //chem_.Shutdown(&engine_state_, &chem_status_); + //FreeAlquimiaProblemMetaData(&chem_metadata_); // Delete the various geochemical conditions. for (GeochemicalConditionMap::iterator iter = chem_conditions_.begin(); iter != chem_conditions_.end(); ++iter) { - FreeAlquimiaGeochemicalCondition(&iter->second->condition); - FreeAlquimiaState(&iter->second->chem_state); - FreeAlquimiaProperties(&iter->second->mat_props); - FreeAlquimiaAuxiliaryData(&iter->second->aux_data); + //FreeBGCGeochemicalCondition(&iter->second->condition); + FreeBGCState(&iter->second->chem_state); + FreeBGCProperties(&iter->second->mat_props); + FreeBGCAuxiliaryData(&iter->second->aux_data); delete iter->second; } - FreeAlquimiaEngineStatus(&chem_status_); + //FreeAlquimiaEngineStatus(&chem_status_); } -void ChemistryEngine::InitState(AlquimiaProperties& mat_props, - AlquimiaState& chem_state, - AlquimiaAuxiliaryData& aux_data, - AlquimiaAuxiliaryOutputData& aux_output) +void BGCEngine::InitState(BGCProperties& mat_props, + BGCState& chem_state, + BGCAuxiliaryData& aux_data) { - AllocateAlquimiaProperties(&sizes_, &mat_props); - AllocateAlquimiaState(&sizes_, &chem_state); - AllocateAlquimiaAuxiliaryData(&sizes_, &aux_data); - AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); + AllocateBGCProperties(&sizes_, &mat_props); + AllocateBGCState(&sizes_, &chem_state); + AllocateBGCAuxiliaryData(&sizes_, &aux_data); + //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); // Make sure the auxiliary ints/doubles are zeroed out. std::fill(aux_data.aux_ints.data, aux_data.aux_ints.data + aux_data.aux_ints.size, 0); std::fill(aux_data.aux_doubles.data, aux_data.aux_doubles.data + aux_data.aux_doubles.size, 0.0); } -void ChemistryEngine::FreeState(AlquimiaProperties& mat_props, - AlquimiaState& chem_state, - AlquimiaAuxiliaryData& aux_data, - AlquimiaAuxiliaryOutputData& aux_output) +void BGCEngine::FreeState(BGCProperties& mat_props, + BGCState& chem_state, + BGCAuxiliaryData& aux_data) { - FreeAlquimiaProperties(&mat_props); - FreeAlquimiaState(&chem_state); - FreeAlquimiaAuxiliaryData(&aux_data); - FreeAlquimiaAuxiliaryOutputData(&aux_output); + FreeBGCProperties(&mat_props); + FreeBGCState(&chem_state); + FreeBGCAuxiliaryData(&aux_data); + //FreeAlquimiaAuxiliaryOutputData(&aux_output); } -bool ChemistryEngine::Advance(const double delta_time, - const AlquimiaProperties& mat_props, - AlquimiaState& chem_state, - AlquimiaAuxiliaryData& aux_data, - AlquimiaAuxiliaryOutputData& aux_output, +bool BGCEngine::Advance(const double delta_time, + const BGCProperties& mat_props, + BGCState& chem_state, + BGCAuxiliaryData& aux_data, + BGCAuxiliaryOutputData& aux_output, int& num_iterations) { diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 3b6feca92..d42079574 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -1,15 +1,15 @@ /* Alqumia - Copyright 2010-201x held jointly by LANS/LANL, LBNL, and PNNL. - Amanzi is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are + Copyright 2010-201x held jointly by LANS/LANL, LBNL, and PNNL. + Amanzi is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. Author: Jeffrey Johnson - This is a point of contact for the chemistry engine exposed by Alquimia - to the rest of Amanzi--it provides the ability to enforce geochemical + This is a point of contact for the chemistry engine exposed by Alquimia + to the rest of Amanzi--it provides the ability to enforce geochemical conditions and to integrate reactions given a chemical configuration. */ @@ -27,7 +27,7 @@ #include "alquimia/alquimia_interface.h" namespace Amanzi { -namespace AmanziChemistry { +namespace EcoSIM { struct GeochemicalConditionData @@ -41,15 +41,15 @@ struct GeochemicalConditionData typedef std::map GeochemicalConditionMap; -class ChemistryEngine { +class BGCEngine { public: // Constructs a chemistry engine using the given engine (backend) name and input file. - ChemistryEngine(const std::string& engineName, const std::string& inputFile); + BGCEngine(const std::string& engineName, const std::string& inputFile); // Destructor. - ~ChemistryEngine(); + ~BGCEngine(); // Returns the name of the backend that does the chemistry. const std::string& Name() const; @@ -57,7 +57,7 @@ class ChemistryEngine { // Returns true if the chemistry engine is thread-safe, false if not. bool IsThreadSafe() const; - // These query methods return metadata for the chemical configuration represented + // These query methods return metadata for the chemical configuration represented // within the chemistry engine. int NumPrimarySpecies() const; int NumAqueousComplexes() const; @@ -76,30 +76,28 @@ class ChemistryEngine { std::vector>& subfield_names) const; int NumAqueousKinetics() const; void GetAqueousKineticNames(std::vector& kinetics_names) const; - - // Returns a reference to a "sizes" object that can be queried to find the sizes of the various + + // Returns a reference to a "sizes" object that can be queried to find the sizes of the various // arrays representing the geochemical state within the engine. const AlquimiaSizes& Sizes() const; // Initializes the data structures that hold the chemical state information. - void InitState(AlquimiaProperties& mat_props, - AlquimiaState& chem_state, - AlquimiaAuxiliaryData& aux_data, - AlquimiaAuxiliaryOutputData& aux_output); - + void InitState(BGCProperties& mat_props, + BGCState& chem_state, + BGCAuxiliaryData& aux_data); + // Frees the data structures that hold the chemical state information. - void FreeState(AlquimiaProperties& mat_props, - AlquimiaState& chem_state, - AlquimiaAuxiliaryData& aux_data, - AlquimiaAuxiliaryOutputData& aux_output); + void FreeState(BGCProperties& mat_props, + BGCState& chem_state, + BGCAuxiliaryData& aux_data); - // Creates a geochemical condition with the given name within the chemistry engine, using the + // Creates a geochemical condition with the given name within the chemistry engine, using the // data in the given containers. void CreateCondition(const std::string& condition_name); /* Mineral constraints will be discontinued in Alquimia -- see Sergi - // Adds a mineral constraint to the geochemical condition with the given name. If another - // constraint with the same mineral name exists for this condition, it is replaced by + // Adds a mineral constraint to the geochemical condition with the given name. If another + // constraint with the same mineral name exists for this condition, it is replaced by // this one. void AddMineralConstraint(const std::string& condition_name, const std::string& mineral_name, @@ -107,21 +105,21 @@ class ChemistryEngine { double specific_surface_area); Mineral constraints will be discontinued in Alquimia -- see Sergi */ - // Adds an aqueous constraint to the geochemical condition with the given name. If another - // constraint involving the same primary species exists for this condition, it is replaced by + // Adds an aqueous constraint to the geochemical condition with the given name. If another + // constraint involving the same primary species exists for this condition, it is replaced by // this one. // The constraint type may be "total_aqueous", "total_sorb", "free", "mineral", "gas", // "pH", or "charge". - // The associated (mineral) species must be the name of a mineral mentioned - // in a mineral constraint that has been previously added to this condition + // The associated (mineral) species must be the name of a mineral mentioned + // in a mineral constraint that has been previously added to this condition // using AddMineralConstraint(). void AddAqueousConstraint(const std::string& condition_name, const std::string& primary_species_name, const std::string& constraint_type, const std::string& associated_species); - // Enforces the geochemical condition with the given name on the chemical configuration - // represented by the given array of concentrations at the given time. The order of the + // Enforces the geochemical condition with the given name on the chemical configuration + // represented by the given array of concentrations at the given time. The order of the // concentrations in the array matches that of the species names returned by GetSpeciesNames. void EnforceCondition(const std::string& condition_name, const double time, @@ -130,15 +128,14 @@ class ChemistryEngine { AlquimiaAuxiliaryData& aux_data, AlquimiaAuxiliaryOutputData& aux_output); - // Advances the species represented by the given array of concentrations, replacing old values - // with new values. The order of the concentrations in the array matches that of the species names - // returned by GetSpeciesNames. Returns true if the advance is successful, + // Advances the species represented by the given array of concentrations, replacing old values + // with new values. The order of the concentrations in the array matches that of the species names + // returned by GetSpeciesNames. Returns true if the advance is successful, // false if it fails. bool Advance(const double delta_time, - const AlquimiaProperties& mat_props, - AlquimiaState& chem_state, - AlquimiaAuxiliaryData& aux_data, - AlquimiaAuxiliaryOutputData& aux_output, + const BGCProperties& mat_props, + BGCState& chem_state, + BGCAuxiliaryData& aux_data, int& num_iterations); private: @@ -152,7 +149,7 @@ class ChemistryEngine { AlquimiaEngineStatus chem_status_; AlquimiaProblemMetaData chem_metadata_; - // Mapping of geochemical condition names to geochemical conditions (and flags indicating + // Mapping of geochemical condition names to geochemical conditions (and flags indicating // whether they have been processed). GeochemicalConditionMap chem_conditions_; @@ -161,9 +158,9 @@ class ChemistryEngine { std::string chem_engine_inputfile_; // forbidden. - ChemistryEngine(); - ChemistryEngine(const ChemistryEngine&); - ChemistryEngine& operator=(const ChemistryEngine&); + BGCEngine(); + BGCEngine(const BGCEngine&); + BGCEngine& operator=(const BGCEngine&); }; diff --git a/src/pks/ecosim_pk/BGC_memory.c b/src/pks/ecosim_pk/BGC_memory.c new file mode 100644 index 000000000..be67f17de --- /dev/null +++ b/src/pks/ecosim_pk/BGC_memory.c @@ -0,0 +1,513 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** Alquimia is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + + +/******************************************************************************* + ** + ** Alquimia C memory utilities to handle memory management + ** + ** Notes: + ** + ** - calloc/malloc always return NULL pointers if they fail, so + ** there is no need to pre-assign NULL for the pointers we are + ** allocating here. For zero size or zero members, the returned + ** pointer should be NULL or something that can be freed.... + ** + ** - free just releases the memory, it does not change the value + ** of the pointer. After free, the pointer is no longer valid, so + ** we set it to NULL. + ** + *******************************************************************************/ + +#include "alquimia/alquimia_memory.h" +#include "alquimia/alquimia_interface.h" +#include "alquimia/alquimia_constants.h" +#include "alquimia/alquimia_containers.h" + +// Returns the nearest power of 2 greater than or equal to n, or 0 if n == 0. +static inline int nearest_power_of_2(int n) +{ + if (n == 0) return 0; + int twop = 1; + while (twop < n) + twop *= 2; + return twop; +} + +/******************************************************************************* + ** + ** Alquimia Vectors + ** + *******************************************************************************/ +void AllocateAlquimiaVectorDouble(const int size, AlquimiaVectorDouble* vector) { + if (size > 0) { + vector->size = size; + vector->capacity = nearest_power_of_2(size); + vector->data = (double*) calloc((size_t)vector->capacity, sizeof(double)); + ALQUIMIA_ASSERT(NULL != vector->data); + } else { + vector->size = 0; + vector->capacity = 0; + vector->data = NULL; + } +} /* end AllocateAlquimiaVectorDouble() */ + +void FreeAlquimiaVectorDouble(AlquimiaVectorDouble* vector) { + if (vector != NULL) { + free(vector->data); + vector->data = NULL; + vector->size = 0; + vector->capacity = 0; + } +} /* end FreeAlquimiaVectorDouble() */ + +void AllocateAlquimiaVectorInt(const int size, AlquimiaVectorInt* vector) { + if (size > 0) { + vector->size = size; + vector->capacity = nearest_power_of_2(size); + vector->data = (int*) calloc((size_t)vector->capacity, sizeof(int)); + ALQUIMIA_ASSERT(NULL != vector->data); + } else { + vector->size = 0; + vector->capacity = 0; + vector->data = NULL; + } +} /* end AllocateAlquimiaVectorInt() */ + +void FreeAlquimiaVectorInt(AlquimiaVectorInt* vector) { + if (vector != NULL) { + free(vector->data); + vector->data = NULL; + vector->size = 0; + vector->capacity = 0; + } +} /* end FreeAlquimiaVectorInt() */ + +void AllocateAlquimiaVectorString(const int size, AlquimiaVectorString* vector) { + int i; + if (size > 0) { + vector->size = size; + vector->capacity = nearest_power_of_2(size); + vector->data = (char**) calloc((size_t)vector->capacity, sizeof(char*)); + ALQUIMIA_ASSERT(NULL != vector->data); + for (i = 0; i < vector->size; ++i) { + vector->data[i] = (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); + ALQUIMIA_ASSERT(NULL != vector->data[i]); + } + } else { + vector->size = 0; + vector->capacity = 0; + vector->data = NULL; + } +} /* end AllocateAlquimiaVectorString() */ + +void FreeAlquimiaVectorString(AlquimiaVectorString* vector) { + int i; + if (vector != NULL) { + for (i = 0; i < vector->size; ++i) { + free(vector->data[i]); + } + free(vector->data); + vector->data = NULL; + vector->size = 0; + vector->capacity = 0; + } +} /* end FreeAlquimiaVectorString() */ + +/******************************************************************************* + ** + ** State + ** + *******************************************************************************/ + +void AllocateAlquimiaState(const AlquimiaSizes* const sizes, + AlquimiaState* state) { + AllocateAlquimiaVectorDouble(sizes->num_primary, &(state->total_mobile)); + ALQUIMIA_ASSERT(state->total_mobile.data != NULL); + + AllocateAlquimiaVectorDouble(sizes->num_sorbed, &(state->total_immobile)); + + AllocateAlquimiaVectorDouble(sizes->num_surface_sites, + &(state->surface_site_density)); + + AllocateAlquimiaVectorDouble(sizes->num_ion_exchange_sites, + &(state->cation_exchange_capacity)); + + AllocateAlquimiaVectorDouble(sizes->num_minerals, + &(state->mineral_volume_fraction)); + + AllocateAlquimiaVectorDouble(sizes->num_minerals, + &(state->mineral_specific_surface_area)); +} /* end AllocateAlquimiaState() */ + +void FreeAlquimiaState(AlquimiaState* state) { + if (state != NULL) { + FreeAlquimiaVectorDouble(&(state->total_mobile)); + FreeAlquimiaVectorDouble(&(state->total_immobile)); + FreeAlquimiaVectorDouble(&(state->mineral_volume_fraction)); + FreeAlquimiaVectorDouble(&(state->mineral_specific_surface_area)); + FreeAlquimiaVectorDouble(&(state->cation_exchange_capacity)); + FreeAlquimiaVectorDouble(&(state->surface_site_density)); + } +} /* end FreeAlquimiaState() */ + +/******************************************************************************* + ** + ** Auxiliary Data + ** + *******************************************************************************/ + +void AllocateAlquimiaAuxiliaryData(const AlquimiaSizes* const sizes, + AlquimiaAuxiliaryData* aux_data) { + AllocateAlquimiaVectorInt(sizes->num_aux_integers, + &(aux_data->aux_ints)); + + AllocateAlquimiaVectorDouble(sizes->num_aux_doubles, + &(aux_data->aux_doubles)); + +} /* end AllocateAlquimiaAuxiliaryData() */ + +void FreeAlquimiaAuxiliaryData(AlquimiaAuxiliaryData* aux_data) { + if (aux_data != NULL) { + FreeAlquimiaVectorInt(&(aux_data->aux_ints)); + FreeAlquimiaVectorDouble(&(aux_data->aux_doubles)); + } +} /* end FreeAlquimiaAuxiliaryData() */ + +/******************************************************************************* + ** + ** Properties + ** + *******************************************************************************/ + +void AllocateAlquimiaProperties(const AlquimiaSizes* const sizes, + AlquimiaProperties* props) { + AllocateAlquimiaVectorDouble(sizes->num_isotherm_species, + &(props->isotherm_kd)); + AllocateAlquimiaVectorDouble(sizes->num_isotherm_species, + &(props->freundlich_n)); + AllocateAlquimiaVectorDouble(sizes->num_isotherm_species, + &(props->langmuir_b)); + AllocateAlquimiaVectorDouble(sizes->num_minerals, + &(props->mineral_rate_cnst)); + AllocateAlquimiaVectorDouble(sizes->num_aqueous_kinetics, + &(props->aqueous_kinetic_rate_cnst)); + +} /* end AllocateAlquimiaProperties() */ + +void FreeAlquimiaProperties(AlquimiaProperties* props) { + if (props != NULL) { + FreeAlquimiaVectorDouble(&(props->isotherm_kd)); + FreeAlquimiaVectorDouble(&(props->freundlich_n)); + FreeAlquimiaVectorDouble(&(props->langmuir_b)); + FreeAlquimiaVectorDouble(&(props->mineral_rate_cnst)); + FreeAlquimiaVectorDouble(&(props->aqueous_kinetic_rate_cnst)); + } +} /* end FreeAlquimiaProperties() */ + +/******************************************************************************* + ** + ** Problem Meta Data + ** + *******************************************************************************/ + +void AllocateAlquimiaProblemMetaData(const AlquimiaSizes* const sizes, + AlquimiaProblemMetaData* meta_data) { + + AllocateAlquimiaVectorString(sizes->num_primary, &(meta_data->primary_names)); + ALQUIMIA_ASSERT(meta_data->primary_names.data != NULL); + + AllocateAlquimiaVectorInt(sizes->num_primary, &(meta_data->positivity)); + memset(meta_data->positivity.data, 0, sizeof(int) * sizes->num_primary); + + AllocateAlquimiaVectorString(sizes->num_minerals, + &(meta_data->mineral_names)); + + AllocateAlquimiaVectorString(sizes->num_surface_sites, + &(meta_data->surface_site_names)); + + AllocateAlquimiaVectorString(sizes->num_ion_exchange_sites, + &(meta_data->ion_exchange_names)); + + AllocateAlquimiaVectorString(sizes->num_isotherm_species, + &(meta_data->isotherm_species_names)); + + AllocateAlquimiaVectorString(sizes->num_aqueous_kinetics, + &(meta_data->aqueous_kinetic_names)); + +} /* end AllocateAlquimiaProblemMetaData() */ + +void FreeAlquimiaProblemMetaData(AlquimiaProblemMetaData* meta_data) { + + if (meta_data != NULL) { + FreeAlquimiaVectorString(&(meta_data->primary_names)); + FreeAlquimiaVectorInt(&(meta_data->positivity)); + FreeAlquimiaVectorString(&(meta_data->mineral_names)); + FreeAlquimiaVectorString(&(meta_data->surface_site_names)); + FreeAlquimiaVectorString(&(meta_data->ion_exchange_names)); + FreeAlquimiaVectorString(&(meta_data->isotherm_species_names)); + FreeAlquimiaVectorString(&(meta_data->aqueous_kinetic_names)); + } +} /* end FreeAlquimiaProblemMetaData() */ + +/******************************************************************************* + ** + ** Auxiliary Output Data + ** + *******************************************************************************/ + +void AllocateAlquimiaAuxiliaryOutputData(const AlquimiaSizes* const sizes, + AlquimiaAuxiliaryOutputData* aux_output) { + aux_output->pH = -999.9; + AllocateAlquimiaVectorDouble(sizes->num_minerals, + &(aux_output->mineral_saturation_index)); + + AllocateAlquimiaVectorDouble(sizes->num_aqueous_kinetics, + &(aux_output->aqueous_kinetic_rate)); + + AllocateAlquimiaVectorDouble(sizes->num_minerals, + &(aux_output->mineral_reaction_rate)); + + AllocateAlquimiaVectorDouble(sizes->num_primary, + &(aux_output->primary_free_ion_concentration)); + AllocateAlquimiaVectorDouble(sizes->num_primary, + &(aux_output->primary_activity_coeff)); + + AllocateAlquimiaVectorDouble(sizes->num_aqueous_complexes, + &(aux_output->secondary_free_ion_concentration)); + AllocateAlquimiaVectorDouble(sizes->num_aqueous_complexes, + &(aux_output->secondary_activity_coeff)); + +} /* end AllocateAlquimiaAuxiliaryOutputData() */ + +void FreeAlquimiaAuxiliaryOutputData(AlquimiaAuxiliaryOutputData* aux_output) { + if (aux_output != NULL) { + FreeAlquimiaVectorDouble(&(aux_output->aqueous_kinetic_rate)); + FreeAlquimiaVectorDouble(&(aux_output->mineral_saturation_index)); + FreeAlquimiaVectorDouble(&(aux_output->mineral_reaction_rate)); + FreeAlquimiaVectorDouble(&(aux_output->primary_free_ion_concentration)); + FreeAlquimiaVectorDouble(&(aux_output->primary_activity_coeff)); + FreeAlquimiaVectorDouble(&(aux_output->secondary_free_ion_concentration)); + FreeAlquimiaVectorDouble(&(aux_output->secondary_activity_coeff)); + } +} /* end FreeAlquimiaAuxiliaryOutputData() */ + +/******************************************************************************* + ** + ** Engine Status + ** + *******************************************************************************/ + +void AllocateAlquimiaEngineStatus(AlquimiaEngineStatus* status) { + + status->message = (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); + if (NULL == status->message) { + /* TODO(bja): error handling */ + } +} /* end AllocateAlquimiaEngineStatus() */ + +void FreeAlquimiaEngineStatus(AlquimiaEngineStatus* status) { + if (status != NULL) { + free(status->message); + } + status->message = NULL; + +} /* end FreeAlquimiaEngineStatus() */ + + + +/******************************************************************************* + ** + ** Geochemical conditions/constraints + ** + *******************************************************************************/ + +void AllocateAlquimiaGeochemicalConditionVector(const int num_conditions, + AlquimiaGeochemicalConditionVector* condition_list) { + /* NOTE: we are only allocating pointers to N conditions here, not + the actual conditions themselves. */ + fprintf(stdout, " AllocateAlquimiaGeochemicalConditionList() : %d\n", + num_conditions); + condition_list->size = num_conditions; + condition_list->capacity = nearest_power_of_2(num_conditions); + + if (condition_list->size > 0) { + condition_list->data = (AlquimiaGeochemicalCondition*) + calloc((size_t)condition_list->capacity, + sizeof(AlquimiaGeochemicalCondition)); + } +} /* end AllocateAlquimiaGeochemicalConditionVector() */ + +void AllocateAlquimiaGeochemicalCondition(const int size_name, + const int num_aqueous_constraints, + const int num_mineral_constraints, + AlquimiaGeochemicalCondition* condition) { + /* NOTE: we are only allocating pointers to N constraints here, not + the actual condstraints themselves. */ + if (condition != NULL) { + /* size_name + 1 to include the null character! */ + condition->name = (char*) calloc((size_t)size_name+1, sizeof(char)); + AllocateAlquimiaAqueousConstraintVector(num_aqueous_constraints, &condition->aqueous_constraints); + AllocateAlquimiaMineralConstraintVector(num_mineral_constraints, &condition->mineral_constraints); + } +} /* end AllocateAlquimiaGeochemicalCondition() */ + +void AllocateAlquimiaAqueousConstraint(AlquimiaAqueousConstraint* constraint) { + constraint->primary_species_name = + (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); + constraint->constraint_type = + (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); + constraint->associated_species = + (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); + constraint->value = 0.0; +} /* end AllocateAlquimiaAqueousConstraint() */ + +void AllocateAlquimiaAqueousConstraintVector(int num_constraints, + AlquimiaAqueousConstraintVector* constraint_list) { + constraint_list->size = num_constraints; + constraint_list->capacity = nearest_power_of_2(num_constraints); + if (constraint_list->size > 0) { + constraint_list->data = (AlquimiaAqueousConstraint*) + calloc((size_t)constraint_list->capacity, + sizeof(AlquimiaAqueousConstraint)); + } + else + constraint_list->data = NULL; +} + +void AllocateAlquimiaMineralConstraint(AlquimiaMineralConstraint* constraint) { + constraint->mineral_name = + (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); + constraint->volume_fraction = -1.0; + constraint->specific_surface_area = -1.0; +} /* end AllocateAlquimiaMineralConstraint() */ + +void AllocateAlquimiaMineralConstraintVector(int num_constraints, + AlquimiaMineralConstraintVector* constraint_list) { + constraint_list->size = num_constraints; + constraint_list->capacity = nearest_power_of_2(num_constraints); + if (constraint_list->size > 0) { + constraint_list->data = (AlquimiaMineralConstraint*) + calloc((size_t)constraint_list->capacity, + sizeof(AlquimiaMineralConstraint)); + } + else + constraint_list->data = NULL; +} + +void FreeAlquimiaGeochemicalConditionVector(AlquimiaGeochemicalConditionVector* condition_list) { + int i; + if (condition_list != NULL) { + for (i = 0; i < condition_list->size; ++i) { + FreeAlquimiaGeochemicalCondition(&(condition_list->data[i])); + } + if (condition_list->data != NULL) { + free(condition_list->data); + condition_list->data = NULL; + } + condition_list->size = 0; + condition_list->capacity = 0; + } +} /* end FreeAlquimiaGeochemicalConditionList() */ + +void FreeAlquimiaGeochemicalCondition(AlquimiaGeochemicalCondition* condition) { + if (condition != NULL) { + if (condition->name != NULL) { + free(condition->name); + condition->name = NULL; + } + FreeAlquimiaAqueousConstraintVector(&(condition->aqueous_constraints)); + FreeAlquimiaMineralConstraintVector(&(condition->mineral_constraints)); + } +} /* end FreeAlquimiaGeochemicalCondition() */ + +void FreeAlquimiaAqueousConstraintVector(AlquimiaAqueousConstraintVector* vector) { + int i; + if (vector != NULL) { + for (i = 0; i < vector->size; ++i) { + FreeAlquimiaAqueousConstraint(&vector->data[i]); + } + if (vector->data != NULL) { + free(vector->data); + vector->data = NULL; + } + vector->size = 0; + vector->capacity = 0; + } +} /* end FreeAlquimiaAqueousConstraintVector() */ + +void FreeAlquimiaAqueousConstraint(AlquimiaAqueousConstraint* constraint) { + free(constraint->primary_species_name); + constraint->primary_species_name = NULL; + free(constraint->constraint_type); + constraint->constraint_type = NULL; + free(constraint->associated_species); + constraint->associated_species = NULL; +} /* end FreeAlquimiaAqueousConstraint() */ + +void FreeAlquimiaMineralConstraintVector(AlquimiaMineralConstraintVector* vector) { + int i; + if (vector != NULL) { + for (i = 0; i < vector->size; ++i) { + FreeAlquimiaMineralConstraint(&vector->data[i]); + } + free(vector->data); + vector->data = NULL; + vector->size = 0; + vector->capacity = 0; + } +} /* end FreeAlquimiaMineralConstraintVector() */ + +void FreeAlquimiaMineralConstraint(AlquimiaMineralConstraint* constraint) { + free(constraint->mineral_name); + constraint->mineral_name = NULL; +} /* end FreeAlquimiaMineralConstraint() */ + + +/******************************************************************************* + ** + ** Data convenience struct + ** + *******************************************************************************/ +void AllocateAlquimiaData(AlquimiaData* data) { + AllocateAlquimiaState(&data->sizes, &data->state); + AllocateAlquimiaProperties(&data->sizes, &data->properties); + AllocateAlquimiaAuxiliaryData(&data->sizes, &data->aux_data); + AllocateAlquimiaProblemMetaData(&data->sizes, &data->meta_data); + AllocateAlquimiaAuxiliaryOutputData(&data->sizes, &data->aux_output); +} /* end AllocateAlquimiaData() */ + + +void FreeAlquimiaData(AlquimiaData* data) { + FreeAlquimiaState(&data->state); + FreeAlquimiaProperties(&data->properties); + FreeAlquimiaAuxiliaryData(&data->aux_data); + FreeAlquimiaProblemMetaData(&data->meta_data); + FreeAlquimiaAuxiliaryOutputData(&data->aux_output); +} /* end FreeAlquimiaData() */ diff --git a/src/pks/ecosim_pk/BGC_memory.h b/src/pks/ecosim_pk/BGC_memory.h new file mode 100644 index 000000000..1a613f8b6 --- /dev/null +++ b/src/pks/ecosim_pk/BGC_memory.h @@ -0,0 +1,112 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** Alquimia is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + +#ifndef ALQUIMIA_C_MEMORY_H_ +#define ALQUIMIA_C_MEMORY_H_ + +#include "alquimia/alquimia_interface.h" +#include "alquimia/alquimia_containers.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /* Alquimia Vectors */ + void AllocateAlquimiaVectorDouble(const int size, AlquimiaVectorDouble* vector); + void FreeAlquimiaVectorDouble(AlquimiaVectorDouble* vector); + + void AllocateAlquimiaVectorInt(const int size, AlquimiaVectorInt* vector); + void FreeAlquimiaVectorInt(AlquimiaVectorInt* vector); + + void AllocateAlquimiaVectorString(const int size, AlquimiaVectorString* vector); + void FreeAlquimiaVectorString(AlquimiaVectorString* vector); + + /* State */ + void AllocateAlquimiaState(const AlquimiaSizes* const sizes, + AlquimiaState* state); + + void FreeAlquimiaState(AlquimiaState* state); + + /* Auxiliary Data */ + void AllocateAlquimiaAuxiliaryData(const AlquimiaSizes* const sizes, + AlquimiaAuxiliaryData* aux_data); + void FreeAlquimiaAuxiliaryData(AlquimiaAuxiliaryData* aux_data); + + /* Properties */ + void AllocateAlquimiaProperties(const AlquimiaSizes* const sizes, + AlquimiaProperties* props); + void FreeAlquimiaProperties(AlquimiaProperties* props); + + /* Problem Meta Data */ + void AllocateAlquimiaProblemMetaData(const AlquimiaSizes* const sizes, + AlquimiaProblemMetaData* meta_data); + + void FreeAlquimiaProblemMetaData(AlquimiaProblemMetaData* metda_data); + + /* Status */ + void AllocateAlquimiaEngineStatus(AlquimiaEngineStatus* status); + + void FreeAlquimiaEngineStatus(AlquimiaEngineStatus* status); + + /* Auxiliary Output Data */ + void AllocateAlquimiaAuxiliaryOutputData(const AlquimiaSizes* const sizes, + AlquimiaAuxiliaryOutputData* aux_output); + void FreeAlquimiaAuxiliaryOutputData(AlquimiaAuxiliaryOutputData* aux_output); + + /* Geochemical conditions/constraints */ + void AllocateAlquimiaGeochemicalConditionVector(const int num_conditions, + AlquimiaGeochemicalConditionVector* condition_list); + void AllocateAlquimiaGeochemicalCondition(const int size_name, + const int num_aqueous_constraints, + const int num_mineral_constraints, + AlquimiaGeochemicalCondition* condition); + void AllocateAlquimiaAqueousConstraintVector(const int num_constraints, + AlquimiaAqueousConstraintVector* constraint_list); + void AllocateAlquimiaAqueousConstraint(AlquimiaAqueousConstraint* constraint); + void AllocateAlquimiaMineralConstraintVector(const int num_constraints, + AlquimiaMineralConstraintVector* constraint_list); + void AllocateAlquimiaMineralConstraint(AlquimiaMineralConstraint* constraint); + + void FreeAlquimiaGeochemicalConditionVector(AlquimiaGeochemicalConditionVector* condition_list); + void FreeAlquimiaGeochemicalCondition(AlquimiaGeochemicalCondition* condition); + void FreeAlquimiaAqueousConstraintVector(AlquimiaAqueousConstraintVector* vector); + void FreeAlquimiaAqueousConstraint(AlquimiaAqueousConstraint* constraint); + void FreeAlquimiaMineralConstraintVector(AlquimiaMineralConstraintVector* vector); + void FreeAlquimiaMineralConstraint(AlquimiaMineralConstraint* constraint); + + + /* Data */ + void AllocateAlquimiaData(AlquimiaData* data); + void FreeAlquimiaData(AlquimiaData* data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* ALQUIMIA_C_MEMORY_H_ */ diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index dc53d3c09..dec669cdd 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -109,12 +109,12 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // This is a small function in ChemistryEngine that simply looks at the metadata // finds the number of primary species and fills a vector with the names of those //species - comp_names_.clear(); - bgc_engine_->GetPrimarySpeciesNames(comp_names_); + //comp_names_.clear(); + //bgc_engine_->GetPrimarySpeciesNames(comp_names_); - number_aqueous_components_ = comp_names_.size(); - number_free_ion_ = number_aqueous_components_; - number_total_sorbed_ = number_aqueous_components_; + //number_aqueous_components_ = comp_names_.size(); + //number_free_ion_ = number_aqueous_components_; + //number_total_sorbed_ = number_aqueous_components_; } @@ -175,7 +175,7 @@ void EcoSIM::Setup() { // Setup more auxiliary data if (!S_->HasRecord(alquimia_aux_data_key_, tag_next_)) { - int num_aux_data = chem_engine_->Sizes().num_aux_integers + chem_engine_->Sizes().num_aux_doubles; + int num_aux_data = bgc_engine_->Sizes().num_aux_integers + bgc_engine_->Sizes().num_aux_doubles; S_->Require(alquimia_aux_data_key_, tag_next_, passwd_) .SetMesh(mesh_)->SetGhosted(false)->SetComponent("cell", AmanziMesh::CELL, num_aux_data); @@ -237,10 +237,6 @@ void EcoSIM::Initialize() { auto col_depth = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); - const Epetra_Vector& temp = *(*S_->Get("temperature", tag_next_) - .ViewComponent("cell",false))(0); - int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //This is the main set up code in alquimia it loops over times and chemical conditions @@ -257,8 +253,8 @@ void EcoSIM::Initialize() { << "\" in region \"" << region << "\"\n"; } for (int col=0; col!=num_cols_; ++col) { - FieldToColumn_(col, temp, col_temp.ptr()); - ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); + //FieldToColumn_(col, temp, col_temp.ptr()); + //ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); //We're going to need to write an InitializeSingleColumn code //ierr = InitializeSingleCell(cell, condition); @@ -493,10 +489,8 @@ void EcoSIM::CopyToEcoSIM(int col, BGCState& state, BGCAuxiliaryData& aux_data) { - //NOTE: I Have not touched this yet as it will depend on what we have to - //Transfer - // //Fill state with ATS variables that are going to be changed by EcoSIM + //NEED TO DECIDE WHICH PROPERTIES GO WHERE const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); const auto& fluid_density = *S_->Get(fluid_den_key_, water_tag).ViewComponent("cell", true); const auto& water_saturation = *S_->Get(saturation_key_, water_tag).ViewComponent("cell", true); @@ -522,46 +516,9 @@ void EcoSIM::CopyToEcoSIM(int col, } } - // minerals - assert(state.mineral_volume_fraction.size == number_minerals_); - assert(state.mineral_specific_surface_area.size == number_minerals_); - assert(mat_props.mineral_rate_cnst.size == number_minerals_); - - if (number_minerals_ > 0) { - const auto& mineral_vf = *S_->Get(min_vol_frac_key_, tag_next_).ViewComponent("cell"); - const auto& mineral_ssa = *S_->Get(min_ssa_key_, tag_next_).ViewComponent("cell"); - const auto& mineral_rate = *S_->Get(mineral_rate_constant_key_, tag_next_).ViewComponent("cell"); - for (unsigned int i = 0; i < number_minerals_; ++i) { - state.mineral_volume_fraction.data[i] = mineral_vf[i][cell]; - mat_props.mineral_rate_cnst.data[i] = mineral_rate[i][cell]; - state.mineral_specific_surface_area.data[i] = mineral_ssa[i][cell]; - } - } - - // ion exchange - assert(state.cation_exchange_capacity.size == number_ion_exchange_sites_); - if (number_ion_exchange_sites_ > 0) { - const auto& ion_exchange = *S_->Get(ion_exchange_sites_key_, tag_next_).ViewComponent("cell"); - for (int i = 0; i < number_ion_exchange_sites_; i++) { - state.cation_exchange_capacity.data[i] = ion_exchange[i][cell]; - } - } - - // surface complexation - if (number_sorption_sites_ > 0) { - const auto& sorption_sites = *S_->Get(sorp_sites_key_, tag_next_).ViewComponent("cell"); - - assert(number_sorption_sites_ == state.surface_site_density.size); - for (int i = 0; i < number_sorption_sites_; ++i) { - // FIXME: Need site density names, too? - state.surface_site_density.data[i] = sorption_sites[i][cell]; - // TODO(bandre): need to save surface complexation free site conc here! - } - } - // Auxiliary data -- block copy. - if (S_->HasRecord(alquimia_aux_data_key_, tag_next_)) { - aux_data_ = S_->GetW(alquimia_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); + if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { + aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); int num_aux_ints = chem_engine_->Sizes().num_aux_integers; int num_aux_doubles = chem_engine_->Sizes().num_aux_doubles; @@ -577,39 +534,18 @@ void EcoSIM::CopyToEcoSIM(int col, mat_props.volume = mesh_->cell_volume(cell); mat_props.saturation = water_saturation[0][cell]; - - // sorption isotherms - if (using_sorption_isotherms_) { - const auto& isotherm_kd = *S_->Get(isotherm_kd_key_, tag_next_).ViewComponent("cell"); - const auto& isotherm_freundlich_n = *S_->Get(isotherm_freundlich_n_key_, tag_next_).ViewComponent("cell"); - const auto& isotherm_langmuir_b = *S_->Get(isotherm_langmuir_b_key_, tag_next_).ViewComponent("cell"); - - for (unsigned int i = 0; i < number_aqueous_components_; ++i) { - mat_props.isotherm_kd.data[i] = isotherm_kd[i][cell]; - mat_props.freundlich_n.data[i] = isotherm_freundlich_n[i][cell]; - mat_props.langmuir_b.data[i] = isotherm_langmuir_b[i][cell]; - } - } - - // first order reaction rate cnst - if (number_aqueous_kinetics_ > 0) { - const auto& aqueous_kinetics_rate = *S_->Get(first_order_decay_constant_key_, tag_next_).ViewComponent("cell"); - for (unsigned int i = 0; i < number_aqueous_kinetics_; ++i) { - mat_props.aqueous_kinetic_rate_cnst.data[i] = aqueous_kinetics_rate[i][cell]; - } - } } void EcoSIM::CopyEcoSIMStateToAmanzi( - const int cell, + const int col, const BGCProperties& props, const BGCState& state, const BGCAuxiliaryData& aux_data) { - CopyFromEcoSIM(cell, props, state, aux_data); + CopyFromEcoSIM(col, props, state, aux_data); } -void EcoSIM::CopyFromEcoSIM(const int cell, +void EcoSIM::CopyFromEcoSIM(const int col, const BGCProperties& props, const BGCState& state, const BGCAuxiliaryData& aux_data) @@ -630,11 +566,11 @@ void EcoSIM::CopyFromEcoSIM(const int cell, //Here is where the auxiliary data is filled need to try to change this to columns //This may not be trivial - if (S_->HasRecord(alquimia_aux_data_key_, tag_next_)) { - aux_data_ = S_->GetW(alquimia_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); + if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { + aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); - int num_aux_ints = chem_engine_->Sizes().num_aux_integers; - int num_aux_doubles = chem_engine_->Sizes().num_aux_doubles; + int num_aux_ints = bgc_engine_->Sizes().num_aux_integers; + int num_aux_doubles = bgc_engine_->Sizes().num_aux_doubles; for (int i = 0; i < num_aux_ints; i++) { double* cell_aux_ints = (*aux_data_)[i]; @@ -670,12 +606,12 @@ int EcoSIM::InitializeSingleColumn(int col, const std::string& condition) { // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but // should use the same tag as transport. See #673 - CopyToAlquimia(col, bgc_props_, bgc_state_, bgc_aux_data_); + CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_); bgc_engine_->EnforceCondition(condition, current_time_, bgc_props_, bgc_state_, bgc_aux_data_); - CopyAlquimiaStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_); + CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_); // ETC: hacking to get consistent solution -- if there is no water From 1fbee736374a0a6b1b79ea64041a4b514d834795 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 19 Jan 2023 17:35:50 -0800 Subject: [PATCH 004/582] Actually defined column size, and other minor edits. --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 51 ++++++++++++++++++++--- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index dec669cdd..4d3e05aac 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -20,7 +20,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& S, const Teuchos::RCP& solution): PK_Physical_Default(pk_tree, global_list, S, solution), - PK(pk_tree, global_list, S, solution) + PK(pk_tree, global_list, S, solution), + ncells_per_col_(-1) { domain_ = plist_->get("domain name", "domain"); @@ -29,12 +30,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // transport, flow, and energy // What do we need for EcoSIM? Based on the variables doc it is: // grid position (X,Y,Z) - can we just pass Z and assume X and Y are 0? - // soil texture - not sure where this is // bulk density - not sure - // Elevation // Aspect in geometric format - // soil texture (sand, clay, silt) - // water table depth + // water table depth - There's a water table evaluator in + // /src/constitutive_relations/column_integrators/ but I don't see it used + // anywhere can we just use it here? // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); @@ -46,6 +46,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, ice_den_key_ = Keys::readKey(plist_, domain, "ice mass density", "mass_density_ice"); mass_den_key_ = Keys::readKey(plist_, domain, "mass density", mass_key); rhos_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); + elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); //energy T_key_ = Keys::readKey(plist_, domain_name, "temperature", "temperature"); @@ -56,6 +57,14 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); + //There are no native variables for sand, silt and clay we need to implement these + //ourselves. Is this something that can be in the EcoSIM input file? In that case + //it should just be just held in memory. + + sand_frac_key_ = Keys::readKey(*plist_, domain_ss_, "sand fraction", "sand_fraction"); + silt_frac_key_ = Keys::readKey(*plist_, domain_ss_, "silt fraction", "silt_fraction"); + clay_frac_key_ = Keys::readKey(*plist_, domain_ss_, "clay fraction", "clay_fraction"); + // parameters // initial timestep dt_ = plist_->get("initial time step", 1.); @@ -160,6 +169,28 @@ void EcoSIM::Setup() { } */ + //Need to do some basic setup of the columns: + mesh_surf_ = S_->GetMesh(domain_surf_); + num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + + for (unsigned int col = 0; col != num_cols_; ++col) { + int f = mesh_surf_->entity_get_parent(AmanziMesh::CELL, col); + auto& col_iter = mesh_->cells_of_column(col); + std::size_t ncol_cells = col_iter.size(); + + // unclear which this should be: + // -- col area is the true face area + double col_area = mesh_->face_area(f); + // -- col area is the projected face area + // double col_area = mesh_surf_->cell_volume(col); + + if (ncells_per_col_ < 0) { + ncells_per_col_ = ncol_cells; + } else { + AMANZI_ASSERT(ncol_cells == ncells_per_col_); + } + } + //This is for the Auxiliary Data which we will need if (plist_->isParameter("auxiliary data")) { auto names = plist_->get >("auxiliary data"); @@ -502,6 +533,16 @@ void EcoSIM::CopyToEcoSIM(int col, const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); + //Define the column vectors to hold the data + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + //Here is where we should do the various field-to-column calls to then pass along + //to the data structures that will pass the data to EcoSIM + //Format is: + //FieldToColumn_(column index, dataset to copy from, vector to put the data in) + + FieldToColumn_(col,temp, col_temp.ptr()); + state.water_density = fluid_density[0][cell]; state.porosity = porosity[0][cell]; From 8a7e059a69351389474955e5cf672b5d2e545e8f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 26 Jan 2023 16:52:53 -0800 Subject: [PATCH 005/582] Modifications to the variables that need to be transfered --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 152 ++++++++++++++++------ 1 file changed, 113 insertions(+), 39 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4d3e05aac..473b574b7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -30,7 +30,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // transport, flow, and energy // What do we need for EcoSIM? Based on the variables doc it is: // grid position (X,Y,Z) - can we just pass Z and assume X and Y are 0? - // bulk density - not sure // Aspect in geometric format // water table depth - There's a water table evaluator in // /src/constitutive_relations/column_integrators/ but I don't see it used @@ -41,12 +40,25 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //Flow poro_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); - saturation_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); + saturation_liquid_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); + saturation_gas_key_ = Keys::readKey(*plist_,domain_,"saturation gas", "saturation_gas"); + saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); + elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); + water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); + rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeabiilty","relative_permeability"); + + //densities + //If we need bulk density do we need volume fractions of each quantity? + //This can be computed from the saturations and porosity (I think) via: + // f_rock = (1 - porosity) + // f_liq = S_liq * porosity + // f_gas = S_gas * porosity + // f_ice = S_ice * porosity + fluid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_den_key_ = Keys::readKey(plist_, domain, "ice mass density", "mass_density_ice"); - mass_den_key_ = Keys::readKey(plist_, domain, "mass density", mass_key); - rhos_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); - elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); + gas_den_key_ = Keys::readKey(plist_,domain,"gas mass density", "mass_density_gas") + rock_den_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); //energy T_key_ = Keys::readKey(plist_, domain_name, "temperature", "temperature"); @@ -57,14 +69,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); - //There are no native variables for sand, silt and clay we need to implement these - //ourselves. Is this something that can be in the EcoSIM input file? In that case - //it should just be just held in memory. - - sand_frac_key_ = Keys::readKey(*plist_, domain_ss_, "sand fraction", "sand_fraction"); - silt_frac_key_ = Keys::readKey(*plist_, domain_ss_, "silt fraction", "silt_fraction"); - clay_frac_key_ = Keys::readKey(*plist_, domain_ss_, "clay fraction", "clay_fraction"); - // parameters // initial timestep dt_ = plist_->get("initial time step", 1.); @@ -251,11 +255,16 @@ void EcoSIM::Initialize() { // I think this is everything from ATS that needs to be updated S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(fluid_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(saturation_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(mass_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(rhos_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); @@ -349,11 +358,16 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // Update all dependencies again S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(fluid_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(saturation_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(mass_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(rhos_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); @@ -459,6 +473,18 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, } } +// I think I need a function for pushing from the column back to the field +// with any luck it's just the reverse of the above similar to how it's done +// cell by cell in alquimia + +void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + double* col_vec, int ncol) +{ + auto& col_iter = mesh_->cells_of_column(col); + for (std::size_t i=0; i!=col_iter.size(); ++i) { + vec[col_iter[i]] = col_vec[i]; + } +} // helper function for collecting column dz and depth void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, @@ -522,39 +548,90 @@ void EcoSIM::CopyToEcoSIM(int col, { //Fill state with ATS variables that are going to be changed by EcoSIM //NEED TO DECIDE WHICH PROPERTIES GO WHERE + const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); + const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); + const auto& gas_saturation = *S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", true); + const auto& ice_saturation = *S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", true); + const auto& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", true); + const auto& water_content = *S_->Get(water_content_key_, water_tag).ViewComponent("cell", true); + const auto& relative_permeability = *S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", true); const auto& fluid_density = *S_->Get(fluid_den_key_, water_tag).ViewComponent("cell", true); - const auto& water_saturation = *S_->Get(saturation_key_, water_tag).ViewComponent("cell", true); - const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); const auto& ice_density = *S_->Get(ice_den_key_, water_tag).ViewComponent("cell", true); - const auto& mass_density = *S_->Get(mass_den_key_, water_tag).ViewComponent("cell", true); - const auto& rock_density = *S_->Get(rhos_key_, water_tag).ViewComponent("cell", true); - const auto& Temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", true); + const auto& gas_density = *S_->Get(gas_den_key_, water_tag).ViewComponent("cell", true); + const auto& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", true); + const auto& temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", true); const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); //Define the column vectors to hold the data + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //Here is where we should do the various field-to-column calls to then pass along //to the data structures that will pass the data to EcoSIM //Format is: //FieldToColumn_(column index, dataset to copy from, vector to put the data in) + FieldToColumn_(col,tcc,col_tcc.ptr()); + FieldToColumn_(col,porosity,col_poro.ptr()); + FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); + FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); + FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); + FieldToColumn_(col,elevation,col_elev.ptr()); + FieldToColumn_(col,water_content,col_wc.ptr()); + FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); + FieldToColumn_(col,fluid_density,col_f_dens.ptr()); + FieldToColumn_(col,ice_density,col_i_dens.ptr()); + FieldToColumn_(col,gas_density,col_g_dens.ptr()); + FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,temp, col_temp.ptr()); + FieldToColumn_(col,conductivity,col_cond.ptr()); + FieldToColumn_(col,cell_volume,col_vol.ptr()); - state.water_density = fluid_density[0][cell]; - state.porosity = porosity[0][cell]; - - //We are probably going to need to do something like this that loops over - //All transport components to give them over to EcoSIM - for (int i = 0; i < number_aqueous_components_; i++) { - state.total_mobile.data[i] = (*aqueous_components)[i][cell]; - - if (using_sorption_) { - const auto& sorbed = *S_->Get(total_sorbed_key_, tag_next_).ViewComponent("cell"); - state.total_immobile.data[i] = sorbed[i][cell]; - } + //For now I'm just gonna guess what is modified and what isn't + // + // modified: + // saturation, tcc, water content? + // + // not modified: + // everything else? + + state.fluid_density = col_f_dens; + state.gas_density = col_g_dens; + state.ice_density = col_i_dens; + state.porosity = col_poro; + state.water_content = col_wc; + state.temperature = col_temp; + + //mat_props.volume = mesh_->cell_volume(cell; + //mat_props.saturation = water_saturation[0][cell]; + + mat_props.liquid_saturation = col_l_sat; + mat_props.gas_saturation = col_g_sat; + mat_props.ice_saturation = col_i_sat; + mat_props.elevation = col_elev; + mat_props.relative_permeability = col_rel_perm; + mat_props.conductivity = col_cond; + mat_props.volume = col_vol; + + num_components = tcc.NumVectors(); + + for (int i = 0; i < num_components; i++) { + state.total_mobile.data[i] = (*col_tcc)[i]; } // Auxiliary data -- block copy. @@ -572,9 +649,6 @@ void EcoSIM::CopyToEcoSIM(int col, aux_data.aux_doubles.data[i] = cell_aux_doubles[cell]; } } - - mat_props.volume = mesh_->cell_volume(cell); - mat_props.saturation = water_saturation[0][cell]; } void EcoSIM::CopyEcoSIMStateToAmanzi( From 56ed045e178fa57c299b76d51f3bda57e167267f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 26 Jan 2023 17:14:31 -0800 Subject: [PATCH 006/582] Test of how to repack the data into state --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 51 ++++++++++++++--------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 473b574b7..8af626375 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -630,6 +630,14 @@ void EcoSIM::CopyToEcoSIM(int col, num_components = tcc.NumVectors(); + //This probably isn't going to work. I think I either need to think + //of a way to do this + //Possible ideas: + // 1) creat a data column per component (how to do that without hard coding?) + // 2) have some sort of array of shape num_componentsXcolumnsize and loop over + // the components + // For #2 I think I just need to change the serieal dense vector call to + // a different data type (are these always 1d?) What is the 2d version? for (int i = 0; i < num_components; i++) { state.total_mobile.data[i] = (*col_tcc)[i]; } @@ -670,13 +678,15 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - for (int i = 0; i < number_aqueous_components_; ++i) { - (*aqueous_components)[i][cell] = state.total_mobile.data[i]; + col_f_dens = state.fluid_density; + col_g_dens = state.gas_density; + col_i_dnes = state.ice_density; + col_poro = state.porosity; + col_wc = state.water_content; + col_temp = state.temperature; - if (using_sorption_) { - auto& sorbed = *S_->GetW(total_sorbed_key_, tag_next_, passwd_).ViewComponent("cell"); - sorbed[i][cell] = state.total_immobile.data[i]; - } + for (int i = 0; i < num_components; i++) { + state.total_mobile.data[i] = (*col_tcc)[i]; } //Here is where the auxiliary data is filled need to try to change this to columns @@ -697,20 +707,23 @@ void EcoSIM::CopyFromEcoSIM(const int col, } } + //pack this data back into the num_columns + ColumnToField_(col,tcc,col_tcc.ptr()); + ColumnToField_(col,porosity,col_poro.ptr()); + ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); + ColumnToField_(col,gas_saturation,col_g_sat.ptr()); + ColumnToField_(col,ice_saturation,col_i_sat.ptr()); + ColumnToField_(col,elevation,col_elev.ptr()); + ColumnToField_(col,water_content,col_wc.ptr()); + ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); + ColumnToField_(col,fluid_density,col_f_dens.ptr()); + ColumnToField_(col,ice_density,col_i_dens.ptr()); + ColumnToField_(col,gas_density,col_g_dens.ptr()); + ColumnToField_(col,rock_density,col_r_dens.ptr()); + ColumnToField_(col,temp, col_temp.ptr()); + ColumnToField_(col,conductivity,col_cond.ptr()); + ColumnToField_(col,cell_volume,col_vol.ptr()); - // Here is where constants are saved as properties (things that won't be - //changed by EcoSIM) - if (using_sorption_isotherms_) { - auto& isotherm_kd = *S_->GetW(isotherm_kd_key_, tag_next_, passwd_).ViewComponent("cell"); - auto& isotherm_freundlich_n = *S_->GetW(isotherm_freundlich_n_key_, tag_next_, passwd_).ViewComponent("cell"); - auto& isotherm_langmuir_b = *S_->GetW(isotherm_langmuir_b_key_, tag_next_, passwd_).ViewComponent("cell"); - - for (unsigned int i = 0; i < number_aqueous_components_; ++i) { - isotherm_kd[i][cell] = mat_props.isotherm_kd.data[i]; - isotherm_freundlich_n[i][cell] = mat_props.freundlich_n.data[i]; - isotherm_langmuir_b[i][cell] = mat_props.langmuir_b.data[i]; - } - } } /* ******************************************************************* From 2d254cd21f4a53a0915b17d500f316d4c026c0ef Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 30 Jan 2023 17:19:36 -0800 Subject: [PATCH 007/582] tidying up header and CMake files, and creating registration file. --- src/pks/ecosim_pk/BGCEngine.hh | 85 +++-------------------- src/pks/ecosim_pk/CMakeLists.txt | 14 ++-- src/pks/ecosim_pk/Ecosim_ATS_interface.hh | 37 ++++++++-- src/pks/ecosim_pk/Ecosim_interface_reg.hh | 19 +++++ 4 files changed, 65 insertions(+), 90 deletions(-) create mode 100644 src/pks/ecosim_pk/Ecosim_interface_reg.hh diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index d42079574..6b1c8d617 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -20,27 +20,15 @@ #include #include -#include "alquimia/alquimia_memory.h" -#include "alquimia/alquimia_util.h" +#include "BGC_memory.h" +/*#include "alquimia/alquimia_util.h" #include "alquimia/alquimia_constants.h" #include "alquimia/alquimia_containers.h" -#include "alquimia/alquimia_interface.h" +#include "alquimia/alquimia_interface.h"*/ namespace Amanzi { namespace EcoSIM { - -struct GeochemicalConditionData -{ - bool processed; - AlquimiaProperties mat_props; - AlquimiaGeochemicalCondition condition; - AlquimiaState chem_state; - AlquimiaAuxiliaryData aux_data; -}; - -typedef std::map GeochemicalConditionMap; - class BGCEngine { public: @@ -57,26 +45,6 @@ class BGCEngine { // Returns true if the chemistry engine is thread-safe, false if not. bool IsThreadSafe() const; - // These query methods return metadata for the chemical configuration represented - // within the chemistry engine. - int NumPrimarySpecies() const; - int NumAqueousComplexes() const; - int NumSorbedSpecies() const; - void GetPrimarySpeciesNames(std::vector& species_names) const; - int NumMinerals() const; - void GetMineralNames(std::vector& mineral_names) const; - int NumSurfaceSites() const; - void GetSurfaceSiteNames(std::vector& site_names) const; - int NumIonExchangeSites() const; - void GetIonExchangeNames(std::vector& ion_exchange_names) const; - int NumIsothermSpecies() const; - void GetIsothermSpeciesNames(std::vector& species_names) const; - int NumFreeIonSpecies() const; - void GetAuxiliaryOutputNames(std::vector& aux_names, - std::vector>& subfield_names) const; - int NumAqueousKinetics() const; - void GetAqueousKineticNames(std::vector& kinetics_names) const; - // Returns a reference to a "sizes" object that can be queried to find the sizes of the various // arrays representing the geochemical state within the engine. const AlquimiaSizes& Sizes() const; @@ -91,36 +59,6 @@ class BGCEngine { BGCState& chem_state, BGCAuxiliaryData& aux_data); - // Creates a geochemical condition with the given name within the chemistry engine, using the - // data in the given containers. - void CreateCondition(const std::string& condition_name); - - /* Mineral constraints will be discontinued in Alquimia -- see Sergi - // Adds a mineral constraint to the geochemical condition with the given name. If another - // constraint with the same mineral name exists for this condition, it is replaced by - // this one. - void AddMineralConstraint(const std::string& condition_name, - const std::string& mineral_name, - double volume_fraction, - double specific_surface_area); - Mineral constraints will be discontinued in Alquimia -- see Sergi */ - - // Adds an aqueous constraint to the geochemical condition with the given name. If another - // constraint involving the same primary species exists for this condition, it is replaced by - // this one. - // The constraint type may be "total_aqueous", "total_sorb", "free", "mineral", "gas", - // "pH", or "charge". - // The associated (mineral) species must be the name of a mineral mentioned - // in a mineral constraint that has been previously added to this condition - // using AddMineralConstraint(). - void AddAqueousConstraint(const std::string& condition_name, - const std::string& primary_species_name, - const std::string& constraint_type, - const std::string& associated_species); - - // Enforces the geochemical condition with the given name on the chemical configuration - // represented by the given array of concentrations at the given time. The order of the - // concentrations in the array matches that of the species names returned by GetSpeciesNames. void EnforceCondition(const std::string& condition_name, const double time, const AlquimiaProperties& mat_props, @@ -140,22 +78,19 @@ class BGCEngine { private: - // Alquimia data structures. - bool chem_initialized_; + // bgc data structures. + bool bgc_initialized_; void* engine_state_; - AlquimiaEngineFunctionality functionality_; + + /*AlquimiaEngineFunctionality functionality_; AlquimiaSizes sizes_; AlquimiaInterface chem_; AlquimiaEngineStatus chem_status_; - AlquimiaProblemMetaData chem_metadata_; - - // Mapping of geochemical condition names to geochemical conditions (and flags indicating - // whether they have been processed). - GeochemicalConditionMap chem_conditions_; + AlquimiaProblemMetaData chem_metadata_;*/ // Back-end engine name and input file. - std::string chem_engine_name_; - std::string chem_engine_inputfile_; + std::string bgc_engine_name_; + std::string bgc_engine_inputfile_; // forbidden. BGCEngine(); diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index b2bf0be7d..d0801848a 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -5,20 +5,17 @@ add_subdirectory(constitutive_relations) include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/root_storage) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/flux_uptake) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/atm_flux) # ATS EcoSIM pk +# For adding F90 files add the F90 file to the ecosim source files and +# inc files. The inc file also needs a header set(ats_ecosim_src_files - Ecosim_interface_test.cc - constitutive_relations/flux_uptake/eco_fort_test.F90 + Ecosim_ATS_interface.cc ) set(ats_ecosim_inc_files Ecosim_interface_test.hh - constitutive_relations/flux_uptake/eco_fort_test.F90 - constitutive_relations/flux_uptake/eco_fort_test_interface_private.hh ) set(ats_ecosim_link_libs @@ -51,13 +48,10 @@ add_amanzi_library(ats_ecosim # register evaluators/factories/pks register_evaluator_with_factory( - HEADERFILE Ecosim_interface_test_reg.hh + HEADERFILE Ecosim_interface_reg.hh LISTNAME ATS_ECOSIM_REG ) -#Do I need this? -#seems like you don't need the file, it's auto-generated -generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh LISTNAME ATS_ECOSIM_REG INSTALL True diff --git a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh index 8048e261b..872131846 100644 --- a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh +++ b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh @@ -23,6 +23,9 @@ #ifndef PKS_ECOSIM_HH_ #define PKS_ECOSIM_HH_ +#include + +#include "Epetra_MultiVector.h" #include "Teuchos_ParameterList.hpp" #include "Teuchos_RCP.hpp" #include "Epetra_SerialDenseVector.h" @@ -30,9 +33,13 @@ #include "VerboseObject.hh" #include "TreeVector.hh" +#include "Key.hh" +#include "Mesh.hh" +#include "State.hh" #include "BGCEngine.hh" #include "PK_Factory.hh" #include "pk_physical_default.hh" +#include "PK_Physical.hh" namespace Amanzi { namespace EcoSIM { @@ -125,17 +132,37 @@ class EcoSIM : public PK_Physical_Default { double* col_vec, int ncol); void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, Teuchos::Ptr depth, - Teuchos::Ptr dz) + Teuchos::Ptr dz); //evaluator for transpiration; //I don't think I need this anymore //Teuchos::RCP p_root_eval_; + int number_aqueous_components_; + // keys - Key wc_key_; - Key wc_root_key_; - Key trans_key_; - Key p_root_key_; + Key tcc_key_; + Key poro_key_; + Key saturation_liquid_key_; + Key saturation_gas_key_; + Key saturation_ice_key_; + Key elev_key_; + Key water_content_key_; + Key rel_perm_key_; + Key fluid_den_key_; + Key ice_den_key_; + Key gas_den_key_; + Key rock_den_key_; + Key T_key_; + Key conductivity_key_; + Key cv_key; + Key ecosim_aux_data_key_; + + private: + BGCState bgc_state_; + BGCProperties bgc_props_; + BGCAuxiliaryData bgc_aux_data_; + private: //factory registration static RegisteredPKFactory reg_; diff --git a/src/pks/ecosim_pk/Ecosim_interface_reg.hh b/src/pks/ecosim_pk/Ecosim_interface_reg.hh new file mode 100644 index 000000000..8af97cb0c --- /dev/null +++ b/src/pks/ecosim_pk/Ecosim_interface_reg.hh @@ -0,0 +1,19 @@ +/* -*- mode: c++; indent-tabs-mode: nil -*- */ +/* ------------------------------------------------------------------------- + * ATS + * + * License: see $ATS_DIR/COPYRIGHT + * Author: Ethan Coon + * + * ------------------------------------------------------------------------- */ + +#include "Ecosim_interface.hh" + +namespace Amanzi { +namespace EcoSIM { + +RegisteredPKFactory EcoSIM::reg_("EcoSIM for ATS"); + + +} // namespace +} // namespace From 28cfda7ac78e68f664a498a99427ae2a09ea32db Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 31 Jan 2023 12:36:10 -0800 Subject: [PATCH 008/582] reorganizing dirs and adding definitions for bgc data structures --- src/pks/ecosim_pk/BGCEngine.cc | 27 ++- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 58 +++-- src/pks/ecosim_pk/{ => data}/BGC_memory.c | 62 +++--- src/pks/ecosim_pk/{ => data}/BGC_memory.h | 0 .../ecosim_pk/data/alquimia_containers.F90 | 207 ++++++++++++++++++ src/pks/ecosim_pk/data/alquimia_containers.h | 188 ++++++++++++++++ 6 files changed, 476 insertions(+), 66 deletions(-) rename src/pks/ecosim_pk/{ => data}/BGC_memory.c (95%) rename src/pks/ecosim_pk/{ => data}/BGC_memory.h (100%) create mode 100644 src/pks/ecosim_pk/data/alquimia_containers.F90 create mode 100644 src/pks/ecosim_pk/data/alquimia_containers.h diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index ae0557eb5..d9dbf0876 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -148,8 +148,8 @@ BGCEngine::~BGCEngine() //chem_.Shutdown(&engine_state_, &chem_status_); //FreeAlquimiaProblemMetaData(&chem_metadata_); - // Delete the various geochemical conditions. - for (GeochemicalConditionMap::iterator + // As there are no chemical conditions, am I just deleting variables? + /*for (GeochemicalConditionMap::iterator iter = chem_conditions_.begin(); iter != chem_conditions_.end(); ++iter) { //FreeBGCGeochemicalCondition(&iter->second->condition); @@ -157,7 +157,11 @@ BGCEngine::~BGCEngine() FreeBGCProperties(&iter->second->mat_props); FreeBGCAuxiliaryData(&iter->second->aux_data); delete iter->second; - } + }*/ + + FreeBGCState(state); + FreeBGCProperties(props); + FreeBGCAuxiliaryData(aux_data); //FreeAlquimiaEngineStatus(&chem_status_); } @@ -176,13 +180,13 @@ void BGCEngine::InitState(BGCProperties& mat_props, std::fill(aux_data.aux_doubles.data, aux_data.aux_doubles.data + aux_data.aux_doubles.size, 0.0); } -void BGCEngine::FreeState(BGCProperties& mat_props, - BGCState& chem_state, +void BGCEngine::FreeState(BGCProperties& props, + BGCState& state, BGCAuxiliaryData& aux_data) { - FreeBGCProperties(&mat_props); - FreeBGCState(&chem_state); - FreeBGCAuxiliaryData(&aux_data); + FreeBGCProperties(&props); + FreeBGCState(&state); + FreeBGCAuxiliaryData(&data); //FreeAlquimiaAuxiliaryOutputData(&aux_output); } @@ -208,10 +212,11 @@ bool BGCEngine::Advance(const double delta_time, } -//Here is where alquimai has the set condition functions. -//Is this the equivalent to setting ICs for the runs? +//For now I don't need any of the rest of this code yet. Just commenting +//out in case I need it later. +/* void ChemistryEngine::CreateCondition(const std::string& condition_name) { // NOTE: a condition with zero aqueous/mineral constraints is assumed to be defined in @@ -525,7 +530,7 @@ void ChemistryEngine::GetAqueousKineticNames(std::vector& kinetics_ const AlquimiaSizes& ChemistryEngine::Sizes() const { return sizes_; -} +}*/ } // namespace } // namespace diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 8af626375..e87b3df6b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -196,6 +196,8 @@ void EcoSIM::Setup() { } //This is for the Auxiliary Data which we will need + //commenting for now because we don't need it yet + /* if (plist_->isParameter("auxiliary data")) { auto names = plist_->get >("auxiliary data"); @@ -216,7 +218,7 @@ void EcoSIM::Setup() { S_->GetRecordW(alquimia_aux_data_key_, tag_next_, passwd_).set_io_vis(false); } - + */ std::cout << "\nEnd setup\n"; } @@ -610,23 +612,23 @@ void EcoSIM::CopyToEcoSIM(int col, // not modified: // everything else? - state.fluid_density = col_f_dens; - state.gas_density = col_g_dens; - state.ice_density = col_i_dens; - state.porosity = col_poro; - state.water_content = col_wc; - state.temperature = col_temp; + bgc_state.fluid_density = col_f_dens; + bgc_state.gas_density = col_g_dens; + bgc_state.ice_density = col_i_dens; + bgc_state.porosity = col_poro; + bgc_state.water_content = col_wc; + bgc_state.temperature = col_temp; //mat_props.volume = mesh_->cell_volume(cell; //mat_props.saturation = water_saturation[0][cell]; - mat_props.liquid_saturation = col_l_sat; - mat_props.gas_saturation = col_g_sat; - mat_props.ice_saturation = col_i_sat; - mat_props.elevation = col_elev; - mat_props.relative_permeability = col_rel_perm; - mat_props.conductivity = col_cond; - mat_props.volume = col_vol; + bgc_props.liquid_saturation = col_l_sat; + bgc_props.gas_saturation = col_g_sat; + bgc_props.ice_saturation = col_i_sat; + bgc_props.elevation = col_elev; + bgc_props.relative_permeability = col_rel_perm; + bgc_props.conductivity = col_cond; + bgc_props.volume = col_vol; num_components = tcc.NumVectors(); @@ -639,7 +641,7 @@ void EcoSIM::CopyToEcoSIM(int col, // For #2 I think I just need to change the serieal dense vector call to // a different data type (are these always 1d?) What is the 2d version? for (int i = 0; i < num_components; i++) { - state.total_mobile.data[i] = (*col_tcc)[i]; + bgc_state.total_mobile.data[i] = (*col_tcc)[i]; } // Auxiliary data -- block copy. @@ -678,20 +680,28 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - col_f_dens = state.fluid_density; - col_g_dens = state.gas_density; - col_i_dnes = state.ice_density; - col_poro = state.porosity; - col_wc = state.water_content; - col_temp = state.temperature; + col_f_dens = bgc_state.fluid_density; + col_g_dens = bgc_state.gas_density; + col_i_dnes = bgc_state.ice_density; + col_poro = bgc_state.porosity; + col_wc = bgc_state.water_content; + col_temp = bgc_state.temperature; + + col_l_sat = bgc_props.liquid_saturation; + col_g_sat = bgc_props.gas_saturation; + col_i_sat = bgc_props.ice_saturation; + col_elev = bgc_props.elevation; + col_rel_perm = bgc_props.relative_permeability; + col_cond = bgc_props.conductivity; + col_vol = bgc_props.volume; for (int i = 0; i < num_components; i++) { - state.total_mobile.data[i] = (*col_tcc)[i]; + bgc_state.total_mobile.data[i] = (*col_tcc)[i]; } //Here is where the auxiliary data is filled need to try to change this to columns //This may not be trivial - if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { + /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); int num_aux_ints = bgc_engine_->Sizes().num_aux_integers; @@ -705,7 +715,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, double* cell_aux_doubles = (*aux_data_)[i + num_aux_ints]; cell_aux_doubles[cell] = aux_data.aux_doubles.data[i]; } - } + }*/ //pack this data back into the num_columns ColumnToField_(col,tcc,col_tcc.ptr()); diff --git a/src/pks/ecosim_pk/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c similarity index 95% rename from src/pks/ecosim_pk/BGC_memory.c rename to src/pks/ecosim_pk/data/BGC_memory.c index be67f17de..ac7d856c0 100644 --- a/src/pks/ecosim_pk/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -1,29 +1,29 @@ /* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ /* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -** through Lawrence Berkeley National Laboratory (subject to receipt of any +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any ** required approvals from the U.S. Dept. of Energy). All rights reserved. -** +** ** Alquimia is available under a BSD license. See LICENSE.txt for more ** information. ** -** If you have questions about your rights to use or distribute this software, -** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property ** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -** -** NOTICE. This software was developed under funding from the U.S. Department -** of Energy. As such, the U.S. Government has been granted for itself and -** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -** license in the Software to reproduce, prepare derivative works, and perform -** publicly and display publicly. Beginning five (5) years after the date -** permission to assert copyright is obtained from the U.S. Department of Energy, -** and subject to any subsequent five (5) year renewals, the U.S. Government is -** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, ** irrevocable, worldwide license in the Software to reproduce, prepare derivative -** works, distribute copies to the public, perform publicly and display publicly, +** works, distribute copies to the public, perform publicly and display publicly, ** and to permit others to do so. -** +** ** Authors: Benjamin Andre */ @@ -45,7 +45,7 @@ ** *******************************************************************************/ -#include "alquimia/alquimia_memory.h" +#include "BGC_memory.h" #include "alquimia/alquimia_interface.h" #include "alquimia/alquimia_constants.h" #include "alquimia/alquimia_containers.h" @@ -65,7 +65,7 @@ static inline int nearest_power_of_2(int n) ** Alquimia Vectors ** *******************************************************************************/ -void AllocateAlquimiaVectorDouble(const int size, AlquimiaVectorDouble* vector) { +void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { if (size > 0) { vector->size = size; vector->capacity = nearest_power_of_2(size); @@ -78,7 +78,7 @@ void AllocateAlquimiaVectorDouble(const int size, AlquimiaVectorDouble* vector) } } /* end AllocateAlquimiaVectorDouble() */ -void FreeAlquimiaVectorDouble(AlquimiaVectorDouble* vector) { +void FreeBGCVectorDouble(BGCVectorDouble* vector) { if (vector != NULL) { free(vector->data); vector->data = NULL; @@ -87,7 +87,7 @@ void FreeAlquimiaVectorDouble(AlquimiaVectorDouble* vector) { } } /* end FreeAlquimiaVectorDouble() */ -void AllocateAlquimiaVectorInt(const int size, AlquimiaVectorInt* vector) { +void AllocateBGCVectorInt(const int size, BGCVectorInt* vector) { if (size > 0) { vector->size = size; vector->capacity = nearest_power_of_2(size); @@ -99,8 +99,8 @@ void AllocateAlquimiaVectorInt(const int size, AlquimiaVectorInt* vector) { vector->data = NULL; } } /* end AllocateAlquimiaVectorInt() */ - -void FreeAlquimiaVectorInt(AlquimiaVectorInt* vector) { + +void FreeBGCVectorInt(BGCVectorInt* vector) { if (vector != NULL) { free(vector->data); vector->data = NULL; @@ -109,7 +109,7 @@ void FreeAlquimiaVectorInt(AlquimiaVectorInt* vector) { } } /* end FreeAlquimiaVectorInt() */ -void AllocateAlquimiaVectorString(const int size, AlquimiaVectorString* vector) { +void AllocateBGCVectorString(const int size, BGCVectorString* vector) { int i; if (size > 0) { vector->size = size; @@ -126,7 +126,7 @@ void AllocateAlquimiaVectorString(const int size, AlquimiaVectorString* vector) vector->data = NULL; } } /* end AllocateAlquimiaVectorString() */ - + void FreeAlquimiaVectorString(AlquimiaVectorString* vector) { int i; if (vector != NULL) { @@ -146,9 +146,9 @@ void FreeAlquimiaVectorString(AlquimiaVectorString* vector) { ** *******************************************************************************/ -void AllocateAlquimiaState(const AlquimiaSizes* const sizes, - AlquimiaState* state) { - AllocateAlquimiaVectorDouble(sizes->num_primary, &(state->total_mobile)); +void AllocateBGCState(const BGCSizes* const sizes, + BGCState* state) { + AllocateBGCVectorDouble(sizes->num_primary, &(state->total_mobile)); ALQUIMIA_ASSERT(state->total_mobile.data != NULL); AllocateAlquimiaVectorDouble(sizes->num_sorbed, &(state->total_immobile)); @@ -359,13 +359,13 @@ void AllocateAlquimiaGeochemicalConditionVector(const int num_conditions, if (condition_list->size > 0) { condition_list->data = (AlquimiaGeochemicalCondition*) - calloc((size_t)condition_list->capacity, + calloc((size_t)condition_list->capacity, sizeof(AlquimiaGeochemicalCondition)); } } /* end AllocateAlquimiaGeochemicalConditionVector() */ void AllocateAlquimiaGeochemicalCondition(const int size_name, - const int num_aqueous_constraints, + const int num_aqueous_constraints, const int num_mineral_constraints, AlquimiaGeochemicalCondition* condition) { /* NOTE: we are only allocating pointers to N constraints here, not @@ -394,7 +394,7 @@ void AllocateAlquimiaAqueousConstraintVector(int num_constraints, constraint_list->capacity = nearest_power_of_2(num_constraints); if (constraint_list->size > 0) { constraint_list->data = (AlquimiaAqueousConstraint*) - calloc((size_t)constraint_list->capacity, + calloc((size_t)constraint_list->capacity, sizeof(AlquimiaAqueousConstraint)); } else @@ -414,7 +414,7 @@ void AllocateAlquimiaMineralConstraintVector(int num_constraints, constraint_list->capacity = nearest_power_of_2(num_constraints); if (constraint_list->size > 0) { constraint_list->data = (AlquimiaMineralConstraint*) - calloc((size_t)constraint_list->capacity, + calloc((size_t)constraint_list->capacity, sizeof(AlquimiaMineralConstraint)); } else diff --git a/src/pks/ecosim_pk/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.h similarity index 100% rename from src/pks/ecosim_pk/BGC_memory.h rename to src/pks/ecosim_pk/data/BGC_memory.h diff --git a/src/pks/ecosim_pk/data/alquimia_containers.F90 b/src/pks/ecosim_pk/data/alquimia_containers.F90 new file mode 100644 index 000000000..6f5eed8f7 --- /dev/null +++ b/src/pks/ecosim_pk/data/alquimia_containers.F90 @@ -0,0 +1,207 @@ + +! +! Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +! through Lawrence Berkeley National Laboratory (subject to receipt of any +! required approvals from the U.S. Dept. of Energy). All rights reserved. +! +! Alquimia is available under a BSD license. See LICENSE.txt for more +! information. +! +! If you have questions about your rights to use or distribute this software, +! please contact Berkeley Lab's Technology Transfer and Intellectual Property +! Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +! +! NOTICE. This software was developed under funding from the U.S. Department +! of Energy. As such, the U.S. Government has been granted for itself and +! others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +! license in the Software to reproduce, prepare derivative works, and perform +! publicly and display publicly. Beginning five (5) years after the date +! permission to assert copyright is obtained from the U.S. Department of Energy, +! and subject to any subsequent five (5) year renewals, the U.S. Government is +! granted for itself and others acting on its behalf a paid-up, nonexclusive, +! irrevocable, worldwide license in the Software to reproduce, prepare derivative +! works, distribute copies to the public, perform publicly and display publicly, +! and to permit others to do so. +! +! Authors: Benjamin Andre +! + +! **************************************************************************** ! +! +! Alquimia Containers module +! +! Author: Benjamin Andre +! +! WARNINGS: +! +! * The alquimia data structures defined in the this are dictated by +! the alquimia API! Do NOT change them unless you make +! corresponding changes to the c containers (and doc). +! +! * The order of the data members matters! If num_primary is the +! first member and num_minerals is the third, then they must be in +! those positions on both the c and fortran side of the interface! +! +! * The names of the containers and their members should be the same +! for both c and fortran. The language interface doesn't require +! this, but it makes it easier for the reader to understand what is +! going on. +! +! **************************************************************************** ! + +module AlquimiaContainers_module + + use, intrinsic :: iso_c_binding + + implicit none + + integer (c_int), parameter :: kAlquimiaMaxStringLength = 512 + integer (c_int), parameter :: kAlquimiaMaxWordLength = 32 + + integer (c_int), parameter :: kAlquimiaNoError = 0 + integer (c_int), parameter :: kAlquimiaErrorInvalidEngine = 1 + integer (c_int), parameter :: kAlquimiaErrorUnknownConstraintName = 2 + integer (c_int), parameter :: kAlquimiaErrorUnsupportedFunctionality = 3 + integer (c_int), parameter :: kAlquimiaErrorEngineIntegrity = 4577 + + character (13), parameter :: kAlquimiaStringTotalAqueous = 'total_aqueous' + character (12), parameter :: kAlquimiaStringTotalSorbed = 'total_sorbed' + character (25), parameter :: kAlquimiaStringTotalAqueousPlusSorbed = 'total_aqueous_plus_sorbed' + character (4), parameter :: kAlquimiaStringFree = 'free' + character (2), parameter :: kAlquimiaStringPH = 'pH' + character (7), parameter :: kAlquimiaStringMineral = 'mineral' + character (3), parameter :: kAlquimiaStringGas = 'gas' + character (6), parameter :: kAlquimiaStringCharge = 'charge' + + type, public, bind(c) :: AlquimiaVectorDouble + integer (c_int) :: size + integer (c_int) :: capacity + type (c_ptr) :: data + end type AlquimiaVectorDouble + + type, public, bind(c) :: AlquimiaVectorInt + integer (c_int) :: size + integer (c_int) :: capacity + type (c_ptr) :: data + end type AlquimiaVectorInt + + type, public, bind(c) :: AlquimiaVectorString + integer (c_int) :: size + integer (c_int) :: capacity + type (c_ptr) :: data + end type AlquimiaVectorString + + type, public, bind(c) :: AlquimiaSizes + integer (c_int) :: num_primary + integer (c_int) :: num_sorbed + integer (c_int) :: num_minerals + integer (c_int) :: num_aqueous_complexes + integer (c_int) :: num_aqueous_kinetics + integer (c_int) :: num_surface_sites + integer (c_int) :: num_ion_exchange_sites + integer (c_int) :: num_isotherm_species + integer (c_int) :: num_aux_integers + integer (c_int) :: num_aux_doubles + end type AlquimiaSizes + + type, public, bind(c) :: AlquimiaState + real (c_double) :: water_density + real (c_double) :: porosity + real (c_double) :: temperature + real (c_double) :: aqueous_pressure + type (AlquimiaVectorDouble) :: total_mobile + type (AlquimiaVectorDouble) :: total_immobile + type (AlquimiaVectorDouble) :: mineral_volume_fraction + type (AlquimiaVectorDouble) :: mineral_specific_surface_area + type (AlquimiaVectorDouble) :: surface_site_density + type (AlquimiaVectorDouble) :: cation_exchange_capacity + end type AlquimiaState + + type, public, bind(c) :: AlquimiaProperties + real (c_double) :: volume + real (c_double) :: saturation + type (AlquimiaVectorDouble) :: isotherm_kd + type (AlquimiaVectorDouble) :: freundlich_n + type (AlquimiaVectorDouble) :: langmuir_b + type (AlquimiaVectorDouble) :: mineral_rate_cnst +!! real (c_double) :: solid_density + type (AlquimiaVectorDouble) :: aqueous_kinetic_rate_cnst + end type AlquimiaProperties + + type, public, bind(c) :: AlquimiaAuxiliaryData + type (AlquimiaVectorInt) :: aux_ints + type (AlquimiaVectorDouble) :: aux_doubles + end type AlquimiaAuxiliaryData + + type, public, bind(c) :: AlquimiaEngineStatus + integer (c_int) :: error + type (c_ptr) :: message + logical (c_bool) :: converged + integer (c_int) :: num_rhs_evaluations + integer (c_int) :: num_jacobian_evaluations + integer (c_int) :: num_newton_iterations + end type AlquimiaEngineStatus + + type, public, bind(c) :: AlquimiaEngineFunctionality + logical (c_bool) :: thread_safe + logical (c_bool) :: temperature_dependent + logical (c_bool) :: pressure_dependent + logical (c_bool) :: porosity_update + logical (c_bool) :: operator_splitting + logical (c_bool) :: global_implicit + integer (c_int) :: index_base + end type AlquimiaEngineFunctionality + + type, public, bind(c) :: AlquimiaProblemMetaData + type (AlquimiaVectorString) :: primary_names + type (AlquimiaVectorInt) :: positivity + type (AlquimiaVectorString) :: mineral_names + type (AlquimiaVectorString) :: surface_site_names + type (AlquimiaVectorString) :: ion_exchange_names + type (AlquimiaVectorString) :: isotherm_species_names + type (AlquimiaVectorString) :: aqueous_kinetic_names + end type AlquimiaProblemMetaData + + type, public, bind(c) :: AlquimiaAuxiliaryOutputData + real (c_double) :: pH + type (AlquimiaVectorDouble) :: aqueous_kinetic_rate + type (AlquimiaVectorDouble) :: mineral_saturation_index + type (AlquimiaVectorDouble) :: mineral_reaction_rate + type (AlquimiaVectorDouble) :: primary_free_ion_concentration + type (AlquimiaVectorDouble) :: primary_activity_coeff + type (AlquimiaVectorDouble) :: secondary_free_ion_concentration + type (AlquimiaVectorDouble) :: secondary_activity_coeff + end type AlquimiaAuxiliaryOutputData + + type, public, bind(c) :: AlquimiaAqueousConstraint + type (c_ptr) :: primary_species_name + type (c_ptr) :: constraint_type + type (c_ptr) :: associated_species + real (c_double) :: value + end type AlquimiaAqueousConstraint + + type, public, bind(c) :: AlquimiaAqueousConstraintVector + integer (c_int) :: size + integer (c_int) :: capacity + type (c_ptr) :: data + end type AlquimiaAqueousConstraintVector + + type, public, bind(c) :: AlquimiaMineralConstraint + type (c_ptr) :: mineral_name + real (c_double) :: volume_fraction + real (c_double) :: specific_surface_area + end type AlquimiaMineralConstraint + + type, public, bind(c) :: AlquimiaMineralConstraintVector + integer (c_int) :: size + integer (c_int) :: capacity + type (c_ptr) :: data + end type AlquimiaMineralConstraintVector + + type, public, bind(c) :: AlquimiaGeochemicalCondition + type (c_ptr) :: name + type (AlquimiaAqueousConstraintVector) :: aqueous_constraints + type (AlquimiaMineralConstraintVector) :: mineral_constraints + end type AlquimiaGeochemicalCondition + +end module AlquimiaContainers_module diff --git a/src/pks/ecosim_pk/data/alquimia_containers.h b/src/pks/ecosim_pk/data/alquimia_containers.h new file mode 100644 index 000000000..caf8b0193 --- /dev/null +++ b/src/pks/ecosim_pk/data/alquimia_containers.h @@ -0,0 +1,188 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** Alquimia is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + +#ifndef ALQUIMIA_CONTAINERS_H_ +#define ALQUIMIA_CONTAINERS_H_ + +/******************************************************************************* + ** + ** C implementation of the alquimia containers. + ** + ** These are passed directly into the fortran routines. The + ** signatures must match exactly with the fortran side of things. + ** + ******************************************************************************/ + +#include "alquimia/alquimia.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + typedef struct { + int size, capacity; + double* data; + } AlquimiaVectorDouble; + + typedef struct { + int size, capacity; + int* data; + } AlquimiaVectorInt; + + typedef struct { + /* NOTE: this is a vector of strings */ + int size, capacity; + char** data; + } AlquimiaVectorString; + + typedef struct { + int num_primary; + int num_sorbed; + int num_minerals; + int num_aqueous_complexes; + int num_aqueous_kinetics; + int num_surface_sites; + int num_ion_exchange_sites; + int num_isotherm_species; + int num_aux_integers; + int num_aux_doubles; + } AlquimiaSizes; + + typedef struct { + double water_density; /* [kg/m^3] */ + double porosity; /* [-] */ + double temperature; /* [celsius] */ + double aqueous_pressure; /* [Pa] */ + AlquimiaVectorDouble total_mobile; /* [molarity] */ + AlquimiaVectorDouble total_immobile; /* [moles/m^3 bulk] */ + AlquimiaVectorDouble mineral_volume_fraction; /* [-] */ + AlquimiaVectorDouble mineral_specific_surface_area; /* [m^2 mineral/m^3 bulk] */ + AlquimiaVectorDouble surface_site_density; /* [moles/m^3 bulk] */ + AlquimiaVectorDouble cation_exchange_capacity; /* [moles/m^3 bulk] */ + } AlquimiaState; + + typedef struct { + double volume; /* [m^3] */ + double saturation; /* [m^3 liquid / m^3 pore space] */ + AlquimiaVectorDouble isotherm_kd; /* [kg H20 / m^3 bulk] */ + AlquimiaVectorDouble freundlich_n; /* [-] */ + AlquimiaVectorDouble langmuir_b; /* [-] */ + AlquimiaVectorDouble mineral_rate_cnst; /* [mol/m^2-sec] */ + AlquimiaVectorDouble aqueous_kinetic_rate_cnst; /* [sec^-1] */ + } AlquimiaProperties; + + typedef struct { + AlquimiaVectorInt aux_ints; /* [-] */ + AlquimiaVectorDouble aux_doubles; /* [-] */ + } AlquimiaAuxiliaryData; + + typedef struct { + int error; + char* message; + bool converged; + int num_rhs_evaluations; + int num_jacobian_evaluations; + int num_newton_iterations; + } AlquimiaEngineStatus; + + typedef struct { + bool thread_safe; + bool temperature_dependent; + bool pressure_dependent; + bool porosity_update; + bool operator_splitting; + bool global_implicit; + int index_base; + } AlquimiaEngineFunctionality; + + typedef struct { + AlquimiaVectorString primary_names; + AlquimiaVectorInt positivity; + AlquimiaVectorString mineral_names; + AlquimiaVectorString surface_site_names; + AlquimiaVectorString ion_exchange_names; + AlquimiaVectorString isotherm_species_names; + AlquimiaVectorString aqueous_kinetic_names; + } AlquimiaProblemMetaData; + + typedef struct { + double pH; + AlquimiaVectorDouble aqueous_kinetic_rate; /* [?] */ + AlquimiaVectorDouble mineral_saturation_index; /* [mol/sec/m^3] */ + AlquimiaVectorDouble mineral_reaction_rate; /* [mol/sec/m^3 bulk] */ + AlquimiaVectorDouble primary_free_ion_concentration; /* [molality] */ + AlquimiaVectorDouble primary_activity_coeff; /* [-] */ + AlquimiaVectorDouble secondary_free_ion_concentration; /* [molality] */ + AlquimiaVectorDouble secondary_activity_coeff; /* [-] */ + } AlquimiaAuxiliaryOutputData; + + /* + ** Geochemical Conditions + */ + + typedef struct { + char* primary_species_name; + char* constraint_type; + char* associated_species; + double value; + } AlquimiaAqueousConstraint; + + typedef struct { + int size, capacity; + AlquimiaAqueousConstraint* data; + } AlquimiaAqueousConstraintVector; + + typedef struct { + char* mineral_name; + double volume_fraction; + double specific_surface_area; + } AlquimiaMineralConstraint; + + typedef struct { + int size, capacity; + AlquimiaMineralConstraint* data; + } AlquimiaMineralConstraintVector; + + /* A geochemical condition is an array of aqueous and mineral geochemical constraints */ + typedef struct { + char* name; + AlquimiaAqueousConstraintVector aqueous_constraints; + AlquimiaMineralConstraintVector mineral_constraints; + } AlquimiaGeochemicalCondition; + + typedef struct { + int size, capacity; + AlquimiaGeochemicalCondition* data; + } AlquimiaGeochemicalConditionVector; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* ALQUIMIA_CONTAINERS_H_ */ From adf67485f329e4c6dbc0b8669e20b1a68f415c58 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 31 Jan 2023 14:28:36 -0800 Subject: [PATCH 009/582] edits to the containers program. --- src/pks/ecosim_pk/data/BGC_containers.F90 | 133 +++++++++++ ...alquimia_containers.h => BGC_containers.h} | 151 +++++-------- .../ecosim_pk/data/alquimia_containers.F90 | 207 ------------------ 3 files changed, 188 insertions(+), 303 deletions(-) create mode 100644 src/pks/ecosim_pk/data/BGC_containers.F90 rename src/pks/ecosim_pk/data/{alquimia_containers.h => BGC_containers.h} (53%) delete mode 100644 src/pks/ecosim_pk/data/alquimia_containers.F90 diff --git a/src/pks/ecosim_pk/data/BGC_containers.F90 b/src/pks/ecosim_pk/data/BGC_containers.F90 new file mode 100644 index 000000000..e9ceb9182 --- /dev/null +++ b/src/pks/ecosim_pk/data/BGC_containers.F90 @@ -0,0 +1,133 @@ + +! +! Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +! through Lawrence Berkeley National Laboratory (subject to receipt of any +! required approvals from the U.S. Dept. of Energy). All rights reserved. +! +! Alquimia is available under a BSD license. See LICENSE.txt for more +! information. +! +! If you have questions about your rights to use or distribute this software, +! please contact Berkeley Lab's Technology Transfer and Intellectual Property +! Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +! +! NOTICE. This software was developed under funding from the U.S. Department +! of Energy. As such, the U.S. Government has been granted for itself and +! others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +! license in the Software to reproduce, prepare derivative works, and perform +! publicly and display publicly. Beginning five (5) years after the date +! permission to assert copyright is obtained from the U.S. Department of Energy, +! and subject to any subsequent five (5) year renewals, the U.S. Government is +! granted for itself and others acting on its behalf a paid-up, nonexclusive, +! irrevocable, worldwide license in the Software to reproduce, prepare derivative +! works, distribute copies to the public, perform publicly and display publicly, +! and to permit others to do so. +! +! Authors: Benjamin Andre +! + +! **************************************************************************** ! +! +! Alquimia Containers module +! +! Author: Benjamin Andre +! +! WARNINGS: +! +! * The alquimia data structures defined in the this are dictated by +! the alquimia API! Do NOT change them unless you make +! corresponding changes to the c containers (and doc). +! +! * The order of the data members matters! If num_primary is the +! first member and num_minerals is the third, then they must be in +! those positions on both the c and fortran side of the interface! +! +! * The names of the containers and their members should be the same +! for both c and fortran. The language interface doesn't require +! this, but it makes it easier for the reader to understand what is +! going on. +! +! **************************************************************************** ! + +module AlquimiaContainers_module + + use, intrinsic :: iso_c_binding + + implicit none + + integer (c_int), parameter :: kAlquimiaMaxStringLength = 512 + integer (c_int), parameter :: kAlquimiaMaxWordLength = 32 + + integer (c_int), parameter :: kAlquimiaNoError = 0 + integer (c_int), parameter :: kAlquimiaErrorInvalidEngine = 1 + integer (c_int), parameter :: kAlquimiaErrorUnknownConstraintName = 2 + integer (c_int), parameter :: kAlquimiaErrorUnsupportedFunctionality = 3 + integer (c_int), parameter :: kAlquimiaErrorEngineIntegrity = 4577 + + character (13), parameter :: kAlquimiaStringTotalAqueous = 'total_aqueous' + character (12), parameter :: kAlquimiaStringTotalSorbed = 'total_sorbed' + character (25), parameter :: kAlquimiaStringTotalAqueousPlusSorbed = 'total_aqueous_plus_sorbed' + character (4), parameter :: kAlquimiaStringFree = 'free' + character (2), parameter :: kAlquimiaStringPH = 'pH' + character (7), parameter :: kAlquimiaStringMineral = 'mineral' + character (3), parameter :: kAlquimiaStringGas = 'gas' + character (6), parameter :: kAlquimiaStringCharge = 'charge' + + type, public, bind(c) :: BGCVectorDouble + integer (c_int) :: size + integer (c_int) :: capacity + type (c_ptr) :: data + end type BGCVectorDouble + + type, public, bind(c) :: BGCVectorInt + integer (c_int) :: size + integer (c_int) :: capacity + type (c_ptr) :: data + end type BGCVectorInt + + type, public, bind(c) :: BGCVectorString + integer (c_int) :: size + integer (c_int) :: capacity + type (c_ptr) :: data + end type BGCVectorString + + type, public, bind(c) :: BGCSizes + integer (c_int) :: num_primary + integer (c_int) :: num_sorbed + integer (c_int) :: num_minerals + integer (c_int) :: num_aqueous_complexes + integer (c_int) :: num_aqueous_kinetics + integer (c_int) :: num_surface_sites + integer (c_int) :: num_ion_exchange_sites + integer (c_int) :: num_isotherm_species + integer (c_int) :: num_aux_integers + integer (c_int) :: num_aux_doubles + end type BGCSizes + + type, public, bind(c) :: BGCState + ! I think I have to write the data as vector doubles + type (BGCVectorDouble) :: fluid_density + type (BGCVectorDouble) :: gas_density + type (BGCVectorDouble) :: ice_density + type (BGCVectorDouble) :: porosity + type (BGCVectorDouble) :: water_content + type (BGCVectorDouble) :: temperature + type (BGCVectorDouble) :: total_mobile + end type BGCState + + type, public, bind(c) :: BGCProperties + type (BGCVectorDouble) :: liquid_saturation + type (BGCVectorDouble) :: gas_saturation + type (BGCVectorDouble) :: ice_saturation + type (BGCVectorDouble) :: elevation + type (BGCVectorDouble) :: relative_permeability + type (BGCVectorDouble) :: conductivity + type (BGCVectorDouble) :: volume + end type BGCProperties + + type, public, bind(c) :: BGCAuxiliaryData + type (BGCVectorInt) :: aux_ints + type (BGCVectorDouble) :: aux_doubles + end type BGCAuxiliaryData + +end module AlquimiaContainers_module diff --git a/src/pks/ecosim_pk/data/alquimia_containers.h b/src/pks/ecosim_pk/data/BGC_containers.h similarity index 53% rename from src/pks/ecosim_pk/data/alquimia_containers.h rename to src/pks/ecosim_pk/data/BGC_containers.h index caf8b0193..6b690e4f2 100644 --- a/src/pks/ecosim_pk/data/alquimia_containers.h +++ b/src/pks/ecosim_pk/data/BGC_containers.h @@ -1,29 +1,29 @@ /* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ /* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -** through Lawrence Berkeley National Laboratory (subject to receipt of any +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any ** required approvals from the U.S. Dept. of Energy). All rights reserved. -** +** ** Alquimia is available under a BSD license. See LICENSE.txt for more ** information. ** -** If you have questions about your rights to use or distribute this software, -** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property ** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -** -** NOTICE. This software was developed under funding from the U.S. Department -** of Energy. As such, the U.S. Government has been granted for itself and -** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -** license in the Software to reproduce, prepare derivative works, and perform -** publicly and display publicly. Beginning five (5) years after the date -** permission to assert copyright is obtained from the U.S. Department of Energy, -** and subject to any subsequent five (5) year renewals, the U.S. Government is -** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, ** irrevocable, worldwide license in the Software to reproduce, prepare derivative -** works, distribute copies to the public, perform publicly and display publicly, +** works, distribute copies to the public, perform publicly and display publicly, ** and to permit others to do so. -** +** ** Authors: Benjamin Andre */ @@ -48,18 +48,18 @@ extern "C" { typedef struct { int size, capacity; double* data; - } AlquimiaVectorDouble; + } BGCVectorDouble; typedef struct { int size, capacity; int* data; - } AlquimiaVectorInt; + } BGCVectorInt; typedef struct { /* NOTE: this is a vector of strings */ int size, capacity; char** data; - } AlquimiaVectorString; + } BGCVectorString; typedef struct { int num_primary; @@ -72,36 +72,33 @@ extern "C" { int num_isotherm_species; int num_aux_integers; int num_aux_doubles; - } AlquimiaSizes; - + } BGCSizes; + typedef struct { - double water_density; /* [kg/m^3] */ - double porosity; /* [-] */ - double temperature; /* [celsius] */ - double aqueous_pressure; /* [Pa] */ - AlquimiaVectorDouble total_mobile; /* [molarity] */ - AlquimiaVectorDouble total_immobile; /* [moles/m^3 bulk] */ - AlquimiaVectorDouble mineral_volume_fraction; /* [-] */ - AlquimiaVectorDouble mineral_specific_surface_area; /* [m^2 mineral/m^3 bulk] */ - AlquimiaVectorDouble surface_site_density; /* [moles/m^3 bulk] */ - AlquimiaVectorDouble cation_exchange_capacity; /* [moles/m^3 bulk] */ - } AlquimiaState; - + BGCVectorDouble fluid_density; + BGCVectorDouble gas_density; + BGCVectorDouble ice_density; + BGCVectorDouble porosity; + BGCVectorDouble water_content; + BGCVectorDouble temperature; + BGCVectorDouble total_mobile; + } BGCState; + typedef struct { - double volume; /* [m^3] */ - double saturation; /* [m^3 liquid / m^3 pore space] */ - AlquimiaVectorDouble isotherm_kd; /* [kg H20 / m^3 bulk] */ - AlquimiaVectorDouble freundlich_n; /* [-] */ - AlquimiaVectorDouble langmuir_b; /* [-] */ - AlquimiaVectorDouble mineral_rate_cnst; /* [mol/m^2-sec] */ - AlquimiaVectorDouble aqueous_kinetic_rate_cnst; /* [sec^-1] */ - } AlquimiaProperties; - + BGCVectorDouble liquid_saturation; + BGCVectorDouble gas_saturation; + BGCVectorDouble ice_saturation; + BGCVectorDouble elevation; + BGCVectorDouble relative_permeability; + BGCVectorDouble conductivity; + BGCVectorDouble volume; + } BGCProperties; + typedef struct { AlquimiaVectorInt aux_ints; /* [-] */ AlquimiaVectorDouble aux_doubles; /* [-] */ - } AlquimiaAuxiliaryData; - + } BGCAuxiliaryData; + /* typedef struct { int error; char* message; @@ -109,8 +106,8 @@ extern "C" { int num_rhs_evaluations; int num_jacobian_evaluations; int num_newton_iterations; - } AlquimiaEngineStatus; - + } BGCEngineStatus; + typedef struct { bool thread_safe; bool temperature_dependent; @@ -119,8 +116,8 @@ extern "C" { bool operator_splitting; bool global_implicit; int index_base; - } AlquimiaEngineFunctionality; - + } BGCEngineFunctionality; + typedef struct { AlquimiaVectorString primary_names; AlquimiaVectorInt positivity; @@ -129,58 +126,20 @@ extern "C" { AlquimiaVectorString ion_exchange_names; AlquimiaVectorString isotherm_species_names; AlquimiaVectorString aqueous_kinetic_names; - } AlquimiaProblemMetaData; - + } BGCProblemMetaData; + typedef struct { double pH; - AlquimiaVectorDouble aqueous_kinetic_rate; /* [?] */ - AlquimiaVectorDouble mineral_saturation_index; /* [mol/sec/m^3] */ - AlquimiaVectorDouble mineral_reaction_rate; /* [mol/sec/m^3 bulk] */ - AlquimiaVectorDouble primary_free_ion_concentration; /* [molality] */ - AlquimiaVectorDouble primary_activity_coeff; /* [-] */ - AlquimiaVectorDouble secondary_free_ion_concentration; /* [molality] */ - AlquimiaVectorDouble secondary_activity_coeff; /* [-] */ - } AlquimiaAuxiliaryOutputData; - - /* - ** Geochemical Conditions + AlquimiaVectorDouble aqueous_kinetic_rate; // [?] + AlquimiaVectorDouble mineral_saturation_index; // [mol/sec/m^3] + AlquimiaVectorDouble mineral_reaction_rate; // [mol/sec/m^3 bulk] + AlquimiaVectorDouble primary_free_ion_concentration; // [molality] + AlquimiaVectorDouble primary_activity_coeff; // [-] + AlquimiaVectorDouble secondary_free_ion_concentration; // [molality] + AlquimiaVectorDouble secondary_activity_coeff; // [-] + } BGCAuxiliaryOutputData; */ - typedef struct { - char* primary_species_name; - char* constraint_type; - char* associated_species; - double value; - } AlquimiaAqueousConstraint; - - typedef struct { - int size, capacity; - AlquimiaAqueousConstraint* data; - } AlquimiaAqueousConstraintVector; - - typedef struct { - char* mineral_name; - double volume_fraction; - double specific_surface_area; - } AlquimiaMineralConstraint; - - typedef struct { - int size, capacity; - AlquimiaMineralConstraint* data; - } AlquimiaMineralConstraintVector; - - /* A geochemical condition is an array of aqueous and mineral geochemical constraints */ - typedef struct { - char* name; - AlquimiaAqueousConstraintVector aqueous_constraints; - AlquimiaMineralConstraintVector mineral_constraints; - } AlquimiaGeochemicalCondition; - - typedef struct { - int size, capacity; - AlquimiaGeochemicalCondition* data; - } AlquimiaGeochemicalConditionVector; - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/pks/ecosim_pk/data/alquimia_containers.F90 b/src/pks/ecosim_pk/data/alquimia_containers.F90 deleted file mode 100644 index 6f5eed8f7..000000000 --- a/src/pks/ecosim_pk/data/alquimia_containers.F90 +++ /dev/null @@ -1,207 +0,0 @@ - -! -! Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -! through Lawrence Berkeley National Laboratory (subject to receipt of any -! required approvals from the U.S. Dept. of Energy). All rights reserved. -! -! Alquimia is available under a BSD license. See LICENSE.txt for more -! information. -! -! If you have questions about your rights to use or distribute this software, -! please contact Berkeley Lab's Technology Transfer and Intellectual Property -! Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -! -! NOTICE. This software was developed under funding from the U.S. Department -! of Energy. As such, the U.S. Government has been granted for itself and -! others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -! license in the Software to reproduce, prepare derivative works, and perform -! publicly and display publicly. Beginning five (5) years after the date -! permission to assert copyright is obtained from the U.S. Department of Energy, -! and subject to any subsequent five (5) year renewals, the U.S. Government is -! granted for itself and others acting on its behalf a paid-up, nonexclusive, -! irrevocable, worldwide license in the Software to reproduce, prepare derivative -! works, distribute copies to the public, perform publicly and display publicly, -! and to permit others to do so. -! -! Authors: Benjamin Andre -! - -! **************************************************************************** ! -! -! Alquimia Containers module -! -! Author: Benjamin Andre -! -! WARNINGS: -! -! * The alquimia data structures defined in the this are dictated by -! the alquimia API! Do NOT change them unless you make -! corresponding changes to the c containers (and doc). -! -! * The order of the data members matters! If num_primary is the -! first member and num_minerals is the third, then they must be in -! those positions on both the c and fortran side of the interface! -! -! * The names of the containers and their members should be the same -! for both c and fortran. The language interface doesn't require -! this, but it makes it easier for the reader to understand what is -! going on. -! -! **************************************************************************** ! - -module AlquimiaContainers_module - - use, intrinsic :: iso_c_binding - - implicit none - - integer (c_int), parameter :: kAlquimiaMaxStringLength = 512 - integer (c_int), parameter :: kAlquimiaMaxWordLength = 32 - - integer (c_int), parameter :: kAlquimiaNoError = 0 - integer (c_int), parameter :: kAlquimiaErrorInvalidEngine = 1 - integer (c_int), parameter :: kAlquimiaErrorUnknownConstraintName = 2 - integer (c_int), parameter :: kAlquimiaErrorUnsupportedFunctionality = 3 - integer (c_int), parameter :: kAlquimiaErrorEngineIntegrity = 4577 - - character (13), parameter :: kAlquimiaStringTotalAqueous = 'total_aqueous' - character (12), parameter :: kAlquimiaStringTotalSorbed = 'total_sorbed' - character (25), parameter :: kAlquimiaStringTotalAqueousPlusSorbed = 'total_aqueous_plus_sorbed' - character (4), parameter :: kAlquimiaStringFree = 'free' - character (2), parameter :: kAlquimiaStringPH = 'pH' - character (7), parameter :: kAlquimiaStringMineral = 'mineral' - character (3), parameter :: kAlquimiaStringGas = 'gas' - character (6), parameter :: kAlquimiaStringCharge = 'charge' - - type, public, bind(c) :: AlquimiaVectorDouble - integer (c_int) :: size - integer (c_int) :: capacity - type (c_ptr) :: data - end type AlquimiaVectorDouble - - type, public, bind(c) :: AlquimiaVectorInt - integer (c_int) :: size - integer (c_int) :: capacity - type (c_ptr) :: data - end type AlquimiaVectorInt - - type, public, bind(c) :: AlquimiaVectorString - integer (c_int) :: size - integer (c_int) :: capacity - type (c_ptr) :: data - end type AlquimiaVectorString - - type, public, bind(c) :: AlquimiaSizes - integer (c_int) :: num_primary - integer (c_int) :: num_sorbed - integer (c_int) :: num_minerals - integer (c_int) :: num_aqueous_complexes - integer (c_int) :: num_aqueous_kinetics - integer (c_int) :: num_surface_sites - integer (c_int) :: num_ion_exchange_sites - integer (c_int) :: num_isotherm_species - integer (c_int) :: num_aux_integers - integer (c_int) :: num_aux_doubles - end type AlquimiaSizes - - type, public, bind(c) :: AlquimiaState - real (c_double) :: water_density - real (c_double) :: porosity - real (c_double) :: temperature - real (c_double) :: aqueous_pressure - type (AlquimiaVectorDouble) :: total_mobile - type (AlquimiaVectorDouble) :: total_immobile - type (AlquimiaVectorDouble) :: mineral_volume_fraction - type (AlquimiaVectorDouble) :: mineral_specific_surface_area - type (AlquimiaVectorDouble) :: surface_site_density - type (AlquimiaVectorDouble) :: cation_exchange_capacity - end type AlquimiaState - - type, public, bind(c) :: AlquimiaProperties - real (c_double) :: volume - real (c_double) :: saturation - type (AlquimiaVectorDouble) :: isotherm_kd - type (AlquimiaVectorDouble) :: freundlich_n - type (AlquimiaVectorDouble) :: langmuir_b - type (AlquimiaVectorDouble) :: mineral_rate_cnst -!! real (c_double) :: solid_density - type (AlquimiaVectorDouble) :: aqueous_kinetic_rate_cnst - end type AlquimiaProperties - - type, public, bind(c) :: AlquimiaAuxiliaryData - type (AlquimiaVectorInt) :: aux_ints - type (AlquimiaVectorDouble) :: aux_doubles - end type AlquimiaAuxiliaryData - - type, public, bind(c) :: AlquimiaEngineStatus - integer (c_int) :: error - type (c_ptr) :: message - logical (c_bool) :: converged - integer (c_int) :: num_rhs_evaluations - integer (c_int) :: num_jacobian_evaluations - integer (c_int) :: num_newton_iterations - end type AlquimiaEngineStatus - - type, public, bind(c) :: AlquimiaEngineFunctionality - logical (c_bool) :: thread_safe - logical (c_bool) :: temperature_dependent - logical (c_bool) :: pressure_dependent - logical (c_bool) :: porosity_update - logical (c_bool) :: operator_splitting - logical (c_bool) :: global_implicit - integer (c_int) :: index_base - end type AlquimiaEngineFunctionality - - type, public, bind(c) :: AlquimiaProblemMetaData - type (AlquimiaVectorString) :: primary_names - type (AlquimiaVectorInt) :: positivity - type (AlquimiaVectorString) :: mineral_names - type (AlquimiaVectorString) :: surface_site_names - type (AlquimiaVectorString) :: ion_exchange_names - type (AlquimiaVectorString) :: isotherm_species_names - type (AlquimiaVectorString) :: aqueous_kinetic_names - end type AlquimiaProblemMetaData - - type, public, bind(c) :: AlquimiaAuxiliaryOutputData - real (c_double) :: pH - type (AlquimiaVectorDouble) :: aqueous_kinetic_rate - type (AlquimiaVectorDouble) :: mineral_saturation_index - type (AlquimiaVectorDouble) :: mineral_reaction_rate - type (AlquimiaVectorDouble) :: primary_free_ion_concentration - type (AlquimiaVectorDouble) :: primary_activity_coeff - type (AlquimiaVectorDouble) :: secondary_free_ion_concentration - type (AlquimiaVectorDouble) :: secondary_activity_coeff - end type AlquimiaAuxiliaryOutputData - - type, public, bind(c) :: AlquimiaAqueousConstraint - type (c_ptr) :: primary_species_name - type (c_ptr) :: constraint_type - type (c_ptr) :: associated_species - real (c_double) :: value - end type AlquimiaAqueousConstraint - - type, public, bind(c) :: AlquimiaAqueousConstraintVector - integer (c_int) :: size - integer (c_int) :: capacity - type (c_ptr) :: data - end type AlquimiaAqueousConstraintVector - - type, public, bind(c) :: AlquimiaMineralConstraint - type (c_ptr) :: mineral_name - real (c_double) :: volume_fraction - real (c_double) :: specific_surface_area - end type AlquimiaMineralConstraint - - type, public, bind(c) :: AlquimiaMineralConstraintVector - integer (c_int) :: size - integer (c_int) :: capacity - type (c_ptr) :: data - end type AlquimiaMineralConstraintVector - - type, public, bind(c) :: AlquimiaGeochemicalCondition - type (c_ptr) :: name - type (AlquimiaAqueousConstraintVector) :: aqueous_constraints - type (AlquimiaMineralConstraintVector) :: mineral_constraints - end type AlquimiaGeochemicalCondition - -end module AlquimiaContainers_module From f4349114c16185a0d0808208e8d7ff3d8502b4c6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 1 Feb 2023 12:34:30 -0800 Subject: [PATCH 010/582] edits to the memory and names of variables --- src/pks/ecosim_pk/BGCEngine.cc | 12 +-- src/pks/ecosim_pk/BGCEngine.hh | 1 + src/pks/ecosim_pk/CMakeLists.txt | 3 +- src/pks/ecosim_pk/data/BGC_containers.F90 | 34 ++++----- src/pks/ecosim_pk/data/BGC_memory.c | 7 +- src/pks/ecosim_pk/data/BGC_memory.h | 92 +++++++++++------------ 6 files changed, 76 insertions(+), 73 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index d9dbf0876..b720649e9 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -166,12 +166,12 @@ BGCEngine::~BGCEngine() //FreeAlquimiaEngineStatus(&chem_status_); } -void BGCEngine::InitState(BGCProperties& mat_props, - BGCState& chem_state, +void BGCEngine::InitState(BGCProperties& props, + BGCState& state, BGCAuxiliaryData& aux_data) { - AllocateBGCProperties(&sizes_, &mat_props); - AllocateBGCState(&sizes_, &chem_state); + AllocateBGCProperties(&sizes_, &props); + AllocateBGCState(&sizes_, &state); AllocateBGCAuxiliaryData(&sizes_, &aux_data); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); @@ -191,8 +191,8 @@ void BGCEngine::FreeState(BGCProperties& props, } bool BGCEngine::Advance(const double delta_time, - const BGCProperties& mat_props, - BGCState& chem_state, + const BGCProperties& props, + BGCState& state, BGCAuxiliaryData& aux_data, BGCAuxiliaryOutputData& aux_output, int& num_iterations) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 6b1c8d617..d87f66f43 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -21,6 +21,7 @@ #include #include "BGC_memory.h" +#include "BGC_containers.h" /*#include "alquimia/alquimia_util.h" #include "alquimia/alquimia_constants.h" #include "alquimia/alquimia_containers.h" diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index d0801848a..4c632d44c 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -1,10 +1,11 @@ # -*- mode: cmake -*- add_subdirectory(constitutive_relations) +add_subdirectory(data) include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/root_storage) +#include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/root_storage) # ATS EcoSIM pk # For adding F90 files add the F90 file to the ecosim source files and diff --git a/src/pks/ecosim_pk/data/BGC_containers.F90 b/src/pks/ecosim_pk/data/BGC_containers.F90 index e9ceb9182..14247dc9a 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.F90 +++ b/src/pks/ecosim_pk/data/BGC_containers.F90 @@ -55,23 +55,23 @@ module AlquimiaContainers_module implicit none - integer (c_int), parameter :: kAlquimiaMaxStringLength = 512 - integer (c_int), parameter :: kAlquimiaMaxWordLength = 32 - - integer (c_int), parameter :: kAlquimiaNoError = 0 - integer (c_int), parameter :: kAlquimiaErrorInvalidEngine = 1 - integer (c_int), parameter :: kAlquimiaErrorUnknownConstraintName = 2 - integer (c_int), parameter :: kAlquimiaErrorUnsupportedFunctionality = 3 - integer (c_int), parameter :: kAlquimiaErrorEngineIntegrity = 4577 - - character (13), parameter :: kAlquimiaStringTotalAqueous = 'total_aqueous' - character (12), parameter :: kAlquimiaStringTotalSorbed = 'total_sorbed' - character (25), parameter :: kAlquimiaStringTotalAqueousPlusSorbed = 'total_aqueous_plus_sorbed' - character (4), parameter :: kAlquimiaStringFree = 'free' - character (2), parameter :: kAlquimiaStringPH = 'pH' - character (7), parameter :: kAlquimiaStringMineral = 'mineral' - character (3), parameter :: kAlquimiaStringGas = 'gas' - character (6), parameter :: kAlquimiaStringCharge = 'charge' + integer (c_int), parameter :: kBGCMaxStringLength = 512 + integer (c_int), parameter :: kBGCMaxWordLength = 32 + + integer (c_int), parameter :: kBGCNoError = 0 + integer (c_int), parameter :: kBGCErrorInvalidEngine = 1 + integer (c_int), parameter :: kBGCErrorUnknownConstraintName = 2 + integer (c_int), parameter :: kBGCErrorUnsupportedFunctionality = 3 + integer (c_int), parameter :: kBGCErrorEngineIntegrity = 4577 + + character (13), parameter :: kBGCStringTotalAqueous = 'total_aqueous' + character (12), parameter :: kBGCStringTotalSorbed = 'total_sorbed' + character (25), parameter :: kBGCStringTotalAqueousPlusSorbed = 'total_aqueous_plus_sorbed' + character (4), parameter :: kBGCStringFree = 'free' + character (2), parameter :: kBGCStringPH = 'pH' + character (7), parameter :: kBGCStringMineral = 'mineral' + character (3), parameter :: kBGCStringGas = 'gas' + character (6), parameter :: kBGCStringCharge = 'charge' type, public, bind(c) :: BGCVectorDouble integer (c_int) :: size diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index ac7d856c0..9a696bbca 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -46,9 +46,10 @@ *******************************************************************************/ #include "BGC_memory.h" -#include "alquimia/alquimia_interface.h" -#include "alquimia/alquimia_constants.h" -#include "alquimia/alquimia_containers.h" +#include "BGC_containers.h" +//#include "alquimia/alquimia_interface.h" +//#include "alquimia/alquimia_constants.h" +//#include "alquimia/alquimia_containers.h" // Returns the nearest power of 2 greater than or equal to n, or 0 if n == 0. static inline int nearest_power_of_2(int n) diff --git a/src/pks/ecosim_pk/data/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.h index 1a613f8b6..976dded96 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.h +++ b/src/pks/ecosim_pk/data/BGC_memory.h @@ -1,89 +1,90 @@ /* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ /* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -** through Lawrence Berkeley National Laboratory (subject to receipt of any +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any ** required approvals from the U.S. Dept. of Energy). All rights reserved. -** +** ** Alquimia is available under a BSD license. See LICENSE.txt for more ** information. ** -** If you have questions about your rights to use or distribute this software, -** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property ** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -** -** NOTICE. This software was developed under funding from the U.S. Department -** of Energy. As such, the U.S. Government has been granted for itself and -** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -** license in the Software to reproduce, prepare derivative works, and perform -** publicly and display publicly. Beginning five (5) years after the date -** permission to assert copyright is obtained from the U.S. Department of Energy, -** and subject to any subsequent five (5) year renewals, the U.S. Government is -** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, ** irrevocable, worldwide license in the Software to reproduce, prepare derivative -** works, distribute copies to the public, perform publicly and display publicly, +** works, distribute copies to the public, perform publicly and display publicly, ** and to permit others to do so. -** +** ** Authors: Benjamin Andre */ -#ifndef ALQUIMIA_C_MEMORY_H_ -#define ALQUIMIA_C_MEMORY_H_ +#ifndef BGC_C_MEMORY_H_ +#define BGC_C_MEMORY_H_ -#include "alquimia/alquimia_interface.h" -#include "alquimia/alquimia_containers.h" +//#include "alquimia/alquimia_interface.h" +//#include "alquimia/alquimia_containers.h" +#include "BGC_containers.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - + /* Alquimia Vectors */ - void AllocateAlquimiaVectorDouble(const int size, AlquimiaVectorDouble* vector); - void FreeAlquimiaVectorDouble(AlquimiaVectorDouble* vector); + void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector); + void FreeBGCVectorDouble(BGCVectorDouble* vector); - void AllocateAlquimiaVectorInt(const int size, AlquimiaVectorInt* vector); - void FreeAlquimiaVectorInt(AlquimiaVectorInt* vector); + void AllocateBGCVectorInt(const int size, BGCVectorInt* vector); + void FreeBGCVectorInt(BGCVectorInt* vector); - void AllocateAlquimiaVectorString(const int size, AlquimiaVectorString* vector); - void FreeAlquimiaVectorString(AlquimiaVectorString* vector); + void AllocateBGCVectorString(const int size, BGCVectorString* vector); + void FreeBGCVectorString(BGCVectorString* vector); /* State */ - void AllocateAlquimiaState(const AlquimiaSizes* const sizes, - AlquimiaState* state); + void AllocateBGCState(const BGCSizes* const sizes, + BGCState* state); - void FreeAlquimiaState(AlquimiaState* state); + void FreeBGCState(BGCState* state); - /* Auxiliary Data */ - void AllocateAlquimiaAuxiliaryData(const AlquimiaSizes* const sizes, - AlquimiaAuxiliaryData* aux_data); - void FreeAlquimiaAuxiliaryData(AlquimiaAuxiliaryData* aux_data); + /* Auxiliary Data */ + void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, + BGCAuxiliaryData* aux_data); + void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data); /* Properties */ - void AllocateAlquimiaProperties(const AlquimiaSizes* const sizes, - AlquimiaProperties* props); - void FreeAlquimiaProperties(AlquimiaProperties* props); + void AllocateBGCProperties(const BGCSizes* const sizes, + BGCProperties* props); + void FreeBGCProperties(BGCProperties* props); - /* Problem Meta Data */ - void AllocateAlquimiaProblemMetaData(const AlquimiaSizes* const sizes, + // Problem Meta Data + /*void AllocateAlquimiaProblemMetaData(const AlquimiaSizes* const sizes, AlquimiaProblemMetaData* meta_data); void FreeAlquimiaProblemMetaData(AlquimiaProblemMetaData* metda_data); - /* Status */ + // Status void AllocateAlquimiaEngineStatus(AlquimiaEngineStatus* status); void FreeAlquimiaEngineStatus(AlquimiaEngineStatus* status); - /* Auxiliary Output Data */ + // Auxiliary Output Data void AllocateAlquimiaAuxiliaryOutputData(const AlquimiaSizes* const sizes, AlquimiaAuxiliaryOutputData* aux_output); void FreeAlquimiaAuxiliaryOutputData(AlquimiaAuxiliaryOutputData* aux_output); - /* Geochemical conditions/constraints */ + // Geochemical conditions/constraints void AllocateAlquimiaGeochemicalConditionVector(const int num_conditions, AlquimiaGeochemicalConditionVector* condition_list); void AllocateAlquimiaGeochemicalCondition(const int size_name, - const int num_aqueous_constraints, + const int num_aqueous_constraints, const int num_mineral_constraints, AlquimiaGeochemicalCondition* condition); void AllocateAlquimiaAqueousConstraintVector(const int num_constraints, @@ -100,10 +101,9 @@ extern "C" { void FreeAlquimiaMineralConstraintVector(AlquimiaMineralConstraintVector* vector); void FreeAlquimiaMineralConstraint(AlquimiaMineralConstraint* constraint); - - /* Data */ + // Data void AllocateAlquimiaData(AlquimiaData* data); - void FreeAlquimiaData(AlquimiaData* data); + void FreeAlquimiaData(AlquimiaData* data);*/ #ifdef __cplusplus } From 8ba209de517f47b299957d594857e5ae9411df9f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 1 Feb 2023 15:09:19 -0800 Subject: [PATCH 011/582] More allocation of memory and addition of constants files. --- src/pks/ecosim_pk/BGCEngine.hh | 3 +- src/pks/ecosim_pk/data/BGC_constants.c | 54 ++++++++ src/pks/ecosim_pk/data/BGC_constants.h | 64 ++++++++++ src/pks/ecosim_pk/data/BGC_containers.F90 | 4 +- src/pks/ecosim_pk/data/BGC_memory.c | 145 ++++++++++------------ 5 files changed, 190 insertions(+), 80 deletions(-) create mode 100644 src/pks/ecosim_pk/data/BGC_constants.c create mode 100644 src/pks/ecosim_pk/data/BGC_constants.h diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index d87f66f43..8d7bbc3f8 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -22,6 +22,7 @@ #include "BGC_memory.h" #include "BGC_containers.h" +#include "BGC_constants.h" /*#include "alquimia/alquimia_util.h" #include "alquimia/alquimia_constants.h" #include "alquimia/alquimia_containers.h" @@ -48,7 +49,7 @@ class BGCEngine { // Returns a reference to a "sizes" object that can be queried to find the sizes of the various // arrays representing the geochemical state within the engine. - const AlquimiaSizes& Sizes() const; + const BGCSizes& Sizes() const; // Initializes the data structures that hold the chemical state information. void InitState(BGCProperties& mat_props, diff --git a/src/pks/ecosim_pk/data/BGC_constants.c b/src/pks/ecosim_pk/data/BGC_constants.c new file mode 100644 index 000000000..2d7e98717 --- /dev/null +++ b/src/pks/ecosim_pk/data/BGC_constants.c @@ -0,0 +1,54 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** Alquimia is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + + +#include "BGC_constants.h" + +/* String lengths */ +const int kBGCMaxStringLength = 512; +const int kBGCMaxWordLength = 32; + +/* Geochemistry Engine Strings */ +const char* kBGCStringPFloTran = "PFloTran"; +const char* kBGCStringCrunchFlow = "CrunchFlow"; +const char* kBGCStringTotal = "total_aqueous"; +const char* kBGCStringTotalSorbed = "total_sorbed"; +const char* kBGCStringTotalAqueousPlusSorbed = "total_aqueous_plus_sorbed"; +const char* kBGCStringFree = "free"; +const char* kBGCStringPH = "pH"; +const char* kBGCStringMineral = "mineral"; +const char* kBGCStringGas = "gas"; +const char* kBGCStringCharge = "charge"; + +/* Error Codes */ +const int kBGCNoError = 0; +const int kBGCErrorInvalidEngine = 1; +const int kBGCErrorUnknownConstraintName = 2; +const int kBGCErrorUnsupportedFunctionality = 3; +const int kBGCErrorEngineIntegrity = 4577; diff --git a/src/pks/ecosim_pk/data/BGC_constants.h b/src/pks/ecosim_pk/data/BGC_constants.h new file mode 100644 index 000000000..3667f22d2 --- /dev/null +++ b/src/pks/ecosim_pk/data/BGC_constants.h @@ -0,0 +1,64 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** BGC Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** BGC is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to BGC (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + +#ifndef BGC_CONSTANTS_H_ +#define BGC_CONSTANTS_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* String lengths */ +extern const int kBGCMaxStringLength; +extern const int kBGCMaxWordLength; + +/* Geochemistry Engine Strings */ +extern const char* kBGCStringPFloTran; +extern const char* kBGCStringCrunchFlow; +extern const char* kBGCStringTotalAqueous; +extern const char* kBGCStringTotalSorbed; +extern const char* kBGCStringTotalAqueousPlusSorbed; +extern const char* kBGCStringFree; +extern const char* kBGCStringPH; +extern const char* kBGCStringMineral; +extern const char* kBGCStringGas; +extern const char* kBGCStringCharge; + +/* Error Codes */ +extern const int kBGCNoError; +extern const int kBGCErrorInvalidEngine; +extern const int kBGCErrorUnknownConstraintName; +extern const int kBGCErrorUnsupportedFunctionality; +extern const int kBGCErrorEngineIntegrity; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* BGC_CONSTANTS_H_ */ diff --git a/src/pks/ecosim_pk/data/BGC_containers.F90 b/src/pks/ecosim_pk/data/BGC_containers.F90 index 14247dc9a..9308ce759 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.F90 +++ b/src/pks/ecosim_pk/data/BGC_containers.F90 @@ -49,7 +49,7 @@ ! ! **************************************************************************** ! -module AlquimiaContainers_module +module BGCContainers_module use, intrinsic :: iso_c_binding @@ -130,4 +130,4 @@ module AlquimiaContainers_module type (BGCVectorDouble) :: aux_doubles end type BGCAuxiliaryData -end module AlquimiaContainers_module +end module BGCContainers_module diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index 9a696bbca..9456625a3 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -128,7 +128,7 @@ void AllocateBGCVectorString(const int size, BGCVectorString* vector) { } } /* end AllocateAlquimiaVectorString() */ -void FreeAlquimiaVectorString(AlquimiaVectorString* vector) { +void FreeBGCVectorString(BGCVectorString* vector) { int i; if (vector != NULL) { for (i = 0; i < vector->size; ++i) { @@ -149,32 +149,24 @@ void FreeAlquimiaVectorString(AlquimiaVectorString* vector) { void AllocateBGCState(const BGCSizes* const sizes, BGCState* state) { - AllocateBGCVectorDouble(sizes->num_primary, &(state->total_mobile)); - ALQUIMIA_ASSERT(state->total_mobile.data != NULL); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->fluid_density)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->gas_density)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->ice_density)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->porosity)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->water_content)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->temperature)); + //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); - AllocateAlquimiaVectorDouble(sizes->num_sorbed, &(state->total_immobile)); - - AllocateAlquimiaVectorDouble(sizes->num_surface_sites, - &(state->surface_site_density)); - - AllocateAlquimiaVectorDouble(sizes->num_ion_exchange_sites, - &(state->cation_exchange_capacity)); - - AllocateAlquimiaVectorDouble(sizes->num_minerals, - &(state->mineral_volume_fraction)); - - AllocateAlquimiaVectorDouble(sizes->num_minerals, - &(state->mineral_specific_surface_area)); } /* end AllocateAlquimiaState() */ -void FreeAlquimiaState(AlquimiaState* state) { +void FreeBGCState(BGCState* state) { if (state != NULL) { - FreeAlquimiaVectorDouble(&(state->total_mobile)); - FreeAlquimiaVectorDouble(&(state->total_immobile)); - FreeAlquimiaVectorDouble(&(state->mineral_volume_fraction)); - FreeAlquimiaVectorDouble(&(state->mineral_specific_surface_area)); - FreeAlquimiaVectorDouble(&(state->cation_exchange_capacity)); - FreeAlquimiaVectorDouble(&(state->surface_site_density)); + FreeBGCVectorDouble(&(state->fluid_density)); + FreeBGCVectorDouble(&(state->gas_density)); + FreeBGCVectorDouble(&(state->ice_density)); + FreeBGCVectorDouble(&(state->porosity)); + FreeBGCVectorDouble(&(state->water_content)); + FreeBGCVectorDouble(&(state->temperature)); } } /* end FreeAlquimiaState() */ @@ -184,20 +176,20 @@ void FreeAlquimiaState(AlquimiaState* state) { ** *******************************************************************************/ -void AllocateAlquimiaAuxiliaryData(const AlquimiaSizes* const sizes, - AlquimiaAuxiliaryData* aux_data) { - AllocateAlquimiaVectorInt(sizes->num_aux_integers, +void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, + BGCAuxiliaryData* aux_data) { + AllocateBGCVectorInt(sizes->num_aux_integers, &(aux_data->aux_ints)); - AllocateAlquimiaVectorDouble(sizes->num_aux_doubles, + AllocateBGCVectorDouble(sizes->num_aux_doubles, &(aux_data->aux_doubles)); } /* end AllocateAlquimiaAuxiliaryData() */ -void FreeAlquimiaAuxiliaryData(AlquimiaAuxiliaryData* aux_data) { +void FreeBGCAuxiliaryData(AlquimiaAuxiliaryData* aux_data) { if (aux_data != NULL) { - FreeAlquimiaVectorInt(&(aux_data->aux_ints)); - FreeAlquimiaVectorDouble(&(aux_data->aux_doubles)); + FreeBGCVectorInt(&(aux_data->aux_ints)); + FreeBGCVectorDouble(&(aux_data->aux_doubles)); } } /* end FreeAlquimiaAuxiliaryData() */ @@ -207,28 +199,26 @@ void FreeAlquimiaAuxiliaryData(AlquimiaAuxiliaryData* aux_data) { ** *******************************************************************************/ -void AllocateAlquimiaProperties(const AlquimiaSizes* const sizes, - AlquimiaProperties* props) { - AllocateAlquimiaVectorDouble(sizes->num_isotherm_species, - &(props->isotherm_kd)); - AllocateAlquimiaVectorDouble(sizes->num_isotherm_species, - &(props->freundlich_n)); - AllocateAlquimiaVectorDouble(sizes->num_isotherm_species, - &(props->langmuir_b)); - AllocateAlquimiaVectorDouble(sizes->num_minerals, - &(props->mineral_rate_cnst)); - AllocateAlquimiaVectorDouble(sizes->num_aqueous_kinetics, - &(props->aqueous_kinetic_rate_cnst)); - +void AllocateBGCProperties(const BGCSizes* const sizes, + BGCProperties* props) { + AllocateBGCVectorDouble(sizes->num_cols_, &(state->liquid_saturation)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->gas_saturation)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->ice_saturation)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->elevation)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->relative_permeability)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->conductivity)); + AllocateBGCVectorDouble(sizes->num_cols_, &(state->volume)); } /* end AllocateAlquimiaProperties() */ -void FreeAlquimiaProperties(AlquimiaProperties* props) { +void FreeBGCProperties(AlquimiaProperties* props) { if (props != NULL) { - FreeAlquimiaVectorDouble(&(props->isotherm_kd)); - FreeAlquimiaVectorDouble(&(props->freundlich_n)); - FreeAlquimiaVectorDouble(&(props->langmuir_b)); - FreeAlquimiaVectorDouble(&(props->mineral_rate_cnst)); - FreeAlquimiaVectorDouble(&(props->aqueous_kinetic_rate_cnst)); + FreeBGCVectorDouble(&(props->liquid_saturation)); + FreeBGCVectorDouble(&(props->gas_saturation)); + FreeBGCVectorDouble(&(props->ice_saturation)); + FreeBGCVectorDouble(&(props->elevation)); + FreeBGCVectorDouble(&(props->relative_permeability)); + FreeBGCVectorDouble(&(props->conductivity)); + FreeBGCVectorDouble(&(props->volume)); } } /* end FreeAlquimiaProperties() */ @@ -237,7 +227,7 @@ void FreeAlquimiaProperties(AlquimiaProperties* props) { ** Problem Meta Data ** *******************************************************************************/ - +/* void AllocateAlquimiaProblemMetaData(const AlquimiaSizes* const sizes, AlquimiaProblemMetaData* meta_data) { @@ -262,7 +252,7 @@ void AllocateAlquimiaProblemMetaData(const AlquimiaSizes* const sizes, AllocateAlquimiaVectorString(sizes->num_aqueous_kinetics, &(meta_data->aqueous_kinetic_names)); -} /* end AllocateAlquimiaProblemMetaData() */ +} //end AllocateAlquimiaProblemMetaData() void FreeAlquimiaProblemMetaData(AlquimiaProblemMetaData* meta_data) { @@ -275,14 +265,14 @@ void FreeAlquimiaProblemMetaData(AlquimiaProblemMetaData* meta_data) { FreeAlquimiaVectorString(&(meta_data->isotherm_species_names)); FreeAlquimiaVectorString(&(meta_data->aqueous_kinetic_names)); } -} /* end FreeAlquimiaProblemMetaData() */ +} end FreeAlquimiaProblemMetaData() */ /******************************************************************************* ** ** Auxiliary Output Data ** *******************************************************************************/ - +/* void AllocateAlquimiaAuxiliaryOutputData(const AlquimiaSizes* const sizes, AlquimiaAuxiliaryOutputData* aux_output) { aux_output->pH = -999.9; @@ -305,7 +295,7 @@ void AllocateAlquimiaAuxiliaryOutputData(const AlquimiaSizes* const sizes, AllocateAlquimiaVectorDouble(sizes->num_aqueous_complexes, &(aux_output->secondary_activity_coeff)); -} /* end AllocateAlquimiaAuxiliaryOutputData() */ +} // end AllocateAlquimiaAuxiliaryOutputData() void FreeAlquimiaAuxiliaryOutputData(AlquimiaAuxiliaryOutputData* aux_output) { if (aux_output != NULL) { @@ -317,21 +307,21 @@ void FreeAlquimiaAuxiliaryOutputData(AlquimiaAuxiliaryOutputData* aux_output) { FreeAlquimiaVectorDouble(&(aux_output->secondary_free_ion_concentration)); FreeAlquimiaVectorDouble(&(aux_output->secondary_activity_coeff)); } -} /* end FreeAlquimiaAuxiliaryOutputData() */ +} end FreeAlquimiaAuxiliaryOutputData() */ /******************************************************************************* ** ** Engine Status ** *******************************************************************************/ - +/* void AllocateAlquimiaEngineStatus(AlquimiaEngineStatus* status) { status->message = (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); if (NULL == status->message) { - /* TODO(bja): error handling */ + // TODO(bja): error handling } -} /* end AllocateAlquimiaEngineStatus() */ +} // end AllocateAlquimiaEngineStatus() void FreeAlquimiaEngineStatus(AlquimiaEngineStatus* status) { if (status != NULL) { @@ -339,7 +329,7 @@ void FreeAlquimiaEngineStatus(AlquimiaEngineStatus* status) { } status->message = NULL; -} /* end FreeAlquimiaEngineStatus() */ +} end FreeAlquimiaEngineStatus() */ @@ -348,11 +338,11 @@ void FreeAlquimiaEngineStatus(AlquimiaEngineStatus* status) { ** Geochemical conditions/constraints ** *******************************************************************************/ - +/* void AllocateAlquimiaGeochemicalConditionVector(const int num_conditions, AlquimiaGeochemicalConditionVector* condition_list) { - /* NOTE: we are only allocating pointers to N conditions here, not - the actual conditions themselves. */ + // NOTE: we are only allocating pointers to N conditions here, not + the actual conditions themselves. fprintf(stdout, " AllocateAlquimiaGeochemicalConditionList() : %d\n", num_conditions); condition_list->size = num_conditions; @@ -363,21 +353,21 @@ void AllocateAlquimiaGeochemicalConditionVector(const int num_conditions, calloc((size_t)condition_list->capacity, sizeof(AlquimiaGeochemicalCondition)); } -} /* end AllocateAlquimiaGeochemicalConditionVector() */ +} // end AllocateAlquimiaGeochemicalConditionVector() void AllocateAlquimiaGeochemicalCondition(const int size_name, const int num_aqueous_constraints, const int num_mineral_constraints, AlquimiaGeochemicalCondition* condition) { - /* NOTE: we are only allocating pointers to N constraints here, not - the actual condstraints themselves. */ + // NOTE: we are only allocating pointers to N constraints here, not + the actual condstraints themselves. if (condition != NULL) { - /* size_name + 1 to include the null character! */ + // size_name + 1 to include the null character! condition->name = (char*) calloc((size_t)size_name+1, sizeof(char)); AllocateAlquimiaAqueousConstraintVector(num_aqueous_constraints, &condition->aqueous_constraints); AllocateAlquimiaMineralConstraintVector(num_mineral_constraints, &condition->mineral_constraints); } -} /* end AllocateAlquimiaGeochemicalCondition() */ +} // end AllocateAlquimiaGeochemicalCondition() void AllocateAlquimiaAqueousConstraint(AlquimiaAqueousConstraint* constraint) { constraint->primary_species_name = @@ -387,7 +377,7 @@ void AllocateAlquimiaAqueousConstraint(AlquimiaAqueousConstraint* constraint) { constraint->associated_species = (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); constraint->value = 0.0; -} /* end AllocateAlquimiaAqueousConstraint() */ +} // end AllocateAlquimiaAqueousConstraint() void AllocateAlquimiaAqueousConstraintVector(int num_constraints, AlquimiaAqueousConstraintVector* constraint_list) { @@ -407,7 +397,7 @@ void AllocateAlquimiaMineralConstraint(AlquimiaMineralConstraint* constraint) { (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); constraint->volume_fraction = -1.0; constraint->specific_surface_area = -1.0; -} /* end AllocateAlquimiaMineralConstraint() */ +} // end AllocateAlquimiaMineralConstraint() void AllocateAlquimiaMineralConstraintVector(int num_constraints, AlquimiaMineralConstraintVector* constraint_list) { @@ -435,7 +425,7 @@ void FreeAlquimiaGeochemicalConditionVector(AlquimiaGeochemicalConditionVector* condition_list->size = 0; condition_list->capacity = 0; } -} /* end FreeAlquimiaGeochemicalConditionList() */ +} // end FreeAlquimiaGeochemicalConditionList() void FreeAlquimiaGeochemicalCondition(AlquimiaGeochemicalCondition* condition) { if (condition != NULL) { @@ -446,7 +436,7 @@ void FreeAlquimiaGeochemicalCondition(AlquimiaGeochemicalCondition* condition) { FreeAlquimiaAqueousConstraintVector(&(condition->aqueous_constraints)); FreeAlquimiaMineralConstraintVector(&(condition->mineral_constraints)); } -} /* end FreeAlquimiaGeochemicalCondition() */ +} // end FreeAlquimiaGeochemicalCondition() void FreeAlquimiaAqueousConstraintVector(AlquimiaAqueousConstraintVector* vector) { int i; @@ -461,7 +451,7 @@ void FreeAlquimiaAqueousConstraintVector(AlquimiaAqueousConstraintVector* vector vector->size = 0; vector->capacity = 0; } -} /* end FreeAlquimiaAqueousConstraintVector() */ +} // end FreeAlquimiaAqueousConstraintVector() void FreeAlquimiaAqueousConstraint(AlquimiaAqueousConstraint* constraint) { free(constraint->primary_species_name); @@ -470,7 +460,7 @@ void FreeAlquimiaAqueousConstraint(AlquimiaAqueousConstraint* constraint) { constraint->constraint_type = NULL; free(constraint->associated_species); constraint->associated_species = NULL; -} /* end FreeAlquimiaAqueousConstraint() */ +} // end FreeAlquimiaAqueousConstraint() void FreeAlquimiaMineralConstraintVector(AlquimiaMineralConstraintVector* vector) { int i; @@ -483,12 +473,12 @@ void FreeAlquimiaMineralConstraintVector(AlquimiaMineralConstraintVector* vector vector->size = 0; vector->capacity = 0; } -} /* end FreeAlquimiaMineralConstraintVector() */ +} // end FreeAlquimiaMineralConstraintVector() void FreeAlquimiaMineralConstraint(AlquimiaMineralConstraint* constraint) { free(constraint->mineral_name); constraint->mineral_name = NULL; -} /* end FreeAlquimiaMineralConstraint() */ +} // end FreeAlquimiaMineralConstraint() */ /******************************************************************************* @@ -496,13 +486,14 @@ void FreeAlquimiaMineralConstraint(AlquimiaMineralConstraint* constraint) { ** Data convenience struct ** *******************************************************************************/ +/* void AllocateAlquimiaData(AlquimiaData* data) { AllocateAlquimiaState(&data->sizes, &data->state); AllocateAlquimiaProperties(&data->sizes, &data->properties); AllocateAlquimiaAuxiliaryData(&data->sizes, &data->aux_data); AllocateAlquimiaProblemMetaData(&data->sizes, &data->meta_data); AllocateAlquimiaAuxiliaryOutputData(&data->sizes, &data->aux_output); -} /* end AllocateAlquimiaData() */ +} // end AllocateAlquimiaData() void FreeAlquimiaData(AlquimiaData* data) { @@ -511,4 +502,4 @@ void FreeAlquimiaData(AlquimiaData* data) { FreeAlquimiaAuxiliaryData(&data->aux_data); FreeAlquimiaProblemMetaData(&data->meta_data); FreeAlquimiaAuxiliaryOutputData(&data->aux_output); -} /* end FreeAlquimiaData() */ +} // end FreeAlquimiaData() */ From 41d5c1356c363abc300e43b90ba54931996226d7 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Feb 2023 14:45:38 -0800 Subject: [PATCH 012/582] changes to variable names and wrapping things up --- src/pks/ecosim_pk/BGCEngine.cc | 41 +++--- src/pks/ecosim_pk/BGCEngine.hh | 19 ++- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 159 +++++++++------------- src/pks/ecosim_pk/Ecosim_ATS_interface.hh | 2 +- src/pks/ecosim_pk/data/BGC_constants.c | 1 + src/pks/ecosim_pk/data/BGC_memory.c | 45 +++--- 6 files changed, 117 insertions(+), 150 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index b720649e9..5374e22c5 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -33,35 +33,34 @@ namespace { //Here are the major function that the engine will need -void CopyEcoSIMState(EcoSIMState* dest, EcoSIMState* src) +void CopyBGCState(BGCState* dest, BGCState* src) { - //NEED TO EDIT STILL - dest->water_density = src->water_density; - dest->porosity = src->porosity; - dest->temperature = src->temperature; - dest->aqueous_pressure = src->aqueous_pressure; - memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); - memcpy(dest->total_immobile.data, src->total_immobile.data, sizeof(double) * src->total_immobile.size); - memcpy(dest->mineral_volume_fraction.data, src->mineral_volume_fraction.data, sizeof(double) * src->mineral_volume_fraction.size); - memcpy(dest->mineral_specific_surface_area.data, src->mineral_specific_surface_area.data, sizeof(double) * src->mineral_specific_surface_area.size); - memcpy(dest->surface_site_density.data, src->surface_site_density.data, sizeof(double) * src->surface_site_density.size); - memcpy(dest->cation_exchange_capacity.data, src->cation_exchange_capacity.data, sizeof(double) * src->cation_exchange_capacity.size); + memcpy(dest->liquid_density.size = src->liquid_density.size, sizeof(double) * src->liquid_density.size); + memcpy(dest->gas_density.size = src->gas_density.size, sizeof(double) * src->gas_density.size); + memcpy(dest->ice_density.size = src->ice_density.size, sizeof(double) * src->ice_density.size); + memcpy(dest->porosity.size = src->porosity.size, sizeof(double) * src->porosity.size); + memcpy(dest->water_content.size = src->water_content.size, sizeof(double) * src->water_content.size); + memcpy(dest->temperature.size = src->temperature.size, sizeof(double) * src->temperature.size); + //memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); + + //dest->water_density = src->water_density; + //memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); } // These functions are going into the next release of Alquimia. -void CopyEcoSIMProperties(EcoSIMProperties* dest, EcoSIMProperties* src) +void CopyBGCProperties(BGCProperties* dest, BGCProperties* src) { //NEED TO EDIT STILL - dest->volume = src->saturation; - dest->saturation = src->saturation; - memcpy(dest->aqueous_kinetic_rate_cnst.data, src->aqueous_kinetic_rate_cnst.data, sizeof(double) * src->aqueous_kinetic_rate_cnst.size); - memcpy(dest->mineral_rate_cnst.data, src->mineral_rate_cnst.data, sizeof(double) * src->mineral_rate_cnst.size); - memcpy(dest->isotherm_kd.data, src->isotherm_kd.data, sizeof(double) * src->isotherm_kd.size); - memcpy(dest->freundlich_n.data, src->freundlich_n.data, sizeof(double) * src->freundlich_n.size); - memcpy(dest->langmuir_b.data, src->langmuir_b.data, sizeof(double) * src->langmuir_b.size); + memcpy(dest->liquid_saturation.size = src->liquid_saturation.size, sizeof(double) * src->liquid_saturation.size); + memcpy(dest->gas_saturation.size = src->gas_saturation.size, sizeof(double) * src->gas_saturation.size); + memcpy(dest->ice_saturation.size = src->ice_saturation.size, sizeof(double) * src->ice_saturation.size); + memcpy(dest->elevation.size = src->elevation.size, sizeof(double) * src->elevation.size); + memcpy(dest->relative_permeability.size = src->relative_permeability.size, sizeof(double) * src->relative_permeability.size); + memcpy(dest->conductivity.size = src->conductivity.size, sizeof(double) * src->conductivity.size); + memcpy(dest->volume.size = src->volume.size, sizeof(double) * src->volume.size); } -void CopyEcoSIMAuxiliaryData(EcoSIMAuxiliaryData* dest, EcoSIMAuxiliaryData* src) +void CopyBGCAuxiliaryData(BGCAuxiliaryData* dest, bgcAuxiliaryData* src) { memcpy(dest->aux_ints.data, src->aux_ints.data, sizeof(int) * src->aux_ints.size); memcpy(dest->aux_doubles.data, src->aux_doubles.data, sizeof(double) * src->aux_doubles.size); diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 8d7bbc3f8..d0e13bd7e 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -52,29 +52,28 @@ class BGCEngine { const BGCSizes& Sizes() const; // Initializes the data structures that hold the chemical state information. - void InitState(BGCProperties& mat_props, - BGCState& chem_state, + void InitState(BGCProperties& props, + BGCState& state, BGCAuxiliaryData& aux_data); // Frees the data structures that hold the chemical state information. - void FreeState(BGCProperties& mat_props, - BGCState& chem_state, + void FreeState(BGCProperties& props, + BGCState& state, BGCAuxiliaryData& aux_data); void EnforceCondition(const std::string& condition_name, const double time, - const AlquimiaProperties& mat_props, - AlquimiaState& chem_state, - AlquimiaAuxiliaryData& aux_data, - AlquimiaAuxiliaryOutputData& aux_output); + const AlquimiaProperties& props, + AlquimiaState& state, + AlquimiaAuxiliaryData& aux_data); // Advances the species represented by the given array of concentrations, replacing old values // with new values. The order of the concentrations in the array matches that of the species names // returned by GetSpeciesNames. Returns true if the advance is successful, // false if it fails. bool Advance(const double delta_time, - const BGCProperties& mat_props, - BGCState& chem_state, + const BGCProperties& props, + BGCState& state, BGCAuxiliaryData& aux_data, int& num_iterations); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e87b3df6b..4404109e7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -55,7 +55,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // f_gas = S_gas * porosity // f_ice = S_ice * porosity - fluid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); + liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_den_key_ = Keys::readKey(plist_, domain, "ice mass density", "mass_density_ice"); gas_den_key_ = Keys::readKey(plist_,domain,"gas mass density", "mass_density_gas") rock_den_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); @@ -84,9 +84,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // We will probably need something like this eventually if we add in other BGC codes but it // is very complex and we can almost certainly do something simpler to start out with to just get // EcoSIM running. - // - // For now I'm changing the syntax from chem_engine to bgc_engine but I'll probably end up - // either cutting this out or commenting it out. if (!plist_->isParameter("engine")) { Errors::Message msg; @@ -101,27 +98,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string engine_name = plist_->get("engine"); std::string engine_inputfile = plist_->get("engine input file"); bgc_engine_ = Teuchos::rcp(new EcoSIM::BGCEngine(engine_name, engine_inputfile)); - //When creating the engine there are a few functions in ChemistryEngine that - //are called AllocateAlquimiaEngineStatus, CreateAlquimiaInterface, and chem_.Setup - //these are functions in the Alquimia standalone code - // - // AllocateAlquimiaEngineStatus - is in alquimia_memory.c does some simple memory - // Calculation I think. - // - // CreateAlquimiaInterface - in alquimia_interface.c, this makes the main - // decision between Pflotran and CrunchFlow, then allocates to the interface - // called chem_ where to find the processes the interface will need including - // Setup, Shutdown, ProcessCondition, ReactionStepOperatorSplit, GetAuxiliaryOutput - // GetProblemMetaData - // - // Basically it goes Alquimia PK -> ChemistryEngine -> Alquimia Interface -> - // CrunchFlow/PFloTran. We don't have to stick to this and probably just simplify to: - // EcoSIM_PK -> BGCEngine -> EcoSIM driver - - // grab the component names - // This is a small function in ChemistryEngine that simply looks at the metadata - // finds the number of primary species and fills a vector with the names of those - //species + //comp_names_.clear(); //bgc_engine_->GetPrimarySpeciesNames(comp_names_); @@ -134,9 +111,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, /* ******************************************************************* * Destroy ansilary data structures. ******************************************************************* */ -//Going to need this eventually to clear the strutures -//the various data structures were named for alquimia i.e. -//alq_mat_props_, alq_state, ect. changed to just bgc EcoSIM::~EcoSIM() { if (bgc_initialized_) @@ -148,17 +122,6 @@ EcoSIM::~EcoSIM() void EcoSIM::Setup() { std::cout << "beginning Ecosim setup\n"; PK_Physical_Default::Setup(); - //I actually don't think we have much to do here. In BGC_simple they set up - //The arrays for the PFTs and the carbon pools but we're not going to setup - //variables in this way. Other than that it sets the required variables. It - //seems like these are things that are "owned" by this PK so the auxiliary data - //Leaving in the alquimia code for this. It seems to set the auxiliary data up - //in several different ways. Still need to understand what is going on here. - // - //To further confuse things the chemistry engine function called Setup occurs - //When the engine is created in the constructor NOT called in the PK setup - - // Set up auxiliary chemistry data using the ChemistryEngine. /*This is for setting up the Auxiliary Output data which I'm not sure we need chem_engine_->GetAuxiliaryOutputNames(aux_names_, aux_subfield_names_); @@ -238,9 +201,9 @@ void EcoSIM::Initialize() { //which can be found in Amanzi/src/PKs/PK_Physical.cc: // initialize fields as soon as possible - for (size_t i = 0; i < aux_names_.size(); ++i) { + /*for (size_t i = 0; i < aux_names_.size(); ++i) { InitializeCVField(S_, *vo_, aux_names_[i], tag_next_, passwd_, 0.0); - } + }*/ //Now we call the engine's init state function which allocates the data bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_); @@ -254,7 +217,6 @@ void EcoSIM::Initialize() { // output (probably don't need for now) // Ensure dependencies are filled - // I think this is everything from ATS that needs to be updated S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); @@ -263,7 +225,7 @@ void EcoSIM::Initialize() { S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(fluid_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -272,9 +234,6 @@ void EcoSIM::Initialize() { S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); // init root carbon - // I think we can basically make use of the FieldToColumn_ function to take - // all of the properties we need (water, heat, ect) and pass them to each - // column auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_depth = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -366,7 +325,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(fluid_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -558,7 +517,7 @@ void EcoSIM::CopyToEcoSIM(int col, const auto& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", true); const auto& water_content = *S_->Get(water_content_key_, water_tag).ViewComponent("cell", true); const auto& relative_permeability = *S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", true); - const auto& fluid_density = *S_->Get(fluid_den_key_, water_tag).ViewComponent("cell", true); + const auto& liquid_density = *S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", true); const auto& ice_density = *S_->Get(ice_den_key_, water_tag).ViewComponent("cell", true); const auto& gas_density = *S_->Get(gas_den_key_, water_tag).ViewComponent("cell", true); const auto& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", true); @@ -588,7 +547,7 @@ void EcoSIM::CopyToEcoSIM(int col, //Format is: //FieldToColumn_(column index, dataset to copy from, vector to put the data in) - FieldToColumn_(col,tcc,col_tcc.ptr()); + //FieldToColumn_(col,tcc,col_tcc.ptr()); FieldToColumn_(col,porosity,col_poro.ptr()); FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); @@ -596,7 +555,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,elevation,col_elev.ptr()); FieldToColumn_(col,water_content,col_wc.ptr()); FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); - FieldToColumn_(col,fluid_density,col_f_dens.ptr()); + FieldToColumn_(col,liquid_density,col_f_dens.ptr()); FieldToColumn_(col,ice_density,col_i_dens.ptr()); FieldToColumn_(col,gas_density,col_g_dens.ptr()); FieldToColumn_(col,rock_density,col_r_dens.ptr()); @@ -604,32 +563,30 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,conductivity,col_cond.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); - //For now I'm just gonna guess what is modified and what isn't - // - // modified: - // saturation, tcc, water content? - // - // not modified: - // everything else? - - bgc_state.fluid_density = col_f_dens; - bgc_state.gas_density = col_g_dens; - bgc_state.ice_density = col_i_dens; - bgc_state.porosity = col_poro; - bgc_state.water_content = col_wc; - bgc_state.temperature = col_temp; + // I think I need to loop over the column data and save it to the data + // structures. Eventually I could probably rewrite FieldToColumn_ to do this + // automatically, but I just want to test this for now + + for (int i=0; i < ncells_per_col_; ++i) { + bgc_state.liquid_density.data[i] = col_f_dens[i]; + bgc_state.gas_density.data[i] = col_g_dens[i]; + bgc_state.ice_density.data[i] = col_i_dens[i]; + bgc_state.porosity.data[i] = col_poro[i]; + bgc_state.water_content.data[i] = col_wc[i]; + bgc_state.temperature.data[i] = col_temp[i]; + + bgc_props.liquid_saturation.data[i] = col_l_sat[i]; + bgc_props.gas_saturation.data[i] = col_g_sat[i]; + bgc_props.ice_saturation.data[i] = col_i_sat[i]; + bgc_props.elevation.data[i] = col_elev[i]; + bgc_props.relative_permeability.data[i] = col_rel_perm[i]; + bgc_props.conductivity.data[i] = col_cond[i]; + bgc_props.volume.data[i] = col_vol[i]; + } //mat_props.volume = mesh_->cell_volume(cell; //mat_props.saturation = water_saturation[0][cell]; - bgc_props.liquid_saturation = col_l_sat; - bgc_props.gas_saturation = col_g_sat; - bgc_props.ice_saturation = col_i_sat; - bgc_props.elevation = col_elev; - bgc_props.relative_permeability = col_rel_perm; - bgc_props.conductivity = col_cond; - bgc_props.volume = col_vol; - num_components = tcc.NumVectors(); //This probably isn't going to work. I think I either need to think @@ -640,9 +597,9 @@ void EcoSIM::CopyToEcoSIM(int col, // the components // For #2 I think I just need to change the serieal dense vector call to // a different data type (are these always 1d?) What is the 2d version? - for (int i = 0; i < num_components; i++) { - bgc_state.total_mobile.data[i] = (*col_tcc)[i]; - } + //for (int i = 0; i < num_components; i++) { + // bgc_state.total_mobile.data[i] = (*col_tcc)[i]; + //} // Auxiliary data -- block copy. if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { @@ -679,25 +636,28 @@ void EcoSIM::CopyFromEcoSIM(const int col, // be updated here. // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - - col_f_dens = bgc_state.fluid_density; - col_g_dens = bgc_state.gas_density; - col_i_dnes = bgc_state.ice_density; - col_poro = bgc_state.porosity; - col_wc = bgc_state.water_content; - col_temp = bgc_state.temperature; - - col_l_sat = bgc_props.liquid_saturation; - col_g_sat = bgc_props.gas_saturation; - col_i_sat = bgc_props.ice_saturation; - col_elev = bgc_props.elevation; - col_rel_perm = bgc_props.relative_permeability; - col_cond = bgc_props.conductivity; - col_vol = bgc_props.volume; - - for (int i = 0; i < num_components; i++) { - bgc_state.total_mobile.data[i] = (*col_tcc)[i]; + //I probably need to copy the columns cell by cell in a loop + //Can I do this in the field to column function? + + for (int i=0; i < ncells_per_col_; ++i) { + col_f_dens[i] = bgc_state.liquid_density.data[i]; + col_g_dens[i] = bgc_state.gas_density.data[i]; + col_i_dnes[i] = bgc_state.ice_density.data[i]; + col_poro[i] = bgc_state.porosity.data[i]; + col_wc[i] = bgc_state.water_content.data[i]; + col_temp[i] = bgc_state.temperature.data[i]; + + col_l_sat[i] = bgc_props.liquid_saturation.data[i]; + col_g_sat[i] = bgc_props.gas_saturation.data[i]; + col_i_sat[i] = bgc_props.ice_saturation.data[i]; + col_elev[i] = bgc_props.elevation.data[i]; + col_rel_perm[i] = bgc_props.relative_permeability.data[i]; + col_cond[i] = bgc_props.conductivity.data[i]; + col_vol[i] = bgc_props.volume.data[i]; } + /*for (int i = 0; i < num_components; i++) { + bgc_state.total_mobile.data[i] = (*col_tcc)[i]; + }*/ //Here is where the auxiliary data is filled need to try to change this to columns //This may not be trivial @@ -718,7 +678,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, }*/ //pack this data back into the num_columns - ColumnToField_(col,tcc,col_tcc.ptr()); + //ColumnToField_(col,tcc,col_tcc.ptr()); ColumnToField_(col,porosity,col_poro.ptr()); ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); ColumnToField_(col,gas_saturation,col_g_sat.ptr()); @@ -726,7 +686,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,elevation,col_elev.ptr()); ColumnToField_(col,water_content,col_wc.ptr()); ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); - ColumnToField_(col,fluid_density,col_f_dens.ptr()); + ColumnToField_(col,liquid_density,col_f_dens.ptr()); ColumnToField_(col,ice_density,col_i_dens.ptr()); ColumnToField_(col,gas_density,col_g_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); @@ -746,8 +706,8 @@ int EcoSIM::InitializeSingleColumn(int col, const std::string& condition) // should use the same tag as transport. See #673 CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_); - bgc_engine_->EnforceCondition(condition, current_time_, bgc_props_, - bgc_state_, bgc_aux_data_); + //bgc_engine_->EnforceCondition(condition, current_time_, bgc_props_, + // bgc_state_, bgc_aux_data_); CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_); @@ -780,6 +740,10 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) int num_iterations = 0; //Think a bit about what to do with this + /***************************************************************** + ADVANCE CALL GOES HERE + ****************************************************************** + if (ecosim_mat_props_.saturation > saturation_tolerance_) { bool success = bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_aux_data_, num_iterations); @@ -791,6 +755,7 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) return -1; } } + */ // Move the information back into Amanzi's state, updating the given total concentration vector. CopyEcoSIMStateToAmanzi(col, diff --git a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh index 872131846..001dfb369 100644 --- a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh +++ b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh @@ -149,7 +149,7 @@ class EcoSIM : public PK_Physical_Default { Key elev_key_; Key water_content_key_; Key rel_perm_key_; - Key fluid_den_key_; + Key liquid_den_key_; Key ice_den_key_; Key gas_den_key_; Key rock_den_key_; diff --git a/src/pks/ecosim_pk/data/BGC_constants.c b/src/pks/ecosim_pk/data/BGC_constants.c index 2d7e98717..8af45ce6f 100644 --- a/src/pks/ecosim_pk/data/BGC_constants.c +++ b/src/pks/ecosim_pk/data/BGC_constants.c @@ -37,6 +37,7 @@ const int kBGCMaxWordLength = 32; /* Geochemistry Engine Strings */ const char* kBGCStringPFloTran = "PFloTran"; const char* kBGCStringCrunchFlow = "CrunchFlow"; +const char* kBGCStringEcoSIM = "EcoSIM"; const char* kBGCStringTotal = "total_aqueous"; const char* kBGCStringTotalSorbed = "total_sorbed"; const char* kBGCStringTotalAqueousPlusSorbed = "total_aqueous_plus_sorbed"; diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index 9456625a3..084ba5440 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -146,15 +146,19 @@ void FreeBGCVectorString(BGCVectorString* vector) { ** State ** *******************************************************************************/ - +/*Note that sizes for all the datasets that are single vectors should just be +the size of the column, need to test +For reference the old function call was: void AllocateBGCState(const BGCSizes* const sizes, - BGCState* state) { - AllocateBGCVectorDouble(sizes->num_cols_, &(state->fluid_density)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->gas_density)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->ice_density)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->porosity)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->water_content)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->temperature)); + BGCState* state)*/ + +void AllocateBGCState(BGCState* state) { + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_density)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_density)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->porosity)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateAlquimiaState() */ @@ -176,12 +180,11 @@ void FreeBGCState(BGCState* state) { ** *******************************************************************************/ -void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, - BGCAuxiliaryData* aux_data) { - AllocateBGCVectorInt(sizes->num_aux_integers, +void AllocateBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { + AllocateBGCVectorInt(sizes->ncells_per_col_, &(aux_data->aux_ints)); - AllocateBGCVectorDouble(sizes->num_aux_doubles, + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(aux_data->aux_doubles)); } /* end AllocateAlquimiaAuxiliaryData() */ @@ -199,15 +202,15 @@ void FreeBGCAuxiliaryData(AlquimiaAuxiliaryData* aux_data) { ** *******************************************************************************/ -void AllocateBGCProperties(const BGCSizes* const sizes, - BGCProperties* props) { - AllocateBGCVectorDouble(sizes->num_cols_, &(state->liquid_saturation)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->gas_saturation)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->ice_saturation)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->elevation)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->relative_permeability)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->conductivity)); - AllocateBGCVectorDouble(sizes->num_cols_, &(state->volume)); +void AllocateBGCProperties(BGCProperties* props) { + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->liquid_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->elevation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->relative_permeability)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->conductivity)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->volume)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->total_mobile)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(AlquimiaProperties* props) { From 3bdd08f14133bc50f5f292ca84d4b8ad2481731d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Feb 2023 15:11:49 -0800 Subject: [PATCH 013/582] updates to variable names and function definitions --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 129 +++++++++++++--------- src/pks/ecosim_pk/Ecosim_ATS_interface.hh | 6 +- 2 files changed, 82 insertions(+), 53 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4404109e7..471fcc44b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -233,46 +233,28 @@ void EcoSIM::Initialize() { S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); - // init root carbon - auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_depth = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //This is the main set up code in alquimia it loops over times and chemical conditions //I don't know that we need the two initial loops. I'm just including them because we might + for (int col=0; col!=num_cols_; ++col) { + //FieldToColumn_(col, temp, col_temp.ptr()); + //ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); - if (fabs(initial_conditions_time_ - S_->get_time()) < 1e-8 * (1.0 + fabs(S_->get_time()))) { - for (auto it = chem_initial_conditions_.begin(); it != chem_initial_conditions_.end(); ++it) { - std::string region = it->first; - std::string condition = it->second; + //We're going to need to write an InitializeSingleColumn code + //ierr = InitializeSingleCell(cell, condition); - if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "enforcing geochemical condition \"" << condition - << "\" in region \"" << region << "\"\n"; - } - for (int col=0; col!=num_cols_; ++col) { - //FieldToColumn_(col, temp, col_temp.ptr()); - //ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); - - //We're going to need to write an InitializeSingleColumn code - //ierr = InitializeSingleCell(cell, condition); - - ierr = InitializeSingleColumn(col, condition); - //In Alquimia this function simply calls CopyToAlquimia, then - //Calls the chemistry engine and enforces condition, then copies - //From Alquimia to Amanzi - // - //The copy to alquimia function takes the cell index, because it - //is assigning things cell by cell in state. For colums this will - //be a bit trickier I THINK we could use the FieldToColumn_ function - //To do this, but I think I will actually need to figure out a test - //for this before I actually code it up - } - } - } + ierr = InitializeSingleColumn(col); + //In Alquimia this function simply calls CopyToAlquimia, then + //Calls the chemistry engine and enforces condition, then copies + //From Alquimia to Amanzi + // + //The copy to alquimia function takes the cell index, because it + //is assigning things cell by cell in state. For colums this will + //be a bit trickier I THINK we could use the FieldToColumn_ function + //To do this, but I think I will actually need to figure out a test + //for this before I actually code it up +} // verbose message if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { @@ -342,20 +324,74 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); // grab the required fields + /* Epetra_MultiVector& sc_pools = *S_->GetW(key_, tag_next_, name_) .ViewComponent("cell",false); Epetra_MultiVector& co2_decomp = *S_->GetW("co2_decomposition", tag_next_, name_) .ViewComponent("cell",false); Epetra_MultiVector& trans = *S_->GetW(trans_key_, tag_next_, name_) + .ViewComponent("cell",false);*/ + //Do I need to update everything here? + + S_->GetEvaluator("porosity", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& porosity = *S_->Get("porosity", tag_next_) .ViewComponent("cell",false); + S_->GetEvaluator("saturation_liquid", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& liquid_saturation = *S_->Get("saturation_liquid", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("saturation_gas", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& gas_saturation = *S_->Get("saturation_gas", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("saturation_ice", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& ice_saturation = *S_->Get("saturation_ice", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("water_content", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& water_content = *S_->Get("water_content", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("relatiive_permeabiilty", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& relative_permeability = *S_->Get("relative_permeabiilty", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& liquid_density = *S_->Get("mass_density_liquid", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& gas_density = *S_->Get("mass_density_gas", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& ice_density = *S_->Get("mass_density_ice", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("density_rock", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& rock_density = *S_->Get("density_rock", tag_next_) + .ViewComponent("cell",false); + S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); const Epetra_MultiVector& temp = *S_->Get("temperature", tag_next_) .ViewComponent("cell",false); - S_->GetEvaluator("pressure", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& pres = *S_->Get("pressure", tag_next_) - .ViewComponent("cell",false); + S_->GetEvaluator("thermal_conductivity", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& conductivity = *S_->Get("thermal_conductivity", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("cell_volume", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& cell_volume = *S_->Get("cell_volume", tag_next_) + .ViewComponent("cell",false); + + //S_->GetEvaluator("pressure", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& pres = *S_->Get("pressure", tag_next_) + // .ViewComponent("cell",false); // note that this is used as the column area, which is maybe not always // right. Likely correct for soil carbon calculations and incorrect for @@ -365,13 +401,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& scv = *S_->Get("surface-cell_volume", tag_next_) .ViewComponent("cell", false); - // loop over columns and apply the model for (AmanziMesh::Entity_ID col=0; col!=num_cols_; ++col) { - // update the various soil arrays - FieldToColumn_(col, *temp(0), temp_c.ptr()); - FieldToColumn_(col, *pres(0), pres_c.ptr()); - ColDepthDz_(col, depth_c.ptr(), dz_c.ptr()); auto& col_iter = mesh_->cells_of_column(col); ncells_per_col_ = col_iter.size(); @@ -392,16 +423,12 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { } // end loop over columns // mark primaries as changed - changedEvaluatorPrimary(trans_key_, tag_next_, *S_); - changedEvaluatorPrimary(shaded_sw_key_, tag_next_, *S_); - changedEvaluatorPrimary(total_lai_key_, tag_next_, *S_); - return false; // Compute the next time step. // * will we need to do this? * ComputeNextTimeStep(); - return failed; + //return failed; std::cout << "\nEnd Advance\n"; } @@ -700,7 +727,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, * This helper performs initialization on a single cell within Amanzi's state. * It returns an error code that indicates success (0) or failure (1). ******************************************************************* */ -int EcoSIM::InitializeSingleColumn(int col, const std::string& condition) +int EcoSIM::InitializeSingleColumn(int col) { // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but // should use the same tag as transport. See #673 @@ -718,9 +745,9 @@ int EcoSIM::InitializeSingleColumn(int col, const std::string& condition) // overwritten as 0 to get expected output. Therefore we manually overwrite // this now. Previously this happened due to a bug in ATS's reactive // transport coupler -- happy accidents. - if (alq_mat_props_.saturation <= saturation_tolerance_) - for (int i=0; i!=aqueous_components_->NumVectors(); ++i) (*aqueous_components_)[i][cell] = 0.; - return 0; + //if (alq_mat_props_.saturation <= saturation_tolerance_) + // for (int i=0; i!=aqueous_components_->NumVectors(); ++i) (*aqueous_components_)[i][cell] = 0.; + //return 0; } /* ******************************************************************* diff --git a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh index 001dfb369..69d7613bd 100644 --- a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh +++ b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh @@ -106,7 +106,7 @@ class EcoSIM : public PK_Physical_Default { const BGCState& state, const BGCAuxiliaryData& aux_data); - int InitializeSingleColumn(int col, const std::string& condition); + int InitializeSingleColumn(int col); int AdvanceSingleColumn(double dt, int col); @@ -130,10 +130,12 @@ class EcoSIM : public PK_Physical_Default { void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, double* col_vec, int ncol); - void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, + void ColDepthDz_(AmanziMesh::Entity_ID col, Teuchos::Ptr depth, Teuchos::Ptr dz); + void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + double* col_vec, int ncol) //evaluator for transpiration; //I don't think I need this anymore //Teuchos::RCP p_root_eval_; From 95de6f3807bb7d6c1df69d98b462f25adc7c7982 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Feb 2023 13:02:01 -0800 Subject: [PATCH 014/582] Updates to CMakeLists to register everything --- src/pks/ecosim_pk/CMakeLists.txt | 8 +++-- src/pks/ecosim_pk/data/CMakeLists.txt | 47 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/pks/ecosim_pk/data/CMakeLists.txt diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 4c632d44c..01be5eed2 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -13,10 +13,12 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) set(ats_ecosim_src_files Ecosim_ATS_interface.cc + BGCEngine.cc ) set(ats_ecosim_inc_files Ecosim_interface_test.hh + BGCEngine.hh ) set(ats_ecosim_link_libs @@ -36,7 +38,7 @@ set(ats_ecosim_link_libs ats_pks ats_eos ats_operators - ecosim_relations + ats_ecosim_data ) @@ -49,8 +51,8 @@ add_amanzi_library(ats_ecosim # register evaluators/factories/pks register_evaluator_with_factory( - HEADERFILE Ecosim_interface_reg.hh - LISTNAME ATS_ECOSIM_REG + HEADERFILE ats_ecosim_data_registration.hh + LISTNAME ATS_ECOSIM_DATA_REG ) HEADERFILE ats_ecosim_registration.hh diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt new file mode 100644 index 000000000..725582412 --- /dev/null +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -0,0 +1,47 @@ +# -*- mode: cmake -*- +# +# ATS +# Data management programs for EcoSIM_ATS +# + +# collect all sources +set(ats_ecosim_data_src_files + BGC_constants.c + BGC_memory.c +) +set(ats_ecosim_data_inc_files + BGC_constants.h + BGC_containers.h + BGC_memory.h +) + +set(ats_ecosim_data_link_libs + ${Teuchos_LIBRARIES} + ${Epetra_LIBRARIES} + error_handling + atk + mesh + data_structures + whetstone + operators + solvers + time_integration + state + pks + chemistry_pk + ats_pks + ats_eos + ats_operators +) + +# make the library +add_amanzi_library(ats_ecosim_data + SOURCE ${ats_ecosim_data_src_files} + HEADERS ${ats_ecosim_data_inc_files} + LINK_LIBS ${ats_ecosim_data_link_libs}) + +generate_evaluators_registration_header( + HEADERFILE ats_ecosim_data_registration.hh + LISTNAME ATS_ECOSIM_DATA_REG + INSTALL True + ) From 8ea940ad57598477a600a6cc2c933a6459105f13 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Feb 2023 13:09:21 -0800 Subject: [PATCH 015/582] registering the pk up the directory chain --- src/executables/ats_registration_files.hh | 1 + src/pks/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/executables/ats_registration_files.hh b/src/executables/ats_registration_files.hh index 9ce410fa7..165c0e932 100644 --- a/src/executables/ats_registration_files.hh +++ b/src/executables/ats_registration_files.hh @@ -25,3 +25,4 @@ #ifdef ALQUIMIA_ENABLED # include "pks_chemistry_registration.hh" #endif +#include "ats_ecosim_registration.hh" diff --git a/src/pks/CMakeLists.txt b/src/pks/CMakeLists.txt index ed7c4769a..c8963f40c 100644 --- a/src/pks/CMakeLists.txt +++ b/src/pks/CMakeLists.txt @@ -57,3 +57,4 @@ add_subdirectory(deform) add_subdirectory(surface_balance) add_subdirectory(biogeochemistry) add_subdirectory(mpc) +add_subdirectory(ecosim_pk) From 66d730a9bddb5fa47f393e4973b3c4de60fac7ed Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Feb 2023 13:50:57 -0800 Subject: [PATCH 016/582] Added evaluators for bulk density and hydraulic conductivity. --- .../bulk_density/bulk_density.py | 27 ++ .../bulk_density/bulk_density_evaluator.cc | 295 ++++++++++++++++++ .../bulk_density/bulk_density_evaluator.hh | 62 ++++ .../bulk_density_evaluator_reg.hh | 11 + .../bulk_density/bulk_density_model.cc | 91 ++++++ .../bulk_density/bulk_density_model.hh | 47 +++ .../hydraulic_conductivity.py | 20 ++ .../hydraulic_conductivity_evaluator.cc | 145 +++++++++ .../hydraulic_conductivity_evaluator.hh | 57 ++++ .../hydraulic_conductivity_evaluator_reg.hh | 11 + .../hydraulic_conductivity_model.cc | 61 ++++ .../hydraulic_conductivity_model.hh | 42 +++ 12 files changed, 869 insertions(+) create mode 100644 src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density.py create mode 100644 src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc create mode 100644 src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh create mode 100644 src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh create mode 100644 src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc create mode 100644 src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh create mode 100644 src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py create mode 100644 src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc create mode 100644 src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh create mode 100644 src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh create mode 100644 src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc create mode 100644 src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density.py b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density.py new file mode 100644 index 000000000..72d42d87d --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density.py @@ -0,0 +1,27 @@ +"""Richards water content evaluator: the standard form as a function of liquid saturation.""" + +import sys, os +sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) +from evaluator_generator import generate_evaluator + +""" Note that the density of rock could be either in mols or kg so this will + only make sense if it's given in mols """ + +deps = [("porosity", "phi"), + ("density_rock","nr"), + ("saturation_liquid", "sl"), + ("molar_density_liquid", "nl"), + ("saturation_ice", "si"), + ("molar_density_ice", "ni"), + ("saturation_gas", "sg"), + ("molar_density_gas", "ng") + ] +params = [] + +import sympy +phi, nr, sl, nl, si, ni, sg, ng = sympy.var("phi,nr,sl,nl,si,ni,sg,ng") +expression = nr*(1 - phi) + phi*(sl*nl + si*ni + sg*ng); + +generate_evaluator("bulk_density", "ecosim_pk", + "bulk density", "bulk_density", + deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc new file mode 100644 index 000000000..2b8851ae9 --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc @@ -0,0 +1,295 @@ +/* + The bulk density evaluator is an algebraic evaluator of a given model. +Richards water content evaluator: the standard form as a function of liquid saturation. + Generated via evaluator_generator. +*/ + +#include "bulk_density_evaluator.hh" +#include "bulk_density_model.hh" + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +// Constructor from ParameterList +BulkDensityEvaluator::BulkDensityEvaluator(Teuchos::ParameterList& plist) : + EvaluatorSecondaryMonotypeCV(plist) +{ + Teuchos::ParameterList& sublist = plist_.sublist("bulk_density parameters"); + model_ = Teuchos::rcp(new BulkDensityModel(sublist)); + InitializeFromPlist_(); +} + + +// Copy constructor +BulkDensityEvaluator::BulkDensityEvaluator(const BulkDensityEvaluator& other) : + EvaluatorSecondaryMonotypeCV(other), + phi_key_(other.phi_key_), + nr_key_(other.nr_key_), + sl_key_(other.sl_key_), + nl_key_(other.nl_key_), + si_key_(other.si_key_), + ni_key_(other.ni_key_), + sg_key_(other.sg_key_), + ng_key_(other.ng_key_), + model_(other.model_) {} + + +// Virtual copy constructor +Teuchos::RCP +BulkDensityEvaluator::Clone() const +{ + return Teuchos::rcp(new BulkDensityEvaluator(*this)); +} + + +// Initialize by setting up dependencies +void +BulkDensityEvaluator::InitializeFromPlist_() +{ + // Set up my dependencies + // - defaults to prefixed via domain + Key domain_name = Keys::getDomain(my_key_); + + // - pull Keys from plist + // dependency: porosity + phi_key_ = Keys::readKey(plist_, domain_name, "porosity", "porosity"); + dependencies_.insert(phi_key_); + + // dependency: density_rock + nr_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); + dependencies_.insert(nr_key_); + + // dependency: saturation_liquid + sl_key_ = Keys::readKey(plist_, domain_name, "saturation liquid", "saturation_liquid"); + dependencies_.insert(sl_key_); + + // dependency: molar_density_liquid + nl_key_ = Keys::readKey(plist_, domain_name, "molar density liquid", "molar_density_liquid"); + dependencies_.insert(nl_key_); + + // dependency: saturation_ice + si_key_ = Keys::readKey(plist_, domain_name, "saturation ice", "saturation_ice"); + dependencies_.insert(si_key_); + + // dependency: molar_density_ice + ni_key_ = Keys::readKey(plist_, domain_name, "molar density ice", "molar_density_ice"); + dependencies_.insert(ni_key_); + + // dependency: saturation_gas + sg_key_ = Keys::readKey(plist_, domain_name, "saturation gas", "saturation_gas"); + dependencies_.insert(sg_key_); + + // dependency: molar_density_gas + ng_key_ = Keys::readKey(plist_, domain_name, "molar density gas", "molar_density_gas"); + dependencies_.insert(ng_key_); +} + + +void +BulkDensityEvaluator::EvaluateField_(const Teuchos::Ptr& S, + const Teuchos::Ptr& result) +{ +Teuchos::RCP phi = S->GetFieldData(phi_key_); +Teuchos::RCP nr = S->GetFieldData(nr_key_); +Teuchos::RCP sl = S->GetFieldData(sl_key_); +Teuchos::RCP nl = S->GetFieldData(nl_key_); +Teuchos::RCP si = S->GetFieldData(si_key_); +Teuchos::RCP ni = S->GetFieldData(ni_key_); +Teuchos::RCP sg = S->GetFieldData(sg_key_); +Teuchos::RCP ng = S->GetFieldData(ng_key_); + + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->BulkDensity(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } +} + + +void +BulkDensityEvaluator::EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, + Key wrt_key, const Teuchos::Ptr& result) +{ +Teuchos::RCP phi = S->GetFieldData(phi_key_); +Teuchos::RCP nr = S->GetFieldData(nr_key_); +Teuchos::RCP sl = S->GetFieldData(sl_key_); +Teuchos::RCP nl = S->GetFieldData(nl_key_); +Teuchos::RCP si = S->GetFieldData(si_key_); +Teuchos::RCP ni = S->GetFieldData(ni_key_); +Teuchos::RCP sg = S->GetFieldData(sg_key_); +Teuchos::RCP ng = S->GetFieldData(ng_key_); + + if (wrt_key == phi_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DBulkDensityDPorosity(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } + + } else if (wrt_key == nr_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DBulkDensityDDensityRock(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } + + } else if (wrt_key == sl_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DBulkDensityDSaturationLiquid(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } + + } else if (wrt_key == nl_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DBulkDensityDMolarDensityLiquid(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } + + } else if (wrt_key == si_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DBulkDensityDSaturationIce(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } + + } else if (wrt_key == ni_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DBulkDensityDMolarDensityIce(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } + + } else if (wrt_key == sg_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DBulkDensityDSaturationGas(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } + + } else if (wrt_key == ng_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); + const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); + const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); + const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); + const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DBulkDensityDMolarDensityGas(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + } + } + + } else { + ASSERT(0); + } +} + + +} //namespace +} //namespace +} //namespace \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh new file mode 100644 index 000000000..ca5798738 --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh @@ -0,0 +1,62 @@ +/* + The bulk density evaluator is an algebraic evaluator of a given model. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#ifndef AMANZI_ECOSIM_PK_BULK_DENSITY_EVALUATOR_HH_ +#define AMANZI_ECOSIM_PK_BULK_DENSITY_EVALUATOR_HH_ + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +class BulkDensityModel; + +class BulkDensityEvaluator : public EvaluatorSecondaryMonotypeCV { + + public: + explicit + BulkDensityEvaluator(Teuchos::ParameterList& plist); + BulkDensityEvaluator(const BulkDensityEvaluator& other); + + virtual Teuchos::RCP Clone() const; + + // Required methods from EvaluatorSecondaryMonotypeCV + virtual void EvaluateField_(const Teuchos::Ptr& S, + const Teuchos::Ptr& result); + virtual void EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, + Key wrt_key, const Teuchos::Ptr& result); + + Teuchos::RCP get_model() { return model_; } + + protected: + void InitializeFromPlist_(); + + Key phi_key_; + Key nr_key_; + Key sl_key_; + Key nl_key_; + Key si_key_; + Key ni_key_; + Key sg_key_; + Key ng_key_; + + Teuchos::RCP model_; + + private: + static Utils::RegisteredFactory reg_; + +}; + +} //namespace +} //namespace +} //namespace + +#endif \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh new file mode 100644 index 000000000..029ee74cc --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh @@ -0,0 +1,11 @@ +#include "bulk_density_evaluator.hh" + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +Utils::RegisteredFactory BulkDensityEvaluator::reg_("bulk density"); + +} //namespace +} //namespace +} //namespace diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc new file mode 100644 index 000000000..95af0c5c6 --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc @@ -0,0 +1,91 @@ +/* + The bulk density model is an algebraic model with dependencies. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#include "Teuchos_ParameterList.hpp" +#include "dbc.hh" +#include "bulk_density_model.hh" + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +// Constructor from ParameterList +BulkDensityModel::BulkDensityModel(Teuchos::ParameterList& plist) +{ + InitializeFromPlist_(plist); +} + + +// Initialize parameters +void +BulkDensityModel::InitializeFromPlist_(Teuchos::ParameterList& plist) +{ + +} + + +// main method +double +BulkDensityModel::BulkDensity(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return nr*(1 - phi) + phi*(ng*sg + ni*si + nl*sl); +} + +double +BulkDensityModel::DBulkDensityDPorosity(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return ng*sg + ni*si + nl*sl - nr; +} + +double +BulkDensityModel::DBulkDensityDDensityRock(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return 1 - phi; +} + +double +BulkDensityModel::DBulkDensityDSaturationLiquid(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return nl*phi; +} + +double +BulkDensityModel::DBulkDensityDMolarDensityLiquid(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return phi*sl; +} + +double +BulkDensityModel::DBulkDensityDSaturationIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return ni*phi; +} + +double +BulkDensityModel::DBulkDensityDMolarDensityIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return phi*si; +} + +double +BulkDensityModel::DBulkDensityDSaturationGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return ng*phi; +} + +double +BulkDensityModel::DBulkDensityDMolarDensityGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +{ + return phi*sg; +} + +} //namespace +} //namespace +} //namespace + \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh new file mode 100644 index 000000000..39380c2d4 --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh @@ -0,0 +1,47 @@ +/* + The bulk density model is an algebraic model with dependencies. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#ifndef AMANZI_ECOSIM_PK_BULK_DENSITY_MODEL_HH_ +#define AMANZI_ECOSIM_PK_BULK_DENSITY_MODEL_HH_ + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +class BulkDensityModel { + + public: + explicit + BulkDensityModel(Teuchos::ParameterList& plist); + + double BulkDensity(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + + double DBulkDensityDPorosity(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + double DBulkDensityDDensityRock(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + double DBulkDensityDSaturationLiquid(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + double DBulkDensityDMolarDensityLiquid(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + double DBulkDensityDSaturationIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + double DBulkDensityDMolarDensityIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + double DBulkDensityDSaturationGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + double DBulkDensityDMolarDensityGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + + protected: + void InitializeFromPlist_(Teuchos::ParameterList& plist); + + protected: + + + +}; + +} //namespace +} //namespace +} //namespace + +#endif \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py new file mode 100644 index 000000000..ae7e5fa26 --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py @@ -0,0 +1,20 @@ +"""Richards water content evaluator: the standard form as a function of liquid saturation.""" + +import sys, os +sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) +from evaluator_generator import generate_evaluator + +deps = [("permeabiilty","k"), + ("mass_density_liquid", "rho"), + ("viscosity_liquid", "mu"), + ] +params = [("g", "double", "gravitational constant")] + +import sympy +k, rho, mu = sympy.var("k,rho,mu") +g_ = sympy.var("g_") +expression = (k * rho * mu) / mu; + +generate_evaluator("hydraulic_conductivity", "ecosim_pk", + "hydraulic conductivity", "hydraulic_conductivity", + deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc new file mode 100644 index 000000000..18508c265 --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc @@ -0,0 +1,145 @@ +/* + The hydraulic conductivity evaluator is an algebraic evaluator of a given model. +Richards water content evaluator: the standard form as a function of liquid saturation. + Generated via evaluator_generator. +*/ + +#include "hydraulic_conductivity_evaluator.hh" +#include "hydraulic_conductivity_model.hh" + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +// Constructor from ParameterList +HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(Teuchos::ParameterList& plist) : + EvaluatorSecondaryMonotypeCV(plist) +{ + Teuchos::ParameterList& sublist = plist_.sublist("hydraulic_conductivity parameters"); + model_ = Teuchos::rcp(new HydraulicConductivityModel(sublist)); + InitializeFromPlist_(); +} + + +// Copy constructor +HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other) : + EvaluatorSecondaryMonotypeCV(other), + k_key_(other.k_key_), + rho_key_(other.rho_key_), + mu_key_(other.mu_key_), + model_(other.model_) {} + + +// Virtual copy constructor +Teuchos::RCP +HydraulicConductivityEvaluator::Clone() const +{ + return Teuchos::rcp(new HydraulicConductivityEvaluator(*this)); +} + + +// Initialize by setting up dependencies +void +HydraulicConductivityEvaluator::InitializeFromPlist_() +{ + // Set up my dependencies + // - defaults to prefixed via domain + Key domain_name = Keys::getDomain(my_key_); + + // - pull Keys from plist + // dependency: permeabiilty + k_key_ = Keys::readKey(plist_, domain_name, "permeabiilty", "permeabiilty"); + dependencies_.insert(k_key_); + + // dependency: mass_density_liquid + rho_key_ = Keys::readKey(plist_, domain_name, "mass density liquid", "mass_density_liquid"); + dependencies_.insert(rho_key_); + + // dependency: viscosity_liquid + mu_key_ = Keys::readKey(plist_, domain_name, "viscosity liquid", "viscosity_liquid"); + dependencies_.insert(mu_key_); +} + + +void +HydraulicConductivityEvaluator::EvaluateField_(const Teuchos::Ptr& S, + const Teuchos::Ptr& result) +{ +Teuchos::RCP k = S->GetFieldData(k_key_); +Teuchos::RCP rho = S->GetFieldData(rho_key_); +Teuchos::RCP mu = S->GetFieldData(mu_key_); + + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->HydraulicConductivity(k_v[0][i], rho_v[0][i], mu_v[0][i]); + } + } +} + + +void +HydraulicConductivityEvaluator::EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, + Key wrt_key, const Teuchos::Ptr& result) +{ +Teuchos::RCP k = S->GetFieldData(k_key_); +Teuchos::RCP rho = S->GetFieldData(rho_key_); +Teuchos::RCP mu = S->GetFieldData(mu_key_); + + if (wrt_key == k_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DHydraulicConductivityDPermeabiilty(k_v[0][i], rho_v[0][i], mu_v[0][i]); + } + } + + } else if (wrt_key == rho_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DHydraulicConductivityDMassDensityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); + } + } + + } else if (wrt_key == mu_key_) { + for (CompositeVector::name_iterator comp=result->begin(); + comp!=result->end(); ++comp) { + const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + + int ncomp = result->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DHydraulicConductivityDViscosityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); + } + } + + } else { + ASSERT(0); + } +} + + +} //namespace +} //namespace +} //namespace \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh new file mode 100644 index 000000000..f11c7f72b --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh @@ -0,0 +1,57 @@ +/* + The hydraulic conductivity evaluator is an algebraic evaluator of a given model. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#ifndef AMANZI_ECOSIM_PK_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ +#define AMANZI_ECOSIM_PK_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +class HydraulicConductivityModel; + +class HydraulicConductivityEvaluator : public EvaluatorSecondaryMonotypeCV { + + public: + explicit + HydraulicConductivityEvaluator(Teuchos::ParameterList& plist); + HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other); + + virtual Teuchos::RCP Clone() const; + + // Required methods from EvaluatorSecondaryMonotypeCV + virtual void EvaluateField_(const Teuchos::Ptr& S, + const Teuchos::Ptr& result); + virtual void EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, + Key wrt_key, const Teuchos::Ptr& result); + + Teuchos::RCP get_model() { return model_; } + + protected: + void InitializeFromPlist_(); + + Key k_key_; + Key rho_key_; + Key mu_key_; + + Teuchos::RCP model_; + + private: + static Utils::RegisteredFactory reg_; + +}; + +} //namespace +} //namespace +} //namespace + +#endif \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh new file mode 100644 index 000000000..fdaa8e2fc --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh @@ -0,0 +1,11 @@ +#include "hydraulic_conductivity_evaluator.hh" + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +Utils::RegisteredFactory HydraulicConductivityEvaluator::reg_("hydraulic conductivity"); + +} //namespace +} //namespace +} //namespace diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc new file mode 100644 index 000000000..25dd7695f --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc @@ -0,0 +1,61 @@ +/* + The hydraulic conductivity model is an algebraic model with dependencies. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#include "Teuchos_ParameterList.hpp" +#include "dbc.hh" +#include "hydraulic_conductivity_model.hh" + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +// Constructor from ParameterList +HydraulicConductivityModel::HydraulicConductivityModel(Teuchos::ParameterList& plist) +{ + InitializeFromPlist_(plist); +} + + +// Initialize parameters +void +HydraulicConductivityModel::InitializeFromPlist_(Teuchos::ParameterList& plist) +{ + g_ = plist.get("gravitational constant"); +} + + +// main method +double +HydraulicConductivityModel::HydraulicConductivity(double k, double rho, double mu) const +{ + return k*rho; +} + +double +HydraulicConductivityModel::DHydraulicConductivityDPermeabiilty(double k, double rho, double mu) const +{ + return rho; +} + +double +HydraulicConductivityModel::DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const +{ + return k; +} + +double +HydraulicConductivityModel::DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const +{ + return 0; +} + +} //namespace +} //namespace +} //namespace + \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh new file mode 100644 index 000000000..3cb3a917d --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh @@ -0,0 +1,42 @@ +/* + The hydraulic conductivity model is an algebraic model with dependencies. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#ifndef AMANZI_ECOSIM_PK_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ +#define AMANZI_ECOSIM_PK_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ + +namespace Amanzi { +namespace Ecosim_pk { +namespace Relations { + +class HydraulicConductivityModel { + + public: + explicit + HydraulicConductivityModel(Teuchos::ParameterList& plist); + + double HydraulicConductivity(double k, double rho, double mu) const; + + double DHydraulicConductivityDPermeabiilty(double k, double rho, double mu) const; + double DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const; + double DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const; + + protected: + void InitializeFromPlist_(Teuchos::ParameterList& plist); + + protected: + + double g_; + +}; + +} //namespace +} //namespace +} //namespace + +#endif \ No newline at end of file From 3dd23f756f40ae7c62c3504b62b048cbb9550fd9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Feb 2023 15:43:33 -0800 Subject: [PATCH 017/582] modified CMakeLists to include constitutive relations --- src/pks/ecosim_pk/CMakeLists.txt | 5 +- .../constitutive_relations/CMakeLists.txt | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 01be5eed2..bf25a0213 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -5,7 +5,9 @@ add_subdirectory(data) include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) -#include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/root_storage) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/data) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/bulk_density) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity) # ATS EcoSIM pk # For adding F90 files add the F90 file to the ecosim source files and @@ -39,6 +41,7 @@ set(ats_ecosim_link_libs ats_eos ats_operators ats_ecosim_data + ats_ecosim_relations ) diff --git a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt new file mode 100644 index 000000000..c3bd09b07 --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt @@ -0,0 +1,53 @@ +# -*- mode: cmake -*- +# +# ATS +# Constitutive relations for flow +# + + +# collect all sources + +list(APPEND subdirs bulk_density hydraulic_conductivity) + +set(ats_ecosim_relations_src_files "") +set(ats_ecosim_relations_inc_files "") + +foreach(lcv IN LISTS subdirs) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/${lcv}) + + file(GLOB subdir_sources "./${lcv}/*.cc") + set(ats_ecosim_relations_src_files ${ats_ecosim_relations_src_files} ${subdir_sources}) + + file(GLOB subdir_incs "./${lcv}/*.hh") + set(ats_ecosim_relations_inc_files ${ats_ecosim_relations_inc_files} ${subdir_incs}) + + file(GLOB registrations "./${lcv}/*_reg.hh" ) + foreach(reg_lcv IN LISTS registrations) + register_abs_evaluator_with_factory(HEADERFILE ${reg_lcv} LISTNAME ATS_ECOISIM_RELATIONS_REG) + endforeach(reg_lcv) + +endforeach(lcv) + +set(ats_ecosim_relations_link_libs + ${Teuchos_LIBRARIES} + ${Epetra_LIBRARIES} + error_handling + atk + mesh + data_structures + whetstone + solvers + state + ) + +# make the library +add_amanzi_library(ats_ecosim_relations + SOURCE ${ats_ecosim_relations_src_files} + HEADERS ${ats_ecosim_relations_inc_files} + LINK_LIBS ${ats_ecosim_relations_link_libs}) + +generate_evaluators_registration_header( + HEADERFILE ats_ecosim_relations_registration.hh + LISTNAME ATS_ECOSIM_RELATIONS_REG + INSTALL True + ) From 16101b91a705a09b9f4df2856a5a544d9b3fd34a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 23 Feb 2023 14:12:40 -0800 Subject: [PATCH 018/582] bugfixes for the cmake registrations. --- src/executables/ats_registration_files.hh | 2 ++ src/pks/ecosim_pk/CMakeLists.txt | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/executables/ats_registration_files.hh b/src/executables/ats_registration_files.hh index 165c0e932..f7ecb5ce2 100644 --- a/src/executables/ats_registration_files.hh +++ b/src/executables/ats_registration_files.hh @@ -26,3 +26,5 @@ # include "pks_chemistry_registration.hh" #endif #include "ats_ecosim_registration.hh" +#include "ats_ecosim_relations_registration.hh" +#include "ats_ecosim_data_registration.hh" diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index bf25a0213..1ee0fa55f 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -58,6 +58,17 @@ register_evaluator_with_factory( LISTNAME ATS_ECOSIM_DATA_REG ) +register_evaluator_with_factory( + HEADERFILE bulk_density_evaluator_reg.hh + LISTNAME ATS_ECOSIM_REG +) + +register_evaluator_with_factory( + HEADERFILE hydraulic_conductivity_evaluator_reg.hh + LISTNAME ATS_ECOSIM_REG +) + +generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh LISTNAME ATS_ECOSIM_REG INSTALL True From c6e34506305da459f74f16e2062a8e56720fab53 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 1 Mar 2023 13:49:35 -0800 Subject: [PATCH 019/582] bug fixes for relations registration --- src/pks/ecosim_pk/CMakeLists.txt | 20 ++++++++++---------- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/Ecosim_interface_reg.hh | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 1ee0fa55f..01654a833 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -14,12 +14,12 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/h # inc files. The inc file also needs a header set(ats_ecosim_src_files - Ecosim_ATS_interface.cc + EcoSIM_ATS_interface.cc BGCEngine.cc ) set(ats_ecosim_inc_files - Ecosim_interface_test.hh + EcoSIM_interface_test.hh BGCEngine.hh ) @@ -58,15 +58,15 @@ register_evaluator_with_factory( LISTNAME ATS_ECOSIM_DATA_REG ) -register_evaluator_with_factory( - HEADERFILE bulk_density_evaluator_reg.hh - LISTNAME ATS_ECOSIM_REG -) +#register_evaluator_with_factory( +# HEADERFILE bulk_density_evaluator_reg.hh +# LISTNAME ATS_ECOSIM_REG +#) -register_evaluator_with_factory( - HEADERFILE hydraulic_conductivity_evaluator_reg.hh - LISTNAME ATS_ECOSIM_REG -) +#register_evaluator_with_factory( +# HEADERFILE hydraulic_conductivity_evaluator_reg.hh +# LISTNAME ATS_ECOSIM_REG +#) generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 471fcc44b..08c8f77cc 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -9,7 +9,7 @@ --------------------------------------------------------------------------*/ -#include "Ecosim_ATS_interface.hh" +#include "EcoSIM_ATS_interface.hh" #include "pk_helpers.hh" namespace Amanzi { diff --git a/src/pks/ecosim_pk/Ecosim_interface_reg.hh b/src/pks/ecosim_pk/Ecosim_interface_reg.hh index 8af97cb0c..eb1d7be50 100644 --- a/src/pks/ecosim_pk/Ecosim_interface_reg.hh +++ b/src/pks/ecosim_pk/Ecosim_interface_reg.hh @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- */ -#include "Ecosim_interface.hh" +#include "EcoSIM_interface.hh" namespace Amanzi { namespace EcoSIM { From 9c7b443a2ad89b73d859549ea074fb574d7f726e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 1 Mar 2023 15:48:51 -0800 Subject: [PATCH 020/582] updates to ats version cmake --- tools/cmake/ATSVersion.cmake | 44 +++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/tools/cmake/ATSVersion.cmake b/tools/cmake/ATSVersion.cmake index e0e6bb8ea..9e291dddf 100644 --- a/tools/cmake/ATSVersion.cmake +++ b/tools/cmake/ATSVersion.cmake @@ -2,16 +2,16 @@ # # ATS Version Information: -# -# Information about the current source is extracted from the git repository and used to -# create the version string (ATS_VERSION). +# +# Information about the current source is extracted from the git repository and used to +# create the version string (ATS_VERSION). # # NOTE: this information won't be accessible without the full repository. # So for releases we need to extract this and set it as part of the tarball creation. # # * if ats_version.hh does not exist create it # * if git is found -# use git to create version strings +# use git to create version strings # * else # use statically defined version strings # * endif @@ -31,13 +31,13 @@ message(STATUS ">>>> JDM: ${ATS_SUBMODULE_DIR}") find_package(Git) -if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) +if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) # Get the name of the current branch. set(GIT_ARGS status) execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_ARGS} WORKING_DIRECTORY ${ATS_SUBMODULE_DIR} - RESULT_VARIABLE err_occurred + RESULT_VARIABLE err_occurred OUTPUT_VARIABLE ATS_GIT_STATUS ERROR_VARIABLE err OUTPUT_STRIP_TRAILING_WHITESPACE @@ -57,7 +57,7 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) STRING(REPLACE "\n" ";" ATS_GIT_STATUS_LIST ${ATS_GIT_STATUS}) # Extract the first entry - reuse the ATS_GIT_STATUS variable LIST(GET ATS_GIT_STATUS_LIST 0 ATS_GIT_STATUS) - if (${ATS_GIT_STATUS} MATCHES "(D|d)etached") + if (${ATS_GIT_STATUS} MATCHES "(D|d)etached") # For now just set branch to detached - we could add a lookup for tags later set(ATS_GIT_BRANCH detached) elseif(${ATS_GIT_STATUS} MATCHES "On branch") @@ -73,7 +73,7 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) set(GIT_ARGS rev-parse --short HEAD) execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_ARGS} WORKING_DIRECTORY ${ATS_SUBMODULE_DIR} - RESULT_VARIABLE err_occurred + RESULT_VARIABLE err_occurred OUTPUT_VARIABLE ATS_GIT_GLOBAL_HASH ERROR_VARIABLE err OUTPUT_STRIP_TRAILING_WHITESPACE @@ -90,7 +90,7 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) set(GIT_ARGS tag -l ats-*) execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_ARGS} WORKING_DIRECTORY ${ATS_SUBMODULE_DIR} - RESULT_VARIABLE err_occurred + RESULT_VARIABLE err_occurred OUTPUT_VARIABLE ATS_GIT_LATEST_TAG ERROR_VARIABLE err OUTPUT_STRIP_TRAILING_WHITESPACE @@ -99,7 +99,7 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) # Put the tags in a list STRING(REPLACE "\n" ";" ATS_GIT_LATEST_TAG_LIST ${ATS_GIT_LATEST_TAG}) # Extract the lastest tag of the form ats-* - IF ( ${ATS_GIT_BRANCH} MATCHES "master" ) + IF ( ${ATS_GIT_BRANCH} MATCHES "master" ) FOREACH(atag ${ATS_GIT_LATEST_TAG_LIST}) IF ( ${atag} MATCHES "^ats-.*-dev" ) set ( ATS_GIT_LATEST_TAG ${atag} ) @@ -113,19 +113,22 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) ENDFOREACH() ENDIF() - # message(STATUS ">>>> JDM: GIT_EXEC = ${GIT_EXECUTABLE}") - # message(STATUS ">>>> JDM: GIT_ARGS = ${GIT_ARGS}") - # message(STATUS ">>>> JDM: RESULT_VARIABLE = ${err_occurred}") - # message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG = ${ATS_GIT_LATEST_TAG}") + message(STATUS ">>>> JDM: GIT_EXEC = ${GIT_EXECUTABLE}") + message(STATUS ">>>> JDM: GIT_ARGS = ${GIT_ARGS}") + message(STATUS ">>>> JDM: RESULT_VARIABLE = ${err_occurred}") + message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG = ${ATS_GIT_LATEST_TAG}") - STRING(REGEX REPLACE "ats-" "" ATS_GIT_LATEST_TAG_VER ${ATS_GIT_LATEST_TAG}) - STRING(REGEX REPLACE "\\..*" "" ATS_GIT_LATEST_TAG_MAJOR ${ATS_GIT_LATEST_TAG_VER}) - STRING(REGEX MATCH "\\.[0-9][0-9]?[\\.,-]" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_VER}) - STRING(REGEX REPLACE "[\\.,-]" "" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_MINOR} ) + STRING(REGEX REPLACE "ats-" "" ATS_GIT_LATEST_TAG_VER ${ATS_GIT_LATEST_TAG}) + STRING(REGEX REPLACE "\\..*" "" ATS_GIT_LATEST_TAG_MAJOR ${ATS_GIT_LATEST_TAG_VER}) + STRING(REGEX MATCH "\\.[0-9][0-9]?[\\.,-]" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_VER}) + STRING(REGEX REPLACE "[\\.,-]" "" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_MINOR} ) set(ATS_VERSION_MAJOR ${ATS_GIT_LATEST_TAG_MAJOR}) set(ATS_VERSION_MINOR ${ATS_GIT_LATEST_TAG_MINOR}) + message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG_MAJOR = ${ATS_GIT_LATEST_TAG_MAJOR}") + message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG_MINOR = ${ATS_GIT_LATEST_TAG_MINOR}") + # # ATS version # @@ -138,7 +141,7 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) else() message(STATUS " >>>>>>>> Using static version information to create ats_version.hh") - if ( NOT GIT_FOUND ) + if ( NOT GIT_FOUND ) message(STATUS " >>>>>> Could not locate Git executable.") endif() if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/ ) @@ -172,11 +175,10 @@ configure_file(${version_template} ${CMAKE_CURRENT_BINARY_DIR}/extras/ats_version.hh @ONLY) -add_install_include_file(${CMAKE_CURRENT_BINARY_DIR}/ats_version.hh) +add_install_include_file(${CMAKE_CURRENT_BINARY_DIR}/ats_version.hh) message(STATUS "\t >>>>> ATS Version: ${ATS_VERSION}") message(STATUS "\t >>>>> MAJOR ${ATS_VERSION_MAJOR}") message(STATUS "\t >>>>> MINOR ${ATS_VERSION_MINOR}") message(STATUS "\t >>>>> PATCH ${ATS_VERSION_PATCH}") message(STATUS "\t >>>>> HASH ${ATS_VERSION_HASH}") - From 05903f960610a6fa0c03cb1b59b110ecb92bc4db Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 2 Mar 2023 11:31:26 -0800 Subject: [PATCH 021/582] change some of the version cmake files --- tools/cmake/ATSVersion.cmake | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/cmake/ATSVersion.cmake b/tools/cmake/ATSVersion.cmake index 9e291dddf..249427035 100644 --- a/tools/cmake/ATSVersion.cmake +++ b/tools/cmake/ATSVersion.cmake @@ -59,7 +59,8 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) LIST(GET ATS_GIT_STATUS_LIST 0 ATS_GIT_STATUS) if (${ATS_GIT_STATUS} MATCHES "(D|d)etached") # For now just set branch to detached - we could add a lookup for tags later - set(ATS_GIT_BRANCH detached) + #set(ATS_GIT_BRANCH detached) + set(ATS_GIT_BRANCH master) elseif(${ATS_GIT_STATUS} MATCHES "On branch") # Extract the branch name STRING(REPLACE "On branch " "" ATS_GIT_BRANCH ${ATS_GIT_STATUS}) @@ -118,16 +119,16 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) message(STATUS ">>>> JDM: RESULT_VARIABLE = ${err_occurred}") message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG = ${ATS_GIT_LATEST_TAG}") - STRING(REGEX REPLACE "ats-" "" ATS_GIT_LATEST_TAG_VER ${ATS_GIT_LATEST_TAG}) - STRING(REGEX REPLACE "\\..*" "" ATS_GIT_LATEST_TAG_MAJOR ${ATS_GIT_LATEST_TAG_VER}) - STRING(REGEX MATCH "\\.[0-9][0-9]?[\\.,-]" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_VER}) - STRING(REGEX REPLACE "[\\.,-]" "" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_MINOR} ) + #STRING(REGEX REPLACE "ats-" "" ATS_GIT_LATEST_TAG_VER ${ATS_GIT_LATEST_TAG}) + #STRING(REGEX REPLACE "\\..*" "" ATS_GIT_LATEST_TAG_MAJOR ${ATS_GIT_LATEST_TAG_VER}) + #STRING(REGEX MATCH "\\.[0-9][0-9]?[\\.,-]" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_VER}) + #STRING(REGEX REPLACE "[\\.,-]" "" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_MINOR} ) - set(ATS_VERSION_MAJOR ${ATS_GIT_LATEST_TAG_MAJOR}) - set(ATS_VERSION_MINOR ${ATS_GIT_LATEST_TAG_MINOR}) + #set(ATS_VERSION_MAJOR ${ATS_GIT_LATEST_TAG_MAJOR}) + #set(ATS_VERSION_MINOR ${ATS_GIT_LATEST_TAG_MINOR}) - message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG_MAJOR = ${ATS_GIT_LATEST_TAG_MAJOR}") - message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG_MINOR = ${ATS_GIT_LATEST_TAG_MINOR}") + #message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG_MAJOR = ${ATS_GIT_LATEST_TAG_MAJOR}") + #message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG_MINOR = ${ATS_GIT_LATEST_TAG_MINOR}") # # ATS version From ac0c45134ddab7e20ec3819f8c6526a4ee471578 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 2 Mar 2023 11:39:59 -0800 Subject: [PATCH 022/582] more changes --- tools/cmake/ATSVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cmake/ATSVersion.cmake b/tools/cmake/ATSVersion.cmake index 249427035..ecbed0f0d 100644 --- a/tools/cmake/ATSVersion.cmake +++ b/tools/cmake/ATSVersion.cmake @@ -98,7 +98,7 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) ERROR_STRIP_TRAILING_WHITESPACE) # Put the tags in a list - STRING(REPLACE "\n" ";" ATS_GIT_LATEST_TAG_LIST ${ATS_GIT_LATEST_TAG}) + #STRING(REPLACE "\n" ";" ATS_GIT_LATEST_TAG_LIST ${ATS_GIT_LATEST_TAG}) # Extract the lastest tag of the form ats-* IF ( ${ATS_GIT_BRANCH} MATCHES "master" ) FOREACH(atag ${ATS_GIT_LATEST_TAG_LIST}) From 45e418c44f9d021036bf882e8081219674612d41 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 2 Mar 2023 12:28:20 -0800 Subject: [PATCH 023/582] Updated the evaluators with current syntax. --- .../bulk_density/bulk_density_evaluator.cc | 143 +++++++++--------- .../hydraulic_conductivity_evaluator.cc | 67 ++++---- 2 files changed, 111 insertions(+), 99 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc index 2b8851ae9..59df5a977 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc @@ -1,6 +1,6 @@ /* The bulk density evaluator is an algebraic evaluator of a given model. -Richards water content evaluator: the standard form as a function of liquid saturation. +Richards water content evaluator: the standard form as a function of liquid saturation. Generated via evaluator_generator. */ @@ -22,7 +22,8 @@ BulkDensityEvaluator::BulkDensityEvaluator(Teuchos::ParameterList& plist) : // Copy constructor -BulkDensityEvaluator::BulkDensityEvaluator(const BulkDensityEvaluator& other) : +//Other examples don't seem to have this copy (unneccesary?) +/*BulkDensityEvaluator::BulkDensityEvaluator(const BulkDensityEvaluator& other) : EvaluatorSecondaryMonotypeCV(other), phi_key_(other.phi_key_), nr_key_(other.nr_key_), @@ -31,8 +32,8 @@ BulkDensityEvaluator::BulkDensityEvaluator(const BulkDensityEvaluator& other) : si_key_(other.si_key_), ni_key_(other.ni_key_), sg_key_(other.sg_key_), - ng_key_(other.ng_key_), - model_(other.model_) {} + ng_key_(other.ng_key_), + model_(other.model_) {}*/ // Virtual copy constructor @@ -49,58 +50,62 @@ BulkDensityEvaluator::InitializeFromPlist_() { // Set up my dependencies // - defaults to prefixed via domain - Key domain_name = Keys::getDomain(my_key_); + // Seems to not handle keys or tags right fixing: + //Key domain_name = Keys::getDomain(my_key_); + Key domain_name = Keys::getDomain(my_keys_.front().first); + Tag tag = my_keys_.front().second; // - pull Keys from plist // dependency: porosity phi_key_ = Keys::readKey(plist_, domain_name, "porosity", "porosity"); - dependencies_.insert(phi_key_); + dependencies_.insert(KeyTag{ phi_key_, tag }); // dependency: density_rock nr_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); - dependencies_.insert(nr_key_); + dependencies_.insert(KeyTag{ nr_key_, tag}); // dependency: saturation_liquid sl_key_ = Keys::readKey(plist_, domain_name, "saturation liquid", "saturation_liquid"); - dependencies_.insert(sl_key_); + dependencies_.insert(KeyTag{ sl_key_, tag}); // dependency: molar_density_liquid nl_key_ = Keys::readKey(plist_, domain_name, "molar density liquid", "molar_density_liquid"); - dependencies_.insert(nl_key_); + dependencies_.insert(KeyTag{ nl_key_,tag}); // dependency: saturation_ice si_key_ = Keys::readKey(plist_, domain_name, "saturation ice", "saturation_ice"); - dependencies_.insert(si_key_); + dependencies_.insert(KeyTag{ si_key_, tag}); // dependency: molar_density_ice ni_key_ = Keys::readKey(plist_, domain_name, "molar density ice", "molar_density_ice"); - dependencies_.insert(ni_key_); + dependencies_.insert(KeyTag{ ni_key_, tag}); // dependency: saturation_gas sg_key_ = Keys::readKey(plist_, domain_name, "saturation gas", "saturation_gas"); - dependencies_.insert(sg_key_); + dependencies_.insert(KeyTag{ sg_key_, tag}); // dependency: molar_density_gas ng_key_ = Keys::readKey(plist_, domain_name, "molar density gas", "molar_density_gas"); - dependencies_.insert(ng_key_); + dependencies_.insert(KeyTag{ ng_key_, tag}); } void -BulkDensityEvaluator::EvaluateField_(const Teuchos::Ptr& S, +BulkDensityEvaluator::Evaluate_(const Teuchos::Ptr& S, const Teuchos::Ptr& result) { -Teuchos::RCP phi = S->GetFieldData(phi_key_); -Teuchos::RCP nr = S->GetFieldData(nr_key_); -Teuchos::RCP sl = S->GetFieldData(sl_key_); -Teuchos::RCP nl = S->GetFieldData(nl_key_); -Teuchos::RCP si = S->GetFieldData(si_key_); -Teuchos::RCP ni = S->GetFieldData(ni_key_); -Teuchos::RCP sg = S->GetFieldData(sg_key_); -Teuchos::RCP ng = S->GetFieldData(ng_key_); - - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + Tag tag = my_keys_.front().second; + Teuchos::RCP phi = S.GetPtr(phi_key_, tag); + Teuchos::RCP nr = S.GetPtr(nr_key_, tag); + Teuchos::RCP sl = S.GetPtr(sl_key_, tag); + Teuchos::RCP nl = S.GetPtr(nl_key_, tag); + Teuchos::RCP si = S.GetPtr(si_key_, tag); + Teuchos::RCP ni = S.GetPtr(ni_key_, tag); + Teuchos::RCP sg = S.GetPtr(sg_key_, tag); + Teuchos::RCP ng = S.GetPtr(ng_key_, tag); + + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -109,9 +114,9 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->BulkDensity(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } @@ -121,20 +126,22 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); void BulkDensityEvaluator::EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, - Key wrt_key, const Teuchos::Ptr& result) + Key wrt_key, const Tag& wrt_tag, const Teuchos::Ptr& result) { -Teuchos::RCP phi = S->GetFieldData(phi_key_); -Teuchos::RCP nr = S->GetFieldData(nr_key_); -Teuchos::RCP sl = S->GetFieldData(sl_key_); -Teuchos::RCP nl = S->GetFieldData(nl_key_); -Teuchos::RCP si = S->GetFieldData(si_key_); -Teuchos::RCP ni = S->GetFieldData(ni_key_); -Teuchos::RCP sg = S->GetFieldData(sg_key_); -Teuchos::RCP ng = S->GetFieldData(ng_key_); + Tag tag = my_keys_.front().second; + Teuchos::RCP phi = S.GetPtr(phi_key_, tag); + Teuchos::RCP nr = S.GetPtr(nr_key_, tag); + Teuchos::RCP sl = S.GetPtr(sl_key_, tag); + Teuchos::RCP nl = S.GetPtr(nl_key_, tag); + Teuchos::RCP si = S.GetPtr(si_key_, tag); + Teuchos::RCP ni = S.GetPtr(ni_key_, tag); + Teuchos::RCP sg = S.GetPtr(sg_key_, tag); + Teuchos::RCP ng = S.GetPtr(ng_key_, tag); + if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -145,15 +152,15 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DBulkDensityDPorosity(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } } } else if (wrt_key == nr_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -162,17 +169,17 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DBulkDensityDDensityRock(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -181,17 +188,17 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DBulkDensityDSaturationLiquid(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -200,17 +207,17 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DBulkDensityDMolarDensityLiquid(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } } } else if (wrt_key == si_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -219,17 +226,17 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DBulkDensityDSaturationIce(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } } } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -238,17 +245,17 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DBulkDensityDMolarDensityIce(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } } } else if (wrt_key == sg_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -257,17 +264,17 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DBulkDensityDSaturationGas(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } } } else if (wrt_key == ng_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -276,9 +283,9 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DBulkDensityDMolarDensityGas(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); } @@ -292,4 +299,4 @@ Teuchos::RCP ng = S->GetFieldData(ng_key_); } //namespace } //namespace -} //namespace \ No newline at end of file +} //namespace diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc index 18508c265..53880fe77 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc @@ -1,6 +1,6 @@ /* The hydraulic conductivity evaluator is an algebraic evaluator of a given model. -Richards water content evaluator: the standard form as a function of liquid saturation. +Richards water content evaluator: the standard form as a function of liquid saturation. Generated via evaluator_generator. */ @@ -22,12 +22,13 @@ HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(Teuchos::Paramete // Copy constructor -HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other) : +//Don't seem to need this +/*HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other) : EvaluatorSecondaryMonotypeCV(other), k_key_(other.k_key_), rho_key_(other.rho_key_), - mu_key_(other.mu_key_), - model_(other.model_) {} + mu_key_(other.mu_key_), + model_(other.model_) {}*/ // Virtual copy constructor @@ -44,20 +45,22 @@ HydraulicConductivityEvaluator::InitializeFromPlist_() { // Set up my dependencies // - defaults to prefixed via domain - Key domain_name = Keys::getDomain(my_key_); + //Key domain_name = Keys::getDomain(my_key_); + Key domain_name = Keys::getDomain(my_keys_.front().first); + Tag tag = my_keys_.front().second; // - pull Keys from plist // dependency: permeabiilty k_key_ = Keys::readKey(plist_, domain_name, "permeabiilty", "permeabiilty"); - dependencies_.insert(k_key_); + dependencies_.insert(KeyTag{ k_key_, tag }); // dependency: mass_density_liquid rho_key_ = Keys::readKey(plist_, domain_name, "mass density liquid", "mass_density_liquid"); - dependencies_.insert(rho_key_); + dependencies_.insert(KeyTag{ rho_key_, tag}); // dependency: viscosity_liquid mu_key_ = Keys::readKey(plist_, domain_name, "viscosity liquid", "viscosity_liquid"); - dependencies_.insert(mu_key_); + dependencies_.insert(KeyTag{ mu_key_, tag}); } @@ -65,18 +68,19 @@ void HydraulicConductivityEvaluator::EvaluateField_(const Teuchos::Ptr& S, const Teuchos::Ptr& result) { -Teuchos::RCP k = S->GetFieldData(k_key_); -Teuchos::RCP rho = S->GetFieldData(rho_key_); -Teuchos::RCP mu = S->GetFieldData(mu_key_); + Tag tag = my_keys_.front().second; + Teuchos::RCP k = S.GetPtr(k_key_, tag); + Teuchos::RCP rho = S.GetPtr(rho_key_, tag); + Teuchos::RCP mu = S.GetPtr(mu_key_, tag); - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->HydraulicConductivity(k_v[0][i], rho_v[0][i], mu_v[0][i]); } @@ -88,47 +92,48 @@ void HydraulicConductivityEvaluator::EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, Key wrt_key, const Teuchos::Ptr& result) { -Teuchos::RCP k = S->GetFieldData(k_key_); -Teuchos::RCP rho = S->GetFieldData(rho_key_); -Teuchos::RCP mu = S->GetFieldData(mu_key_); + Tag tag = my_keys_.front().second; + Teuchos::RCP k = S.GetPtr(k_key_, tag); + Teuchos::RCP rho = S.GetPtr(rho_key_, tag); + Teuchos::RCP mu = S.GetPtr(mu_key_, tag); if (wrt_key == k_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DHydraulicConductivityDPermeabiilty(k_v[0][i], rho_v[0][i], mu_v[0][i]); } } } else if (wrt_key == rho_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DHydraulicConductivityDMassDensityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); } } } else if (wrt_key == mu_key_) { - for (CompositeVector::name_iterator comp=result->begin(); - comp!=result->end(); ++comp) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - int ncomp = result->size(*comp, false); + int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { result_v[0][i] = model_->DHydraulicConductivityDViscosityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); } @@ -142,4 +147,4 @@ Teuchos::RCP mu = S->GetFieldData(mu_key_); } //namespace } //namespace -} //namespace \ No newline at end of file +} //namespace From e9caa7de5aef2b99263381169c595978f1576b79 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 2 Mar 2023 14:18:40 -0800 Subject: [PATCH 024/582] fixing some of the function calls --- .../bulk_density/bulk_density_evaluator.cc | 8 +++--- .../bulk_density/bulk_density_evaluator.hh | 25 +++++++++---------- .../hydraulic_conductivity_evaluator.cc | 8 +++--- .../hydraulic_conductivity_evaluator.hh | 25 ++++++++----------- 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc index 59df5a977..9e7dbd1d1 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc @@ -91,8 +91,8 @@ BulkDensityEvaluator::InitializeFromPlist_() void -BulkDensityEvaluator::Evaluate_(const Teuchos::Ptr& S, - const Teuchos::Ptr& result) +BulkDensityEvaluator::Evaluate_(const State& S, + const std::vector& result) { Tag tag = my_keys_.front().second; Teuchos::RCP phi = S.GetPtr(phi_key_, tag); @@ -125,8 +125,8 @@ BulkDensityEvaluator::Evaluate_(const Teuchos::Ptr& S, void -BulkDensityEvaluator::EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, - Key wrt_key, const Tag& wrt_tag, const Teuchos::Ptr& result) +BulkDensityEvaluator::EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) { Tag tag = my_keys_.front().second; Teuchos::RCP phi = S.GetPtr(phi_key_, tag); diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh index ca5798738..a7c20ddef 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh @@ -3,7 +3,7 @@ Generated via evaluator_generator with: Richards water content evaluator: the standard form as a function of liquid saturation. - + Authors: Ethan Coon (ecoon@lanl.gov) */ @@ -20,25 +20,24 @@ namespace Relations { class BulkDensityModel; class BulkDensityEvaluator : public EvaluatorSecondaryMonotypeCV { - public: explicit BulkDensityEvaluator(Teuchos::ParameterList& plist); - BulkDensityEvaluator(const BulkDensityEvaluator& other); - - virtual Teuchos::RCP Clone() const; - - // Required methods from EvaluatorSecondaryMonotypeCV - virtual void EvaluateField_(const Teuchos::Ptr& S, - const Teuchos::Ptr& result); - virtual void EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, - Key wrt_key, const Teuchos::Ptr& result); + BulkDensityEvaluator(const BulkDensityEvaluator& other) = default; + virtual Teuchos::RCP Clone() const override; Teuchos::RCP get_model() { return model_; } protected: - void InitializeFromPlist_(); + // Required methods from EvaluatorSecondaryMonotypeCV + virtual void Evaluate_(const State& S, + const std::vector& result) override; + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) override; + + void InitializeFromPlist_(); + protected: Key phi_key_; Key nr_key_; Key sl_key_; @@ -59,4 +58,4 @@ class BulkDensityEvaluator : public EvaluatorSecondaryMonotypeCV { } //namespace } //namespace -#endif \ No newline at end of file +#endif diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc index 53880fe77..a6c52d27b 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc @@ -65,8 +65,8 @@ HydraulicConductivityEvaluator::InitializeFromPlist_() void -HydraulicConductivityEvaluator::EvaluateField_(const Teuchos::Ptr& S, - const Teuchos::Ptr& result) +HydraulicConductivityEvaluator::Evaluate_(const State& S, + const std::vector& result) { Tag tag = my_keys_.front().second; Teuchos::RCP k = S.GetPtr(k_key_, tag); @@ -89,8 +89,8 @@ HydraulicConductivityEvaluator::EvaluateField_(const Teuchos::Ptr& S, void -HydraulicConductivityEvaluator::EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, - Key wrt_key, const Teuchos::Ptr& result) +HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) { Tag tag = my_keys_.front().second; Teuchos::RCP k = S.GetPtr(k_key_, tag); diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh index f11c7f72b..7f7168c02 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh @@ -3,7 +3,7 @@ Generated via evaluator_generator with: Richards water content evaluator: the standard form as a function of liquid saturation. - + Authors: Ethan Coon (ecoon@lanl.gov) */ @@ -20,23 +20,20 @@ namespace Relations { class HydraulicConductivityModel; class HydraulicConductivityEvaluator : public EvaluatorSecondaryMonotypeCV { - public: - explicit - HydraulicConductivityEvaluator(Teuchos::ParameterList& plist); - HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other); - - virtual Teuchos::RCP Clone() const; - - // Required methods from EvaluatorSecondaryMonotypeCV - virtual void EvaluateField_(const Teuchos::Ptr& S, - const Teuchos::Ptr& result); - virtual void EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, - Key wrt_key, const Teuchos::Ptr& result); + explicit HydraulicConductivityEvaluator(Teuchos::ParameterList& plist); + HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other) = default; + virtual Teuchos::RCP Clone() const override; Teuchos::RCP get_model() { return model_; } protected: + // Required methods from EvaluatorSecondaryMonotypeCV + virtual void Evaluate_(const State& S, + const std::vector& result) override; + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) override; + void InitializeFromPlist_(); Key k_key_; @@ -54,4 +51,4 @@ class HydraulicConductivityEvaluator : public EvaluatorSecondaryMonotypeCV { } //namespace } //namespace -#endif \ No newline at end of file +#endif From df07410423b4830cd4a29a541a2e077656e94062 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 2 Mar 2023 14:33:47 -0800 Subject: [PATCH 025/582] minor bulk density bugfix --- .../bulk_density/bulk_density_evaluator.cc | 4 ++-- .../hydraulic_conductivity_evaluator.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc index 9e7dbd1d1..537b92c7c 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc @@ -150,7 +150,7 @@ BulkDensityEvaluator::EvaluatePartialDerivative_(const State& S, const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result->ViewComponent(*comp,false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { @@ -292,7 +292,7 @@ BulkDensityEvaluator::EvaluatePartialDerivative_(const State& S, } } else { - ASSERT(0); + AMANZI_ASSERT(0); } } diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc index a6c52d27b..c66f59eb4 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc @@ -140,7 +140,7 @@ HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, } } else { - ASSERT(0); + AMANZI_ASSERT(0); } } From eb05bf2b6009ac2303957b9c6fd9e65d059042cb Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 2 Mar 2023 14:45:48 -0800 Subject: [PATCH 026/582] alquimia inclusion bugfix --- src/pks/ecosim_pk/data/BGC_containers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.h b/src/pks/ecosim_pk/data/BGC_containers.h index 6b690e4f2..fab3869a7 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.h +++ b/src/pks/ecosim_pk/data/BGC_containers.h @@ -39,7 +39,7 @@ ** ******************************************************************************/ -#include "alquimia/alquimia.h" +//#include "alquimia/alquimia.h" #ifdef __cplusplus extern "C" { From a2cac4489361c5e83a18b0e99dfb1ce49e72d550 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 2 Mar 2023 16:04:45 -0800 Subject: [PATCH 027/582] various fixes to the memory codes --- src/pks/ecosim_pk/data/BGC_containers.h | 6 ++++-- src/pks/ecosim_pk/data/BGC_memory.c | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.h b/src/pks/ecosim_pk/data/BGC_containers.h index fab3869a7..4bceab6e5 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.h +++ b/src/pks/ecosim_pk/data/BGC_containers.h @@ -40,6 +40,8 @@ ******************************************************************************/ //#include "alquimia/alquimia.h" +#include +#include #ifdef __cplusplus extern "C" { @@ -95,8 +97,8 @@ extern "C" { } BGCProperties; typedef struct { - AlquimiaVectorInt aux_ints; /* [-] */ - AlquimiaVectorDouble aux_doubles; /* [-] */ + BGCVectorInt aux_ints; /* [-] */ + BGCVectorDouble aux_doubles; /* [-] */ } BGCAuxiliaryData; /* typedef struct { diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index 084ba5440..920ab1412 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -71,7 +71,7 @@ void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { vector->size = size; vector->capacity = nearest_power_of_2(size); vector->data = (double*) calloc((size_t)vector->capacity, sizeof(double)); - ALQUIMIA_ASSERT(NULL != vector->data); + //ALQUIMIA_ASSERT(NULL != vector->data); } else { vector->size = 0; vector->capacity = 0; @@ -93,7 +93,7 @@ void AllocateBGCVectorInt(const int size, BGCVectorInt* vector) { vector->size = size; vector->capacity = nearest_power_of_2(size); vector->data = (int*) calloc((size_t)vector->capacity, sizeof(int)); - ALQUIMIA_ASSERT(NULL != vector->data); + //ALQUIMIA_ASSERT(NULL != vector->data); } else { vector->size = 0; vector->capacity = 0; @@ -116,10 +116,10 @@ void AllocateBGCVectorString(const int size, BGCVectorString* vector) { vector->size = size; vector->capacity = nearest_power_of_2(size); vector->data = (char**) calloc((size_t)vector->capacity, sizeof(char*)); - ALQUIMIA_ASSERT(NULL != vector->data); + //ALQUIMIA_ASSERT(NULL != vector->data); for (i = 0; i < vector->size; ++i) { - vector->data[i] = (char*) calloc((size_t)kAlquimiaMaxStringLength, sizeof(char)); - ALQUIMIA_ASSERT(NULL != vector->data[i]); + vector->data[i] = (char*) calloc((size_t)kBGCMaxStringLength, sizeof(char)); + //ALQUIMIA_ASSERT(NULL != vector->data[i]); } } else { vector->size = 0; From 159af43d2fb4850f8f339a9b4c170adbc558b4c2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 6 Mar 2023 11:44:52 -0800 Subject: [PATCH 028/582] header declaration bug --- src/pks/ecosim_pk/data/BGC_containers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.h b/src/pks/ecosim_pk/data/BGC_containers.h index 4bceab6e5..79813932e 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.h +++ b/src/pks/ecosim_pk/data/BGC_containers.h @@ -40,7 +40,7 @@ ******************************************************************************/ //#include "alquimia/alquimia.h" -#include +//#include #include #ifdef __cplusplus From 8c0ddbb6c8ad73345a1ea46bf4546326630584ad Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 6 Mar 2023 15:37:35 -0800 Subject: [PATCH 029/582] various minor bugfixes --- src/pks/ecosim_pk/data/BGC_constants.c | 1 - src/pks/ecosim_pk/data/BGC_constants.h | 6 +++--- src/pks/ecosim_pk/data/BGC_containers.h | 1 + src/pks/ecosim_pk/data/BGC_memory.c | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_constants.c b/src/pks/ecosim_pk/data/BGC_constants.c index 8af45ce6f..2d7e98717 100644 --- a/src/pks/ecosim_pk/data/BGC_constants.c +++ b/src/pks/ecosim_pk/data/BGC_constants.c @@ -37,7 +37,6 @@ const int kBGCMaxWordLength = 32; /* Geochemistry Engine Strings */ const char* kBGCStringPFloTran = "PFloTran"; const char* kBGCStringCrunchFlow = "CrunchFlow"; -const char* kBGCStringEcoSIM = "EcoSIM"; const char* kBGCStringTotal = "total_aqueous"; const char* kBGCStringTotalSorbed = "total_sorbed"; const char* kBGCStringTotalAqueousPlusSorbed = "total_aqueous_plus_sorbed"; diff --git a/src/pks/ecosim_pk/data/BGC_constants.h b/src/pks/ecosim_pk/data/BGC_constants.h index 3667f22d2..a79b68044 100644 --- a/src/pks/ecosim_pk/data/BGC_constants.h +++ b/src/pks/ecosim_pk/data/BGC_constants.h @@ -1,16 +1,16 @@ /* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ /* -** BGC Copyright (c) 2013-2016, The Regents of the University of California, +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, ** through Lawrence Berkeley National Laboratory (subject to receipt of any ** required approvals from the U.S. Dept. of Energy). All rights reserved. ** -** BGC is available under a BSD license. See LICENSE.txt for more +** Alquimia is available under a BSD license. See LICENSE.txt for more ** information. ** ** If you have questions about your rights to use or distribute this software, ** please contact Berkeley Lab's Technology Transfer and Intellectual Property -** Management at TTD@lbl.gov referring to BGC (LBNL Ref. 2013-119). +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). ** ** NOTICE. This software was developed under funding from the U.S. Department ** of Energy. As such, the U.S. Government has been granted for itself and diff --git a/src/pks/ecosim_pk/data/BGC_containers.h b/src/pks/ecosim_pk/data/BGC_containers.h index 79813932e..7794c6192 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.h +++ b/src/pks/ecosim_pk/data/BGC_containers.h @@ -42,6 +42,7 @@ //#include "alquimia/alquimia.h" //#include #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index 920ab1412..ab8208a97 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -47,6 +47,7 @@ #include "BGC_memory.h" #include "BGC_containers.h" +#include "BGC_constants.h" //#include "alquimia/alquimia_interface.h" //#include "alquimia/alquimia_constants.h" //#include "alquimia/alquimia_containers.h" @@ -213,7 +214,7 @@ void AllocateBGCProperties(BGCProperties* props) { AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->total_mobile)); } /* end AllocateAlquimiaProperties() */ -void FreeBGCProperties(AlquimiaProperties* props) { +void FreeBGCProperties(BGCProperties* props) { if (props != NULL) { FreeBGCVectorDouble(&(props->liquid_saturation)); FreeBGCVectorDouble(&(props->gas_saturation)); From 6bac34f76c2bf48d3371bebaa6f1995e8d48ad02 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Mar 2023 12:03:48 -0800 Subject: [PATCH 030/582] fixed declaration conflict --- src/pks/ecosim_pk/data/BGC_memory.c | 2 +- src/pks/ecosim_pk/data/BGC_memory.h | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index ab8208a97..c216f392c 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -190,7 +190,7 @@ void AllocateBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { } /* end AllocateAlquimiaAuxiliaryData() */ -void FreeBGCAuxiliaryData(AlquimiaAuxiliaryData* aux_data) { +void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { if (aux_data != NULL) { FreeBGCVectorInt(&(aux_data->aux_ints)); FreeBGCVectorDouble(&(aux_data->aux_doubles)); diff --git a/src/pks/ecosim_pk/data/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.h index 976dded96..97dc96f81 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.h +++ b/src/pks/ecosim_pk/data/BGC_memory.h @@ -49,19 +49,16 @@ extern "C" { void FreeBGCVectorString(BGCVectorString* vector); /* State */ - void AllocateBGCState(const BGCSizes* const sizes, - BGCState* state); + void AllocateBGCState(BGCState* state); void FreeBGCState(BGCState* state); /* Auxiliary Data */ - void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, - BGCAuxiliaryData* aux_data); + void AllocateBGCAuxiliaryData(BGCAuxiliaryData* aux_data); void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data); /* Properties */ - void AllocateBGCProperties(const BGCSizes* const sizes, - BGCProperties* props); + void AllocateBGCProperties(BGCProperties* props); void FreeBGCProperties(BGCProperties* props); // Problem Meta Data From 1ed521377633e2344293e669dd99af19376bb1c5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Mar 2023 14:07:13 -0800 Subject: [PATCH 031/582] defined BGCsizes --- src/pks/ecosim_pk/data/BGC_containers.h | 11 +---------- src/pks/ecosim_pk/data/BGC_memory.c | 6 +++--- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.h b/src/pks/ecosim_pk/data/BGC_containers.h index 7794c6192..28a2f3bef 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.h +++ b/src/pks/ecosim_pk/data/BGC_containers.h @@ -65,16 +65,7 @@ extern "C" { } BGCVectorString; typedef struct { - int num_primary; - int num_sorbed; - int num_minerals; - int num_aqueous_complexes; - int num_aqueous_kinetics; - int num_surface_sites; - int num_ion_exchange_sites; - int num_isotherm_species; - int num_aux_integers; - int num_aux_doubles; + int ncells_per_col_; } BGCSizes; typedef struct { diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index c216f392c..c88344bd6 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -153,7 +153,7 @@ For reference the old function call was: void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ -void AllocateBGCState(BGCState* state) { +void AllocateBGCState(const BGCSizes* const sizes, BGCState* state) { AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_density)); @@ -181,7 +181,7 @@ void FreeBGCState(BGCState* state) { ** *******************************************************************************/ -void AllocateBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { +void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data) { AllocateBGCVectorInt(sizes->ncells_per_col_, &(aux_data->aux_ints)); @@ -203,7 +203,7 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { ** *******************************************************************************/ -void AllocateBGCProperties(BGCProperties* props) { +void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props) { AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->liquid_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_saturation)); From 82840df0509e4cd14e218f7591c863d04512ccec Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Mar 2023 14:28:31 -0800 Subject: [PATCH 032/582] fixed the declaration conflict (again) --- src/pks/ecosim_pk/data/BGC_memory.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.h index 97dc96f81..f53da8d64 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.h +++ b/src/pks/ecosim_pk/data/BGC_memory.h @@ -49,16 +49,18 @@ extern "C" { void FreeBGCVectorString(BGCVectorString* vector); /* State */ - void AllocateBGCState(BGCState* state); - + void AllocateBGCState(const BGCSizes* const sizes, + BGCState* state); void FreeBGCState(BGCState* state); /* Auxiliary Data */ - void AllocateBGCAuxiliaryData(BGCAuxiliaryData* aux_data); + void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, + BGCAuxiliaryData* aux_data); void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data); /* Properties */ - void AllocateBGCProperties(BGCProperties* props); + void AllocateBGCProperties(const BGCSizes* const sizes, + BGCProperties* props); void FreeBGCProperties(BGCProperties* props); // Problem Meta Data From 48b748b8840d78887bf81b292f5b6dc59b40cdfa Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Mar 2023 14:53:32 -0800 Subject: [PATCH 033/582] minor bugfix --- src/pks/ecosim_pk/data/BGC_memory.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index c88344bd6..eac526553 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -204,14 +204,14 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { *******************************************************************************/ void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props) { - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->liquid_saturation)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_saturation)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_saturation)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->elevation)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->relative_permeability)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->conductivity)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->volume)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->total_mobile)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->gas_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->ice_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->elevation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->conductivity)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->total_mobile)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { From 57698fbd1368bc2bd7769b5e0b0b5075f32a46c2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Mar 2023 15:15:05 -0800 Subject: [PATCH 034/582] minor fix --- src/pks/ecosim_pk/data/BGC_memory.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index eac526553..89613cf51 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -211,7 +211,6 @@ void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props) { AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->conductivity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->total_mobile)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { From f67b7b52149925b0679f5ea979c5fdf0f9ed123a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Mar 2023 15:50:23 -0800 Subject: [PATCH 035/582] Fixed typo in header setting --- src/pks/ecosim_pk/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 01654a833..81738ae6d 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -19,7 +19,7 @@ set(ats_ecosim_src_files ) set(ats_ecosim_inc_files - EcoSIM_interface_test.hh + EcoSIM_ATS_interface.hh BGCEngine.hh ) From ceb24bc3c1376937cb9b3eec5df6ced6e75185ac Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Mar 2023 16:07:58 -0800 Subject: [PATCH 036/582] trying to understand these ifdef statements (what controls them?) --- src/pks/ecosim_pk/Ecosim_ATS_interface.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh index 69d7613bd..29fc1d7df 100644 --- a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh +++ b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh @@ -20,8 +20,8 @@ //#ifndef PKS_BGC_SIMPLE_HH_ //#define PKS_BGC_SIMPLE_HH_ -#ifndef PKS_ECOSIM_HH_ -#define PKS_ECOSIM_HH_ +//#ifndef PKS_ECOSIM_HH_ +//#define PKS_ECOSIM_HH_ #include @@ -173,4 +173,4 @@ class EcoSIM : public PK_Physical_Default { } // namespace EcoSIM } // namespace Amanzi -#endif +//#endif From 3911e3ccdc3a55c7c22aa2455822d888be673d48 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Mar 2023 16:20:25 -0800 Subject: [PATCH 037/582] bugfix in registration --- src/pks/ecosim_pk/Ecosim_interface_reg.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/Ecosim_interface_reg.hh b/src/pks/ecosim_pk/Ecosim_interface_reg.hh index eb1d7be50..ebcbe418b 100644 --- a/src/pks/ecosim_pk/Ecosim_interface_reg.hh +++ b/src/pks/ecosim_pk/Ecosim_interface_reg.hh @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- */ -#include "EcoSIM_interface.hh" +#include "EcoSIM_ATS_interface.hh" namespace Amanzi { namespace EcoSIM { From 59fd850962cbc6c6a29f1e99573520ce5795f2e0 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 11:54:21 -0800 Subject: [PATCH 038/582] minor bugfixes --- src/pks/ecosim_pk/BGCEngine.cc | 11 ++++++++--- src/pks/ecosim_pk/BGCEngine.hh | 5 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 5374e22c5..c8466cec7 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -35,7 +35,7 @@ namespace { void CopyBGCState(BGCState* dest, BGCState* src) { - memcpy(dest->liquid_density.size = src->liquid_density.size, sizeof(double) * src->liquid_density.size); + memcpy(dest->fluid_density.size = src->fluid_density.size, sizeof(double) * src->fluid_density.size); memcpy(dest->gas_density.size = src->gas_density.size, sizeof(double) * src->gas_density.size); memcpy(dest->ice_density.size = src->ice_density.size, sizeof(double) * src->ice_density.size); memcpy(dest->porosity.size = src->porosity.size, sizeof(double) * src->porosity.size); @@ -60,7 +60,7 @@ void CopyBGCProperties(BGCProperties* dest, BGCProperties* src) memcpy(dest->volume.size = src->volume.size, sizeof(double) * src->volume.size); } -void CopyBGCAuxiliaryData(BGCAuxiliaryData* dest, bgcAuxiliaryData* src) +void CopyBGCAuxiliaryData(BGCAuxiliaryData* dest, BGCAuxiliaryData* src) { memcpy(dest->aux_ints.data, src->aux_ints.data, sizeof(int) * src->aux_ints.size); memcpy(dest->aux_doubles.data, src->aux_doubles.data, sizeof(double) * src->aux_doubles.size); @@ -134,7 +134,10 @@ BGCEngine::BGCEngine(const std::string& engineName, */ //We don't need the chem interface call //Place the call to the EcoSIM setup driver here: + + /******************************** EcoSIMSetup(); + *********************************/ // Allocate storage for additional Alquimia data. // Below this sets up Alquimia metadata I don't think we @@ -207,8 +210,10 @@ bool BGCEngine::Advance(const double delta_time, */ //This is alquimia's advance function which we won't need //calling EcoSIM advance driver - EcoSIMAdvance(); + /************************* + EcoSIMAdvance(); + *************************/ } diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index d0e13bd7e..a038dbc04 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -32,7 +32,6 @@ namespace Amanzi { namespace EcoSIM { class BGCEngine { - public: // Constructs a chemistry engine using the given engine (backend) name and input file. @@ -60,12 +59,12 @@ class BGCEngine { void FreeState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data); - + /* Don't need for now void EnforceCondition(const std::string& condition_name, const double time, const AlquimiaProperties& props, AlquimiaState& state, - AlquimiaAuxiliaryData& aux_data); + AlquimiaAuxiliaryData& aux_data);*/ // Advances the species represented by the given array of concentrations, replacing old values // with new values. The order of the concentrations in the array matches that of the species names From 2d1b1664a5a6ab723a6c2779ca159b45d8f18d2c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 12:02:03 -0800 Subject: [PATCH 039/582] minor bugfix --- src/pks/ecosim_pk/BGCEngine.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index c8466cec7..034492a35 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -142,7 +142,6 @@ BGCEngine::BGCEngine(const std::string& engineName, // Allocate storage for additional Alquimia data. // Below this sets up Alquimia metadata I don't think we //need this - } } BGCEngine::~BGCEngine() From efdc25101d599c321dff856bff2ff971fab17894 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 13:29:15 -0800 Subject: [PATCH 040/582] Testing multiple registration methods --- src/pks/ecosim_pk/BGCEngine.hh | 6 +++--- src/pks/ecosim_pk/CMakeLists.txt | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index a038dbc04..221d49c3b 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -13,8 +13,8 @@ conditions and to integrate reactions given a chemical configuration. */ -#ifndef AMANZI_CHEMISTRY_ENGINE_HH_ -#define AMANZI_CHEMISTRY_ENGINE_HH_ +//#ifndef AMANZI_CHEMISTRY_ENGINE_HH_ +//#define AMANZI_CHEMISTRY_ENGINE_HH_ #include #include @@ -102,4 +102,4 @@ class BGCEngine { } // namespace } // namespace -#endif +//#endif diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 81738ae6d..4e97f4f76 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -21,6 +21,7 @@ set(ats_ecosim_src_files set(ats_ecosim_inc_files EcoSIM_ATS_interface.hh BGCEngine.hh + EcoSIM_interface_reg.hh ) set(ats_ecosim_link_libs @@ -58,15 +59,20 @@ register_evaluator_with_factory( LISTNAME ATS_ECOSIM_DATA_REG ) -#register_evaluator_with_factory( -# HEADERFILE bulk_density_evaluator_reg.hh -# LISTNAME ATS_ECOSIM_REG -#) +register_evaluator_with_factory( + HEADERFILE bulk_density_evaluator_reg.hh + LISTNAME ATS_ECOSIM_REG +) -#register_evaluator_with_factory( -# HEADERFILE hydraulic_conductivity_evaluator_reg.hh -# LISTNAME ATS_ECOSIM_REG -#) +register_evaluator_with_factory( + HEADERFILE hydraulic_conductivity_evaluator_reg.hh + LISTNAME ATS_ECOSIM_REG +) + +register_evaluator_with_factory( + HEADERFILE EcoSIM_ATS_interface_reg.hh + LISTNAME ATS_ECOSIM_REG +) generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh From bdeb09f66b8ca23ad26f1fd368793775f22dd93e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 13:37:35 -0800 Subject: [PATCH 041/582] testing --- src/pks/ecosim_pk/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 4e97f4f76..ad32e5030 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -60,12 +60,12 @@ register_evaluator_with_factory( ) register_evaluator_with_factory( - HEADERFILE bulk_density_evaluator_reg.hh + HEADERFILE constitutive_relations/bulk_density/_evaluator_reg.hh LISTNAME ATS_ECOSIM_REG ) register_evaluator_with_factory( - HEADERFILE hydraulic_conductivity_evaluator_reg.hh + HEADERFILE constitutive_relations/hydraulic_conductivity/_evaluator_reg.hh LISTNAME ATS_ECOSIM_REG ) From a500b0b5ea4a67abf0cee735fe9eaf924a04d367 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 13:42:14 -0800 Subject: [PATCH 042/582] testing --- src/pks/ecosim_pk/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index ad32e5030..a8a65d21a 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -60,12 +60,12 @@ register_evaluator_with_factory( ) register_evaluator_with_factory( - HEADERFILE constitutive_relations/bulk_density/_evaluator_reg.hh + HEADERFILE constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh LISTNAME ATS_ECOSIM_REG ) register_evaluator_with_factory( - HEADERFILE constitutive_relations/hydraulic_conductivity/_evaluator_reg.hh + HEADERFILE constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh LISTNAME ATS_ECOSIM_REG ) From 98c1be7b529fb8147bc1a6963b5908c2d8f53f85 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 13:48:04 -0800 Subject: [PATCH 043/582] testing --- src/pks/ecosim_pk/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index a8a65d21a..9744edc4c 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -70,7 +70,7 @@ register_evaluator_with_factory( ) register_evaluator_with_factory( - HEADERFILE EcoSIM_ATS_interface_reg.hh + HEADERFILE EcoSIM_interface_reg.hh LISTNAME ATS_ECOSIM_REG ) From 0b6fd218bebe4fde918698f94254d1136f6201bd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 14:00:55 -0800 Subject: [PATCH 044/582] testing --- src/pks/ecosim_pk/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 9744edc4c..c29cb34fc 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -21,7 +21,6 @@ set(ats_ecosim_src_files set(ats_ecosim_inc_files EcoSIM_ATS_interface.hh BGCEngine.hh - EcoSIM_interface_reg.hh ) set(ats_ecosim_link_libs @@ -69,10 +68,10 @@ register_evaluator_with_factory( LISTNAME ATS_ECOSIM_REG ) -register_evaluator_with_factory( - HEADERFILE EcoSIM_interface_reg.hh - LISTNAME ATS_ECOSIM_REG -) +#register_evaluator_with_factory( +# HEADERFILE EcoSIM_interface_reg.hh +# LISTNAME ATS_ECOSIM_REG +#) generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh From 87913be246f0dedb6e7045ad7556852be773880f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 14:10:03 -0800 Subject: [PATCH 045/582] changed the registration in file --- src/pks/ecosim_pk/ats_ecosim_registration.hh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/ats_ecosim_registration.hh.in b/src/pks/ecosim_pk/ats_ecosim_registration.hh.in index 21e62d006..ebcbe418b 100644 --- a/src/pks/ecosim_pk/ats_ecosim_registration.hh.in +++ b/src/pks/ecosim_pk/ats_ecosim_registration.hh.in @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- */ -#include "Ecosim_interface_test.hh" +#include "EcoSIM_ATS_interface.hh" namespace Amanzi { namespace EcoSIM { From 6dd981755ba2fcf8972f3ea3e1061c7781cb38a6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 14:25:54 -0800 Subject: [PATCH 046/582] testing --- src/pks/ecosim_pk/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index c29cb34fc..06902139f 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -68,10 +68,10 @@ register_evaluator_with_factory( LISTNAME ATS_ECOSIM_REG ) -#register_evaluator_with_factory( -# HEADERFILE EcoSIM_interface_reg.hh -# LISTNAME ATS_ECOSIM_REG -#) +register_evaluator_with_factory( + HEADERFILE EcoSIM_interface_reg.hh + LISTNAME ATS_ECOSIM_REG +) generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh From 5222f45fed2e24ccf420baf05a6bc75b6f289447 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 14:35:38 -0800 Subject: [PATCH 047/582] test --- src/pks/ecosim_pk/CMakeLists.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 06902139f..2ffbfb4a6 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -53,20 +53,20 @@ add_amanzi_library(ats_ecosim #================================================ # register evaluators/factories/pks -register_evaluator_with_factory( - HEADERFILE ats_ecosim_data_registration.hh - LISTNAME ATS_ECOSIM_DATA_REG -) +#register_evaluator_with_factory( +# HEADERFILE ats_ecosim_data_registration.hh +# LISTNAME ATS_ECOSIM_DATA_REG +#) -register_evaluator_with_factory( - HEADERFILE constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh - LISTNAME ATS_ECOSIM_REG -) +#register_evaluator_with_factory( +# HEADERFILE constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh +# LISTNAME ATS_ECOSIM_REG +#) -register_evaluator_with_factory( - HEADERFILE constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh - LISTNAME ATS_ECOSIM_REG -) +#register_evaluator_with_factory( +# HEADERFILE constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh +# LISTNAME ATS_ECOSIM_REG +#) register_evaluator_with_factory( HEADERFILE EcoSIM_interface_reg.hh From 39a10cdc4e020eaf268c5b9d4940a3b9745d5fdd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 14:38:01 -0800 Subject: [PATCH 048/582] test --- src/pks/ecosim_pk/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 2ffbfb4a6..24c721ad6 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -68,10 +68,10 @@ add_amanzi_library(ats_ecosim # LISTNAME ATS_ECOSIM_REG #) -register_evaluator_with_factory( - HEADERFILE EcoSIM_interface_reg.hh - LISTNAME ATS_ECOSIM_REG -) +#register_evaluator_with_factory( +# HEADERFILE EcoSIM_interface_reg.hh +# LISTNAME ATS_ECOSIM_REG +#) generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh From 834d11f66c6976abd3c60033a9c39e42a280d25b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 14:46:46 -0800 Subject: [PATCH 049/582] test --- src/pks/ecosim_pk/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 24c721ad6..194bbde90 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -44,6 +44,7 @@ set(ats_ecosim_link_libs ats_ecosim_relations ) +message(inc_files="${ats_ecosim_inc_files}") add_amanzi_library(ats_ecosim SOURCE ${ats_ecosim_src_files} From 2a9739fc97d96cc34d4a6d0066925b4a8d26f216 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 15:12:32 -0800 Subject: [PATCH 050/582] adding some other headers --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 08c8f77cc..e4374117a 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -9,9 +9,26 @@ --------------------------------------------------------------------------*/ -#include "EcoSIM_ATS_interface.hh" +#include +#include +#include + +// TPLs +#include "Epetra_MultiVector.h" +#include "Epetra_Vector.h" +#include "Epetra_SerialDenseVector.h" +#include "Teuchos_RCPDecl.hpp" +#include "Teuchos_ParameterList.hpp" + +// Amanzi +#include "errors.hh" +#include "exceptions.hh" +#include "Mesh.hh" + #include "pk_helpers.hh" +#include "EcoSIM_ATS_interface.hh" + namespace Amanzi { namespace EcoSIM { From fd6d769c5e7bf3c8b9f194c96105bb2ffae1e75a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 15:31:01 -0800 Subject: [PATCH 051/582] test --- src/pks/ecosim_pk/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 194bbde90..7c5ff5ebd 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -20,7 +20,6 @@ set(ats_ecosim_src_files set(ats_ecosim_inc_files EcoSIM_ATS_interface.hh - BGCEngine.hh ) set(ats_ecosim_link_libs From 0f8f4fa214b6bc1b2326223f9109b5dad9fb1fff Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 15:45:32 -0800 Subject: [PATCH 052/582] minor formatting change --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 -- src/pks/ecosim_pk/Ecosim_ATS_interface.hh | 2 -- src/pks/ecosim_pk/Ecosim_interface_reg.hh | 1 - 3 files changed, 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e4374117a..93b3972ed 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -1,5 +1,3 @@ -/* -*- mode: c++; indent-tabs-mode: nil -*- */ - /*-------------------------------------------------------------------------- ATS diff --git a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh index 29fc1d7df..e1ea350ba 100644 --- a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh +++ b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh @@ -1,5 +1,3 @@ -/* -*- mode: c++; indent-tabs-mode: nil -*- */ - /*-------------------------------------------------------------------------- ATS diff --git a/src/pks/ecosim_pk/Ecosim_interface_reg.hh b/src/pks/ecosim_pk/Ecosim_interface_reg.hh index ebcbe418b..8179c2c00 100644 --- a/src/pks/ecosim_pk/Ecosim_interface_reg.hh +++ b/src/pks/ecosim_pk/Ecosim_interface_reg.hh @@ -1,4 +1,3 @@ -/* -*- mode: c++; indent-tabs-mode: nil -*- */ /* ------------------------------------------------------------------------- * ATS * From 1cd8857b5c1fde5cab986be6df12f95434c8e904 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 15:46:53 -0800 Subject: [PATCH 053/582] define the if statement --- src/pks/ecosim_pk/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 7c5ff5ebd..194bbde90 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -20,6 +20,7 @@ set(ats_ecosim_src_files set(ats_ecosim_inc_files EcoSIM_ATS_interface.hh + BGCEngine.hh ) set(ats_ecosim_link_libs From 0d19f91e787281bc25411672d977f716ae28f31d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 15:47:14 -0800 Subject: [PATCH 054/582] missed this formatting change --- src/pks/ecosim_pk/Ecosim_ATS_interface.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh index e1ea350ba..54bcf2de5 100644 --- a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh +++ b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh @@ -18,8 +18,8 @@ //#ifndef PKS_BGC_SIMPLE_HH_ //#define PKS_BGC_SIMPLE_HH_ -//#ifndef PKS_ECOSIM_HH_ -//#define PKS_ECOSIM_HH_ +#ifndef PKS_ECOSIM_HH_ +#define PKS_ECOSIM_HH_ #include @@ -171,4 +171,4 @@ class EcoSIM : public PK_Physical_Default { } // namespace EcoSIM } // namespace Amanzi -//#endif +#endif From b6bc2f07a391a9d5384a421a761daeed0b1c7e64 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 15:58:11 -0800 Subject: [PATCH 055/582] test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 93b3972ed..57d84ee1f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -25,7 +25,7 @@ #include "pk_helpers.hh" -#include "EcoSIM_ATS_interface.hh" +//#include "EcoSIM_ATS_interface.hh" namespace Amanzi { namespace EcoSIM { From b270f06b19c5e50cc47082f8403899a9cb88b23d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Mar 2023 20:33:42 -0800 Subject: [PATCH 056/582] test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 57d84ee1f..93b3972ed 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -25,7 +25,7 @@ #include "pk_helpers.hh" -//#include "EcoSIM_ATS_interface.hh" +#include "EcoSIM_ATS_interface.hh" namespace Amanzi { namespace EcoSIM { From 3c92073e17df386e42f1974ca49839a0f60789be Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 9 Mar 2023 14:11:50 -0800 Subject: [PATCH 057/582] test --- src/pks/ecosim_pk/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 194bbde90..8f03c85d3 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -69,10 +69,10 @@ add_amanzi_library(ats_ecosim # LISTNAME ATS_ECOSIM_REG #) -#register_evaluator_with_factory( -# HEADERFILE EcoSIM_interface_reg.hh -# LISTNAME ATS_ECOSIM_REG -#) +register_evaluator_with_factory( + HEADERFILE EcoSIM_interface_reg.hh + LISTNAME ATS_ECOSIM_REG +) generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh From 904d3b5af55eca1dc1b9d2a1966e9fe55e93a378 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 9 Mar 2023 14:28:02 -0800 Subject: [PATCH 058/582] deleting the generated reg files --- src/pks/ecosim_pk/ats_ecosim_registration.hh | 19 ------------------- .../ecosim_pk/ats_ecosim_registration.hh.in | 19 ------------------- 2 files changed, 38 deletions(-) delete mode 100644 src/pks/ecosim_pk/ats_ecosim_registration.hh delete mode 100644 src/pks/ecosim_pk/ats_ecosim_registration.hh.in diff --git a/src/pks/ecosim_pk/ats_ecosim_registration.hh b/src/pks/ecosim_pk/ats_ecosim_registration.hh deleted file mode 100644 index 21e62d006..000000000 --- a/src/pks/ecosim_pk/ats_ecosim_registration.hh +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- mode: c++; indent-tabs-mode: nil -*- */ -/* ------------------------------------------------------------------------- - * ATS - * - * License: see $ATS_DIR/COPYRIGHT - * Author: Ethan Coon - * - * ------------------------------------------------------------------------- */ - -#include "Ecosim_interface_test.hh" - -namespace Amanzi { -namespace EcoSIM { - -RegisteredPKFactory EcoSIM::reg_("EcoSIM for ATS"); - - -} // namespace -} // namespace diff --git a/src/pks/ecosim_pk/ats_ecosim_registration.hh.in b/src/pks/ecosim_pk/ats_ecosim_registration.hh.in deleted file mode 100644 index ebcbe418b..000000000 --- a/src/pks/ecosim_pk/ats_ecosim_registration.hh.in +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- mode: c++; indent-tabs-mode: nil -*- */ -/* ------------------------------------------------------------------------- - * ATS - * - * License: see $ATS_DIR/COPYRIGHT - * Author: Ethan Coon - * - * ------------------------------------------------------------------------- */ - -#include "EcoSIM_ATS_interface.hh" - -namespace Amanzi { -namespace EcoSIM { - -RegisteredPKFactory EcoSIM::reg_("EcoSIM for ATS"); - - -} // namespace -} // namespace From eae95b307f94093aa51aeb6cacbd452d14a75ed4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 9 Mar 2023 14:43:58 -0800 Subject: [PATCH 059/582] might need to rename the reg file --- src/pks/ecosim_pk/CMakeLists.txt | 2 +- .../{Ecosim_interface_reg.hh => EcoSIM_ATS_interface_reg.hh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/pks/ecosim_pk/{Ecosim_interface_reg.hh => EcoSIM_ATS_interface_reg.hh} (100%) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 8f03c85d3..f898e6b7d 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -70,7 +70,7 @@ add_amanzi_library(ats_ecosim #) register_evaluator_with_factory( - HEADERFILE EcoSIM_interface_reg.hh + HEADERFILE EcoSIM_ATS_interface_reg.hh LISTNAME ATS_ECOSIM_REG ) diff --git a/src/pks/ecosim_pk/Ecosim_interface_reg.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface_reg.hh similarity index 100% rename from src/pks/ecosim_pk/Ecosim_interface_reg.hh rename to src/pks/ecosim_pk/EcoSIM_ATS_interface_reg.hh From d3eefb6cc1315d8ebc57cbcaa9ae344650d384fe Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 9 Mar 2023 15:06:17 -0800 Subject: [PATCH 060/582] test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 93b3972ed..a595f67c1 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -7,7 +7,7 @@ --------------------------------------------------------------------------*/ -#include +/*#include #include #include @@ -25,7 +25,7 @@ #include "pk_helpers.hh" -#include "EcoSIM_ATS_interface.hh" +#include "EcoSIM_ATS_interface.hh"*/ namespace Amanzi { namespace EcoSIM { From 40df25e1dcc3017def988deaec8eb730c918b9a8 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 9 Mar 2023 15:18:44 -0800 Subject: [PATCH 061/582] test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index a595f67c1..6dfc0eb44 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -23,9 +23,8 @@ #include "exceptions.hh" #include "Mesh.hh" -#include "pk_helpers.hh" - -#include "EcoSIM_ATS_interface.hh"*/ +#include "pk_helpers.hh"*/ +#include "EcoSIM_ATS_interface.hh" namespace Amanzi { namespace EcoSIM { From d58702465c959ac6b91cfe7d9c1577d5d5013165 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 9 Mar 2023 16:12:19 -0800 Subject: [PATCH 062/582] removing file --- src/pks/ecosim_pk/Ecosim_ATS_interface.hh | 174 ---------------------- 1 file changed, 174 deletions(-) delete mode 100644 src/pks/ecosim_pk/Ecosim_ATS_interface.hh diff --git a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh b/src/pks/ecosim_pk/Ecosim_ATS_interface.hh deleted file mode 100644 index 54bcf2de5..000000000 --- a/src/pks/ecosim_pk/Ecosim_ATS_interface.hh +++ /dev/null @@ -1,174 +0,0 @@ -/*-------------------------------------------------------------------------- - ATS - - License: see $ATS_DIR/COPYRIGHT - Author: Andrew Graus - - The idea here is to begin writing the EcoSIM ATS interface with a simple - program. To start we are going to try to do a few things: - - 1) Initalize a PK called EcoSIM_ATS - 2) Have that PK take in the water content - 3) modify the water content in a simple way to mock roots (take away water) - 4) modify it so it will take in tracers (how roots take in nutrients) - - --------------------------------------------------------------------------*/ -//Eventually add if statement here (probably tied to something at compile time -// -//#ifndef PKS_BGC_SIMPLE_HH_ -//#define PKS_BGC_SIMPLE_HH_ - -#ifndef PKS_ECOSIM_HH_ -#define PKS_ECOSIM_HH_ - -#include - -#include "Epetra_MultiVector.h" -#include "Teuchos_ParameterList.hpp" -#include "Teuchos_RCP.hpp" -#include "Epetra_SerialDenseVector.h" - -#include "VerboseObject.hh" -#include "TreeVector.hh" - -#include "Key.hh" -#include "Mesh.hh" -#include "State.hh" -#include "BGCEngine.hh" -#include "PK_Factory.hh" -#include "pk_physical_default.hh" -#include "PK_Physical.hh" - -namespace Amanzi { -namespace EcoSIM { - -class EcoSIM : public PK_Physical_Default { - - public: - - //Unclear if the constructor is neccessary - EcoSIM(Teuchos::ParameterList& pk_tree, - const Teuchos::RCP& plist, - const Teuchos::RCP& S, - const Teuchos::RCP& solution); - - // Virtual destructor - virtual ~EcoSIM() override {} - - // is a PK - // -- Setup data - //virtual void Setup(const Teuchos::Ptr&S); - virtual void Setup() override; - - // -- initalize owned (dependent) variables - //virtual void Initialize(const Teuchos::Ptr& S); - virtual void Initialize() override; - - // --provide timestep size - virtual double get_dt() override { - return dt_; - } - - virtual void set_dt(double dt) override { - dt_ = dt; - } - - // -- commit the model - //virtual void CommitStep(double t_old, double t_new, const Teuchos::RCP& S); - virtual void CommitStep(double t_old, double t_new, const Tag& tag) override; - - // -- Update diagnostics for vis. - //virtual void CalculateDiagnostics(const Teuchos::RCP& S) {} - //virtual void CalculateDiagnostics(const Tag& tag) override; - - // -- advance the model - virtual bool AdvanceStep(double t_old, double t_new, bool reinit) override; - - virtual std::string name(){return "EcoSIM for ATS";}; - - void CopyToEcoSIM(int col, - BGCProperties& props, - BGCState& state, - BGCAuxiliaryData& aux_data); - - private: - - //Helper functions from Alquimia - void CopyToEcoSIM(int col, - BGCProperties& props, - BGCState& state, - BGCAuxiliaryData& aux_data); - - void CopyFromEcoSIM(const int cell, - const BGCProperties& props, - const BGCState& state, - const BGCAuxiliaryData& aux_data); - - int InitializeSingleColumn(int col); - - int AdvanceSingleColumn(double dt, int col); - - void CopyEcoSIMStateToAmanzi( - const int cell, - const BGCProperties& props, - const BGCState& state, - const BGCAuxiliaryData& aux_data); - - void ComputeNextTimeStep(); - - protected: - double dt_; - Teuchos::RCP mesh_surf_; //might need this? - //Key domain_surf_; - - //The helper functions from BGC are protected not private (unclear why) - //I don't think I need this here, probably in the engine - void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - Teuchos::Ptr col_vec, bool copy); - - void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - double* col_vec, int ncol); - void ColDepthDz_(AmanziMesh::Entity_ID col, - Teuchos::Ptr depth, - Teuchos::Ptr dz); - - void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - double* col_vec, int ncol) - //evaluator for transpiration; - //I don't think I need this anymore - //Teuchos::RCP p_root_eval_; - - int number_aqueous_components_; - - // keys - Key tcc_key_; - Key poro_key_; - Key saturation_liquid_key_; - Key saturation_gas_key_; - Key saturation_ice_key_; - Key elev_key_; - Key water_content_key_; - Key rel_perm_key_; - Key liquid_den_key_; - Key ice_den_key_; - Key gas_den_key_; - Key rock_den_key_; - Key T_key_; - Key conductivity_key_; - Key cv_key; - Key ecosim_aux_data_key_; - - private: - BGCState bgc_state_; - BGCProperties bgc_props_; - BGCAuxiliaryData bgc_aux_data_; - - private: - //factory registration - static RegisteredPKFactory reg_; -}; - -} // namespace EcoSIM -} // namespace Amanzi - -#endif From b5d098fc474ea21da96933b479f163913709580b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 9 Mar 2023 16:13:00 -0800 Subject: [PATCH 063/582] re-adding file --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 174 ++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 src/pks/ecosim_pk/EcoSIM_ATS_interface.hh diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh new file mode 100644 index 000000000..54bcf2de5 --- /dev/null +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -0,0 +1,174 @@ +/*-------------------------------------------------------------------------- + ATS + + License: see $ATS_DIR/COPYRIGHT + Author: Andrew Graus + + The idea here is to begin writing the EcoSIM ATS interface with a simple + program. To start we are going to try to do a few things: + + 1) Initalize a PK called EcoSIM_ATS + 2) Have that PK take in the water content + 3) modify the water content in a simple way to mock roots (take away water) + 4) modify it so it will take in tracers (how roots take in nutrients) + + --------------------------------------------------------------------------*/ +//Eventually add if statement here (probably tied to something at compile time +// +//#ifndef PKS_BGC_SIMPLE_HH_ +//#define PKS_BGC_SIMPLE_HH_ + +#ifndef PKS_ECOSIM_HH_ +#define PKS_ECOSIM_HH_ + +#include + +#include "Epetra_MultiVector.h" +#include "Teuchos_ParameterList.hpp" +#include "Teuchos_RCP.hpp" +#include "Epetra_SerialDenseVector.h" + +#include "VerboseObject.hh" +#include "TreeVector.hh" + +#include "Key.hh" +#include "Mesh.hh" +#include "State.hh" +#include "BGCEngine.hh" +#include "PK_Factory.hh" +#include "pk_physical_default.hh" +#include "PK_Physical.hh" + +namespace Amanzi { +namespace EcoSIM { + +class EcoSIM : public PK_Physical_Default { + + public: + + //Unclear if the constructor is neccessary + EcoSIM(Teuchos::ParameterList& pk_tree, + const Teuchos::RCP& plist, + const Teuchos::RCP& S, + const Teuchos::RCP& solution); + + // Virtual destructor + virtual ~EcoSIM() override {} + + // is a PK + // -- Setup data + //virtual void Setup(const Teuchos::Ptr&S); + virtual void Setup() override; + + // -- initalize owned (dependent) variables + //virtual void Initialize(const Teuchos::Ptr& S); + virtual void Initialize() override; + + // --provide timestep size + virtual double get_dt() override { + return dt_; + } + + virtual void set_dt(double dt) override { + dt_ = dt; + } + + // -- commit the model + //virtual void CommitStep(double t_old, double t_new, const Teuchos::RCP& S); + virtual void CommitStep(double t_old, double t_new, const Tag& tag) override; + + // -- Update diagnostics for vis. + //virtual void CalculateDiagnostics(const Teuchos::RCP& S) {} + //virtual void CalculateDiagnostics(const Tag& tag) override; + + // -- advance the model + virtual bool AdvanceStep(double t_old, double t_new, bool reinit) override; + + virtual std::string name(){return "EcoSIM for ATS";}; + + void CopyToEcoSIM(int col, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data); + + private: + + //Helper functions from Alquimia + void CopyToEcoSIM(int col, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data); + + void CopyFromEcoSIM(const int cell, + const BGCProperties& props, + const BGCState& state, + const BGCAuxiliaryData& aux_data); + + int InitializeSingleColumn(int col); + + int AdvanceSingleColumn(double dt, int col); + + void CopyEcoSIMStateToAmanzi( + const int cell, + const BGCProperties& props, + const BGCState& state, + const BGCAuxiliaryData& aux_data); + + void ComputeNextTimeStep(); + + protected: + double dt_; + Teuchos::RCP mesh_surf_; //might need this? + //Key domain_surf_; + + //The helper functions from BGC are protected not private (unclear why) + //I don't think I need this here, probably in the engine + void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + Teuchos::Ptr col_vec, bool copy); + + void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + double* col_vec, int ncol); + void ColDepthDz_(AmanziMesh::Entity_ID col, + Teuchos::Ptr depth, + Teuchos::Ptr dz); + + void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + double* col_vec, int ncol) + //evaluator for transpiration; + //I don't think I need this anymore + //Teuchos::RCP p_root_eval_; + + int number_aqueous_components_; + + // keys + Key tcc_key_; + Key poro_key_; + Key saturation_liquid_key_; + Key saturation_gas_key_; + Key saturation_ice_key_; + Key elev_key_; + Key water_content_key_; + Key rel_perm_key_; + Key liquid_den_key_; + Key ice_den_key_; + Key gas_den_key_; + Key rock_den_key_; + Key T_key_; + Key conductivity_key_; + Key cv_key; + Key ecosim_aux_data_key_; + + private: + BGCState bgc_state_; + BGCProperties bgc_props_; + BGCAuxiliaryData bgc_aux_data_; + + private: + //factory registration + static RegisteredPKFactory reg_; +}; + +} // namespace EcoSIM +} // namespace Amanzi + +#endif From 52be9b65657f890ed8dc98b05949a06d9460beb0 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 10 Mar 2023 13:44:18 -0800 Subject: [PATCH 064/582] fixing definitions --- src/pks/ecosim_pk/BGCEngine.hh | 7 +++++++ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 221d49c3b..49b4e4a8c 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -76,6 +76,13 @@ class BGCEngine { BGCAuxiliaryData& aux_data, int& num_iterations); + //Functions from the alquimia util section, I don't think I need the full code so I think + //I can just copy these functions over + void CopyBGCState(const BGCState* const source, + BGCState* destination); + void CopyBGCProperties(const BGCProperties* const source, + BGCProperties* destination); + private: // bgc data structures. diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 54bcf2de5..83e73e6fd 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -86,10 +86,10 @@ class EcoSIM : public PK_Physical_Default { virtual std::string name(){return "EcoSIM for ATS";}; - void CopyToEcoSIM(int col, + /*void CopyToEcoSIM(int col, BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data); + BGCAuxiliaryData& aux_data);*/ private: From 082fcb21b53a61c14d4c27e04a1deb710b19e880 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Mar 2023 13:48:33 -0700 Subject: [PATCH 065/582] bug fixes --- src/pks/ecosim_pk/BGCEngine.cc | 38 ++++++++++++++++++++-------------- src/pks/ecosim_pk/BGCEngine.hh | 3 ++- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 034492a35..c76230f47 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -35,12 +35,12 @@ namespace { void CopyBGCState(BGCState* dest, BGCState* src) { - memcpy(dest->fluid_density.size = src->fluid_density.size, sizeof(double) * src->fluid_density.size); - memcpy(dest->gas_density.size = src->gas_density.size, sizeof(double) * src->gas_density.size); - memcpy(dest->ice_density.size = src->ice_density.size, sizeof(double) * src->ice_density.size); - memcpy(dest->porosity.size = src->porosity.size, sizeof(double) * src->porosity.size); - memcpy(dest->water_content.size = src->water_content.size, sizeof(double) * src->water_content.size); - memcpy(dest->temperature.size = src->temperature.size, sizeof(double) * src->temperature.size); + memcpy(dest->fluid_density.size, src->fluid_density.size, sizeof(double) * src->fluid_density.size); + memcpy(dest->gas_density.size, src->gas_density.size, sizeof(double) * src->gas_density.size); + memcpy(dest->ice_density.size, src->ice_density.size, sizeof(double) * src->ice_density.size); + memcpy(dest->porosity.size, src->porosity.size, sizeof(double) * src->porosity.size); + memcpy(dest->water_content.size, src->water_content.size, sizeof(double) * src->water_content.size); + memcpy(dest->temperature.size, src->temperature.size, sizeof(double) * src->temperature.size); //memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); //dest->water_density = src->water_density; @@ -51,13 +51,13 @@ void CopyBGCState(BGCState* dest, BGCState* src) void CopyBGCProperties(BGCProperties* dest, BGCProperties* src) { //NEED TO EDIT STILL - memcpy(dest->liquid_saturation.size = src->liquid_saturation.size, sizeof(double) * src->liquid_saturation.size); - memcpy(dest->gas_saturation.size = src->gas_saturation.size, sizeof(double) * src->gas_saturation.size); - memcpy(dest->ice_saturation.size = src->ice_saturation.size, sizeof(double) * src->ice_saturation.size); - memcpy(dest->elevation.size = src->elevation.size, sizeof(double) * src->elevation.size); - memcpy(dest->relative_permeability.size = src->relative_permeability.size, sizeof(double) * src->relative_permeability.size); - memcpy(dest->conductivity.size = src->conductivity.size, sizeof(double) * src->conductivity.size); - memcpy(dest->volume.size = src->volume.size, sizeof(double) * src->volume.size); + memcpy(dest->liquid_saturation.size, src->liquid_saturation.size, sizeof(double) * src->liquid_saturation.size); + memcpy(dest->gas_saturation.size, src->gas_saturation.size, sizeof(double) * src->gas_saturation.size); + memcpy(dest->ice_saturation.size, src->ice_saturation.size, sizeof(double) * src->ice_saturation.size); + memcpy(dest->elevation.size, src->elevation.size, sizeof(double) * src->elevation.size); + memcpy(dest->relative_permeability.size, src->relative_permeability.size, sizeof(double) * src->relative_permeability.size); + memcpy(dest->conductivity.size, src->conductivity.size, sizeof(double) * src->conductivity.size); + memcpy(dest->volume.size, src->volume.size, sizeof(double) * src->volume.size); } void CopyBGCAuxiliaryData(BGCAuxiliaryData* dest, BGCAuxiliaryData* src) @@ -160,13 +160,19 @@ BGCEngine::~BGCEngine() delete iter->second; }*/ - FreeBGCState(state); - FreeBGCProperties(props); - FreeBGCAuxiliaryData(aux_data); + //FreeBGCState(state); + //FreeBGCProperties(props); + //FreeBGCAuxiliaryData(aux_data); //FreeAlquimiaEngineStatus(&chem_status_); } +const BGCSizes& +BGCEngine::Sizes() const +{ + return sizes_; +} + void BGCEngine::InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 49b4e4a8c..7bbce8205 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -81,7 +81,7 @@ class BGCEngine { void CopyBGCState(const BGCState* const source, BGCState* destination); void CopyBGCProperties(const BGCProperties* const source, - BGCProperties* destination); + BGCProperties* destination); private: @@ -89,6 +89,7 @@ class BGCEngine { bool bgc_initialized_; void* engine_state_; + BGCSizes sizes_; /*AlquimiaEngineFunctionality functionality_; AlquimiaSizes sizes_; AlquimiaInterface chem_; From f57283e18df56e8ae4fa5f4f84e370c3ceb897d6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Mar 2023 15:20:59 -0700 Subject: [PATCH 066/582] further edits to the memcpy calls --- src/pks/ecosim_pk/BGCEngine.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index c76230f47..e247ebfe7 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -35,12 +35,12 @@ namespace { void CopyBGCState(BGCState* dest, BGCState* src) { - memcpy(dest->fluid_density.size, src->fluid_density.size, sizeof(double) * src->fluid_density.size); - memcpy(dest->gas_density.size, src->gas_density.size, sizeof(double) * src->gas_density.size); - memcpy(dest->ice_density.size, src->ice_density.size, sizeof(double) * src->ice_density.size); - memcpy(dest->porosity.size, src->porosity.size, sizeof(double) * src->porosity.size); - memcpy(dest->water_content.size, src->water_content.size, sizeof(double) * src->water_content.size); - memcpy(dest->temperature.size, src->temperature.size, sizeof(double) * src->temperature.size); + memcpy(dest->fluid_density.data, src->fluid_density.data, sizeof(double) * src->fluid_density.size); + memcpy(dest->gas_density.data, src->gas_density.data, sizeof(double) * src->gas_density.size); + memcpy(dest->ice_density.data, src->ice_density.data, sizeof(double) * src->ice_density.size); + memcpy(dest->porosity.data, src->porosity.data, sizeof(double) * src->porosity.size); + memcpy(dest->water_content.data, src->water_content.data, sizeof(double) * src->water_content.size); + memcpy(dest->temperature.data, src->temperature.data, sizeof(double) * src->temperature.size); //memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); //dest->water_density = src->water_density; @@ -51,13 +51,13 @@ void CopyBGCState(BGCState* dest, BGCState* src) void CopyBGCProperties(BGCProperties* dest, BGCProperties* src) { //NEED TO EDIT STILL - memcpy(dest->liquid_saturation.size, src->liquid_saturation.size, sizeof(double) * src->liquid_saturation.size); - memcpy(dest->gas_saturation.size, src->gas_saturation.size, sizeof(double) * src->gas_saturation.size); - memcpy(dest->ice_saturation.size, src->ice_saturation.size, sizeof(double) * src->ice_saturation.size); - memcpy(dest->elevation.size, src->elevation.size, sizeof(double) * src->elevation.size); - memcpy(dest->relative_permeability.size, src->relative_permeability.size, sizeof(double) * src->relative_permeability.size); - memcpy(dest->conductivity.size, src->conductivity.size, sizeof(double) * src->conductivity.size); - memcpy(dest->volume.size, src->volume.size, sizeof(double) * src->volume.size); + memcpy(dest->liquid_saturation.data, src->liquid_saturation.data, sizeof(double) * src->liquid_saturation.size); + memcpy(dest->gas_saturation.data, src->gas_saturation.data, sizeof(double) * src->gas_saturation.size); + memcpy(dest->ice_saturation.data, src->ice_saturation.data, sizeof(double) * src->ice_saturation.size); + memcpy(dest->elevation.data, src->elevation.data, sizeof(double) * src->elevation.size); + memcpy(dest->relative_permeability.data, src->relative_permeability.data, sizeof(double) * src->relative_permeability.size); + memcpy(dest->conductivity.data, src->conductivity.data, sizeof(double) * src->conductivity.size); + memcpy(dest->volume.data, src->volume.data, sizeof(double) * src->volume.size); } void CopyBGCAuxiliaryData(BGCAuxiliaryData* dest, BGCAuxiliaryData* src) From d4d35e9e9fdc6b320867a557525ab65ec44464c2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Mar 2023 16:04:01 -0700 Subject: [PATCH 067/582] Changes to Cmakelists to link PK to main --- src/executables/CMakeLists.txt | 22 +++++++++++++++------- src/pks/ecosim_pk/BGCEngine.cc | 3 +-- src/pks/ecosim_pk/CMakeLists.txt | 15 --------------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/executables/CMakeLists.txt b/src/executables/CMakeLists.txt index adf7e704f..175ff47fa 100644 --- a/src/executables/CMakeLists.txt +++ b/src/executables/CMakeLists.txt @@ -1,6 +1,6 @@ # -*- mode: cmake -*- -# # Need this define. Errors from MSTK include files +# # Need this define. Errors from MSTK include files # # about MPI_COMM_WORLD. --lpritch # add_definitions("-DMSTK_HAVE_MPI") # add_definitions("-DDISABLE_PHYSICS") @@ -42,6 +42,7 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/energy) include_directories(${ATS_SOURCE_DIR}/src/pks/flow) include_directories(${ATS_SOURCE_DIR}/src/pks/deformation) include_directories(${ATS_SOURCE_DIR}/src/pks/transport) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) include_directories(${ATS_SOURCE_DIR}/src/operators/upwinding) include_directories(${ATS_SOURCE_DIR}/src/operators/advection) include_directories(${ATS_SOURCE_DIR}/src/operators/deformation) @@ -61,6 +62,10 @@ include_evaluators_directories(LISTNAME ATS_SURFACE_BALANCE_REG_INCLUDES) include_evaluators_directories(LISTNAME ATS_BGC_REG_INCLUDES) include_evaluators_directories(LISTNAME ATS_MPC_REG_INCLUDES) include_evaluators_directories(LISTNAME SED_TRANSPORT_REG_INCLUDES) +include_evaluators_directories(LISTNAME ATS_ECOSIM_REG_INCLUDES) +include_evaluators_directories(LISTNAME ATS_ECOSIM_RELATIONS_REG_INCLUDES) +include_evaluators_directories(LISTNAME ATS_ECOSIM_DATA_REG_INCLUDES) + set(ats_src_files ats_mesh_factory.cc @@ -85,7 +90,7 @@ set(amanzi_link_libs whetstone time_integration solvers - dbg + dbg data_structures mesh mesh_audit @@ -100,7 +105,7 @@ set(amanzi_link_libs #mpc_tree transport ) - + set(ats_link_libs ats_operators ats_generic_evals @@ -109,7 +114,7 @@ set(ats_link_libs ats_eos ats_pks ats_transport - #ats_sed_transport + #ats_sed_transport ats_energy ats_energy_relations ats_flow @@ -119,6 +124,9 @@ set(ats_link_libs ats_surface_balance ats_mpc ats_mpc_relations + ats_ecosim + ats_ecosim_data + ats_ecisim_relations ) @@ -144,9 +152,9 @@ add_amanzi_library(ats_executable LINK_LIBS ${amanzi_link_libs} ${tpl_link_libs}) if (APPLE AND BUILD_SHARED_LIBS) set_target_properties(ats_executable PROPERTIES LINK_FLAGS "-Wl,-undefined,dynamic_lookup") -endif() +endif() -if (BUILD_TESTS) +if (BUILD_TESTS) # Add UnitTest includes include_directories(${UnitTest_INCLUDE_DIRS}) @@ -179,6 +187,6 @@ endif() add_amanzi_executable(ats SOURCE main.cc - LINK_LIBS ats_executable ${fates_link_libs} ${tpl_link_libs} ${ats_link_libs} ${amanzi_link_libs} + LINK_LIBS ats_executable ${fates_link_libs} ${tpl_link_libs} ${ats_link_libs} ${amanzi_link_libs} OUTPUT_NAME ats OUTPUT_DIRECTORY ${ATS_BINARY_DIR}) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index e247ebfe7..7b4c85640 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -193,7 +193,7 @@ void BGCEngine::FreeState(BGCProperties& props, { FreeBGCProperties(&props); FreeBGCState(&state); - FreeBGCAuxiliaryData(&data); + FreeBGCAuxiliaryData(&aux_data); //FreeAlquimiaAuxiliaryOutputData(&aux_output); } @@ -201,7 +201,6 @@ bool BGCEngine::Advance(const double delta_time, const BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - BGCAuxiliaryOutputData& aux_output, int& num_iterations) { diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index f898e6b7d..836cb22b2 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -54,21 +54,6 @@ add_amanzi_library(ats_ecosim #================================================ # register evaluators/factories/pks -#register_evaluator_with_factory( -# HEADERFILE ats_ecosim_data_registration.hh -# LISTNAME ATS_ECOSIM_DATA_REG -#) - -#register_evaluator_with_factory( -# HEADERFILE constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh -# LISTNAME ATS_ECOSIM_REG -#) - -#register_evaluator_with_factory( -# HEADERFILE constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh -# LISTNAME ATS_ECOSIM_REG -#) - register_evaluator_with_factory( HEADERFILE EcoSIM_ATS_interface_reg.hh LISTNAME ATS_ECOSIM_REG From 6733ee28ba3b0fc729205c10a68a13ca3b64558b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Mar 2023 16:13:08 -0700 Subject: [PATCH 068/582] minor bugfixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 10 +++++----- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 6dfc0eb44..9cbbdd140 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -70,16 +70,16 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // f_ice = S_ice * porosity liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); - ice_den_key_ = Keys::readKey(plist_, domain, "ice mass density", "mass_density_ice"); - gas_den_key_ = Keys::readKey(plist_,domain,"gas mass density", "mass_density_gas") - rock_den_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); + ice_den_key_ = Keys::readKey(*plist_, domain, "ice mass density", "mass_density_ice"); + gas_den_key_ = Keys::readKey(*plist_,domain,"gas mass density", "mass_density_gas") + rock_den_key_ = Keys::readKey(*plist_, domain_name, "density rock", "density_rock"); //energy - T_key_ = Keys::readKey(plist_, domain_name, "temperature", "temperature"); + T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); conductivity_key_ = = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); //Other - cv_key_ = Keys::readKey(plist_, domain_name, "cell volume", "cell_volume"); + cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 83e73e6fd..bdc7b319f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -133,7 +133,7 @@ class EcoSIM : public PK_Physical_Default { Teuchos::Ptr dz); void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - double* col_vec, int ncol) + double* col_vec, int ncol); //evaluator for transpiration; //I don't think I need this anymore //Teuchos::RCP p_root_eval_; From c9cf6b4400fd84ce152583a7528a6314e6bb0151 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Mar 2023 16:19:45 -0700 Subject: [PATCH 069/582] minor bugfixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 ++++---- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 9cbbdd140..e211c457e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -70,13 +70,13 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // f_ice = S_ice * porosity liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); - ice_den_key_ = Keys::readKey(*plist_, domain, "ice mass density", "mass_density_ice"); - gas_den_key_ = Keys::readKey(*plist_,domain,"gas mass density", "mass_density_gas") - rock_den_key_ = Keys::readKey(*plist_, domain_name, "density rock", "density_rock"); + ice_den_key_ = Keys::readKey(*plist_, domain_, "ice mass density", "mass_density_ice"); + gas_den_key_ = Keys::readKey(*plist_, domain_,"gas mass density", "mass_density_gas") + rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); //energy T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); - conductivity_key_ = = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); + conductivity_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); //Other cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index bdc7b319f..e66384c2d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -155,7 +155,7 @@ class EcoSIM : public PK_Physical_Default { Key rock_den_key_; Key T_key_; Key conductivity_key_; - Key cv_key; + Key cv_key_; Key ecosim_aux_data_key_; private: From 2151dea9ebcece920d3d48d5fd2c4ab932d36594 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Mar 2023 11:50:01 -0700 Subject: [PATCH 070/582] minor bugfixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 ++- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e211c457e..a571c48cb 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -38,6 +38,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, ncells_per_col_(-1) { domain_ = plist_->get("domain name", "domain"); + domain_surf = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); // obtain key of fields // What fields will we need to pass to EcoSIM, presumably fields relating to @@ -87,7 +88,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // initial timestep dt_ = plist_->get("initial time step", 1.); //Heat capacity looks like the default units are molar heat capacity - c_m = plist_.get("heat capacity [J mol^-1 K^-1]"); + c_m_ = plist_.get("heat capacity [J mol^-1 K^-1]"); //They also sometimes use a version of heat capacity that is just this //quantity times 1e-6: //ka_ = 1.e-6 * plist_.get("heat capacity [J kg^-1 K^-1]"); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index e66384c2d..fef141fca 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -53,7 +53,7 @@ class EcoSIM : public PK_Physical_Default { const Teuchos::RCP& solution); // Virtual destructor - virtual ~EcoSIM() override {} + ~EcoSIM(); // is a PK // -- Setup data @@ -118,8 +118,9 @@ class EcoSIM : public PK_Physical_Default { protected: double dt_; + double c_m_; Teuchos::RCP mesh_surf_; //might need this? - //Key domain_surf_; + Key domain_surf_; //The helper functions from BGC are protected not private (unclear why) //I don't think I need this here, probably in the engine @@ -139,6 +140,7 @@ class EcoSIM : public PK_Physical_Default { //Teuchos::RCP p_root_eval_; int number_aqueous_components_; + int ncells_per_col_; // keys Key tcc_key_; @@ -156,6 +158,7 @@ class EcoSIM : public PK_Physical_Default { Key T_key_; Key conductivity_key_; Key cv_key_; + Key min_vol_frac_key_; Key ecosim_aux_data_key_; private: From dffbf0f5b8ca5ce453e4e77765cca7aabf70bc2e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Mar 2023 12:46:15 -0700 Subject: [PATCH 071/582] various declaration bugs --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 82 ++++++++++++++--------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 + 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index a571c48cb..fbd1ca0dc 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -35,10 +35,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& solution): PK_Physical_Default(pk_tree, global_list, S, solution), PK(pk_tree, global_list, S, solution), - ncells_per_col_(-1) + ncells_per_col_(-1), + saved_time_(0.0) { domain_ = plist_->get("domain name", "domain"); - domain_surf = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); + domain_surf_ = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); // obtain key of fields // What fields will we need to pass to EcoSIM, presumably fields relating to @@ -72,7 +73,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_den_key_ = Keys::readKey(*plist_, domain_, "ice mass density", "mass_density_ice"); - gas_den_key_ = Keys::readKey(*plist_, domain_,"gas mass density", "mass_density_gas") + gas_den_key_ = Keys::readKey(*plist_, domain_,"gas mass density", "mass_density_gas"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); //energy @@ -230,6 +231,7 @@ void EcoSIM::Initialize() { // over between runs but ATS doesn't need // AllocateAlquimiaAuxiliaryOutputData - Allocates variables that ATS will eventually // output (probably don't need for now) + int ierr = 0; // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); @@ -610,20 +612,20 @@ void EcoSIM::CopyToEcoSIM(int col, // automatically, but I just want to test this for now for (int i=0; i < ncells_per_col_; ++i) { - bgc_state.liquid_density.data[i] = col_f_dens[i]; - bgc_state.gas_density.data[i] = col_g_dens[i]; - bgc_state.ice_density.data[i] = col_i_dens[i]; - bgc_state.porosity.data[i] = col_poro[i]; - bgc_state.water_content.data[i] = col_wc[i]; - bgc_state.temperature.data[i] = col_temp[i]; - - bgc_props.liquid_saturation.data[i] = col_l_sat[i]; - bgc_props.gas_saturation.data[i] = col_g_sat[i]; - bgc_props.ice_saturation.data[i] = col_i_sat[i]; - bgc_props.elevation.data[i] = col_elev[i]; - bgc_props.relative_permeability.data[i] = col_rel_perm[i]; - bgc_props.conductivity.data[i] = col_cond[i]; - bgc_props.volume.data[i] = col_vol[i]; + state.liquid_density.data[i] = col_f_dens[i]; + state.gas_density.data[i] = col_g_dens[i]; + state.ice_density.data[i] = col_i_dens[i]; + state.porosity.data[i] = col_poro[i]; + state.water_content.data[i] = col_wc[i]; + state.temperature.data[i] = col_temp[i]; + + props.liquid_saturation.data[i] = col_l_sat[i]; + props.gas_saturation.data[i] = col_g_sat[i]; + props.ice_saturation.data[i] = col_i_sat[i]; + props.elevation.data[i] = col_elev[i]; + props.relative_permeability.data[i] = col_rel_perm[i]; + props.conductivity.data[i] = col_cond[i]; + props.volume.data[i] = col_vol[i]; } //mat_props.volume = mesh_->cell_volume(cell; @@ -681,21 +683,39 @@ void EcoSIM::CopyFromEcoSIM(const int col, //I probably need to copy the columns cell by cell in a loop //Can I do this in the field to column function? + //I think I need to redefine this here? + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + for (int i=0; i < ncells_per_col_; ++i) { - col_f_dens[i] = bgc_state.liquid_density.data[i]; - col_g_dens[i] = bgc_state.gas_density.data[i]; - col_i_dnes[i] = bgc_state.ice_density.data[i]; - col_poro[i] = bgc_state.porosity.data[i]; - col_wc[i] = bgc_state.water_content.data[i]; - col_temp[i] = bgc_state.temperature.data[i]; - - col_l_sat[i] = bgc_props.liquid_saturation.data[i]; - col_g_sat[i] = bgc_props.gas_saturation.data[i]; - col_i_sat[i] = bgc_props.ice_saturation.data[i]; - col_elev[i] = bgc_props.elevation.data[i]; - col_rel_perm[i] = bgc_props.relative_permeability.data[i]; - col_cond[i] = bgc_props.conductivity.data[i]; - col_vol[i] = bgc_props.volume.data[i]; + col_f_dens[i] = state.liquid_density.data[i]; + col_g_dens[i] = state.gas_density.data[i]; + col_i_dnes[i] = state.ice_density.data[i]; + col_poro[i] = state.porosity.data[i]; + col_wc[i] = state.water_content.data[i]; + col_temp[i] = state.temperature.data[i]; + + col_l_sat[i] = props.liquid_saturation.data[i]; + col_g_sat[i] = props.gas_saturation.data[i]; + col_i_sat[i] = props.ice_saturation.data[i]; + col_elev[i] = props.elevation.data[i]; + col_rel_perm[i] = props.relative_permeability.data[i]; + col_cond[i] = props.conductivity.data[i]; + col_vol[i] = props.volume.data[i]; } /*for (int i = 0; i < num_components; i++) { bgc_state.total_mobile.data[i] = (*col_tcc)[i]; diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index fef141fca..59745884e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -141,6 +141,9 @@ class EcoSIM : public PK_Physical_Default { int number_aqueous_components_; int ncells_per_col_; + int num_cols_; + double saved_time_; + double current_time_; // keys Key tcc_key_; From 1a7140cb80aed08bc7a35ce38ad1b710d64ef3f3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Mar 2023 12:53:26 -0700 Subject: [PATCH 072/582] declarations --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index fbd1ca0dc..d8789220b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -682,6 +682,21 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->porosity())[cell] = state.porosity; //I probably need to copy the columns cell by cell in a loop //Can I do this in the field to column function? + const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); + const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); + const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); + const auto& gas_saturation = *S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", true); + const auto& ice_saturation = *S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", true); + const auto& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", true); + const auto& water_content = *S_->Get(water_content_key_, water_tag).ViewComponent("cell", true); + const auto& relative_permeability = *S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", true); + const auto& liquid_density = *S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", true); + const auto& ice_density = *S_->Get(ice_den_key_, water_tag).ViewComponent("cell", true); + const auto& gas_density = *S_->Get(gas_den_key_, water_tag).ViewComponent("cell", true); + const auto& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", true); + const auto& temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", true); + const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); + const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -702,7 +717,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, for (int i=0; i < ncells_per_col_; ++i) { - col_f_dens[i] = state.liquid_density.data[i]; + col_f_dens[i] = state.fluid_density.data[i]; col_g_dens[i] = state.gas_density.data[i]; col_i_dnes[i] = state.ice_density.data[i]; col_poro[i] = state.porosity.data[i]; From 0f7ef676ae6061a726e479137cae7692b81a1a92 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Mar 2023 14:26:32 -0700 Subject: [PATCH 073/582] testing copy method --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d8789220b..3022b40d5 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -715,11 +715,14 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + /*Can't save cell by cell doesn't seem to work like this*/ + + col_f_dens.Import(state.fluid_density.data, ncells_per_col_); for (int i=0; i < ncells_per_col_; ++i) { col_f_dens[i] = state.fluid_density.data[i]; col_g_dens[i] = state.gas_density.data[i]; - col_i_dnes[i] = state.ice_density.data[i]; + col_i_dens[i] = state.ice_density.data[i]; col_poro[i] = state.porosity.data[i]; col_wc[i] = state.water_content.data[i]; col_temp[i] = state.temperature.data[i]; @@ -732,6 +735,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, col_cond[i] = props.conductivity.data[i]; col_vol[i] = props.volume.data[i]; } + /*for (int i = 0; i < num_components; i++) { bgc_state.total_mobile.data[i] = (*col_tcc)[i]; }*/ From 88b354fb15c8569934842062ccf5b8c6347dcb6e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Mar 2023 14:37:15 -0700 Subject: [PATCH 074/582] testing copy method --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3022b40d5..ea735e74b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -717,9 +717,10 @@ void EcoSIM::CopyFromEcoSIM(const int col, /*Can't save cell by cell doesn't seem to work like this*/ - col_f_dens.Import(state.fluid_density.data, ncells_per_col_); + //col_f_dens.Import(state.fluid_density.data, ncells_per_col_); for (int i=0; i < ncells_per_col_; ++i) { + col_f_dens(i) = state.fluid_density.data[i]; col_f_dens[i] = state.fluid_density.data[i]; col_g_dens[i] = state.gas_density.data[i]; col_i_dens[i] = state.ice_density.data[i]; From 40aa4423e07e75a7e48aea0a480833cff140afad Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Mar 2023 14:55:48 -0700 Subject: [PATCH 075/582] testing copy method --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index ea735e74b..f4d36db9b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -717,11 +717,8 @@ void EcoSIM::CopyFromEcoSIM(const int col, /*Can't save cell by cell doesn't seem to work like this*/ - //col_f_dens.Import(state.fluid_density.data, ncells_per_col_); - for (int i=0; i < ncells_per_col_; ++i) { - col_f_dens(i) = state.fluid_density.data[i]; - col_f_dens[i] = state.fluid_density.data[i]; + (*col_f_dens)[i] = state.fluid_density.data[i]; col_g_dens[i] = state.gas_density.data[i]; col_i_dens[i] = state.ice_density.data[i]; col_poro[i] = state.porosity.data[i]; From 4414991529ac610d7de7ae8aea4ddc65b6eaf470 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Mar 2023 15:06:58 -0700 Subject: [PATCH 076/582] fixing push back to amanzi state --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f4d36db9b..241fefa1c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -719,19 +719,19 @@ void EcoSIM::CopyFromEcoSIM(const int col, for (int i=0; i < ncells_per_col_; ++i) { (*col_f_dens)[i] = state.fluid_density.data[i]; - col_g_dens[i] = state.gas_density.data[i]; - col_i_dens[i] = state.ice_density.data[i]; - col_poro[i] = state.porosity.data[i]; - col_wc[i] = state.water_content.data[i]; - col_temp[i] = state.temperature.data[i]; - - col_l_sat[i] = props.liquid_saturation.data[i]; - col_g_sat[i] = props.gas_saturation.data[i]; - col_i_sat[i] = props.ice_saturation.data[i]; - col_elev[i] = props.elevation.data[i]; - col_rel_perm[i] = props.relative_permeability.data[i]; - col_cond[i] = props.conductivity.data[i]; - col_vol[i] = props.volume.data[i]; + (*col_g_dens)[i] = state.gas_density.data[i]; + (*col_i_dens)[i] = state.ice_density.data[i]; + (*col_poro)[i] = state.porosity.data[i]; + (*col_wc)[i] = state.water_content.data[i]; + (*col_temp)[i] = state.temperature.data[i]; + + (*col_l_sat)[i] = props.liquid_saturation.data[i]; + (*col_g_sat)[i] = props.gas_saturation.data[i]; + (*col_i_sat)[i] = props.ice_saturation.data[i]; + (*col_elev)[i] = props.elevation.data[i]; + (*col_rel_perm)[i] = props.relative_permeability.data[i]; + (*col_cond)[i] = props.conductivity.data[i]; + (*col_vol)[i] = props.volume.data[i]; } /*for (int i = 0; i < num_components; i++) { From cdfeb2a6992f45727da54af51172e472b9d96b76 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Mar 2023 15:38:04 -0700 Subject: [PATCH 077/582] minor bugfixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 40 ++++++++++++++++------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 241fefa1c..9a8edba59 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -89,7 +89,22 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // initial timestep dt_ = plist_->get("initial time step", 1.); //Heat capacity looks like the default units are molar heat capacity - c_m_ = plist_.get("heat capacity [J mol^-1 K^-1]"); + //c_m_ = plist_.get("heat capacity [J mol^-1 K^-1]"); + + if (plist_.isParameter("heat capacity [J kg^-1 K^-1]")) { + Cv_ = 1.e-6 * plist_.get("heat capacity [J kg^-1 K^-1]"); + molar_basis_ = false; + } else if (plist_.isParameter("heat capacity [MJ kg^-1 K^-1]")) { + Cv_ = plist_.get("heat capacity [MJ kg^-1 K^-1]"); + molar_basis_ = false; + } else if (plist_.isParameter("heat capacity [MJ mol^-1 K^-1]")) { + Cv_ = plist_.get("heat capacity [MJ mol^-1 K^-1]"); + molar_basis_ = true; + } else { + Cv_ = 1.e-6 * plist_.get("heat capacity [J mol^-1 K^-1]"); + molar_basis_ = true; + } + //They also sometimes use a version of heat capacity that is just this //quantity times 1e-6: //ka_ = 1.e-6 * plist_.get("heat capacity [J kg^-1 K^-1]"); @@ -538,18 +553,19 @@ void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, //--------------------------------------------------------------------------- //Alquimia Helper functions //--------------------------------------------------------------------------- -void EcoSIM::CopyToEcoSIM(int col, +/*void EcoSIM::CopyToEcoSIM(int col, BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data) { CopyToEcoSIM(col, props, state, aux_data); -} +}*/ void EcoSIM::CopyToEcoSIM(int col, BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data) + BGCAuxiliaryData& aux_data, + const Tag& water_tag) { //Fill state with ATS variables that are going to be changed by EcoSIM //NEED TO DECIDE WHICH PROPERTIES GO WHERE @@ -666,15 +682,17 @@ void EcoSIM::CopyEcoSIMStateToAmanzi( const int col, const BGCProperties& props, const BGCState& state, - const BGCAuxiliaryData& aux_data) + const BGCAuxiliaryData& aux_data + const Tag& water_tag) { - CopyFromEcoSIM(col, props, state, aux_data); + CopyFromEcoSIM(col, props, state, aux_data, water_tag); } void EcoSIM::CopyFromEcoSIM(const int col, const BGCProperties& props, const BGCState& state, - const BGCAuxiliaryData& aux_data) + const BGCAuxiliaryData& aux_data, + const Tag& water_tag) { // If the chemistry has modified the porosity and/or density, it needs to // be updated here. @@ -783,12 +801,12 @@ int EcoSIM::InitializeSingleColumn(int col) { // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but // should use the same tag as transport. See #673 - CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_); + CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); //bgc_engine_->EnforceCondition(condition, current_time_, bgc_props_, // bgc_state_, bgc_aux_data_); - CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_); + CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); // ETC: hacking to get consistent solution -- if there is no water @@ -814,7 +832,7 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) // // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but // should use the same tag as transport. See #673 - CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_); + CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 0; @@ -838,7 +856,7 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) // Move the information back into Amanzi's state, updating the given total concentration vector. CopyEcoSIMStateToAmanzi(col, - bgc_props_, bgc_state_, bgc_aux_data_); + bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); return num_iterations; } From da5ca0c4963a0a410bebf695c97f82191d1eb2b4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 13:26:31 -0700 Subject: [PATCH 078/582] various minor fixes --- src/pks/ecosim_pk/BGCEngine.hh | 6 +++--- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 16 +--------------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 +++ 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 7bbce8205..bb8cde53a 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -13,8 +13,8 @@ conditions and to integrate reactions given a chemical configuration. */ -//#ifndef AMANZI_CHEMISTRY_ENGINE_HH_ -//#define AMANZI_CHEMISTRY_ENGINE_HH_ +#ifndef BGC_ENGINE_HH_ +#define BGC_ENGINE_HH_ #include #include @@ -110,4 +110,4 @@ class BGCEngine { } // namespace } // namespace -//#endif +#endif diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 9a8edba59..6cda21942 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -89,21 +89,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // initial timestep dt_ = plist_->get("initial time step", 1.); //Heat capacity looks like the default units are molar heat capacity - //c_m_ = plist_.get("heat capacity [J mol^-1 K^-1]"); - - if (plist_.isParameter("heat capacity [J kg^-1 K^-1]")) { - Cv_ = 1.e-6 * plist_.get("heat capacity [J kg^-1 K^-1]"); - molar_basis_ = false; - } else if (plist_.isParameter("heat capacity [MJ kg^-1 K^-1]")) { - Cv_ = plist_.get("heat capacity [MJ kg^-1 K^-1]"); - molar_basis_ = false; - } else if (plist_.isParameter("heat capacity [MJ mol^-1 K^-1]")) { - Cv_ = plist_.get("heat capacity [MJ mol^-1 K^-1]"); - molar_basis_ = true; - } else { - Cv_ = 1.e-6 * plist_.get("heat capacity [J mol^-1 K^-1]"); - molar_basis_ = true; - } + c_m_ = plist_->get("heat capacity [J mol^-1 K^-1]"); //They also sometimes use a version of heat capacity that is just this //quantity times 1e-6: diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 59745884e..1d19c7fe6 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -21,7 +21,9 @@ #ifndef PKS_ECOSIM_HH_ #define PKS_ECOSIM_HH_ +#include #include +#include #include "Epetra_MultiVector.h" #include "Teuchos_ParameterList.hpp" @@ -39,6 +41,7 @@ #include "pk_physical_default.hh" #include "PK_Physical.hh" + namespace Amanzi { namespace EcoSIM { From dbaac7c5adca74d38a815a70f03c08348ba255ce Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 13:43:08 -0700 Subject: [PATCH 079/582] fixed engine definition --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 1d19c7fe6..290c00283 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -167,6 +167,8 @@ class EcoSIM : public PK_Physical_Default { Key min_vol_frac_key_; Key ecosim_aux_data_key_; + Teuchos::RCP bgc_engine_; + private: BGCState bgc_state_; BGCProperties bgc_props_; From 0f1fbe459df888dbd7bd3af3bae0bf53c1335c40 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 14:29:34 -0700 Subject: [PATCH 080/582] trying a different definition --- src/pks/ecosim_pk/BGCEngine.hh | 2 ++ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index bb8cde53a..9d800ca3f 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -100,6 +100,8 @@ class BGCEngine { std::string bgc_engine_name_; std::string bgc_engine_inputfile_; + Teuchos::RCP bgc_engine_; + // forbidden. BGCEngine(); BGCEngine(const BGCEngine&); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 290c00283..186968e47 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -167,7 +167,7 @@ class EcoSIM : public PK_Physical_Default { Key min_vol_frac_key_; Key ecosim_aux_data_key_; - Teuchos::RCP bgc_engine_; + //Teuchos::RCP bgc_engine_; private: BGCState bgc_state_; From b9d4c56de0f9f3100afd2928b20e287f5b4b85c3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 15:58:05 -0700 Subject: [PATCH 081/582] tags? --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 186968e47..cfd79b629 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -45,7 +45,7 @@ namespace Amanzi { namespace EcoSIM { -class EcoSIM : public PK_Physical_Default { +class EcoSIM : public EcoSIM { public: @@ -100,12 +100,14 @@ class EcoSIM : public PK_Physical_Default { void CopyToEcoSIM(int col, BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data); + BGCAuxiliaryData& aux_data, + const Tag& water_tag); void CopyFromEcoSIM(const int cell, const BGCProperties& props, const BGCState& state, - const BGCAuxiliaryData& aux_data); + const BGCAuxiliaryData& aux_data, + const Tag& water_tag); int InitializeSingleColumn(int col); @@ -115,7 +117,8 @@ class EcoSIM : public PK_Physical_Default { const int cell, const BGCProperties& props, const BGCState& state, - const BGCAuxiliaryData& aux_data); + const BGCAuxiliaryData& aux_data, + const Tag& water_tag); void ComputeNextTimeStep(); @@ -174,6 +177,8 @@ class EcoSIM : public PK_Physical_Default { BGCProperties bgc_props_; BGCAuxiliaryData bgc_aux_data_; + bool bgc_initialized_; + private: //factory registration static RegisteredPKFactory reg_; From 7a59b5f19d3c712320256aac5497478a6190d524 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 17:02:39 -0700 Subject: [PATCH 082/582] defining the tag --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index cfd79b629..b1b0cea95 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -101,13 +101,13 @@ class EcoSIM : public EcoSIM { BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - const Tag& water_tag); + const Tag& water_tag = Tags::DEFAULT); void CopyFromEcoSIM(const int cell, const BGCProperties& props, const BGCState& state, const BGCAuxiliaryData& aux_data, - const Tag& water_tag); + const Tag& water_tag = Tags::DEFAULT); int InitializeSingleColumn(int col); @@ -118,7 +118,7 @@ class EcoSIM : public EcoSIM { const BGCProperties& props, const BGCState& state, const BGCAuxiliaryData& aux_data, - const Tag& water_tag); + const Tag& water_tag = Tags::DEFAULT); void ComputeNextTimeStep(); From 23d0b651f3e96e48dd6fb86bc8c1c3187f9f5b82 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 17:13:16 -0700 Subject: [PATCH 083/582] changed final to override --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index b1b0cea95..b9a959f6d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -61,31 +61,31 @@ class EcoSIM : public EcoSIM { // is a PK // -- Setup data //virtual void Setup(const Teuchos::Ptr&S); - virtual void Setup() override; + virtual void Setup() final; // -- initalize owned (dependent) variables //virtual void Initialize(const Teuchos::Ptr& S); - virtual void Initialize() override; + virtual void Initialize() final; // --provide timestep size - virtual double get_dt() override { + virtual double get_dt() final { return dt_; } - virtual void set_dt(double dt) override { + virtual void set_dt(double dt) final { dt_ = dt; } // -- commit the model //virtual void CommitStep(double t_old, double t_new, const Teuchos::RCP& S); - virtual void CommitStep(double t_old, double t_new, const Tag& tag) override; + virtual void CommitStep(double t_old, double t_new, const Tag& tag) final; // -- Update diagnostics for vis. //virtual void CalculateDiagnostics(const Teuchos::RCP& S) {} //virtual void CalculateDiagnostics(const Tag& tag) override; // -- advance the model - virtual bool AdvanceStep(double t_old, double t_new, bool reinit) override; + virtual bool AdvanceStep(double t_old, double t_new, bool reinit) final; virtual std::string name(){return "EcoSIM for ATS";}; From a0dc107a8922bb661476aaca60588afd8f0d0fa5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 17:13:29 -0700 Subject: [PATCH 084/582] changed override to final --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index b1b0cea95..b9a959f6d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -61,31 +61,31 @@ class EcoSIM : public EcoSIM { // is a PK // -- Setup data //virtual void Setup(const Teuchos::Ptr&S); - virtual void Setup() override; + virtual void Setup() final; // -- initalize owned (dependent) variables //virtual void Initialize(const Teuchos::Ptr& S); - virtual void Initialize() override; + virtual void Initialize() final; // --provide timestep size - virtual double get_dt() override { + virtual double get_dt() final { return dt_; } - virtual void set_dt(double dt) override { + virtual void set_dt(double dt) final { dt_ = dt; } // -- commit the model //virtual void CommitStep(double t_old, double t_new, const Teuchos::RCP& S); - virtual void CommitStep(double t_old, double t_new, const Tag& tag) override; + virtual void CommitStep(double t_old, double t_new, const Tag& tag) final; // -- Update diagnostics for vis. //virtual void CalculateDiagnostics(const Teuchos::RCP& S) {} //virtual void CalculateDiagnostics(const Tag& tag) override; // -- advance the model - virtual bool AdvanceStep(double t_old, double t_new, bool reinit) override; + virtual bool AdvanceStep(double t_old, double t_new, bool reinit) final; virtual std::string name(){return "EcoSIM for ATS";}; From 4c36af07332927db36dfa61dfc4faae175b5b018 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 17:27:33 -0700 Subject: [PATCH 085/582] changed some definitions --- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 9d800ca3f..e25065fee 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -100,7 +100,7 @@ class BGCEngine { std::string bgc_engine_name_; std::string bgc_engine_inputfile_; - Teuchos::RCP bgc_engine_; + //Teuchos::RCP bgc_engine_; // forbidden. BGCEngine(); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index b9a959f6d..895d3ada7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -89,6 +89,8 @@ class EcoSIM : public EcoSIM { virtual std::string name(){return "EcoSIM for ATS";}; + Teuchos::RCP bgc_engine() { return chem_engine_; } + /*void CopyToEcoSIM(int col, BGCProperties& props, BGCState& state, @@ -170,7 +172,7 @@ class EcoSIM : public EcoSIM { Key min_vol_frac_key_; Key ecosim_aux_data_key_; - //Teuchos::RCP bgc_engine_; + Teuchos::RCP bgc_engine_; private: BGCState bgc_state_; From 73b965f2e8342d664eb8270d958521bfb024eb8f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 18:37:15 -0700 Subject: [PATCH 086/582] minor fix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 895d3ada7..9f139b517 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -89,7 +89,7 @@ class EcoSIM : public EcoSIM { virtual std::string name(){return "EcoSIM for ATS";}; - Teuchos::RCP bgc_engine() { return chem_engine_; } + Teuchos::RCP bgc_engine() { return bgc_engine_; } /*void CopyToEcoSIM(int col, BGCProperties& props, From 49f1b95ea8ee08b63abcf7d346cfd104aab3278d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 18:48:12 -0700 Subject: [PATCH 087/582] reverted public pk definition --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 9f139b517..393b75c70 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -45,7 +45,7 @@ namespace Amanzi { namespace EcoSIM { -class EcoSIM : public EcoSIM { +class EcoSIM : public PK_Physical { public: From 1de81b3d5db1d3d78c133bf01847f4c7056e3511 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 18:56:41 -0700 Subject: [PATCH 088/582] changing PK call to physical --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 6cda21942..a8e9d8ff6 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -33,7 +33,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& global_list, const Teuchos::RCP& S, const Teuchos::RCP& solution): - PK_Physical_Default(pk_tree, global_list, S, solution), + PK_Physical(pk_tree, global_list, S, solution), PK(pk_tree, global_list, S, solution), ncells_per_col_(-1), saved_time_(0.0) From 1b8c4dded00f24f4aac759e3f75fd9f9dbcfda1a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Mar 2023 19:23:28 -0700 Subject: [PATCH 089/582] changed field to column def --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index a8e9d8ff6..e0e02eaa1 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -471,7 +471,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // helper function for pushing field to column void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - double* col_vec, int ncol) + double* col_vec) { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { @@ -484,7 +484,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // cell by cell in alquimia void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - double* col_vec, int ncol) + double* col_vec) { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 393b75c70..42446e098 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -133,16 +133,16 @@ class EcoSIM : public PK_Physical { //The helper functions from BGC are protected not private (unclear why) //I don't think I need this here, probably in the engine void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - Teuchos::Ptr col_vec, bool copy); + Teuchos::Ptr col_vec); - void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - double* col_vec, int ncol); + //void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + // double* col_vec); void ColDepthDz_(AmanziMesh::Entity_ID col, Teuchos::Ptr depth, Teuchos::Ptr dz); void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - double* col_vec, int ncol); + double* col_vec); //evaluator for transpiration; //I don't think I need this anymore //Teuchos::RCP p_root_eval_; From 82f93a2d1d53d803edfef310dfe9a7be28e747ca Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 12:19:22 -0700 Subject: [PATCH 090/582] changed f2c and c2f functions to accept multivector --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e0e02eaa1..45d9630f1 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -470,7 +470,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, } // helper function for pushing field to column -void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, +void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, double* col_vec) { auto& col_iter = mesh_->cells_of_column(col); @@ -483,7 +483,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // with any luck it's just the reverse of the above similar to how it's done // cell by cell in alquimia -void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, +void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, double* col_vec) { auto& col_iter = mesh_->cells_of_column(col); @@ -630,7 +630,7 @@ void EcoSIM::CopyToEcoSIM(int col, props.volume.data[i] = col_vol[i]; } - //mat_props.volume = mesh_->cell_volume(cell; + //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; num_components = tcc.NumVectors(); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 42446e098..c9007c6b3 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -132,7 +132,7 @@ class EcoSIM : public PK_Physical { //The helper functions from BGC are protected not private (unclear why) //I don't think I need this here, probably in the engine - void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, Teuchos::Ptr col_vec); //void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, @@ -141,7 +141,7 @@ class EcoSIM : public PK_Physical { Teuchos::Ptr depth, Teuchos::Ptr dz); - void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, double* col_vec); //evaluator for transpiration; //I don't think I need this anymore From 5347fc2baa811a2e21d35258e8f2b8825927f967 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 12:33:34 -0700 Subject: [PATCH 091/582] further definition changes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 45d9630f1..97db91ba0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -471,7 +471,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // helper function for pushing field to column void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, - double* col_vec) + Teuchos::Ptr col_vec) { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { @@ -484,7 +484,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& // cell by cell in alquimia void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, - double* col_vec) + Teuchos::Ptr col_vec) { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index c9007c6b3..d1115193f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -142,7 +142,7 @@ class EcoSIM : public PK_Physical { Teuchos::Ptr dz); void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, - double* col_vec); + Teuchos::Ptr col_vec); //evaluator for transpiration; //I don't think I need this anymore //Teuchos::RCP p_root_eval_; From a054749a8c639f1dab3e150464c4bd195caf340f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 12:51:30 -0700 Subject: [PATCH 092/582] various minor fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 40 +++++++++++------------ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 1 + 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 97db91ba0..60678d972 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -614,26 +614,26 @@ void EcoSIM::CopyToEcoSIM(int col, // automatically, but I just want to test this for now for (int i=0; i < ncells_per_col_; ++i) { - state.liquid_density.data[i] = col_f_dens[i]; - state.gas_density.data[i] = col_g_dens[i]; - state.ice_density.data[i] = col_i_dens[i]; - state.porosity.data[i] = col_poro[i]; - state.water_content.data[i] = col_wc[i]; - state.temperature.data[i] = col_temp[i]; - - props.liquid_saturation.data[i] = col_l_sat[i]; - props.gas_saturation.data[i] = col_g_sat[i]; - props.ice_saturation.data[i] = col_i_sat[i]; - props.elevation.data[i] = col_elev[i]; - props.relative_permeability.data[i] = col_rel_perm[i]; - props.conductivity.data[i] = col_cond[i]; - props.volume.data[i] = col_vol[i]; + state.fluid_density.data[i] = (*col_f_dens)[i]; + state.gas_density.data[i] = (*col_g_dens)[i]; + state.ice_density.data[i] = (*col_i_dens)[i]; + state.porosity.data[i] = (*col_poro)[i]; + state.water_content.data[i] = (*col_wc)[i]; + state.temperature.data[i] = (*col_temp)[i]; + + props.liquid_saturation.data[i] = (*col_l_sat)[i]; + props.gas_saturation.data[i] = (*col_g_sat)[i]; + props.ice_saturation.data[i] = (*col_i_sat)[i]; + props.elevation.data[i] = (*col_elev)[i]; + props.relative_permeability.data[i] = (*col_rel_perm)[i]; + props.conductivity.data[i] = (*col_cond)[i]; + props.volume.data[i] = (*col_vol)[i]; } //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; - num_components = tcc.NumVectors(); + num_components_ = tcc.NumVectors(); //This probably isn't going to work. I think I either need to think //of a way to do this @@ -648,10 +648,10 @@ void EcoSIM::CopyToEcoSIM(int col, //} // Auxiliary data -- block copy. - if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { + /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); - int num_aux_ints = chem_engine_->Sizes().num_aux_integers; - int num_aux_doubles = chem_engine_->Sizes().num_aux_doubles; + int num_aux_ints = bgc_engine_->Sizes().num_aux_integers; + int num_aux_doubles = bgc_engine_->Sizes().num_aux_doubles; for (int i = 0; i < num_aux_ints; i++) { double* cell_aux_ints = (*aux_data_)[i]; @@ -661,14 +661,14 @@ void EcoSIM::CopyToEcoSIM(int col, double* cell_aux_doubles = (*aux_data_)[i + num_aux_ints]; aux_data.aux_doubles.data[i] = cell_aux_doubles[cell]; } - } + }*/ } void EcoSIM::CopyEcoSIMStateToAmanzi( const int col, const BGCProperties& props, const BGCState& state, - const BGCAuxiliaryData& aux_data + const BGCAuxiliaryData& aux_data, const Tag& water_tag) { CopyFromEcoSIM(col, props, state, aux_data, water_tag); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index d1115193f..f9bdedaec 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -148,6 +148,7 @@ class EcoSIM : public PK_Physical { //Teuchos::RCP p_root_eval_; int number_aqueous_components_; + int num_components_; int ncells_per_col_; int num_cols_; double saved_time_; From 8e7290a3f38f270685abddc6609c68a36a82cf09 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 13:27:55 -0700 Subject: [PATCH 093/582] various minor fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 60678d972..f1c0254cb 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -138,7 +138,7 @@ EcoSIM::~EcoSIM() // now the PK setup void EcoSIM::Setup() { std::cout << "beginning Ecosim setup\n"; - PK_Physical_Default::Setup(); + //PK_Physical_Default::Setup(); /*This is for setting up the Auxiliary Output data which I'm not sure we need chem_engine_->GetAuxiliaryOutputNames(aux_names_, aux_subfield_names_); @@ -205,8 +205,7 @@ void EcoSIM::Setup() { // -- Initialize owned (dependent) variables. void EcoSIM::Initialize() { std::cout << "\nBegin Initialize\n"; - //PK_Physical_Default::Initialize(S); - PK_Physical_Default::Initialize(); + //PK_Physical_Default::Initialize(); //Now we have to initalize the variables (i.e. give them initial values) //In our PK it will only be done for variables owned by the PK so the aux_names @@ -457,7 +456,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // helper function for pushing field to column void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, - Teuchos::Ptr col_vec, bool copy) + Teuchos::Ptr col_vec) { if (col_vec == Teuchos::null) { col_vec = Teuchos::ptr(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -470,14 +469,14 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, } // helper function for pushing field to column -void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, +/*void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, Teuchos::Ptr col_vec) { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { col_vec[i] = vec[col_iter[i]]; } -} +}*/ // I think I need a function for pushing from the column back to the field // with any luck it's just the reverse of the above similar to how it's done @@ -488,7 +487,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { - vec[col_iter[i]] = col_vec[i]; + vec[col_iter[i]] = (*col_vec)[i]; } } From 6b321e50c48323ee51b9e11a3ba8ac5354d4b700 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 14:37:30 -0700 Subject: [PATCH 094/582] changed some type definitions --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index f9bdedaec..8f77d0cd8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -89,7 +89,7 @@ class EcoSIM : public PK_Physical { virtual std::string name(){return "EcoSIM for ATS";}; - Teuchos::RCP bgc_engine() { return bgc_engine_; } + Teuchos::RCP bgc_engine() { return bgc_engine_; } /*void CopyToEcoSIM(int col, BGCProperties& props, @@ -148,7 +148,7 @@ class EcoSIM : public PK_Physical { //Teuchos::RCP p_root_eval_; int number_aqueous_components_; - int num_components_; + int num_components_; int ncells_per_col_; int num_cols_; double saved_time_; @@ -173,7 +173,7 @@ class EcoSIM : public PK_Physical { Key min_vol_frac_key_; Key ecosim_aux_data_key_; - Teuchos::RCP bgc_engine_; + Teuchos::RCP bgc_engine_; private: BGCState bgc_state_; From 328e9444101f86bb3494da7b80ec5f32c8e0329b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 14:51:47 -0700 Subject: [PATCH 095/582] type definitons --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f1c0254cb..7bdbf0b89 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -114,7 +114,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, } std::string engine_name = plist_->get("engine"); std::string engine_inputfile = plist_->get("engine input file"); - bgc_engine_ = Teuchos::rcp(new EcoSIM::BGCEngine(engine_name, engine_inputfile)); + bgc_engine_ = Teuchos::rcp(new BGCEngine::BGCEngine(engine_name, engine_inputfile)); //comp_names_.clear(); //bgc_engine_->GetPrimarySpeciesNames(comp_names_); From 94522bcbc490091881e758a1809673294c3d009a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 15:30:46 -0700 Subject: [PATCH 096/582] reverting definitions --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 7bdbf0b89..b97138ff4 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -114,7 +114,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, } std::string engine_name = plist_->get("engine"); std::string engine_inputfile = plist_->get("engine input file"); - bgc_engine_ = Teuchos::rcp(new BGCEngine::BGCEngine(engine_name, engine_inputfile)); + bgc_engine_ = Teuchos::rcp(new EcoSIM::BGCEngine(engine_name, engine_inputfile)); //comp_names_.clear(); //bgc_engine_->GetPrimarySpeciesNames(comp_names_); @@ -455,7 +455,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //--------------------------------------------------------------------------- // helper function for pushing field to column -void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, +void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, Teuchos::Ptr col_vec) { if (col_vec == Teuchos::null) { diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 8f77d0cd8..e0ed58a47 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -89,7 +89,7 @@ class EcoSIM : public PK_Physical { virtual std::string name(){return "EcoSIM for ATS";}; - Teuchos::RCP bgc_engine() { return bgc_engine_; } + Teuchos::RCP bgc_engine() { return bgc_engine_; } /*void CopyToEcoSIM(int col, BGCProperties& props, @@ -173,7 +173,7 @@ class EcoSIM : public PK_Physical { Key min_vol_frac_key_; Key ecosim_aux_data_key_; - Teuchos::RCP bgc_engine_; + Teuchos::RCP bgc_engine_; private: BGCState bgc_state_; From 9a94244d9c8ff50e394688cd7235d9661ba30d08 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 15:34:38 -0700 Subject: [PATCH 097/582] testing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b97138ff4..3bd0eeaed 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -114,7 +114,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, } std::string engine_name = plist_->get("engine"); std::string engine_inputfile = plist_->get("engine input file"); - bgc_engine_ = Teuchos::rcp(new EcoSIM::BGCEngine(engine_name, engine_inputfile)); + bgc_engine_ = Teuchos::rcp(new BGCEngine(engine_name, engine_inputfile)); //comp_names_.clear(); //bgc_engine_->GetPrimarySpeciesNames(comp_names_); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index e0ed58a47..33afbe87e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -89,7 +89,7 @@ class EcoSIM : public PK_Physical { virtual std::string name(){return "EcoSIM for ATS";}; - Teuchos::RCP bgc_engine() { return bgc_engine_; } + Teuchos::RCP bgc_engine() { return bgc_engine_; } /*void CopyToEcoSIM(int col, BGCProperties& props, @@ -173,7 +173,7 @@ class EcoSIM : public PK_Physical { Key min_vol_frac_key_; Key ecosim_aux_data_key_; - Teuchos::RCP bgc_engine_; + Teuchos::RCP bgc_engine_; private: BGCState bgc_state_; From 5944a5f89348b7c28de089d11e13e4c2ce7ed40d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 15:56:45 -0700 Subject: [PATCH 098/582] pointer hell --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3bd0eeaed..f92942ff8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -464,7 +464,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { - (*col_vec)[i] = vec[col_iter[i]]; + (*col_vec)[i] = *vec[col_iter[i]]; } } From f00776dbec72305ba21c5c5cf1aad0b09a8c39fa Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 16:22:08 -0700 Subject: [PATCH 099/582] modified the reverse statements to allow writing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f92942ff8..7d4390ab6 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -685,7 +685,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->porosity())[cell] = state.porosity; //I probably need to copy the columns cell by cell in a loop //Can I do this in the field to column function? - const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); + /*const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); const auto& gas_saturation = *S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", true); @@ -699,7 +699,23 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", true); const auto& temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", true); const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); - const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); + const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ + + auto& tcc = *S_->GetW(tcc_key_, water_tag).ViewComponent("cell"); + auto& porosity = *S_->GetW(poro_key_, water_tag).ViewComponent("cell"); + auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag).ViewComponent("cell"); + auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag).ViewComponent("cell"); + auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag).ViewComponent("cell"); + auto& elevation = *S_->GetW(elev_key_, water_tag).ViewComponent("cell"); + auto& water_content = *S_->GetW(water_content_key_, water_tag).ViewComponent("cell"); + auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag).ViewComponent("cell"); + auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag).ViewComponent("cell"); + auto& ice_density = *S_->GetW(ice_den_key_, water_tag).ViewComponent("cell"); + auto& gas_density = *S_->GetW(gas_den_key_, water_tag).ViewComponent("cell"); + auto& rock_density = *S_->GetW(rock_den_key_, water_tag).ViewComponent("cell"); + auto& temp = *S_->GetW(T_key_, water_tag).ViewComponent("cell"); + auto& conductivity = *S_->GetW(conductivity_key_, water_tag).ViewComponent("cell"); + auto& cell_volume = *S_->GetW(cv_key_, water_tag).ViewComponent("cell"); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 027f913175e50d7c912c77faaa80e031bd7fd09f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 16:28:19 -0700 Subject: [PATCH 100/582] test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 7d4390ab6..a9f3c1bad 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -7,7 +7,7 @@ --------------------------------------------------------------------------*/ -/*#include +#include #include #include @@ -23,7 +23,7 @@ #include "exceptions.hh" #include "Mesh.hh" -#include "pk_helpers.hh"*/ +#include "pk_helpers.hh" #include "EcoSIM_ATS_interface.hh" namespace Amanzi { From 1589ae13cda9c5f3fbfb30f8627ffebedabeb2c3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 16:38:00 -0700 Subject: [PATCH 101/582] adding in the password for state --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 30 +++++++++++------------ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 1 + 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index a9f3c1bad..20cb1cdb5 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -701,21 +701,21 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ - auto& tcc = *S_->GetW(tcc_key_, water_tag).ViewComponent("cell"); - auto& porosity = *S_->GetW(poro_key_, water_tag).ViewComponent("cell"); - auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag).ViewComponent("cell"); - auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag).ViewComponent("cell"); - auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag).ViewComponent("cell"); - auto& elevation = *S_->GetW(elev_key_, water_tag).ViewComponent("cell"); - auto& water_content = *S_->GetW(water_content_key_, water_tag).ViewComponent("cell"); - auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag).ViewComponent("cell"); - auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag).ViewComponent("cell"); - auto& ice_density = *S_->GetW(ice_den_key_, water_tag).ViewComponent("cell"); - auto& gas_density = *S_->GetW(gas_den_key_, water_tag).ViewComponent("cell"); - auto& rock_density = *S_->GetW(rock_den_key_, water_tag).ViewComponent("cell"); - auto& temp = *S_->GetW(T_key_, water_tag).ViewComponent("cell"); - auto& conductivity = *S_->GetW(conductivity_key_, water_tag).ViewComponent("cell"); - auto& cell_volume = *S_->GetW(cv_key_, water_tag).ViewComponent("cell"); + auto& tcc = *S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); + auto& porosity = *S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell"); + auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell"); + auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell"); + auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell"); + auto& elevation = *S_->GetW(elev_key_, water_tag, passwd_).ViewComponent("cell"); + auto& water_content = *S_->GetW(water_content_key_, water_tag, passwd_).ViewComponent("cell"); + auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag, passwd_).ViewComponent("cell"); + auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag, passwd_).ViewComponent("cell"); + auto& ice_density = *S_->GetW(ice_den_key_, water_tag, passwd_).ViewComponent("cell"); + auto& gas_density = *S_->GetW(gas_den_key_, water_tag, passwd_).ViewComponent("cell"); + auto& rock_density = *S_->GetW(rock_den_key_, water_tag, passwd_).ViewComponent("cell"); + auto& temp = *S_->GetW(T_key_, water_tag, passwd_).ViewComponent("cell"); + auto& conductivity = *S_->GetW(conductivity_key_, water_tag, passwd_).ViewComponent("cell"); + auto& cell_volume = *S_->GetW(cv_key_, water_tag, passwd_).ViewComponent("cell"); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 33afbe87e..1720a7dd6 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -129,6 +129,7 @@ class EcoSIM : public PK_Physical { double c_m_; Teuchos::RCP mesh_surf_; //might need this? Key domain_surf_; + std::string passwd_ = "state"; //The helper functions from BGC are protected not private (unclear why) //I don't think I need this here, probably in the engine From 2326e8a0fb0cec1979f0004fcf521317ad1b8591 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 16:57:55 -0700 Subject: [PATCH 102/582] test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 20cb1cdb5..aa23325f0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -482,7 +482,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& // with any luck it's just the reverse of the above similar to how it's done // cell by cell in alquimia -void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, +void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector vec, Teuchos::Ptr col_vec) { auto& col_iter = mesh_->cells_of_column(col); @@ -701,8 +701,8 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ - auto& tcc = *S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - auto& porosity = *S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell"); + //auto& tcc = *S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); + auto& porosity = *S_->GetPtrW(poro_key_, water_tag, passwd_).ViewComponent("cell"); auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell"); auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell"); auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell"); From ca0f88a68b90800aed41ddbf0f157cd7c8ccc3bf Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 17:04:28 -0700 Subject: [PATCH 103/582] minor fix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index aa23325f0..5edc9d728 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -702,7 +702,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ //auto& tcc = *S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - auto& porosity = *S_->GetPtrW(poro_key_, water_tag, passwd_).ViewComponent("cell"); + auto& porosity = *S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell"); auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell"); auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell"); auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell"); From 0de896757bb9b395c7de74a9dd8f0c473140ecd9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 17:07:48 -0700 Subject: [PATCH 104/582] fixed header definition --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 1720a7dd6..09f9f846e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -142,7 +142,7 @@ class EcoSIM : public PK_Physical { Teuchos::Ptr depth, Teuchos::Ptr dz); - void ColumnToField_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, + void ColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector vec, Teuchos::Ptr col_vec); //evaluator for transpiration; //I don't think I need this anymore From 32bf8d490c8c61b3588782dbe7f316811ad3ee04 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 17:11:00 -0700 Subject: [PATCH 105/582] type definition fix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5edc9d728..5030ab5ee 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -487,7 +487,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector vec, { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { - vec[col_iter[i]] = (*col_vec)[i]; + vec[col_iter[i]] = (col_vec)[i]; } } From 7af34c54456da5052fb79a9370b54562d23bb747 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 17:14:22 -0700 Subject: [PATCH 106/582] ats --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5030ab5ee..429f5ca5c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -487,7 +487,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector vec, { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { - vec[col_iter[i]] = (col_vec)[i]; + *vec[col_iter[i]] = (*col_vec)[i]; } } From f22c142fa943953ec919be72198801aeb648a80c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 17:18:15 -0700 Subject: [PATCH 107/582] minor typo --- src/executables/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/executables/CMakeLists.txt b/src/executables/CMakeLists.txt index 175ff47fa..a548c0e78 100644 --- a/src/executables/CMakeLists.txt +++ b/src/executables/CMakeLists.txt @@ -126,7 +126,7 @@ set(ats_link_libs ats_mpc_relations ats_ecosim ats_ecosim_data - ats_ecisim_relations + ats_ecosim_relations ) From adcb1f7acae5f5654d9c06839048e2cc237ed90e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Mar 2023 17:21:28 -0700 Subject: [PATCH 108/582] removed unused function call --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 429f5ca5c..d4fd3f546 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -443,7 +443,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // Compute the next time step. // * will we need to do this? * - ComputeNextTimeStep(); + //ComputeNextTimeStep(); //return failed; From 1528751b4e2a830de28a7bbdd4dd76a4402fdb47 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 28 Mar 2023 15:46:42 -0700 Subject: [PATCH 109/582] adding a bunch of prints to figure out whats going on with initialize --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d4fd3f546..e1024d546 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -222,7 +222,9 @@ void EcoSIM::Initialize() { }*/ //Now we call the engine's init state function which allocates the data + std::cout << "\ninitializing BGC engine\n"; bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_); + std::cout << "\engine initialized\n"; //This function calls four separate functions from the interface: // AllocateAlquimiaProperties - Allocates the properties which are things // chemistry doesn't change @@ -233,7 +235,8 @@ void EcoSIM::Initialize() { // output (probably don't need for now) int ierr = 0; - // Ensure dependencies are filled + // Ensure dependencies are fille + std::cout << "\nfilling dependencies\n"; S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); @@ -249,18 +252,20 @@ void EcoSIM::Initialize() { S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + std::cout << "\ndependencies filled\n"; int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //This is the main set up code in alquimia it loops over times and chemical conditions //I don't know that we need the two initial loops. I'm just including them because we might + std::cout << "\ninitializing column loop\n"; for (int col=0; col!=num_cols_; ++col) { //FieldToColumn_(col, temp, col_temp.ptr()); //ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); //We're going to need to write an InitializeSingleColumn code //ierr = InitializeSingleCell(cell, condition); - + std::cout << "\ninitializing column "<< col <<" \n"; ierr = InitializeSingleColumn(col); //In Alquimia this function simply calls CopyToAlquimia, then //Calls the chemistry engine and enforces condition, then copies @@ -272,7 +277,7 @@ void EcoSIM::Initialize() { //To do this, but I think I will actually need to figure out a test //for this before I actually code it up } - + std::cout << "\nfinishing initialize\n"; // verbose message if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); From 0bfb4387fe05765662b7828663278dde88a3e14f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 29 Mar 2023 13:18:20 -0700 Subject: [PATCH 110/582] adding print statements to BGC engine --- src/pks/ecosim_pk/BGCEngine.cc | 3 +++ src/pks/ecosim_pk/BGCEngine.hh | 1 + src/pks/ecosim_pk/data/BGC_memory.c | 8 ++++++++ src/pks/ecosim_pk/data/BGC_memory.h | 1 + 4 files changed, 13 insertions(+) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 7b4c85640..e1e5a57c3 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -177,8 +177,11 @@ void BGCEngine::InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data) { + *vo_->os() << "Allocating prop" << std::endl; AllocateBGCProperties(&sizes_, &props); + *vo_->os() << "Allocating state" << std::endl; AllocateBGCState(&sizes_, &state); + *vo_->os() << "Allocating aux" << std::endl; AllocateBGCAuxiliaryData(&sizes_, &aux_data); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index e25065fee..16aee35f0 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -23,6 +23,7 @@ #include "BGC_memory.h" #include "BGC_containers.h" #include "BGC_constants.h" +#include "VerboseObject.hh" /*#include "alquimia/alquimia_util.h" #include "alquimia/alquimia_constants.h" #include "alquimia/alquimia_containers.h" diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index 89613cf51..6141e5434 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -154,12 +154,17 @@ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state) { + *vo_->os() << "Allocating State vectors with size" << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); + + *vo_->os() << "Finish fluid density" << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->porosity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); + + *vo_->os() << "Finished state allocation" << std::endl; //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateAlquimiaState() */ @@ -204,13 +209,16 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { *******************************************************************************/ void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props) { + *vo_->os() << "Allocating Prop vectors with size" << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); + *vo_->os() << "finished liquid sat" << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->gas_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->ice_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->elevation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->conductivity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); + *vo_->os() << "prop alloc" << std::endl; } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { diff --git a/src/pks/ecosim_pk/data/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.h index f53da8d64..3ea9b5bd7 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.h +++ b/src/pks/ecosim_pk/data/BGC_memory.h @@ -33,6 +33,7 @@ //#include "alquimia/alquimia_interface.h" //#include "alquimia/alquimia_containers.h" #include "BGC_containers.h" +#include "VerboseObject.hh" #ifdef __cplusplus extern "C" { From e03b5daed93e0d1b7fd7ad3d7bb87b45bcad53a4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 29 Mar 2023 13:47:50 -0700 Subject: [PATCH 111/582] adding string --- src/pks/ecosim_pk/data/BGC_memory.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/data/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.h index 3ea9b5bd7..8c1a5f584 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.h +++ b/src/pks/ecosim_pk/data/BGC_memory.h @@ -30,6 +30,7 @@ #ifndef BGC_C_MEMORY_H_ #define BGC_C_MEMORY_H_ +#include //#include "alquimia/alquimia_interface.h" //#include "alquimia/alquimia_containers.h" #include "BGC_containers.h" From 350bea9009063b82006bbf4cf6e89bbccfb860a4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 29 Mar 2023 15:27:53 -0700 Subject: [PATCH 112/582] what --- src/pks/ecosim_pk/data/BGC_memory.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.h index 8c1a5f584..3ea9b5bd7 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.h +++ b/src/pks/ecosim_pk/data/BGC_memory.h @@ -30,7 +30,6 @@ #ifndef BGC_C_MEMORY_H_ #define BGC_C_MEMORY_H_ -#include //#include "alquimia/alquimia_interface.h" //#include "alquimia/alquimia_containers.h" #include "BGC_containers.h" From aee65cd7ce3b081399de94f498d6f397961e6a46 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 29 Mar 2023 15:35:21 -0700 Subject: [PATCH 113/582] replacing with just cout --- src/pks/ecosim_pk/BGCEngine.hh | 1 - src/pks/ecosim_pk/data/BGC_memory.c | 12 ++++++------ src/pks/ecosim_pk/data/BGC_memory.h | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 16aee35f0..e25065fee 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -23,7 +23,6 @@ #include "BGC_memory.h" #include "BGC_containers.h" #include "BGC_constants.h" -#include "VerboseObject.hh" /*#include "alquimia/alquimia_util.h" #include "alquimia/alquimia_constants.h" #include "alquimia/alquimia_containers.h" diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index 6141e5434..3501eb0d0 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -154,17 +154,17 @@ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state) { - *vo_->os() << "Allocating State vectors with size" << ncells_per_col_ << std::endl; + std::cout << "Allocating State vectors with size" << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); - *vo_->os() << "Finish fluid density" << std::endl; + std::cout << "Finish fluid density" << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->porosity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); - *vo_->os() << "Finished state allocation" << std::endl; + std::cout << "Finished state allocation" << std::endl; //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateAlquimiaState() */ @@ -209,16 +209,16 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { *******************************************************************************/ void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props) { - *vo_->os() << "Allocating Prop vectors with size" << ncells_per_col_ << std::endl; + std::cout << "Allocating Prop vectors with size" << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); - *vo_->os() << "finished liquid sat" << std::endl; + std::cout << "finished liquid sat" << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->gas_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->ice_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->elevation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->conductivity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); - *vo_->os() << "prop alloc" << std::endl; + std::cout << "prop alloc" << std::endl; } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { diff --git a/src/pks/ecosim_pk/data/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.h index 3ea9b5bd7..f53da8d64 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.h +++ b/src/pks/ecosim_pk/data/BGC_memory.h @@ -33,7 +33,6 @@ //#include "alquimia/alquimia_interface.h" //#include "alquimia/alquimia_containers.h" #include "BGC_containers.h" -#include "VerboseObject.hh" #ifdef __cplusplus extern "C" { From de8e4fd4ae3a2f3d18359a827ee197e28097662a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 29 Mar 2023 15:35:40 -0700 Subject: [PATCH 114/582] missed file --- src/pks/ecosim_pk/BGCEngine.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index e1e5a57c3..4460b6b2c 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -177,11 +177,11 @@ void BGCEngine::InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data) { - *vo_->os() << "Allocating prop" << std::endl; + std::cout << "Allocating prop" << std::endl; AllocateBGCProperties(&sizes_, &props); - *vo_->os() << "Allocating state" << std::endl; + std::cout << "Allocating state" << std::endl; AllocateBGCState(&sizes_, &state); - *vo_->os() << "Allocating aux" << std::endl; + std::cout << "Allocating aux" << std::endl; AllocateBGCAuxiliaryData(&sizes_, &aux_data); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); From fcfd3daea670cf015e72849b09f38b593436be30 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 29 Mar 2023 15:43:51 -0700 Subject: [PATCH 115/582] changes to statements --- src/pks/ecosim_pk/data/BGC_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.c index 3501eb0d0..efb483796 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.c @@ -44,7 +44,8 @@ ** we set it to NULL. ** *******************************************************************************/ - + +#include #include "BGC_memory.h" #include "BGC_containers.h" #include "BGC_constants.h" From 1d6867701ae6a1cbe47ffd3160fb521c2dc99db1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 29 Mar 2023 15:50:04 -0700 Subject: [PATCH 116/582] renaming and reconfiguring --- src/pks/ecosim_pk/BGCEngine.hh | 6 +++--- .../data/{BGC_constants.c => BGC_constants.cc} | 2 +- .../data/{BGC_constants.h => BGC_constants.hh} | 0 .../data/{BGC_containers.h => BGC_containers.hh} | 0 src/pks/ecosim_pk/data/{BGC_memory.c => BGC_memory.cc} | 8 ++++---- src/pks/ecosim_pk/data/{BGC_memory.h => BGC_memory.hh} | 2 +- src/pks/ecosim_pk/data/CMakeLists.txt | 10 +++++----- 7 files changed, 14 insertions(+), 14 deletions(-) rename src/pks/ecosim_pk/data/{BGC_constants.c => BGC_constants.cc} (98%) rename src/pks/ecosim_pk/data/{BGC_constants.h => BGC_constants.hh} (100%) rename src/pks/ecosim_pk/data/{BGC_containers.h => BGC_containers.hh} (100%) rename src/pks/ecosim_pk/data/{BGC_memory.c => BGC_memory.cc} (99%) rename src/pks/ecosim_pk/data/{BGC_memory.h => BGC_memory.hh} (99%) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index e25065fee..7c4211e00 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -20,9 +20,9 @@ #include #include -#include "BGC_memory.h" -#include "BGC_containers.h" -#include "BGC_constants.h" +#include "BGC_memory.hh" +#include "BGC_containers.hh" +#include "BGC_constants.hh" /*#include "alquimia/alquimia_util.h" #include "alquimia/alquimia_constants.h" #include "alquimia/alquimia_containers.h" diff --git a/src/pks/ecosim_pk/data/BGC_constants.c b/src/pks/ecosim_pk/data/BGC_constants.cc similarity index 98% rename from src/pks/ecosim_pk/data/BGC_constants.c rename to src/pks/ecosim_pk/data/BGC_constants.cc index 2d7e98717..8d35ac4fb 100644 --- a/src/pks/ecosim_pk/data/BGC_constants.c +++ b/src/pks/ecosim_pk/data/BGC_constants.cc @@ -28,7 +28,7 @@ */ -#include "BGC_constants.h" +#include "BGC_constants.hh" /* String lengths */ const int kBGCMaxStringLength = 512; diff --git a/src/pks/ecosim_pk/data/BGC_constants.h b/src/pks/ecosim_pk/data/BGC_constants.hh similarity index 100% rename from src/pks/ecosim_pk/data/BGC_constants.h rename to src/pks/ecosim_pk/data/BGC_constants.hh diff --git a/src/pks/ecosim_pk/data/BGC_containers.h b/src/pks/ecosim_pk/data/BGC_containers.hh similarity index 100% rename from src/pks/ecosim_pk/data/BGC_containers.h rename to src/pks/ecosim_pk/data/BGC_containers.hh diff --git a/src/pks/ecosim_pk/data/BGC_memory.c b/src/pks/ecosim_pk/data/BGC_memory.cc similarity index 99% rename from src/pks/ecosim_pk/data/BGC_memory.c rename to src/pks/ecosim_pk/data/BGC_memory.cc index efb483796..2c671be77 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.c +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -44,11 +44,11 @@ ** we set it to NULL. ** *******************************************************************************/ - + #include -#include "BGC_memory.h" -#include "BGC_containers.h" -#include "BGC_constants.h" +#include "BGC_memory.hh" +#include "BGC_containers.hh" +#include "BGC_constants.hh" //#include "alquimia/alquimia_interface.h" //#include "alquimia/alquimia_constants.h" //#include "alquimia/alquimia_containers.h" diff --git a/src/pks/ecosim_pk/data/BGC_memory.h b/src/pks/ecosim_pk/data/BGC_memory.hh similarity index 99% rename from src/pks/ecosim_pk/data/BGC_memory.h rename to src/pks/ecosim_pk/data/BGC_memory.hh index f53da8d64..6f3e8bfc1 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.h +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -32,7 +32,7 @@ //#include "alquimia/alquimia_interface.h" //#include "alquimia/alquimia_containers.h" -#include "BGC_containers.h" +#include "BGC_containers.hh" #ifdef __cplusplus extern "C" { diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index 725582412..cd99a852c 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -6,13 +6,13 @@ # collect all sources set(ats_ecosim_data_src_files - BGC_constants.c - BGC_memory.c + BGC_constants.cc + BGC_memory.cc ) set(ats_ecosim_data_inc_files - BGC_constants.h - BGC_containers.h - BGC_memory.h + BGC_constants.hh + BGC_containers.hh + BGC_memory.hh ) set(ats_ecosim_data_link_libs From 942820b77f00f3e064b5052946dcbcf11712b303 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 12:53:47 -0700 Subject: [PATCH 117/582] Adding the definition of sizes to prevent hanging --- src/pks/ecosim_pk/BGCEngine.cc | 9 +++++---- src/pks/ecosim_pk/BGCEngine.hh | 3 ++- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/data/BGC_memory.cc | 9 ++++++--- src/pks/ecosim_pk/data/BGC_memory.hh | 9 ++++++--- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 4460b6b2c..da96a116c 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -175,14 +175,15 @@ BGCEngine::Sizes() const void BGCEngine::InitState(BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data) + BGCAuxiliaryData& aux_data + int& ncells_per_col_) { std::cout << "Allocating prop" << std::endl; - AllocateBGCProperties(&sizes_, &props); + AllocateBGCProperties(&sizes_, &props, &ncells_per_col_); std::cout << "Allocating state" << std::endl; - AllocateBGCState(&sizes_, &state); + AllocateBGCState(&sizes_, &state, &ncells_per_col_); std::cout << "Allocating aux" << std::endl; - AllocateBGCAuxiliaryData(&sizes_, &aux_data); + AllocateBGCAuxiliaryData(&sizes_, &aux_data, &ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); // Make sure the auxiliary ints/doubles are zeroed out. diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 7c4211e00..10f6e911d 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -53,7 +53,8 @@ class BGCEngine { // Initializes the data structures that hold the chemical state information. void InitState(BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data); + BGCAuxiliaryData& aux_data + int& ncells_per_col_); // Frees the data structures that hold the chemical state information. void FreeState(BGCProperties& props, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e1024d546..bf5083bf8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -223,7 +223,7 @@ void EcoSIM::Initialize() { //Now we call the engine's init state function which allocates the data std::cout << "\ninitializing BGC engine\n"; - bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_); + bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_); std::cout << "\engine initialized\n"; //This function calls four separate functions from the interface: // AllocateAlquimiaProperties - Allocates the properties which are things diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 2c671be77..ead7c6a84 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -154,7 +154,8 @@ For reference the old function call was: void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ -void AllocateBGCState(const BGCSizes* const sizes, BGCState* state) { +void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, + const int* const ncells_per_col_) { std::cout << "Allocating State vectors with size" << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); @@ -187,7 +188,8 @@ void FreeBGCState(BGCState* state) { ** *******************************************************************************/ -void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data) { +void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, + const int* const ncells_per_col_) { AllocateBGCVectorInt(sizes->ncells_per_col_, &(aux_data->aux_ints)); @@ -209,7 +211,8 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { ** *******************************************************************************/ -void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props) { +void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props, + const int* const ncells_per_col_) { std::cout << "Allocating Prop vectors with size" << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); std::cout << "finished liquid sat" << std::endl; diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index 6f3e8bfc1..f93c55586 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -50,17 +50,20 @@ extern "C" { /* State */ void AllocateBGCState(const BGCSizes* const sizes, - BGCState* state); + BGCState* state, + const int* const ncells_per_col_); void FreeBGCState(BGCState* state); /* Auxiliary Data */ void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, - BGCAuxiliaryData* aux_data); + BGCAuxiliaryData* aux_data, + const int* const ncells_per_col_); void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data); /* Properties */ void AllocateBGCProperties(const BGCSizes* const sizes, - BGCProperties* props); + BGCProperties* props, + const int* const ncells_per_col_); void FreeBGCProperties(BGCProperties* props); // Problem Meta Data From 95c38cf4012f8629ee732cb3cd4a4794290575d7 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 14:20:17 -0700 Subject: [PATCH 118/582] typo fix --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- src/pks/ecosim_pk/BGCEngine.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index da96a116c..057cd822c 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -175,7 +175,7 @@ BGCEngine::Sizes() const void BGCEngine::InitState(BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data + BGCAuxiliaryData& aux_data, int& ncells_per_col_) { std::cout << "Allocating prop" << std::endl; diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 10f6e911d..8b1318726 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -53,7 +53,7 @@ class BGCEngine { // Initializes the data structures that hold the chemical state information. void InitState(BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data + BGCAuxiliaryData& aux_data, int& ncells_per_col_); // Frees the data structures that hold the chemical state information. From 899d4dd7405909154d5e71d61ebb1cd57d9f106b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 15:04:00 -0700 Subject: [PATCH 119/582] testing pointer --- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/data/BGC_memory.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 8b1318726..d4687339c 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -54,7 +54,7 @@ class BGCEngine { void InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& ncells_per_col_); + int& ncells_per_col_); // Frees the data structures that hold the chemical state information. void FreeState(BGCProperties& props, diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index ead7c6a84..652c83f75 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -156,7 +156,7 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, const int* const ncells_per_col_) { - std::cout << "Allocating State vectors with size" << ncells_per_col_ << std::endl; + std::cout << "Allocating State vectors with size " << *ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); std::cout << "Finish fluid density" << std::endl; From 4f491651c290177f02fac2a92a180f6bbf385e82 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 15:18:09 -0700 Subject: [PATCH 120/582] more testing pointers --- src/pks/ecosim_pk/BGCEngine.cc | 1 + src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 ++- src/pks/ecosim_pk/data/BGC_memory.cc | 4 ++-- src/pks/ecosim_pk/data/BGC_memory.hh | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 057cd822c..58c69b3d2 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -179,6 +179,7 @@ void BGCEngine::InitState(BGCProperties& props, int& ncells_per_col_) { std::cout << "Allocating prop" << std::endl; + std::cout << "size: " << ncells_per_col_ << std::endl; AllocateBGCProperties(&sizes_, &props, &ncells_per_col_); std::cout << "Allocating state" << std::endl; AllocateBGCState(&sizes_, &state, &ncells_per_col_); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index bf5083bf8..1e49bdd95 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -222,7 +222,8 @@ void EcoSIM::Initialize() { }*/ //Now we call the engine's init state function which allocates the data - std::cout << "\ninitializing BGC engine\n"; + std::cout << "\ninitializing BGC engine with: " << ncells_per_col_ << "\n"; + bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_); std::cout << "\engine initialized\n"; //This function calls four separate functions from the interface: diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 652c83f75..2ef813c81 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -155,8 +155,8 @@ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, - const int* const ncells_per_col_) { - std::cout << "Allocating State vectors with size " << *ncells_per_col_ << std::endl; + int ncells_per_col_) { + std::cout << "Allocating State vectors with size " << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); std::cout << "Finish fluid density" << std::endl; diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index f93c55586..46bc21306 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -51,7 +51,7 @@ extern "C" { /* State */ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, - const int* const ncells_per_col_); + int ncells_per_col_); void FreeBGCState(BGCState* state); /* Auxiliary Data */ From ae9cc315d2fa5c9b6b6c5493b4b16d719bb1caa5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 15:49:33 -0700 Subject: [PATCH 121/582] dereferencing --- src/pks/ecosim_pk/data/BGC_memory.cc | 4 ++-- src/pks/ecosim_pk/data/BGC_memory.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 2ef813c81..e9051037a 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -155,8 +155,8 @@ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, - int ncells_per_col_) { - std::cout << "Allocating State vectors with size " << ncells_per_col_ << std::endl; + int* ncells_per_col_) { + std::cout << "Allocating State vectors with size " << *ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); std::cout << "Finish fluid density" << std::endl; diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index 46bc21306..da13d2bcf 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -51,7 +51,7 @@ extern "C" { /* State */ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, - int ncells_per_col_); + int* ncells_per_col_); void FreeBGCState(BGCState* state); /* Auxiliary Data */ From 6abf1f2eeae93f866e2157c5baadcf9a1a81af36 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 16:57:56 -0700 Subject: [PATCH 122/582] test --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- src/pks/ecosim_pk/BGCEngine.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 58c69b3d2..a40fd8ae5 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -180,7 +180,7 @@ void BGCEngine::InitState(BGCProperties& props, { std::cout << "Allocating prop" << std::endl; std::cout << "size: " << ncells_per_col_ << std::endl; - AllocateBGCProperties(&sizes_, &props, &ncells_per_col_); + AllocateBGCProperties(&sizes_, &props, ncells_per_col_); std::cout << "Allocating state" << std::endl; AllocateBGCState(&sizes_, &state, &ncells_per_col_); std::cout << "Allocating aux" << std::endl; diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index d4687339c..4314a9413 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -54,7 +54,7 @@ class BGCEngine { void InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& ncells_per_col_); + int ncells_per_col_); // Frees the data structures that hold the chemical state information. void FreeState(BGCProperties& props, From 3a10b9dbfda68c3b7f43799dbf66cc39245a3629 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 17:17:54 -0700 Subject: [PATCH 123/582] typo --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index a40fd8ae5..0934b77e6 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -176,7 +176,7 @@ BGCEngine::Sizes() const void BGCEngine::InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& ncells_per_col_) + int ncells_per_col_) { std::cout << "Allocating prop" << std::endl; std::cout << "size: " << ncells_per_col_ << std::endl; From f50ae969c8c911f89077fdb1c1afc65f4645043c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 17:25:28 -0700 Subject: [PATCH 124/582] changes to other functions --- src/pks/ecosim_pk/data/BGC_memory.cc | 2 +- src/pks/ecosim_pk/data/BGC_memory.hh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index e9051037a..7eee88765 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -189,7 +189,7 @@ void FreeBGCState(BGCState* state) { *******************************************************************************/ void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, - const int* const ncells_per_col_) { + int* ncells_per_col_) { AllocateBGCVectorInt(sizes->ncells_per_col_, &(aux_data->aux_ints)); diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index da13d2bcf..9db1e8fb9 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -57,13 +57,13 @@ extern "C" { /* Auxiliary Data */ void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, - const int* const ncells_per_col_); + int* ncells_per_col_); void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data); /* Properties */ void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props, - const int* const ncells_per_col_); + int* ncells_per_col_); void FreeBGCProperties(BGCProperties* props); // Problem Meta Data From 7c8ff3a17b8503699b77323d9da136cb773ecbc6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 17:30:40 -0700 Subject: [PATCH 125/582] type annoyances --- src/pks/ecosim_pk/data/BGC_memory.cc | 6 +++--- src/pks/ecosim_pk/data/BGC_memory.hh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 7eee88765..0e014eaf7 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -155,7 +155,7 @@ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, - int* ncells_per_col_) { + int ncells_per_col_) { std::cout << "Allocating State vectors with size " << *ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); @@ -189,7 +189,7 @@ void FreeBGCState(BGCState* state) { *******************************************************************************/ void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, - int* ncells_per_col_) { + int ncells_per_col_) { AllocateBGCVectorInt(sizes->ncells_per_col_, &(aux_data->aux_ints)); @@ -212,7 +212,7 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { *******************************************************************************/ void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props, - const int* const ncells_per_col_) { + int ncells_per_col_) { std::cout << "Allocating Prop vectors with size" << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); std::cout << "finished liquid sat" << std::endl; diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index 9db1e8fb9..b534f8fac 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -51,19 +51,19 @@ extern "C" { /* State */ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, - int* ncells_per_col_); + int ncells_per_col_); void FreeBGCState(BGCState* state); /* Auxiliary Data */ void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, - int* ncells_per_col_); + int ncells_per_col_); void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data); /* Properties */ void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props, - int* ncells_per_col_); + int ncells_per_col_); void FreeBGCProperties(BGCProperties* props); // Problem Meta Data From f975bfb4338c8bac188dc37ffafe3280159beeec Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 17:35:45 -0700 Subject: [PATCH 126/582] typo --- src/pks/ecosim_pk/data/BGC_memory.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 0e014eaf7..d591a815d 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -156,7 +156,7 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, int ncells_per_col_) { - std::cout << "Allocating State vectors with size " << *ncells_per_col_ << std::endl; + std::cout << "Allocating State vectors with size " << ncells_per_col_ << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); std::cout << "Finish fluid density" << std::endl; From 711fecbc7dccd7236f37d0ab2ce18eb0ef9986a3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 17:39:01 -0700 Subject: [PATCH 127/582] typo --- src/pks/ecosim_pk/BGCEngine.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 0934b77e6..86209ec0f 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -182,9 +182,9 @@ void BGCEngine::InitState(BGCProperties& props, std::cout << "size: " << ncells_per_col_ << std::endl; AllocateBGCProperties(&sizes_, &props, ncells_per_col_); std::cout << "Allocating state" << std::endl; - AllocateBGCState(&sizes_, &state, &ncells_per_col_); + AllocateBGCState(&sizes_, &state, ncells_per_col_); std::cout << "Allocating aux" << std::endl; - AllocateBGCAuxiliaryData(&sizes_, &aux_data, &ncells_per_col_); + AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); // Make sure the auxiliary ints/doubles are zeroed out. From 1ebca24603220a5cdea21499b5146496d9cc8785 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 17:54:13 -0700 Subject: [PATCH 128/582] adding more print statements --- src/pks/ecosim_pk/data/BGC_memory.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index d591a815d..30cea0627 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -69,9 +69,14 @@ static inline int nearest_power_of_2(int n) ** *******************************************************************************/ void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { + std::cout << "Allocating vector double size: " << size << std::endl; + std::cout << "vector" << vector << std::endl; if (size > 0) { + std::cout << "Allocating size" << std::endl; vector->size = size; + std::cout << "Allocating capacity" << std::endl; vector->capacity = nearest_power_of_2(size); + std::cout << "setting data" << std::endl; vector->data = (double*) calloc((size_t)vector->capacity, sizeof(double)); //ALQUIMIA_ASSERT(NULL != vector->data); } else { From 984191c81e171cf10bf7b7fca10eea94b18e7dbf Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 18:15:29 -0700 Subject: [PATCH 129/582] more testing --- src/pks/ecosim_pk/data/BGC_memory.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 30cea0627..6bea60356 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -70,7 +70,7 @@ static inline int nearest_power_of_2(int n) *******************************************************************************/ void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { std::cout << "Allocating vector double size: " << size << std::endl; - std::cout << "vector" << vector << std::endl; + std::cout << "vector" << *vector << std::endl; if (size > 0) { std::cout << "Allocating size" << std::endl; vector->size = size; From fe6bd14cecaa101299577bbef25a96345ade686c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Mar 2023 18:23:00 -0700 Subject: [PATCH 130/582] printing vec --- src/pks/ecosim_pk/data/BGC_memory.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 6bea60356..9bac702ff 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -70,7 +70,12 @@ static inline int nearest_power_of_2(int n) *******************************************************************************/ void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { std::cout << "Allocating vector double size: " << size << std::endl; - std::cout << "vector" << *vector << std::endl; + std::cout << "vector" << vector << std::endl; + + for (int j = 0; i < *vector.size(); i++){ + std::cout << "element " << j << ": " << *vector[j] << std::endl; + } + if (size > 0) { std::cout << "Allocating size" << std::endl; vector->size = size; From 457af7a9693e84507b3f90f5a0e2c8b22235470f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 13:33:41 -0700 Subject: [PATCH 131/582] reworking the memory size allocation --- src/pks/ecosim_pk/data/BGC_memory.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 9bac702ff..6bc34c197 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -72,7 +72,7 @@ void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { std::cout << "Allocating vector double size: " << size << std::endl; std::cout << "vector" << vector << std::endl; - for (int j = 0; i < *vector.size(); i++){ + for (int j = 0; j < *vector->size; j++){ std::cout << "element " << j << ": " << *vector[j] << std::endl; } @@ -167,6 +167,7 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, int ncells_per_col_) { std::cout << "Allocating State vectors with size " << ncells_per_col_ << std::endl; + sizes.ncells_per_col_ = ncells_per_col_; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); std::cout << "Finish fluid density" << std::endl; From d3290674fe674f826679b6bfe80d5909cbfaa6e5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 13:52:11 -0700 Subject: [PATCH 132/582] reworking memory --- src/pks/ecosim_pk/data/BGC_memory.cc | 10 ++++++---- src/pks/ecosim_pk/data/BGC_memory.hh | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 6bc34c197..097a6ddb8 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -71,11 +71,11 @@ static inline int nearest_power_of_2(int n) void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { std::cout << "Allocating vector double size: " << size << std::endl; std::cout << "vector" << vector << std::endl; - + /* for (int j = 0; j < *vector->size; j++){ std::cout << "element " << j << ": " << *vector[j] << std::endl; } - + */ if (size > 0) { std::cout << "Allocating size" << std::endl; vector->size = size; @@ -164,7 +164,7 @@ For reference the old function call was: void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ -void AllocateBGCState(const BGCSizes* const sizes, BGCState* state, +void AllocateBGCState(BGCSizes* sizes, BGCState* state, int ncells_per_col_) { std::cout << "Allocating State vectors with size " << ncells_per_col_ << std::endl; sizes.ncells_per_col_ = ncells_per_col_; @@ -222,9 +222,11 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { ** *******************************************************************************/ -void AllocateBGCProperties(const BGCSizes* const sizes, BGCProperties* props, +void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, int ncells_per_col_) { std::cout << "Allocating Prop vectors with size" << ncells_per_col_ << std::endl; + sizes.ncells_per_col_ = ncells_per_col_; + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); std::cout << "finished liquid sat" << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->gas_saturation)); diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index b534f8fac..24c3aafd7 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -49,7 +49,7 @@ extern "C" { void FreeBGCVectorString(BGCVectorString* vector); /* State */ - void AllocateBGCState(const BGCSizes* const sizes, + void AllocateBGCState(BGCSizes* sizes, BGCState* state, int ncells_per_col_); void FreeBGCState(BGCState* state); @@ -61,7 +61,7 @@ extern "C" { void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data); /* Properties */ - void AllocateBGCProperties(const BGCSizes* const sizes, + void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, int ncells_per_col_); void FreeBGCProperties(BGCProperties* props); From ecec9d4970b48083f97d82e71c9174a2e9031da9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 14:18:05 -0700 Subject: [PATCH 133/582] lets try this again --- src/pks/ecosim_pk/data/BGC_memory.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 097a6ddb8..b9ea7ecb2 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -167,7 +167,7 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCState(BGCSizes* sizes, BGCState* state, int ncells_per_col_) { std::cout << "Allocating State vectors with size " << ncells_per_col_ << std::endl; - sizes.ncells_per_col_ = ncells_per_col_; + sizes->ncells_per_col_ = ncells_per_col_; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); std::cout << "Finish fluid density" << std::endl; @@ -225,7 +225,7 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, int ncells_per_col_) { std::cout << "Allocating Prop vectors with size" << ncells_per_col_ << std::endl; - sizes.ncells_per_col_ = ncells_per_col_; + sizes->ncells_per_col_ = ncells_per_col_; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); std::cout << "finished liquid sat" << std::endl; From d618c358b43d972e53b4cd06fbbe1d22321df839 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 15:15:57 -0700 Subject: [PATCH 134/582] removing elevation for now --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 1e49bdd95..72bac3a5d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -59,7 +59,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_liquid_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); saturation_gas_key_ = Keys::readKey(*plist_,domain_,"saturation gas", "saturation_gas"); saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); - elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); + //elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeabiilty","relative_permeability"); @@ -243,7 +243,7 @@ void EcoSIM::Initialize() { S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -327,7 +327,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -372,9 +372,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& ice_saturation = *S_->Get("saturation_ice", tag_next_) .ViewComponent("cell",false); - S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) - .ViewComponent("cell",false); + //S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) + // .ViewComponent("cell",false); S_->GetEvaluator("water_content", tag_next_).Update(*S_, name_); const Epetra_MultiVector& water_content = *S_->Get("water_content", tag_next_) @@ -565,7 +565,7 @@ void EcoSIM::CopyToEcoSIM(int col, const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); const auto& gas_saturation = *S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", true); const auto& ice_saturation = *S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", true); - const auto& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", true); + //const auto& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", true); const auto& water_content = *S_->Get(water_content_key_, water_tag).ViewComponent("cell", true); const auto& relative_permeability = *S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", true); const auto& liquid_density = *S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", true); @@ -582,7 +582,7 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -603,7 +603,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); - FieldToColumn_(col,elevation,col_elev.ptr()); + //FieldToColumn_(col,elevation,col_elev.ptr()); FieldToColumn_(col,water_content,col_wc.ptr()); FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); FieldToColumn_(col,liquid_density,col_f_dens.ptr()); @@ -629,7 +629,7 @@ void EcoSIM::CopyToEcoSIM(int col, props.liquid_saturation.data[i] = (*col_l_sat)[i]; props.gas_saturation.data[i] = (*col_g_sat)[i]; props.ice_saturation.data[i] = (*col_i_sat)[i]; - props.elevation.data[i] = (*col_elev)[i]; + //props.elevation.data[i] = (*col_elev)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; props.conductivity.data[i] = (*col_cond)[i]; props.volume.data[i] = (*col_vol)[i]; @@ -712,7 +712,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell"); auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell"); auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell"); - auto& elevation = *S_->GetW(elev_key_, water_tag, passwd_).ViewComponent("cell"); + //auto& elevation = *S_->GetW(elev_key_, water_tag, passwd_).ViewComponent("cell"); auto& water_content = *S_->GetW(water_content_key_, water_tag, passwd_).ViewComponent("cell"); auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag, passwd_).ViewComponent("cell"); auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag, passwd_).ViewComponent("cell"); @@ -729,7 +729,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -753,7 +753,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_l_sat)[i] = props.liquid_saturation.data[i]; (*col_g_sat)[i] = props.gas_saturation.data[i]; (*col_i_sat)[i] = props.ice_saturation.data[i]; - (*col_elev)[i] = props.elevation.data[i]; + //(*col_elev)[i] = props.elevation.data[i]; (*col_rel_perm)[i] = props.relative_permeability.data[i]; (*col_cond)[i] = props.conductivity.data[i]; (*col_vol)[i] = props.volume.data[i]; @@ -787,7 +787,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); ColumnToField_(col,gas_saturation,col_g_sat.ptr()); ColumnToField_(col,ice_saturation,col_i_sat.ptr()); - ColumnToField_(col,elevation,col_elev.ptr()); + //ColumnToField_(col,elevation,col_elev.ptr()); ColumnToField_(col,water_content,col_wc.ptr()); ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); ColumnToField_(col,liquid_density,col_f_dens.ptr()); From ecde0570a426d618799583584519e528482c716b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 15:29:20 -0700 Subject: [PATCH 135/582] replacing mass ice density --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 72bac3a5d..606c17c81 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -51,6 +51,12 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // /src/constitutive_relations/column_integrators/ but I don't see it used // anywhere can we just use it here? + + //For now a few of the evaluators don't work because they are no initialized + // I've commented out elevation and replaced others with something that does + //exist: + // + // mass_density_ice // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); @@ -72,7 +78,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // f_ice = S_ice * porosity liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); - ice_den_key_ = Keys::readKey(*plist_, domain_, "ice mass density", "mass_density_ice"); + ice_den_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); gas_den_key_ = Keys::readKey(*plist_, domain_,"gas mass density", "mass_density_gas"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); From c7a3f2336c85a6326f050d2b66149ef65979eb29 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 15:38:40 -0700 Subject: [PATCH 136/582] replacing mass gas density --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 606c17c81..e0550dd4e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -57,6 +57,9 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //exist: // // mass_density_ice + // mass_gas_density + // + // // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); @@ -79,7 +82,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_den_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); - gas_den_key_ = Keys::readKey(*plist_, domain_,"gas mass density", "mass_density_gas"); + gas_den_key_ = Keys::readKey(*plist_, domain_,"porosity", "porosity"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); //energy From d6f717f3210a08aa6ce35f3b1c736e022e0f663f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 15:51:45 -0700 Subject: [PATCH 137/582] lots of print statements --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e0550dd4e..86b0f3ac3 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -569,6 +569,7 @@ void EcoSIM::CopyToEcoSIM(int col, { //Fill state with ATS variables that are going to be changed by EcoSIM //NEED TO DECIDE WHICH PROPERTIES GO WHERE + std::cout << "\viewing components\n"; const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); @@ -586,6 +587,7 @@ void EcoSIM::CopyToEcoSIM(int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); //Define the column vectors to hold the data + std::cout << "\ncreating column vectors\n"; auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -608,6 +610,7 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(column index, dataset to copy from, vector to put the data in) //FieldToColumn_(col,tcc,col_tcc.ptr()); + std::cout << "\nCopying Amanzi field to column vector\n"; FieldToColumn_(col,porosity,col_poro.ptr()); FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); @@ -627,7 +630,9 @@ void EcoSIM::CopyToEcoSIM(int col, // structures. Eventually I could probably rewrite FieldToColumn_ to do this // automatically, but I just want to test this for now + std::cout << "\nlooping over cells and copying to EcoSIM data structure\n"; for (int i=0; i < ncells_per_col_; ++i) { + std::cout << "\nlooping through cell " << i << "\n"; state.fluid_density.data[i] = (*col_f_dens)[i]; state.gas_density.data[i] = (*col_g_dens)[i]; state.ice_density.data[i] = (*col_i_dens)[i]; @@ -644,6 +649,7 @@ void EcoSIM::CopyToEcoSIM(int col, props.volume.data[i] = (*col_vol)[i]; } + std::cout << "\nFinished loop\n"; //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; @@ -817,13 +823,15 @@ int EcoSIM::InitializeSingleColumn(int col) { // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but // should use the same tag as transport. See #673 + std::cout << "\nCopying to EcoSIM\n"; CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + std::cout << "\nFinished Copying to EcoSIM\n"; //bgc_engine_->EnforceCondition(condition, current_time_, bgc_props_, // bgc_state_, bgc_aux_data_); - + std::cout << "\nCopying back to Amanzi\n"; CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - + std::cout << "\nFinished copying to Amanzi\n"; // ETC: hacking to get consistent solution -- if there is no water // (e.g. surface system, we still need to call EnforceCondition() as it also From 774f0f2796b25c2d92e95605f612eb3b4cb02c7c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 15:57:04 -0700 Subject: [PATCH 138/582] more statements --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 86b0f3ac3..da48a8371 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -569,7 +569,7 @@ void EcoSIM::CopyToEcoSIM(int col, { //Fill state with ATS variables that are going to be changed by EcoSIM //NEED TO DECIDE WHICH PROPERTIES GO WHERE - std::cout << "\viewing components\n"; + std::cout << "\nviewing components\n"; const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); @@ -587,7 +587,7 @@ void EcoSIM::CopyToEcoSIM(int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); //Define the column vectors to hold the data - std::cout << "\ncreating column vectors\n"; + std::cout << "\ncreating column vectors with size: "<< ncells_per_col_ <<\n"; auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 9069fb0bb5634597fafa3d7768281334ad486fd1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 16:02:52 -0700 Subject: [PATCH 139/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index da48a8371..98e88a96e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -587,8 +587,9 @@ void EcoSIM::CopyToEcoSIM(int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); //Define the column vectors to hold the data - std::cout << "\ncreating column vectors with size: "<< ncells_per_col_ <<\n"; + std::cout << "\ncreating column vectors with size: "<< ncells_per_col_ << "\n"; auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + std::cout << "\ncreated first column\n"; auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 7222b1a1e3168094face423806af2615bfc84a8f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 16:15:16 -0700 Subject: [PATCH 140/582] further tests --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 98e88a96e..82313cf60 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -613,6 +613,7 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(col,tcc,col_tcc.ptr()); std::cout << "\nCopying Amanzi field to column vector\n"; FieldToColumn_(col,porosity,col_poro.ptr()); + std::cout << "\npushed first column\n"; FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); From 1043a1cbee4a568589dee7d3cccfcd765cee5cb2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 16:52:18 -0700 Subject: [PATCH 141/582] more print --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 82313cf60..bb2e51333 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -476,9 +476,12 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& if (col_vec == Teuchos::null) { col_vec = Teuchos::ptr(new Epetra_SerialDenseVector(ncells_per_col_)); } - + std::cout << "\ncol: "<< col <<""\n"; auto& col_iter = mesh_->cells_of_column(col); + std::cout << "\ncol_iter: "<< col_iter.size() <<""\n"; for (std::size_t i=0; i!=col_iter.size(); ++i) { + std::cout << "\col_vec: "<< col_vec[i] <<""\n"; + std::cout << "\vec col_vec: "<< vec[col_iter[i]] <<""\n"; (*col_vec)[i] = *vec[col_iter[i]]; } } From d28cd2b613c1f71167e2c45127b2a3deb9e2a6cf Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 16:59:51 -0700 Subject: [PATCH 142/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index bb2e51333..8e4cbaca8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -476,12 +476,12 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& if (col_vec == Teuchos::null) { col_vec = Teuchos::ptr(new Epetra_SerialDenseVector(ncells_per_col_)); } - std::cout << "\ncol: "<< col <<""\n"; + std::cout << "\ncol: "<< col <<"\n"; auto& col_iter = mesh_->cells_of_column(col); - std::cout << "\ncol_iter: "<< col_iter.size() <<""\n"; + std::cout << "\ncol_iter: "<< col_iter.size() <<"\n"; for (std::size_t i=0; i!=col_iter.size(); ++i) { - std::cout << "\col_vec: "<< col_vec[i] <<""\n"; - std::cout << "\vec col_vec: "<< vec[col_iter[i]] <<""\n"; + std::cout << "\col_vec: "<< col_vec[i] <<"\n"; + std::cout << "\vec col_vec: "<< vec[col_iter[i]] <<"\n"; (*col_vec)[i] = *vec[col_iter[i]]; } } From 9c06b1c0c61a49c7fa51870fa2e1349fc758e064 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 3 Apr 2023 17:06:20 -0700 Subject: [PATCH 143/582] test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 8e4cbaca8..b9a9c218c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -480,8 +480,8 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& auto& col_iter = mesh_->cells_of_column(col); std::cout << "\ncol_iter: "<< col_iter.size() <<"\n"; for (std::size_t i=0; i!=col_iter.size(); ++i) { - std::cout << "\col_vec: "<< col_vec[i] <<"\n"; - std::cout << "\vec col_vec: "<< vec[col_iter[i]] <<"\n"; + std::cout << "\col_vec: "<< (*col_vec)[i] <<"\n"; + std::cout << "\vec col_vec: "<< *vec[col_iter[i]] <<"\n"; (*col_vec)[i] = *vec[col_iter[i]]; } } From b46236ca9a741e5eb5ce5b99c3d06e0979174a67 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 4 Apr 2023 11:10:06 -0700 Subject: [PATCH 144/582] more printing tests --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 24 +++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b9a9c218c..b8427018d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -479,9 +479,29 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& std::cout << "\ncol: "<< col <<"\n"; auto& col_iter = mesh_->cells_of_column(col); std::cout << "\ncol_iter: "<< col_iter.size() <<"\n"; + + if (col_vec == nullptr) { + std::cout << "Error col_vec pointer is null\n"; + } + + if (vec == nullptr) { + std::cout << "Error vec pointer is null\n"; + } + for (std::size_t i=0; i!=col_iter.size(); ++i) { - std::cout << "\col_vec: "<< (*col_vec)[i] <<"\n"; - std::cout << "\vec col_vec: "<< *vec[col_iter[i]] <<"\n"; + + if (i >= col_vec->size()) { + std::cout << "Error: index " << i << " is out of bounds for col_vec\n"; + } + + std::size_t vec_index = col_iter[i]; + if (vec_index >= vec->size()) { + std::cout << "Error: index " << vec_index << " is out of bounds for vec\n"; + } + + std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; + std::cout << "vec[" << vec_index << "]: " << *vec[vec_index] << "\n"; + (*col_vec)[i] = *vec[col_iter[i]]; } } From 7c5e0847ccfb4fb12e402fe5d028ffc5702d38b2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 4 Apr 2023 11:35:17 -0700 Subject: [PATCH 145/582] modifications --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b8427018d..3ee9bfb31 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -480,17 +480,9 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& auto& col_iter = mesh_->cells_of_column(col); std::cout << "\ncol_iter: "<< col_iter.size() <<"\n"; - if (col_vec == nullptr) { - std::cout << "Error col_vec pointer is null\n"; - } - - if (vec == nullptr) { - std::cout << "Error vec pointer is null\n"; - } - for (std::size_t i=0; i!=col_iter.size(); ++i) { - if (i >= col_vec->size()) { + if (i >= col_vec->Size()) { std::cout << "Error: index " << i << " is out of bounds for col_vec\n"; } From 6c8761bd1f7f74c1b042a1065abc9fa3c30f2ba7 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 4 Apr 2023 11:57:45 -0700 Subject: [PATCH 146/582] another test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3ee9bfb31..9bda0f31a 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -482,7 +482,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& for (std::size_t i=0; i!=col_iter.size(); ++i) { - if (i >= col_vec->Size()) { + if (i >= col_vec->Length()) { std::cout << "Error: index " << i << " is out of bounds for col_vec\n"; } From 1a48bc3dd4c9c3387971cb143acbe0cefeda14e4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 4 Apr 2023 12:01:09 -0700 Subject: [PATCH 147/582] more testing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 9bda0f31a..b0d09fb9c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -487,7 +487,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& } std::size_t vec_index = col_iter[i]; - if (vec_index >= vec->size()) { + if (vec_index >= vec->MyLength()) { std::cout << "Error: index " << vec_index << " is out of bounds for vec\n"; } From baa155ec4c5ef823c805f995552b7f36b0a02783 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 4 Apr 2023 12:12:12 -0700 Subject: [PATCH 148/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b0d09fb9c..f00d596b7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -487,7 +487,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& } std::size_t vec_index = col_iter[i]; - if (vec_index >= vec->MyLength()) { + if (vec_index >= vec.MyLength()) { std::cout << "Error: index " << vec_index << " is out of bounds for vec\n"; } From e56cf56ae4ae892a65f2aa7c74a5b60a27ec0c4d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 4 Apr 2023 16:45:18 -0700 Subject: [PATCH 149/582] trying another test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f00d596b7..ac158f754 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -492,7 +492,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& } std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; - std::cout << "vec[" << vec_index << "]: " << *vec[vec_index] << "\n"; + //std::cout << "vec[" << vec_index << "]: " << *vec[vec_index] << "\n"; (*col_vec)[i] = *vec[col_iter[i]]; } From 166b3b48faed5d4b552ef508a623d9125710171e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 6 Apr 2023 16:14:42 -0700 Subject: [PATCH 150/582] testing col_iter --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index ac158f754..f00d596b7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -492,7 +492,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& } std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; - //std::cout << "vec[" << vec_index << "]: " << *vec[vec_index] << "\n"; + std::cout << "vec[" << vec_index << "]: " << *vec[vec_index] << "\n"; (*col_vec)[i] = *vec[col_iter[i]]; } From 527f60704677e0761689fab2f628bb43493677d5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 6 Apr 2023 16:43:42 -0700 Subject: [PATCH 151/582] changes to the grabbing of data to prevent segfault --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f00d596b7..5bbc4d2ef 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -598,6 +598,8 @@ void EcoSIM::CopyToEcoSIM(int col, const auto& gas_density = *S_->Get(gas_den_key_, water_tag).ViewComponent("cell", true); const auto& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", true); const auto& temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", true); + //const Epetra_MultiVector& temp = *S_->Get("temperature", tag_next_).ViewComponent("cell", false); + const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); @@ -627,21 +629,21 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(col,tcc,col_tcc.ptr()); std::cout << "\nCopying Amanzi field to column vector\n"; - FieldToColumn_(col,porosity,col_poro.ptr()); + FieldToColumn_(col,*porosity(0),col_poro.ptr()); std::cout << "\npushed first column\n"; - FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); - FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); - FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); + FieldToColumn_(col,*liquid_saturation(0),col_l_sat.ptr()); + FieldToColumn_(col,*gas_saturation(0),col_g_sat.ptr()); + FieldToColumn_(col,*ice_saturation(0),col_i_sat.ptr()); //FieldToColumn_(col,elevation,col_elev.ptr()); - FieldToColumn_(col,water_content,col_wc.ptr()); - FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); - FieldToColumn_(col,liquid_density,col_f_dens.ptr()); - FieldToColumn_(col,ice_density,col_i_dens.ptr()); - FieldToColumn_(col,gas_density,col_g_dens.ptr()); - FieldToColumn_(col,rock_density,col_r_dens.ptr()); - FieldToColumn_(col,temp, col_temp.ptr()); - FieldToColumn_(col,conductivity,col_cond.ptr()); - FieldToColumn_(col,cell_volume,col_vol.ptr()); + FieldToColumn_(col,*water_content(0),col_wc.ptr()); + FieldToColumn_(col,*relative_permeability(0),col_rel_perm.ptr()); + FieldToColumn_(col,*liquid_density(0),col_f_dens.ptr()); + FieldToColumn_(col,*ice_density(0),col_i_dens.ptr()); + FieldToColumn_(col,*gas_density(0),col_g_dens.ptr()); + FieldToColumn_(col,*rock_density(0),col_r_dens.ptr()); + FieldToColumn_(col,*temp(0), col_temp.ptr()); + FieldToColumn_(col,*conductivity(0),col_cond.ptr()); + FieldToColumn_(col,*cell_volume(0),col_vol.ptr()); // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this From c2db521f1bd5dabd538d94cdd02ef75ee1a82054 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 6 Apr 2023 21:40:41 -0700 Subject: [PATCH 152/582] more testing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5bbc4d2ef..8c19dc0d0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -480,6 +480,12 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& auto& col_iter = mesh_->cells_of_column(col); std::cout << "\ncol_iter: "<< col_iter.size() <<"\n"; + for (std::size_t i=0; i!=col_iter.size(); ++i) { + std::size_t vec_index = col_iter[i]; + std::cout << "for i: " << i << "vec_index: " << vec_index << "\n"; + } + + for (std::size_t i=0; i!=col_iter.size(); ++i) { if (i >= col_vec->Length()) { @@ -487,6 +493,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& } std::size_t vec_index = col_iter[i]; + if (vec_index >= vec.MyLength()) { std::cout << "Error: index " << vec_index << " is out of bounds for vec\n"; } @@ -494,7 +501,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; std::cout << "vec[" << vec_index << "]: " << *vec[vec_index] << "\n"; - (*col_vec)[i] = *vec[col_iter[i]]; + (*col_vec)[i] = *vec[vec_index]; } } From 60a12b332cc58065ba9a0dddb0592fa379cf09da Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 6 Apr 2023 22:12:23 -0700 Subject: [PATCH 153/582] changing pointer call further --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 8c19dc0d0..6704e5eeb 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -483,6 +483,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& for (std::size_t i=0; i!=col_iter.size(); ++i) { std::size_t vec_index = col_iter[i]; std::cout << "for i: " << i << "vec_index: " << vec_index << "\n"; + std::cout << "vec[" << vec_index << "]: " << vec[vec_index] << "\n"; } @@ -499,9 +500,10 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& } std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; - std::cout << "vec[" << vec_index << "]: " << *vec[vec_index] << "\n"; + std::cout << "vec[" << vec_index << "]: " << vec[vec_index] << "\n"; - (*col_vec)[i] = *vec[vec_index]; + //(*col_vec)[i] = vec[vec_index]; + (*col_vec)[i] = vec[vec_index]; } } @@ -592,6 +594,8 @@ void EcoSIM::CopyToEcoSIM(int col, //Fill state with ATS variables that are going to be changed by EcoSIM //NEED TO DECIDE WHICH PROPERTIES GO WHERE std::cout << "\nviewing components\n"; + //Might need to switch + //const Epetra_MultiVector& temp also set ViewComponent to false const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); From bbe2d0d3a4a8b2cfca140b4b7c7ec2b40d993f57 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 6 Apr 2023 22:23:25 -0700 Subject: [PATCH 154/582] trying revisions again --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 6704e5eeb..0c35a1933 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -596,23 +596,23 @@ void EcoSIM::CopyToEcoSIM(int col, std::cout << "\nviewing components\n"; //Might need to switch //const Epetra_MultiVector& temp also set ViewComponent to false - const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); - const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); - const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); - const auto& gas_saturation = *S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", true); - const auto& ice_saturation = *S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", true); - //const auto& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", true); - const auto& water_content = *S_->Get(water_content_key_, water_tag).ViewComponent("cell", true); - const auto& relative_permeability = *S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", true); - const auto& liquid_density = *S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", true); - const auto& ice_density = *S_->Get(ice_den_key_, water_tag).ViewComponent("cell", true); - const auto& gas_density = *S_->Get(gas_den_key_, water_tag).ViewComponent("cell", true); - const auto& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", true); - const auto& temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", true); + const Epetra_MultiVector& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& gas_saturation = *S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& ice_saturation = *S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false); + //const Epetra_MultiVector& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& water_content = *S_->Get(water_content_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& relative_permeability = *S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& liquid_density = *S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& ice_density = *S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& gas_density = *S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", false); //const Epetra_MultiVector& temp = *S_->Get("temperature", tag_next_).ViewComponent("cell", false); - const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); - const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true); + const Epetra_MultiVector& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", false); //Define the column vectors to hold the data std::cout << "\ncreating column vectors with size: "<< ncells_per_col_ << "\n"; From 1fcd4b7fbb3bae95df6d7a876eb86d722bacd3a9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 6 Apr 2023 22:40:32 -0700 Subject: [PATCH 155/582] test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 110 +++++++++++----------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0c35a1933..282ead499 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -366,60 +366,60 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //Do I need to update everything here? S_->GetEvaluator("porosity", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& porosity = *S_->Get("porosity", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("saturation_liquid", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& liquid_saturation = *S_->Get("saturation_liquid", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& *(liquid_saturation = *(*S_->Get("saturation_liquid", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("saturation_gas", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& gas_saturation = *S_->Get("saturation_gas", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& gas_saturation = *(*S_->Get("saturation_gas", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("saturation_ice", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& ice_saturation = *S_->Get("saturation_ice", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& ice_saturation = *(*S_->Get("saturation_ice", tag_next_) + .ViewComponent("cell",false))(0); //S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); //const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) // .ViewComponent("cell",false); S_->GetEvaluator("water_content", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& water_content = *S_->Get("water_content", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("relatiive_permeabiilty", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& relative_permeability = *S_->Get("relative_permeabiilty", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeabiilty", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& liquid_density = *S_->Get("mass_density_liquid", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& gas_density = *S_->Get("mass_density_gas", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& ice_density = *S_->Get("mass_density_ice", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("density_rock", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& rock_density = *S_->Get("density_rock", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& rock_density = *(*S_->Get("density_rock", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& temp = *S_->Get("temperature", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& temp = *(*S_->Get("temperature", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("thermal_conductivity", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& conductivity = *S_->Get("thermal_conductivity", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& conductivity = *(*S_->Get("thermal_conductivity", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("cell_volume", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& cell_volume = *S_->Get("cell_volume", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& cell_volume = *(*S_->Get("cell_volume", tag_next_) + .ViewComponent("cell",false))(0); //S_->GetEvaluator("pressure", tag_next_).Update(*S_, name_); //const Epetra_MultiVector& pres = *S_->Get("pressure", tag_next_) @@ -430,8 +430,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // surface vegetation calculations (where the subsurface's face area is more // correct?) S_->GetEvaluator("surface-cell_volume", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& scv = *S_->Get("surface-cell_volume", tag_next_) - .ViewComponent("cell", false); + const Epetra_MultiVector& scv = *(*S_->Get("surface-cell_volume", tag_next_) + .ViewComponent("cell", false))(0); // loop over columns and apply the model for (AmanziMesh::Entity_ID col=0; col!=num_cols_; ++col) { @@ -596,23 +596,23 @@ void EcoSIM::CopyToEcoSIM(int col, std::cout << "\nviewing components\n"; //Might need to switch //const Epetra_MultiVector& temp also set ViewComponent to false - const Epetra_MultiVector& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& gas_saturation = *S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& ice_saturation = *S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& tcc = *(*S_->Get(tcc_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_MultiVector& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& water_content = *S_->Get(water_content_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& relative_permeability = *S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& liquid_density = *S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& ice_density = *S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& gas_density = *S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& relative_permeability = *(*S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_MultiVector& temp = *S_->Get("temperature", tag_next_).ViewComponent("cell", false); - const Epetra_MultiVector& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& conductivity = *(*S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data std::cout << "\ncreating column vectors with size: "<< ncells_per_col_ << "\n"; @@ -640,21 +640,21 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(col,tcc,col_tcc.ptr()); std::cout << "\nCopying Amanzi field to column vector\n"; - FieldToColumn_(col,*porosity(0),col_poro.ptr()); + FieldToColumn_(col,porosity,col_poro.ptr()); std::cout << "\npushed first column\n"; - FieldToColumn_(col,*liquid_saturation(0),col_l_sat.ptr()); - FieldToColumn_(col,*gas_saturation(0),col_g_sat.ptr()); - FieldToColumn_(col,*ice_saturation(0),col_i_sat.ptr()); + FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); + FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); + FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); //FieldToColumn_(col,elevation,col_elev.ptr()); - FieldToColumn_(col,*water_content(0),col_wc.ptr()); - FieldToColumn_(col,*relative_permeability(0),col_rel_perm.ptr()); - FieldToColumn_(col,*liquid_density(0),col_f_dens.ptr()); - FieldToColumn_(col,*ice_density(0),col_i_dens.ptr()); - FieldToColumn_(col,*gas_density(0),col_g_dens.ptr()); - FieldToColumn_(col,*rock_density(0),col_r_dens.ptr()); - FieldToColumn_(col,*temp(0), col_temp.ptr()); - FieldToColumn_(col,*conductivity(0),col_cond.ptr()); - FieldToColumn_(col,*cell_volume(0),col_vol.ptr()); + FieldToColumn_(col,water_content,col_wc.ptr()); + FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); + FieldToColumn_(col,liquid_density,col_f_dens.ptr()); + FieldToColumn_(col,ice_density,col_i_dens.ptr()); + FieldToColumn_(col,gas_density,col_g_dens.ptr()); + FieldToColumn_(col,rock_density,col_r_dens.ptr()); + FieldToColumn_(col,temp, col_temp.ptr()); + FieldToColumn_(col,conductivity,col_cond.ptr()); + FieldToColumn_(col,cell_volume,col_vol.ptr()); // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this From f71c7975ac8c61457b578f0368f539a5ba824b88 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 12:06:20 -0700 Subject: [PATCH 156/582] I hate pointers --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 282ead499..2d9929a1a 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -370,7 +370,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false))(0); S_->GetEvaluator("saturation_liquid", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& *(liquid_saturation = *(*S_->Get("saturation_liquid", tag_next_) + const Epetra_MultiVector& liquid_saturation = *(*S_->Get("saturation_liquid", tag_next_) .ViewComponent("cell",false))(0); S_->GetEvaluator("saturation_gas", tag_next_).Update(*S_, name_); @@ -471,7 +471,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // helper function for pushing field to column void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, - Teuchos::Ptr col_vec) + Epetra_SerialDenseVector& col_vec) { if (col_vec == Teuchos::null) { col_vec = Teuchos::ptr(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -503,7 +503,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& std::cout << "vec[" << vec_index << "]: " << vec[vec_index] << "\n"; //(*col_vec)[i] = vec[vec_index]; - (*col_vec)[i] = vec[vec_index]; + col_vec[i] = vec[vec_index]; } } @@ -596,8 +596,9 @@ void EcoSIM::CopyToEcoSIM(int col, std::cout << "\nviewing components\n"; //Might need to switch //const Epetra_MultiVector& temp also set ViewComponent to false + const Epetra_Vector& porosity = S_->Get(poro_key_, water_tag).ViewComponent("cell", false); + const Epetra_MultiVector& tcc = *(*S_->Get(tcc_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_MultiVector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_MultiVector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_MultiVector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); @@ -616,9 +617,9 @@ void EcoSIM::CopyToEcoSIM(int col, //Define the column vectors to hold the data std::cout << "\ncreating column vectors with size: "<< ncells_per_col_ << "\n"; - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - std::cout << "\ncreated first column\n"; auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + std::cout << "\ncreated first column\n"; + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -640,7 +641,7 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(col,tcc,col_tcc.ptr()); std::cout << "\nCopying Amanzi field to column vector\n"; - FieldToColumn_(col,porosity,col_poro.ptr()); + FieldToColumn_(col,porosity,col_poro); std::cout << "\npushed first column\n"; FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); From 14d3ac1e130b135cd027d179e91b11b776e812ab Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 12:12:50 -0700 Subject: [PATCH 157/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 09f9f846e..194f1555f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -134,7 +134,7 @@ class EcoSIM : public PK_Physical { //The helper functions from BGC are protected not private (unclear why) //I don't think I need this here, probably in the engine void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, - Teuchos::Ptr col_vec); + Epetra_SerialDenseVector& col_vec); //void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // double* col_vec); From 141b1a264743bdf0f77e319506144b18c3a583e6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 13:03:07 -0700 Subject: [PATCH 158/582] reverting to old syntax --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 84 +++++++++++------------ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 +- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 2d9929a1a..52af0be32 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -270,23 +270,23 @@ void EcoSIM::Initialize() { //I don't know that we need the two initial loops. I'm just including them because we might std::cout << "\ninitializing column loop\n"; for (int col=0; col!=num_cols_; ++col) { - //FieldToColumn_(col, temp, col_temp.ptr()); - //ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); - - //We're going to need to write an InitializeSingleColumn code - //ierr = InitializeSingleCell(cell, condition); - std::cout << "\ninitializing column "<< col <<" \n"; - ierr = InitializeSingleColumn(col); - //In Alquimia this function simply calls CopyToAlquimia, then - //Calls the chemistry engine and enforces condition, then copies - //From Alquimia to Amanzi - // - //The copy to alquimia function takes the cell index, because it - //is assigning things cell by cell in state. For colums this will - //be a bit trickier I THINK we could use the FieldToColumn_ function - //To do this, but I think I will actually need to figure out a test - //for this before I actually code it up -} + //FieldToColumn_(col, temp, col_temp.ptr()); + //ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); + + //We're going to need to write an InitializeSingleColumn code + //ierr = InitializeSingleCell(cell, condition); + std::cout << "\ninitializing column "<< col <<" \n"; + ierr = InitializeSingleColumn(col); + //In Alquimia this function simply calls CopyToAlquimia, then + //Calls the chemistry engine and enforces condition, then copies + //From Alquimia to Amanzi + // + //The copy to alquimia function takes the cell index, because it + //is assigning things cell by cell in state. For colums this will + //be a bit trickier I THINK we could use the FieldToColumn_ function + //To do this, but I think I will actually need to figure out a test + //for this before I actually code it up + } std::cout << "\nfinishing initialize\n"; // verbose message if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { @@ -470,12 +470,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //--------------------------------------------------------------------------- // helper function for pushing field to column -void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, - Epetra_SerialDenseVector& col_vec) +void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + Teuchos::Ptr col_vec) { - if (col_vec == Teuchos::null) { - col_vec = Teuchos::ptr(new Epetra_SerialDenseVector(ncells_per_col_)); - } std::cout << "\ncol: "<< col <<"\n"; auto& col_iter = mesh_->cells_of_column(col); std::cout << "\ncol_iter: "<< col_iter.size() <<"\n"; @@ -489,7 +486,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& for (std::size_t i=0; i!=col_iter.size(); ++i) { - if (i >= col_vec->Length()) { + if (i >= col_vec.Length()) { std::cout << "Error: index " << i << " is out of bounds for col_vec\n"; } @@ -499,11 +496,11 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& std::cout << "Error: index " << vec_index << " is out of bounds for vec\n"; } - std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; + std::cout << "col_vec[" << i << "]: " << col_vec[i] << "\n"; std::cout << "vec[" << vec_index << "]: " << vec[vec_index] << "\n"; //(*col_vec)[i] = vec[vec_index]; - col_vec[i] = vec[vec_index]; + (*col_vec)[i] = vec[vec_index]; } } @@ -596,24 +593,23 @@ void EcoSIM::CopyToEcoSIM(int col, std::cout << "\nviewing components\n"; //Might need to switch //const Epetra_MultiVector& temp also set ViewComponent to false - const Epetra_Vector& porosity = S_->Get(poro_key_, water_tag).ViewComponent("cell", false); - - const Epetra_MultiVector& tcc = *(*S_->Get(tcc_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_MultiVector& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", false); - const Epetra_MultiVector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& relative_permeability = *(*S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_MultiVector& temp = *S_->Get("temperature", tag_next_).ViewComponent("cell", false); - - const Epetra_MultiVector& conductivity = *(*S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& tcc = *(*S_->Get(tcc_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", false); + const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& relative_permeability = *(*S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& temp = *S_->Get("temperature", tag_next_).ViewComponent("cell", false); + + const Epetra_Vector& conductivity = *(*S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data std::cout << "\ncreating column vectors with size: "<< ncells_per_col_ << "\n"; @@ -641,7 +637,7 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(col,tcc,col_tcc.ptr()); std::cout << "\nCopying Amanzi field to column vector\n"; - FieldToColumn_(col,porosity,col_poro); + FieldToColumn_(col,porosity,col_poro.ptr()); std::cout << "\npushed first column\n"; FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 194f1555f..49d92b83b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -133,8 +133,8 @@ class EcoSIM : public PK_Physical { //The helper functions from BGC are protected not private (unclear why) //I don't think I need this here, probably in the engine - void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, - Epetra_SerialDenseVector& col_vec); + void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + Teuchos::Ptr col_vec); //void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // double* col_vec); From dda959ed3563a742f5f1789f3e9220ad2d6abfbf Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 13:06:41 -0700 Subject: [PATCH 159/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 52af0be32..e9f0db453 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -486,7 +486,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, for (std::size_t i=0; i!=col_iter.size(); ++i) { - if (i >= col_vec.Length()) { + if (i >= col_vec->Length()) { std::cout << "Error: index " << i << " is out of bounds for col_vec\n"; } From 393a20b1cc9e451d6166278da38b1bfad16005c4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 13:14:43 -0700 Subject: [PATCH 160/582] trying other pointer access tests --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e9f0db453..f614bdf8c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -496,7 +496,8 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, std::cout << "Error: index " << vec_index << " is out of bounds for vec\n"; } - std::cout << "col_vec[" << i << "]: " << col_vec[i] << "\n"; + std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; + std::cout << "col_vec[" << i << "]: " << (*col_vec)->operator[](i) << "\n"; std::cout << "vec[" << vec_index << "]: " << vec[vec_index] << "\n"; //(*col_vec)[i] = vec[vec_index]; From bf358ca978ea10b98cc0ec441ba56f313060a885 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 13:17:09 -0700 Subject: [PATCH 161/582] yeah that doesn't work --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f614bdf8c..611bfaa2f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -497,7 +497,6 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, } std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; - std::cout << "col_vec[" << i << "]: " << (*col_vec)->operator[](i) << "\n"; std::cout << "vec[" << vec_index << "]: " << vec[vec_index] << "\n"; //(*col_vec)[i] = vec[vec_index]; From 9823fae04883f0dce00fb5feefbd77d4679baf86 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 13:59:49 -0700 Subject: [PATCH 162/582] changes to copy to amanzi pointers --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 611bfaa2f..e4316ed59 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -749,21 +749,21 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ - //auto& tcc = *S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - auto& porosity = *S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell"); - auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell"); - auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell"); - auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell"); - //auto& elevation = *S_->GetW(elev_key_, water_tag, passwd_).ViewComponent("cell"); - auto& water_content = *S_->GetW(water_content_key_, water_tag, passwd_).ViewComponent("cell"); - auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag, passwd_).ViewComponent("cell"); - auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag, passwd_).ViewComponent("cell"); - auto& ice_density = *S_->GetW(ice_den_key_, water_tag, passwd_).ViewComponent("cell"); - auto& gas_density = *S_->GetW(gas_den_key_, water_tag, passwd_).ViewComponent("cell"); - auto& rock_density = *S_->GetW(rock_den_key_, water_tag, passwd_).ViewComponent("cell"); - auto& temp = *S_->GetW(T_key_, water_tag, passwd_).ViewComponent("cell"); - auto& conductivity = *S_->GetW(conductivity_key_, water_tag, passwd_).ViewComponent("cell"); - auto& cell_volume = *S_->GetW(cv_key_, water_tag, passwd_).ViewComponent("cell"); + //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); + auto& porosity = S_->GetPtrW(poro_key_, water_tag, passwd_).ViewComponent("cell"); + auto& liquid_saturation = S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell"); + auto& gas_saturation = S_->GetPtrW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell"); + auto& ice_saturation = S_->GetPtrW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell"); + //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); + auto& water_content = S_->GetPtrW(water_content_key_, water_tag, passwd_).ViewComponent("cell"); + auto& relative_permeability = S_->GetPtrW(rel_perm_key_, water_tag, passwd_).ViewComponent("cell"); + auto& liquid_density = S_->GetPtrW(liquid_den_key_, water_tag, passwd_).ViewComponent("cell"); + auto& ice_density = S_->GetPtrW(ice_den_key_, water_tag, passwd_).ViewComponent("cell"); + auto& gas_density = S_->GetPtrW(gas_den_key_, water_tag, passwd_).ViewComponent("cell"); + auto& rock_density = S_->GetPtrW(rock_den_key_, water_tag, passwd_).ViewComponent("cell"); + auto& temp = S_->GetPtrW(T_key_, water_tag, passwd_).ViewComponent("cell"); + auto& conductivity = S_->GetPtrW(conductivity_key_, water_tag, passwd_).ViewComponent("cell"); + auto& cell_volume = S_->GetPtrW(cv_key_, water_tag, passwd_).ViewComponent("cell"); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 7ae003505358192f60bddbc97ffea8e5442f399a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 14:10:10 -0700 Subject: [PATCH 163/582] changes pointers --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e4316ed59..ad1f5727c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,20 +750,20 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - auto& porosity = S_->GetPtrW(poro_key_, water_tag, passwd_).ViewComponent("cell"); - auto& liquid_saturation = S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell"); - auto& gas_saturation = S_->GetPtrW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell"); - auto& ice_saturation = S_->GetPtrW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell"); + auto& porosity = S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& liquid_saturation = S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& gas_saturation = S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& ice_saturation = S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); - auto& water_content = S_->GetPtrW(water_content_key_, water_tag, passwd_).ViewComponent("cell"); - auto& relative_permeability = S_->GetPtrW(rel_perm_key_, water_tag, passwd_).ViewComponent("cell"); - auto& liquid_density = S_->GetPtrW(liquid_den_key_, water_tag, passwd_).ViewComponent("cell"); - auto& ice_density = S_->GetPtrW(ice_den_key_, water_tag, passwd_).ViewComponent("cell"); - auto& gas_density = S_->GetPtrW(gas_den_key_, water_tag, passwd_).ViewComponent("cell"); - auto& rock_density = S_->GetPtrW(rock_den_key_, water_tag, passwd_).ViewComponent("cell"); - auto& temp = S_->GetPtrW(T_key_, water_tag, passwd_).ViewComponent("cell"); - auto& conductivity = S_->GetPtrW(conductivity_key_, water_tag, passwd_).ViewComponent("cell"); - auto& cell_volume = S_->GetPtrW(cv_key_, water_tag, passwd_).ViewComponent("cell"); + auto& water_content = S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& relative_permeability = S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& liquid_density = S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& ice_density = S_->GetPtrW(ice_den_key_, water_tag, passwd_)->LViewComponent("cell"); + auto& gas_density = S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& rock_density = S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& temp = S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& conductivity = S_->GetPtrW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& cell_volume = S_->GetPtrW(cv_key_, water_tag, passwd_)->ViewComponent("cell"); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From c246f900ddd3e31b4824a838c68b3874cb61ac11 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 14:57:14 -0700 Subject: [PATCH 164/582] ats --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index ad1f5727c..8dd9ffa9f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,20 +750,20 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - auto& porosity = S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& liquid_saturation = S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& gas_saturation = S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& ice_saturation = S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& porosity = S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& liquid_saturation = S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& gas_saturation = S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& ice_saturation = S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); - auto& water_content = S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& relative_permeability = S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& liquid_density = S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& ice_density = S_->GetPtrW(ice_den_key_, water_tag, passwd_)->LViewComponent("cell"); - auto& gas_density = S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& rock_density = S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& temp = S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& conductivity = S_->GetPtrW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell"); - auto& cell_volume = S_->GetPtrW(cv_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& water_content = S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& relative_permeability = S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& liquid_density = S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& ice_density = S_->GetPtrW(ice_den_key_, water_tag, passwd_)->LViewComponent("cell"); + Epetra_Vector& gas_density = S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& rock_density = S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& temp = S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& conductivity = S_->GetPtrW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& cell_volume = S_->GetPtrW(cv_key_, water_tag, passwd_)->ViewComponent("cell"); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 80c98dc32be01871f79d6c03b2d5d128ef2c847e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 15:34:52 -0700 Subject: [PATCH 165/582] pointer madness --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 8dd9ffa9f..733883e2f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,20 +750,20 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - Epetra_Vector& porosity = S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& liquid_saturation = S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& gas_saturation = S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& ice_saturation = S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& porosity = *S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& liquid_saturation = *S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& gas_saturation = *S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& ice_saturation = *S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); - Epetra_Vector& water_content = S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& relative_permeability = S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& liquid_density = S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& ice_density = S_->GetPtrW(ice_den_key_, water_tag, passwd_)->LViewComponent("cell"); - Epetra_Vector& gas_density = S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& rock_density = S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& temp = S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& conductivity = S_->GetPtrW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& cell_volume = S_->GetPtrW(cv_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& water_content = *S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& relative_permeability = *S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& liquid_density = *S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& ice_density = *S_->GetPtrW(ice_den_key_, water_tag, passwd_)->LViewComponent("cell"); + Epetra_Vector& gas_density = *S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& rock_density = *S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& temp = *S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& conductivity = *S_->GetPtrW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_Vector& cell_volume = *S_->GetPtrW(cv_key_, water_tag, passwd_)->ViewComponent("cell"); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 7c25d7bac7cefd5b8af6de7645a8061a2f713bab Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 7 Apr 2023 15:41:33 -0700 Subject: [PATCH 166/582] vector changes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 733883e2f..ccb0a98b0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,20 +750,20 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - Epetra_Vector& porosity = *S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& liquid_saturation = *S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& gas_saturation = *S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& ice_saturation = *S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& porosity = *S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& liquid_saturation = *S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& gas_saturation = *S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& ice_saturation = *S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); - Epetra_Vector& water_content = *S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& relative_permeability = *S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& liquid_density = *S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& ice_density = *S_->GetPtrW(ice_den_key_, water_tag, passwd_)->LViewComponent("cell"); - Epetra_Vector& gas_density = *S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& rock_density = *S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& temp = *S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& conductivity = *S_->GetPtrW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_Vector& cell_volume = *S_->GetPtrW(cv_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& water_content = *S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& relative_permeability = *S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& liquid_density = *S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& ice_density = *S_->GetPtrW(ice_den_key_, water_tag, passwd_)->LViewComponent("cell"); + Epetra_MultiVector& gas_density = *S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& rock_density = *S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& temp = *S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& conductivity = *S_->GetPtrW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell"); + Epetra_MultiVector& cell_volume = *S_->GetPtrW(cv_key_, water_tag, passwd_)->ViewComponent("cell"); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 1c063f3a5879c23de8da286e76c182a4f72b5cb5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 10:35:14 -0700 Subject: [PATCH 167/582] added various way to access data --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index ccb0a98b0..f4a7af9ba 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,7 +750,20 @@ void EcoSIM::CopyFromEcoSIM(const int col, const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - Epetra_MultiVector& porosity = *S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); + + //There are various ways to access data unclear which I need + //Attempt 1 fails + //Epetra_MultiVector& porosity = *S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); + + //Attempt 2 + //porosity = Teuchos::rcp(new Epetra_MultiVector(*S_->Get("porosity").ViewComponent("cell", true))); + + //Attempt 3 + //porosity = S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell", false)); + + //Attempt 4 + Teuchos::RCP porosity = S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell", true); + Epetra_MultiVector& liquid_saturation = *S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); Epetra_MultiVector& gas_saturation = *S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); Epetra_MultiVector& ice_saturation = *S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); From 1b77137d987cd01606f73756f7242a0aaec96009 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 11:13:33 -0700 Subject: [PATCH 168/582] fixing typos and typedef --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f4a7af9ba..3e25a1ed8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -771,7 +771,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, Epetra_MultiVector& water_content = *S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); Epetra_MultiVector& relative_permeability = *S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); Epetra_MultiVector& liquid_density = *S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& ice_density = *S_->GetPtrW(ice_den_key_, water_tag, passwd_)->LViewComponent("cell"); + Epetra_MultiVector& ice_density = *S_->GetPtrW(ice_den_key_, water_tag, passwd_)->ViewComponent("cell"); Epetra_MultiVector& gas_density = *S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); Epetra_MultiVector& rock_density = *S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); Epetra_MultiVector& temp = *S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 49d92b83b..1bec26c19 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -142,7 +142,7 @@ class EcoSIM : public PK_Physical { Teuchos::Ptr depth, Teuchos::Ptr dz); - void ColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector vec, + void ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::RCP vec, Teuchos::Ptr col_vec); //evaluator for transpiration; //I don't think I need this anymore From d5c7ba8861bb7df9b3549594b2430d473d3a9743 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 11:33:18 -0700 Subject: [PATCH 169/582] following the elm pk --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 29 +++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3e25a1ed8..3bf4d6caa 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -762,21 +762,24 @@ void EcoSIM::CopyFromEcoSIM(const int col, //porosity = S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell", false)); //Attempt 4 - Teuchos::RCP porosity = S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell", true); + //Teuchos::RCP porosity = S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell", true); - Epetra_MultiVector& liquid_saturation = *S_->GetPtrW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& gas_saturation = *S_->GetPtrW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& ice_saturation = *S_->GetPtrW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell"); + //Attempt 5 (ELM; this should work) + auto& porosity = *S_>GetW(poro_key_, water_tag, passwd_).ViewComponent("cell",false); + + auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell",false); //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); - Epetra_MultiVector& water_content = *S_->GetPtrW(water_content_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& relative_permeability = *S_->GetPtrW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& liquid_density = *S_->GetPtrW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& ice_density = *S_->GetPtrW(ice_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& gas_density = *S_->GetPtrW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& rock_density = *S_->GetPtrW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& temp = *S_->GetPtrW(T_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& conductivity = *S_->GetPtrW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell"); - Epetra_MultiVector& cell_volume = *S_->GetPtrW(cv_key_, water_tag, passwd_)->ViewComponent("cell"); + auto& water_content = *S_->GetW(water_content_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& ice_density = *S_->GetW(ice_den_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& gas_density = *S_->GetW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& rock_density = *S_->GetW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& temp = *S_->GetW(T_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& conductivity = *S_->GetW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& cell_volume = *S_->GetW(cv_key_, water_tag, passwd_)->ViewComponent("cell",false); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 1cc31f36143bacefac0419ce830ecb65c7e6af8b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 11:44:17 -0700 Subject: [PATCH 170/582] typos --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 39 +++++++---------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3bf4d6caa..93f310aa2 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -733,21 +733,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->porosity())[cell] = state.porosity; //I probably need to copy the columns cell by cell in a loop //Can I do this in the field to column function? - /*const auto& tcc = *S_->Get(tcc_key_, water_tag).ViewComponent("cell", true); - const auto& porosity = *S_->Get(poro_key_, water_tag).ViewComponent("cell", true); - const auto& liquid_saturation = *S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", true); - const auto& gas_saturation = *S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", true); - const auto& ice_saturation = *S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", true); - const auto& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", true); - const auto& water_content = *S_->Get(water_content_key_, water_tag).ViewComponent("cell", true); - const auto& relative_permeability = *S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", true); - const auto& liquid_density = *S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", true); - const auto& ice_density = *S_->Get(ice_den_key_, water_tag).ViewComponent("cell", true); - const auto& gas_density = *S_->Get(gas_den_key_, water_tag).ViewComponent("cell", true); - const auto& rock_density = *S_->Get(rock_den_key_, water_tag).ViewComponent("cell", true); - const auto& temp = *S_->Get(T_key_, water_tag).ViewComponent("cell", true); - const auto& conductivity = *S_->Get(conductivity_key_, water_tag).ViewComponent("cell", true); - const auto& cell_volume = *S_->Get(cv_key_, water_tag).ViewComponent("cell", true);*/ //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); @@ -767,19 +752,19 @@ void EcoSIM::CopyFromEcoSIM(const int col, //Attempt 5 (ELM; this should work) auto& porosity = *S_>GetW(poro_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell",false); //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); - auto& water_content = *S_->GetW(water_content_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& ice_density = *S_->GetW(ice_den_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& gas_density = *S_->GetW(gas_den_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& rock_density = *S_->GetW(rock_den_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& temp = *S_->GetW(T_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& conductivity = *S_->GetW(conductivity_key_, water_tag, passwd_)->ViewComponent("cell",false); - auto& cell_volume = *S_->GetW(cv_key_, water_tag, passwd_)->ViewComponent("cell",false); + auto& water_content = *S_->GetW(water_content_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& ice_density = *S_->GetW(ice_den_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& gas_density = *S_->GetW(gas_den_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& rock_density = *S_->GetW(rock_den_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& temp = *S_->GetW(T_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& conductivity = *S_->GetW(conductivity_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& cell_volume = *S_->GetW(cv_key_, water_tag, passwd_).ViewComponent("cell",false); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 49ccd96dff444b3b357e5b714e8f529eea49b0fe Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 11:52:15 -0700 Subject: [PATCH 171/582] fixing typing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 1bec26c19..49d92b83b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -142,7 +142,7 @@ class EcoSIM : public PK_Physical { Teuchos::Ptr depth, Teuchos::Ptr dz); - void ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::RCP vec, + void ColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector vec, Teuchos::Ptr col_vec); //evaluator for transpiration; //I don't think I need this anymore From 53b102e02f51be8027b1c262dcbfc4d64b5827e0 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 11:59:51 -0700 Subject: [PATCH 172/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 93f310aa2..776e14992 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,9 +750,9 @@ void EcoSIM::CopyFromEcoSIM(const int col, //Teuchos::RCP porosity = S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell", true); //Attempt 5 (ELM; this should work) - auto& porosity = *S_>GetW(poro_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& porosity = *S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell",false); auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell",false); auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell",false); //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); From 0e22ba237e2a26e8ca256e917f0062c481852787 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 12:47:18 -0700 Subject: [PATCH 173/582] testing the next tag --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 776e14992..eead5616f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,7 +750,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, //Teuchos::RCP porosity = S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell", true); //Attempt 5 (ELM; this should work) - auto& porosity = *S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& porosity = *S_->GetW(poro_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell",false); auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell",false); auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell",false); From 4503e31a23392d9d97402996d6b64f27243897f0 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 13:00:11 -0700 Subject: [PATCH 174/582] trying override again --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index eead5616f..d35f292cd 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,7 +750,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, //Teuchos::RCP porosity = S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell", true); //Attempt 5 (ELM; this should work) - auto& porosity = *S_->GetW(poro_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell",false); + auto& porosity = *S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false); auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell",false); auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell",false); From 8839e016ae2bc51e3548585c811aed71d38776af Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 13:06:47 -0700 Subject: [PATCH 175/582] changing all the calls to the correct syntax --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d35f292cd..d84acd1de 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -752,19 +752,19 @@ void EcoSIM::CopyFromEcoSIM(const int col, //Attempt 5 (ELM; this should work) auto& porosity = *S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false); - auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& gas_saturation = *S_->GetW(saturation_gas_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& ice_saturation = *S_->GetW(saturation_ice_key_, water_tag, passwd_).ViewComponent("cell",false); - //auto& elevation = S_->GetPtrW(elev_key_, water_tag, passwd_).ViewComponent("cell"); - auto& water_content = *S_->GetW(water_content_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& relative_permeability = *S_->GetW(rel_perm_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& liquid_density = *S_->GetW(liquid_den_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& ice_density = *S_->GetW(ice_den_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& gas_density = *S_->GetW(gas_den_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& rock_density = *S_->GetW(rock_den_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& temp = *S_->GetW(T_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& conductivity = *S_->GetW(conductivity_key_, water_tag, passwd_).ViewComponent("cell",false); - auto& cell_volume = *S_->GetW(cv_key_, water_tag, passwd_).ViewComponent("cell",false); + auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false); + auto& gas_saturation = *S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false); + auto& ice_saturation = *S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false); + //auto& elevation = S_->GetPtrW(elev_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell"); + auto& water_content = *S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false); + auto& relative_permeability = *S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false); + auto& liquid_density = *S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false); + auto& ice_density = *S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false); + auto& gas_density = *S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false); + auto& rock_density = *S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false); + auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, T_key_).ViewComponent("cell",false); + auto& conductivity = *S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false); + auto& cell_volume = *S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 54f18d740a9bb6c043f453f062905bae8fc9c6ef Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 13:28:41 -0700 Subject: [PATCH 176/582] trying temp --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d84acd1de..2e980ad95 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -762,7 +762,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& ice_density = *S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false); auto& gas_density = *S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false); auto& rock_density = *S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false); - auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, T_key_).ViewComponent("cell",false); + auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, name()).ViewComponent("cell",false); auto& conductivity = *S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false); auto& cell_volume = *S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false); From 4cc36d437b5c89a4bb4728fa969228b446cfc5c5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 14:29:53 -0700 Subject: [PATCH 177/582] commenting out temp for now --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 2e980ad95..4dc289d26 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -762,7 +762,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& ice_density = *S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false); auto& gas_density = *S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false); auto& rock_density = *S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false); - auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, name()).ViewComponent("cell",false); + //auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, name()).ViewComponent("cell",false); auto& conductivity = *S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false); auto& cell_volume = *S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false); @@ -779,7 +779,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + //auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -791,7 +791,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_i_dens)[i] = state.ice_density.data[i]; (*col_poro)[i] = state.porosity.data[i]; (*col_wc)[i] = state.water_content.data[i]; - (*col_temp)[i] = state.temperature.data[i]; + //(*col_temp)[i] = state.temperature.data[i]; (*col_l_sat)[i] = props.liquid_saturation.data[i]; (*col_g_sat)[i] = props.gas_saturation.data[i]; @@ -837,7 +837,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,ice_density,col_i_dens.ptr()); ColumnToField_(col,gas_density,col_g_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); - ColumnToField_(col,temp, col_temp.ptr()); + //ColumnToField_(col,temp, col_temp.ptr()); ColumnToField_(col,conductivity,col_cond.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); From 9988fe562ad27d5b0cb33bbf86e13986845d3884 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 15:02:18 -0700 Subject: [PATCH 178/582] modifications to pointers in the copy from area --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 24 +++++++++++------------ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4dc289d26..f8a23a74b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -750,21 +750,21 @@ void EcoSIM::CopyFromEcoSIM(const int col, //Teuchos::RCP porosity = S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell", true); //Attempt 5 (ELM; this should work) - auto& porosity = *S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false); + auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); - auto& liquid_saturation = *S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false); - auto& gas_saturation = *S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false); - auto& ice_saturation = *S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false); + auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); + auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false))(0); + auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); //auto& elevation = S_->GetPtrW(elev_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell"); - auto& water_content = *S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false); - auto& relative_permeability = *S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false); - auto& liquid_density = *S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false); - auto& ice_density = *S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false); - auto& gas_density = *S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false); - auto& rock_density = *S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false); + auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); + auto& relative_permeability = *(*S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false))(0); + auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); + auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); + auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false))(0); + auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); //auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, name()).ViewComponent("cell",false); - auto& conductivity = *S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false); - auto& cell_volume = *S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false); + auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); + auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 49d92b83b..ccbb7e1ff 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -142,7 +142,7 @@ class EcoSIM : public PK_Physical { Teuchos::Ptr depth, Teuchos::Ptr dz); - void ColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector vec, + void ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, Teuchos::Ptr col_vec); //evaluator for transpiration; //I don't think I need this anymore From 5632f93f0968a7c1aab6ae90a76d1258a47fff96 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 15:08:51 -0700 Subject: [PATCH 179/582] changed function types --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f8a23a74b..017c00601 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -518,7 +518,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // with any luck it's just the reverse of the above similar to how it's done // cell by cell in alquimia -void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector vec, +void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, Teuchos::Ptr col_vec) { auto& col_iter = mesh_->cells_of_column(col); From 2d713e62438917e15f63efc19e9c3cc69b2579b6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 15:12:00 -0700 Subject: [PATCH 180/582] pointer fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 017c00601..f628d8088 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -523,7 +523,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, { auto& col_iter = mesh_->cells_of_column(col); for (std::size_t i=0; i!=col_iter.size(); ++i) { - *vec[col_iter[i]] = (*col_vec)[i]; + vec[col_iter[i]] = (*col_vec)[i]; } } From 6a908f1f52c7e419f2628d0656d8b0fdda916998 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 15:30:38 -0700 Subject: [PATCH 181/582] added debugging statements --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f628d8088..e3ea60ac2 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -331,6 +331,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // Ensure dependencies are filled // Fix this from DEFAULT, see amanzi/amanzi#646 --etc // Update all dependencies again + std::cout << "\nupdating dependencies\n"; S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); @@ -364,7 +365,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { Epetra_MultiVector& trans = *S_->GetW(trans_key_, tag_next_, name_) .ViewComponent("cell",false);*/ //Do I need to update everything here? - + std::cout << "\nGrabbing evaluators\n"; S_->GetEvaluator("porosity", tag_next_).Update(*S_, name_); const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) .ViewComponent("cell",false))(0); @@ -434,6 +435,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell", false))(0); // loop over columns and apply the model + std::cout << "\nBegining advance loop\n"; for (AmanziMesh::Entity_ID col=0; col!=num_cols_; ++col) { auto& col_iter = mesh_->cells_of_column(col); @@ -447,8 +449,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // *temp_c, *pres_c, *depth_c, *dz_c, // pfts_[col], soil_carbon_pools_[col], // co2_decomp_c, trans_c, sw_c); - + std::cout << "\nAdvancing col "<< col <<"\n"; AdvanceSingleColumn(dt, col); + std::cout << "\nfinished advancing column\n"; //Copy back to Amanzi From 6a63134a4ef8aa91345963441a3b7fd5370a0c15 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 16:13:32 -0700 Subject: [PATCH 182/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e3ea60ac2..87b8091bf 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -390,7 +390,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("relatiive_permeabiilty", tag_next_).Update(*S_, name_); + S_->GetEvaluator("relative_permeabiilty", tag_next_).Update(*S_, name_); const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeabiilty", tag_next_) .ViewComponent("cell",false))(0); From d4a230b007a4b82d5b6300e1f8fd15884fbb401b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 16:23:11 -0700 Subject: [PATCH 183/582] another typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 87b8091bf..908ea78a3 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -390,7 +390,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("relative_permeabiilty", tag_next_).Update(*S_, name_); + S_->GetEvaluator("relative_permeabilty", tag_next_).Update(*S_, name_); const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeabiilty", tag_next_) .ViewComponent("cell",false))(0); From b847b9d68cb21a48878e060e42076a8d06a3c2cb Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 16:47:00 -0700 Subject: [PATCH 184/582] apparently I can't spell permeability --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 908ea78a3..f714970b6 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -70,7 +70,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); //elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); - rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeabiilty","relative_permeability"); + rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); //densities //If we need bulk density do we need volume fractions of each quantity? @@ -390,8 +390,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("relative_permeabilty", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeabiilty", tag_next_) + S_->GetEvaluator("relative_permeability", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) .ViewComponent("cell",false))(0); S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); From 36bd06242a8ee13ce822a6516c28d53bb4f92d1f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 17:00:34 -0700 Subject: [PATCH 185/582] commenting out gas calls since no gas --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f714970b6..5a03ef5fc 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -398,9 +398,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) - .ViewComponent("cell",false))(0); + //S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) + // .ViewComponent("cell",false))(0); S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) From 77a41546007aef0d33b8281d64f8f7e84cc1112f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 17:05:14 -0700 Subject: [PATCH 186/582] removing ice too --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5a03ef5fc..09263b143 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -402,9 +402,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) // .ViewComponent("cell",false))(0); - S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) - .ViewComponent("cell",false))(0); + //S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) + // .ViewComponent("cell",false))(0); S_->GetEvaluator("density_rock", tag_next_).Update(*S_, name_); const Epetra_MultiVector& rock_density = *(*S_->Get("density_rock", tag_next_) From 069aa08abaa1e53792de024dd7c405030cb80ff4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Apr 2023 17:09:03 -0700 Subject: [PATCH 187/582] removing volume --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 09263b143..dfed7c9e9 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -430,9 +430,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // right. Likely correct for soil carbon calculations and incorrect for // surface vegetation calculations (where the subsurface's face area is more // correct?) - S_->GetEvaluator("surface-cell_volume", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& scv = *(*S_->Get("surface-cell_volume", tag_next_) - .ViewComponent("cell", false))(0); + //S_->GetEvaluator("surface-cell_volume", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& scv = *(*S_->Get("surface-cell_volume", tag_next_) + // .ViewComponent("cell", false))(0); // loop over columns and apply the model std::cout << "\nBegining advance loop\n"; From 0b87c448521205502994970655099c83445aee98 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 11 Apr 2023 14:37:24 -0700 Subject: [PATCH 188/582] modifications to comments --- src/pks/ecosim_pk/BGCEngine.cc | 12 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 257 +++------------------- src/pks/ecosim_pk/data/BGC_constants.cc | 4 + src/pks/ecosim_pk/data/BGC_constants.hh | 7 +- src/pks/ecosim_pk/data/BGC_memory.cc | 17 +- 5 files changed, 47 insertions(+), 250 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 86209ec0f..03a68b9c9 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -32,7 +32,6 @@ namespace EcoSIM { namespace { //Here are the major function that the engine will need - void CopyBGCState(BGCState* dest, BGCState* src) { memcpy(dest->fluid_density.data, src->fluid_density.data, sizeof(double) * src->fluid_density.size); @@ -76,10 +75,6 @@ BGCEngine::BGCEngine(const std::string& engineName, { Errors::Message msg; - // NOTE: Alquimia now has a "hands-off" mode in which Alquimia relies on - // NOTE: reaction properties from the engine as opposed to the ones provided - // NOTE: in Amanzi's input file. As stop-gap solution hands-off is indicated - // NOTE: by the + sign at end of engine name bool hands_off = false; if (bgc_engine_name_ == "EcoSIM") hands_off = true; @@ -160,10 +155,9 @@ BGCEngine::~BGCEngine() delete iter->second; }*/ - //FreeBGCState(state); - //FreeBGCProperties(props); - //FreeBGCAuxiliaryData(aux_data); - + FreeBGCProperties(&props); + FreeBGCState(&state); + FreeBGCAuxiliaryData(&aux_data); //FreeAlquimiaEngineStatus(&chem_status_); } diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index dfed7c9e9..670db6579 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -4,6 +4,12 @@ License: see $ATS_DIR/COPYRIGHT Author: Andrew Graus + This is the main PK for the EcoSIM-ATS interface. This code is written + following the example of Alquimia with some additional code from the + SimpleBGC code for walking the columns. + + The idea is to take the basic code used by alquimia and repurpose it so + that it works on a column by column basis instead of a cell by cell basis --------------------------------------------------------------------------*/ @@ -38,13 +44,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, ncells_per_col_(-1), saved_time_(0.0) { + //grab the relevant domains, surface is needed to find the columns later domain_ = plist_->get("domain name", "domain"); domain_surf_ = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); // obtain key of fields - // What fields will we need to pass to EcoSIM, presumably fields relating to - // transport, flow, and energy - // What do we need for EcoSIM? Based on the variables doc it is: // grid position (X,Y,Z) - can we just pass Z and assume X and Y are 0? // Aspect in geometric format // water table depth - There's a water table evaluator in @@ -59,6 +63,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // mass_density_ice // mass_gas_density // + // additionally temperature doesn't work because it is owned by energy + // // // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); @@ -105,12 +111,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //ka_ = 1.e-6 * plist_.get("heat capacity [J kg^-1 K^-1]"); //Unclear what we need - // Here is where Alquimia initializes the Chemistry engine which handles differences between - // CrunchFlow and PFlotran and eventually runs either code to advance the Chemistry - // We will probably need something like this eventually if we add in other BGC codes but it - // is very complex and we can almost certainly do something simpler to start out with to just get - // EcoSIM running. - + //This initialized the engine (found in BGCEngine.cc) This is the code that + //actually points to the driver if (!plist_->isParameter("engine")) { Errors::Message msg; msg << "No 'engine' parameter found in the parameter list for 'BGC'.\n"; @@ -124,44 +126,18 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string engine_name = plist_->get("engine"); std::string engine_inputfile = plist_->get("engine input file"); bgc_engine_ = Teuchos::rcp(new BGCEngine(engine_name, engine_inputfile)); - - //comp_names_.clear(); - //bgc_engine_->GetPrimarySpeciesNames(comp_names_); - - //number_aqueous_components_ = comp_names_.size(); - //number_free_ion_ = number_aqueous_components_; - //number_total_sorbed_ = number_aqueous_components_; - } -/* ******************************************************************* -* Destroy ansilary data structures. -******************************************************************* */ + +// -- Destroy ansilary data structures. EcoSIM::~EcoSIM() { if (bgc_initialized_) bgc_engine_->FreeState(bgc_props_, bgc_state_, bgc_aux_data_); } - -// now the PK setup +// -- Setup step void EcoSIM::Setup() { - std::cout << "beginning Ecosim setup\n"; - //PK_Physical_Default::Setup(); - - /*This is for setting up the Auxiliary Output data which I'm not sure we need - chem_engine_->GetAuxiliaryOutputNames(aux_names_, aux_subfield_names_); - for (size_t i = 0; i < aux_names_.size(); ++i) { - aux_names_[i] = Keys::getKey(domain_, aux_names_[i]); - - if (!S_->HasRecord(aux_names_[i])) { - S_->Require(aux_names_[i], tag_next_, passwd_, aux_subfield_names_[i]) - .SetMesh(mesh_)->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::CELL, aux_subfield_names_[i].size()); - } - } - */ - //Need to do some basic setup of the columns: mesh_surf_ = S_->GetMesh(domain_surf_); num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -208,16 +184,12 @@ void EcoSIM::Setup() { S_->GetRecordW(alquimia_aux_data_key_, tag_next_, passwd_).set_io_vis(false); } */ - std::cout << "\nEnd setup\n"; } // -- Initialize owned (dependent) variables. void EcoSIM::Initialize() { - std::cout << "\nBegin Initialize\n"; - //PK_Physical_Default::Initialize(); - //Now we have to initalize the variables (i.e. give them initial values) - //In our PK it will only be done for variables owned by the PK so the aux_names + //In our PK it will only be done for variables owned by the PK //Keeping an example of how it's done generically here: //S_->GetW("co2_decomposition", tag_next_, name_).PutScalar(0.); //S_->GetRecordW("co2_decomposition", tag_next_, name_).set_initialized(); @@ -231,22 +203,12 @@ void EcoSIM::Initialize() { }*/ //Now we call the engine's init state function which allocates the data - std::cout << "\ninitializing BGC engine with: " << ncells_per_col_ << "\n"; bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_); - std::cout << "\engine initialized\n"; - //This function calls four separate functions from the interface: - // AllocateAlquimiaProperties - Allocates the properties which are things - // chemistry doesn't change - // AllocateAlquimiaState - Allocates properties of things chemistry CAN change - // AllocateAqluimiaAuxiliaryData - Allocates variables Alquimia needs to carry - // over between runs but ATS doesn't need - // AllocateAlquimiaAuxiliaryOutputData - Allocates variables that ATS will eventually - // output (probably don't need for now) + int ierr = 0; - // Ensure dependencies are fille - std::cout << "\nfilling dependencies\n"; + // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); @@ -262,32 +224,14 @@ void EcoSIM::Initialize() { S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); - std::cout << "\ndependencies filled\n"; int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - //This is the main set up code in alquimia it loops over times and chemical conditions - //I don't know that we need the two initial loops. I'm just including them because we might - std::cout << "\ninitializing column loop\n"; + //Looping over the columns and initializing for (int col=0; col!=num_cols_; ++col) { - //FieldToColumn_(col, temp, col_temp.ptr()); - //ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); - //We're going to need to write an InitializeSingleColumn code - //ierr = InitializeSingleCell(cell, condition); - std::cout << "\ninitializing column "<< col <<" \n"; ierr = InitializeSingleColumn(col); - //In Alquimia this function simply calls CopyToAlquimia, then - //Calls the chemistry engine and enforces condition, then copies - //From Alquimia to Amanzi - // - //The copy to alquimia function takes the cell index, because it - //is assigning things cell by cell in state. For colums this will - //be a bit trickier I THINK we could use the FieldToColumn_ function - //To do this, but I think I will actually need to figure out a test - //for this before I actually code it up } - std::cout << "\nfinishing initialize\n"; // verbose message if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); @@ -297,7 +241,6 @@ void EcoSIM::Initialize() { } void EcoSIM::CommitStep(double t_old, double t_new, const Tag& tag) { - std::cout << "\nRunning commit\n"; // I don't know that we will have much to do here. In SimpleBGC they just copy // Data to the pfts, which we won't be doing. In Alquimia they just save the time @@ -305,7 +248,6 @@ void EcoSIM::CommitStep(double t_old, double t_new, const Tag& tag) { saved_time_ = t_new; - std::cout << "\nEnd commit\n"; } bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { @@ -329,9 +271,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { << "----------------------------------------------------------------" << std::endl; // Ensure dependencies are filled - // Fix this from DEFAULT, see amanzi/amanzi#646 --etc - // Update all dependencies again - std::cout << "\nupdating dependencies\n"; S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); @@ -348,24 +287,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); - //--------------------------------------------------------------------------- - //BGCSimple Advance - //--------------------------------------------------------------------------- - // Copy the PFT from old to new, in case we failed the previous attempt at - // this timestep. This is hackery to get around the fact that PFTs are not - // (but should be) in state. AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); // grab the required fields - /* - Epetra_MultiVector& sc_pools = *S_->GetW(key_, tag_next_, name_) - .ViewComponent("cell",false); - Epetra_MultiVector& co2_decomp = *S_->GetW("co2_decomposition", tag_next_, name_) - .ViewComponent("cell",false); - Epetra_MultiVector& trans = *S_->GetW(trans_key_, tag_next_, name_) - .ViewComponent("cell",false);*/ - //Do I need to update everything here? - std::cout << "\nGrabbing evaluators\n"; S_->GetEvaluator("porosity", tag_next_).Update(*S_, name_); const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) .ViewComponent("cell",false))(0); @@ -422,20 +346,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& cell_volume = *(*S_->Get("cell_volume", tag_next_) .ViewComponent("cell",false))(0); - //S_->GetEvaluator("pressure", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& pres = *S_->Get("pressure", tag_next_) - // .ViewComponent("cell",false); - - // note that this is used as the column area, which is maybe not always - // right. Likely correct for soil carbon calculations and incorrect for - // surface vegetation calculations (where the subsurface's face area is more - // correct?) - //S_->GetEvaluator("surface-cell_volume", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& scv = *(*S_->Get("surface-cell_volume", tag_next_) - // .ViewComponent("cell", false))(0); - // loop over columns and apply the model - std::cout << "\nBegining advance loop\n"; for (AmanziMesh::Entity_ID col=0; col!=num_cols_; ++col) { auto& col_iter = mesh_->cells_of_column(col); @@ -443,18 +354,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //Copy to EcoSIM structures - // call the model - // This will be where we call the main function which advances ecosim - //BGCAdvance(S_->get_time(tag_current_), dt, scv[0][col], cryoturbation_coef_, met, - // *temp_c, *pres_c, *depth_c, *dz_c, - // pfts_[col], soil_carbon_pools_[col], - // co2_decomp_c, trans_c, sw_c); std::cout << "\nAdvancing col "<< col <<"\n"; AdvanceSingleColumn(dt, col); std::cout << "\nfinished advancing column\n"; - //Copy back to Amanzi - } // end loop over columns // mark primaries as changed @@ -468,59 +371,20 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { std::cout << "\nEnd Advance\n"; } -//--------------------------------------------------------------------------- -//Here are the BGCSimple helper functions -//--------------------------------------------------------------------------- - // helper function for pushing field to column void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, Teuchos::Ptr col_vec) { - std::cout << "\ncol: "<< col <<"\n"; auto& col_iter = mesh_->cells_of_column(col); - std::cout << "\ncol_iter: "<< col_iter.size() <<"\n"; for (std::size_t i=0; i!=col_iter.size(); ++i) { std::size_t vec_index = col_iter[i]; - std::cout << "for i: " << i << "vec_index: " << vec_index << "\n"; - std::cout << "vec[" << vec_index << "]: " << vec[vec_index] << "\n"; - } - - - for (std::size_t i=0; i!=col_iter.size(); ++i) { - - if (i >= col_vec->Length()) { - std::cout << "Error: index " << i << " is out of bounds for col_vec\n"; - } - - std::size_t vec_index = col_iter[i]; - - if (vec_index >= vec.MyLength()) { - std::cout << "Error: index " << vec_index << " is out of bounds for vec\n"; - } - std::cout << "col_vec[" << i << "]: " << (*col_vec)[i] << "\n"; - std::cout << "vec[" << vec_index << "]: " << vec[vec_index] << "\n"; - - //(*col_vec)[i] = vec[vec_index]; (*col_vec)[i] = vec[vec_index]; } } -// helper function for pushing field to column -/*void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& vec, - Teuchos::Ptr col_vec) -{ - auto& col_iter = mesh_->cells_of_column(col); - for (std::size_t i=0; i!=col_iter.size(); ++i) { - col_vec[i] = vec[col_iter[i]]; - } -}*/ - -// I think I need a function for pushing from the column back to the field -// with any luck it's just the reverse of the above similar to how it's done -// cell by cell in alquimia - +// helper function for pushing column back to field void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, Teuchos::Ptr col_vec) { @@ -574,17 +438,7 @@ void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, } } -//--------------------------------------------------------------------------- -//Alquimia Helper functions -//--------------------------------------------------------------------------- -/*void EcoSIM::CopyToEcoSIM(int col, - BGCProperties& props, - BGCState& state, - BGCAuxiliaryData& aux_data) -{ - CopyToEcoSIM(col, props, state, aux_data); -}*/ - +//Copy to EcoSIM void EcoSIM::CopyToEcoSIM(int col, BGCProperties& props, BGCState& state, @@ -592,10 +446,6 @@ void EcoSIM::CopyToEcoSIM(int col, const Tag& water_tag) { //Fill state with ATS variables that are going to be changed by EcoSIM - //NEED TO DECIDE WHICH PROPERTIES GO WHERE - std::cout << "\nviewing components\n"; - //Might need to switch - //const Epetra_MultiVector& temp also set ViewComponent to false const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& tcc = *(*S_->Get(tcc_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); @@ -615,9 +465,7 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data - std::cout << "\ncreating column vectors with size: "<< ncells_per_col_ << "\n"; auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - std::cout << "\ncreated first column\n"; auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -637,8 +485,6 @@ void EcoSIM::CopyToEcoSIM(int col, //to the data structures that will pass the data to EcoSIM //Format is: //FieldToColumn_(column index, dataset to copy from, vector to put the data in) - - //FieldToColumn_(col,tcc,col_tcc.ptr()); std::cout << "\nCopying Amanzi field to column vector\n"; FieldToColumn_(col,porosity,col_poro.ptr()); std::cout << "\npushed first column\n"; @@ -658,11 +504,7 @@ void EcoSIM::CopyToEcoSIM(int col, // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this - // automatically, but I just want to test this for now - - std::cout << "\nlooping over cells and copying to EcoSIM data structure\n"; for (int i=0; i < ncells_per_col_; ++i) { - std::cout << "\nlooping through cell " << i << "\n"; state.fluid_density.data[i] = (*col_f_dens)[i]; state.gas_density.data[i] = (*col_g_dens)[i]; state.ice_density.data[i] = (*col_i_dens)[i]; @@ -679,24 +521,11 @@ void EcoSIM::CopyToEcoSIM(int col, props.volume.data[i] = (*col_vol)[i]; } - std::cout << "\nFinished loop\n"; //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; num_components_ = tcc.NumVectors(); - //This probably isn't going to work. I think I either need to think - //of a way to do this - //Possible ideas: - // 1) creat a data column per component (how to do that without hard coding?) - // 2) have some sort of array of shape num_componentsXcolumnsize and loop over - // the components - // For #2 I think I just need to change the serieal dense vector call to - // a different data type (are these always 1d?) What is the 2d version? - //for (int i = 0; i < num_components; i++) { - // bgc_state.total_mobile.data[i] = (*col_tcc)[i]; - //} - // Auxiliary data -- block copy. /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); @@ -734,24 +563,9 @@ void EcoSIM::CopyFromEcoSIM(const int col, // be updated here. // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - //I probably need to copy the columns cell by cell in a loop - //Can I do this in the field to column function? //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - //There are various ways to access data unclear which I need - //Attempt 1 fails - //Epetra_MultiVector& porosity = *S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell"); - - //Attempt 2 - //porosity = Teuchos::rcp(new Epetra_MultiVector(*S_->Get("porosity").ViewComponent("cell", true))); - - //Attempt 3 - //porosity = S_->GetPtrW(poro_key_, water_tag, passwd_)->ViewComponent("cell", false)); - - //Attempt 4 - //Teuchos::RCP porosity = S_->GetW(poro_key_, water_tag, passwd_).ViewComponent("cell", true); - //Attempt 5 (ELM; this should work) auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); @@ -769,7 +583,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); - //I think I need to redefine this here? auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -786,8 +599,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - /*Can't save cell by cell doesn't seem to work like this*/ - for (int i=0; i < ncells_per_col_; ++i) { (*col_f_dens)[i] = state.fluid_density.data[i]; (*col_g_dens)[i] = state.gas_density.data[i]; @@ -805,9 +616,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_vol)[i] = props.volume.data[i]; } - /*for (int i = 0; i < num_components; i++) { - bgc_state.total_mobile.data[i] = (*col_tcc)[i]; - }*/ //Here is where the auxiliary data is filled need to try to change this to columns //This may not be trivial @@ -847,22 +655,18 @@ void EcoSIM::CopyFromEcoSIM(const int col, } /* ******************************************************************* -* This helper performs initialization on a single cell within Amanzi's state. -* It returns an error code that indicates success (0) or failure (1). +* This helper performs initialization on a single column within Amanzi's state. ******************************************************************* */ int EcoSIM::InitializeSingleColumn(int col) { - // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but - // should use the same tag as transport. See #673 - std::cout << "\nCopying to EcoSIM\n"; CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - std::cout << "\nFinished Copying to EcoSIM\n"; - //bgc_engine_->EnforceCondition(condition, current_time_, bgc_props_, - // bgc_state_, bgc_aux_data_); - std::cout << "\nCopying back to Amanzi\n"; + /* ******************************************************************* + * Here is where we will put the call to the BGC engine's set ICs for + * EcoSIM function + ******************************************************************* */ + CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - std::cout << "\nFinished copying to Amanzi\n"; // ETC: hacking to get consistent solution -- if there is no water // (e.g. surface system, we still need to call EnforceCondition() as it also @@ -877,22 +681,15 @@ int EcoSIM::InitializeSingleColumn(int col) /* ******************************************************************* * This helper advances the solution on a single cell within Amanzi's state. -* It returns the number of iterations taken to obtain the advanced solution, -* or -1 if an error occurred. ******************************************************************* */ int EcoSIM::AdvanceSingleColumn(double dt, int col) { - // Copy the state and property information from Amanzi's state within - // this cell to Alquimia. - // // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but // should use the same tag as transport. See #673 CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 0; - - //Think a bit about what to do with this - /***************************************************************** +/***************************************************************** ADVANCE CALL GOES HERE ****************************************************************** diff --git a/src/pks/ecosim_pk/data/BGC_constants.cc b/src/pks/ecosim_pk/data/BGC_constants.cc index 8d35ac4fb..328c1ce26 100644 --- a/src/pks/ecosim_pk/data/BGC_constants.cc +++ b/src/pks/ecosim_pk/data/BGC_constants.cc @@ -27,6 +27,10 @@ ** Authors: Benjamin Andre */ +/*This code is a modification of the constants code contained within alquimia +as of right now it's only needed to hold the size of the string, it could be +eliminated eventually and this code could be removed along with the +corresponding header file*/ #include "BGC_constants.hh" diff --git a/src/pks/ecosim_pk/data/BGC_constants.hh b/src/pks/ecosim_pk/data/BGC_constants.hh index a79b68044..45daecf65 100644 --- a/src/pks/ecosim_pk/data/BGC_constants.hh +++ b/src/pks/ecosim_pk/data/BGC_constants.hh @@ -1,7 +1,7 @@ /* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ /* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, ** through Lawrence Berkeley National Laboratory (subject to receipt of any ** required approvals from the U.S. Dept. of Energy). All rights reserved. ** @@ -27,6 +27,11 @@ ** Authors: Benjamin Andre */ +/*This code is a modification of the constants code contained within alquimia +as of right now it's only needed to hold the size of the string, it could be +eliminated eventually and this code could be removed along with the +corresponding code file*/ + #ifndef BGC_CONSTANTS_H_ #define BGC_CONSTANTS_H_ diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index b9ea7ecb2..6987cf558 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -49,9 +49,6 @@ #include "BGC_memory.hh" #include "BGC_containers.hh" #include "BGC_constants.hh" -//#include "alquimia/alquimia_interface.h" -//#include "alquimia/alquimia_constants.h" -//#include "alquimia/alquimia_containers.h" // Returns the nearest power of 2 greater than or equal to n, or 0 if n == 0. static inline int nearest_power_of_2(int n) @@ -89,7 +86,7 @@ void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { vector->capacity = 0; vector->data = NULL; } -} /* end AllocateAlquimiaVectorDouble() */ +} /* end AllocateBGCVectorDouble() */ void FreeBGCVectorDouble(BGCVectorDouble* vector) { if (vector != NULL) { @@ -98,7 +95,7 @@ void FreeBGCVectorDouble(BGCVectorDouble* vector) { vector->size = 0; vector->capacity = 0; } -} /* end FreeAlquimiaVectorDouble() */ +} /* end FreeBGCVectorDouble() */ void AllocateBGCVectorInt(const int size, BGCVectorInt* vector) { if (size > 0) { @@ -111,7 +108,7 @@ void AllocateBGCVectorInt(const int size, BGCVectorInt* vector) { vector->capacity = 0; vector->data = NULL; } -} /* end AllocateAlquimiaVectorInt() */ +} /* end AllocateBGCVectorInt() */ void FreeBGCVectorInt(BGCVectorInt* vector) { if (vector != NULL) { @@ -120,7 +117,7 @@ void FreeBGCVectorInt(BGCVectorInt* vector) { vector->size = 0; vector->capacity = 0; } -} /* end FreeAlquimiaVectorInt() */ +} /* end FreeBGCVectorInt() */ void AllocateBGCVectorString(const int size, BGCVectorString* vector) { int i; @@ -138,7 +135,7 @@ void AllocateBGCVectorString(const int size, BGCVectorString* vector) { vector->capacity = 0; vector->data = NULL; } -} /* end AllocateAlquimiaVectorString() */ +} /* end AllocateBGCVectorString() */ void FreeBGCVectorString(BGCVectorString* vector) { int i; @@ -151,7 +148,7 @@ void FreeBGCVectorString(BGCVectorString* vector) { vector->size = 0; vector->capacity = 0; } -} /* end FreeAlquimiaVectorString() */ +} /* end FreeBGCVectorString() */ /******************************************************************************* ** @@ -180,7 +177,7 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, std::cout << "Finished state allocation" << std::endl; //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); -} /* end AllocateAlquimiaState() */ +} /* end AllocateBGCState() */ void FreeBGCState(BGCState* state) { if (state != NULL) { From 5a431a42b02e2df1ed5197cb79f01fb790621d1c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 11 Apr 2023 16:15:10 -0700 Subject: [PATCH 189/582] trying something kinda silly with temp --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 +++++++- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 670db6579..41099d1a9 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -184,6 +184,11 @@ void EcoSIM::Setup() { S_->GetRecordW(alquimia_aux_data_key_, tag_next_, passwd_).set_io_vis(false); } */ + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << vo_->color("green") << "Setup of PK was successful, T=" + << S_->get_time() << vo_->reset() << std::endl << std::endl; + } } // -- Initialize owned (dependent) variables. @@ -579,7 +584,8 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); - //auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, name()).ViewComponent("cell",false); + + auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, "").ViewComponent("cell",false); auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index ccbb7e1ff..0122b5bd2 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -182,6 +182,8 @@ class EcoSIM : public PK_Physical { BGCAuxiliaryData bgc_aux_data_; bool bgc_initialized_; + bool using_energy_; + bool using_gas_; private: //factory registration From 17add0b6a442398176977a085a52e6ab826d7b22 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 11 Apr 2023 16:42:05 -0700 Subject: [PATCH 190/582] fix --- src/pks/ecosim_pk/BGCEngine.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 03a68b9c9..8ec0d3f17 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -155,9 +155,9 @@ BGCEngine::~BGCEngine() delete iter->second; }*/ - FreeBGCProperties(&props); - FreeBGCState(&state); - FreeBGCAuxiliaryData(&aux_data); + //FreeBGCProperties(&props); + //FreeBGCState(&state); + //FreeBGCAuxiliaryData(&aux_data); //FreeAlquimiaEngineStatus(&chem_status_); } From 7110a974b1640322490d9cf34bd9ceea70ef05d2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 11 Apr 2023 17:09:35 -0700 Subject: [PATCH 191/582] bugfix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 41099d1a9..77408064d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -186,8 +186,8 @@ void EcoSIM::Setup() { */ if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << vo_->color("green") << "Setup of PK was successful, T=" - << S_->get_time() << vo_->reset() << std::endl << std::endl; + *vo_->os() << vo_->color("green") << "Setup of PK was successful" + << vo_->reset() << std::endl << std::endl; } } From b11e7ed8e336b9ac57ef2a98e2415c836cc0ffea Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 11 Apr 2023 17:20:53 -0700 Subject: [PATCH 192/582] just trying the password energy --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 77408064d..0a5353b79 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -585,7 +585,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); - auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, "").ViewComponent("cell",false); + auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false); auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); From e5c44b3859cbb7e8da06b79916f597053d2589ae Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Apr 2023 11:38:20 -0700 Subject: [PATCH 193/582] added in the calls to run the evaluators --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 39 +++++++++++++++++++++++ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 ++ 2 files changed, 41 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0a5353b79..a0b7596db 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -29,6 +29,10 @@ #include "exceptions.hh" #include "Mesh.hh" +// include evaluators here +#include "hydraulic_conductivity_evaluator.hh" +#include "bulk_density_evaluator.hh" + #include "pk_helpers.hh" #include "EcoSIM_ATS_interface.hh" @@ -100,6 +104,10 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); + //Evaluator keys + hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); + //bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); + // parameters // initial timestep dt_ = plist_->get("initial time step", 1.); @@ -184,6 +192,23 @@ void EcoSIM::Setup() { S_->GetRecordW(alquimia_aux_data_key_, tag_next_, passwd_).set_io_vis(false); } */ + + //Setup Evaluators + requireAtNext(hydra_cond_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireAtCurrent(hydra_cond_key_, tag_current_, *S_, name_); + + /*requireAtNext(bulk_dens_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireAtCurrent(bulk_dens_key_, tag_current_, *S_, name_);*/ + + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -230,6 +255,13 @@ void EcoSIM::Initialize() { S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + //Initialize owned evaluators + S_->GetW(hydra_cond_key_, tag_next_, name_).PutScalar(1.0); + S_->GetRecordW(hydra_cond_key_, tag_next_, name_).set_initialized(); + + //S_->GetW(bulk_dens_key_, tag_next_, name_).PutScalar(1.0); + //S_->GetRecordW(bulk_dens_key_, tag_next_, name_).set_initialized(); + int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //Looping over the columns and initializing @@ -292,6 +324,13 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + //Update owned evaluators + Teuchos::RCP hydra_cond = S_->GetPtr(hydra_cond_key_, Tags::DEFAULT); + S_->GetEvaluator(hydra_cond_key_, Tags:DEFAULT).Update(*S_, name_); + + //Teuchos::RCP bulk_dens = S_->GetPtr(bulk_dens_key_, Tags::DEFAULT); + //S_->GetEvaluator(bulk_dens_key_, Tags:DEFAULT).Update(*S_, name_); + AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); // grab the required fields diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 0122b5bd2..cc64b8783 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -173,6 +173,8 @@ class EcoSIM : public PK_Physical { Key cv_key_; Key min_vol_frac_key_; Key ecosim_aux_data_key_; + Key bulk_dens_key_; + Key hydra_cond_key_; Teuchos::RCP bgc_engine_; From c29c76d11b914f282d9da54bed3dd30f1f12864a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Apr 2023 13:14:10 -0700 Subject: [PATCH 194/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index a0b7596db..6f8ab3594 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -326,10 +326,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //Update owned evaluators Teuchos::RCP hydra_cond = S_->GetPtr(hydra_cond_key_, Tags::DEFAULT); - S_->GetEvaluator(hydra_cond_key_, Tags:DEFAULT).Update(*S_, name_); + S_->GetEvaluator(hydra_cond_key_, Tags::DEFAULT).Update(*S_, name_); //Teuchos::RCP bulk_dens = S_->GetPtr(bulk_dens_key_, Tags::DEFAULT); - //S_->GetEvaluator(bulk_dens_key_, Tags:DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(bulk_dens_key_, Tags::DEFAULT).Update(*S_, name_); AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); From d189078416502a4fa06d09da00141890faedc21e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Apr 2023 14:16:07 -0700 Subject: [PATCH 195/582] changing some tags --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 6f8ab3594..2dfb51a01 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -256,8 +256,10 @@ void EcoSIM::Initialize() { S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); //Initialize owned evaluators - S_->GetW(hydra_cond_key_, tag_next_, name_).PutScalar(1.0); - S_->GetRecordW(hydra_cond_key_, tag_next_, name_).set_initialized(); + *vo_->os() << "Getting hydraulic conductivity" << std::endl; + S_->GetW(hydra_cond_key_, Tags::DEFAULT, name_).PutScalar(1.0); + *vo_->os() << "recording to hydraulic" << std::endl; + S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, name_).set_initialized(); //S_->GetW(bulk_dens_key_, tag_next_, name_).PutScalar(1.0); //S_->GetRecordW(bulk_dens_key_, tag_next_, name_).set_initialized(); @@ -329,7 +331,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(hydra_cond_key_, Tags::DEFAULT).Update(*S_, name_); //Teuchos::RCP bulk_dens = S_->GetPtr(bulk_dens_key_, Tags::DEFAULT); - //S_->GetEvaluator(bulk_dens_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(bulk_dens_key_, Tags::DEFAULT).Update(*S_, name_); AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); From 53c6d96b358b992c2b9e238423e7eab22949747c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Apr 2023 14:49:03 -0700 Subject: [PATCH 196/582] bug in namespace names --- .../bulk_density/bulk_density_evaluator_reg.hh | 2 +- .../hydraulic_conductivity_evaluator_reg.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh index 029ee74cc..45e7753a7 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh @@ -1,7 +1,7 @@ #include "bulk_density_evaluator.hh" namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { Utils::RegisteredFactory BulkDensityEvaluator::reg_("bulk density"); diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh index fdaa8e2fc..63570e4a7 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh @@ -1,7 +1,7 @@ #include "hydraulic_conductivity_evaluator.hh" namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { Utils::RegisteredFactory HydraulicConductivityEvaluator::reg_("hydraulic conductivity"); From 44f2173382f3ddc53f05993e97a56b7368aa7bb5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Apr 2023 15:11:15 -0700 Subject: [PATCH 197/582] more namespace changes --- .../bulk_density/bulk_density_evaluator.cc | 2 +- .../bulk_density/bulk_density_evaluator.hh | 6 +++--- .../bulk_density/bulk_density_model.cc | 5 ++--- .../bulk_density/bulk_density_model.hh | 12 ++++++------ .../hydraulic_conductivity_evaluator.cc | 2 +- .../hydraulic_conductivity_evaluator.hh | 6 +++--- .../hydraulic_conductivity_model.cc | 5 ++--- .../hydraulic_conductivity_model.hh | 12 ++++++------ 8 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc index 537b92c7c..93c11a6ef 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc @@ -8,7 +8,7 @@ Richards water content evaluator: the standard form as a function of liquid satu #include "bulk_density_model.hh" namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { // Constructor from ParameterList diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh index a7c20ddef..cda44091d 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh @@ -7,14 +7,14 @@ Richards water content evaluator: the standard form as a function of liquid satu Authors: Ethan Coon (ecoon@lanl.gov) */ -#ifndef AMANZI_ECOSIM_PK_BULK_DENSITY_EVALUATOR_HH_ -#define AMANZI_ECOSIM_PK_BULK_DENSITY_EVALUATOR_HH_ +#ifndef AMANZI_ECOSIM_BULK_DENSITY_EVALUATOR_HH_ +#define AMANZI_ECOSIM_BULK_DENSITY_EVALUATOR_HH_ #include "Factory.hh" #include "EvaluatorSecondaryMonotype.hh" namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { class BulkDensityModel; diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc index 95af0c5c6..146b91e62 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc @@ -3,7 +3,7 @@ Generated via evaluator_generator with: Richards water content evaluator: the standard form as a function of liquid saturation. - + Authors: Ethan Coon (ecoon@lanl.gov) */ @@ -12,7 +12,7 @@ Richards water content evaluator: the standard form as a function of liquid satu #include "bulk_density_model.hh" namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { // Constructor from ParameterList @@ -88,4 +88,3 @@ BulkDensityModel::DBulkDensityDMolarDensityGas(double phi, double nr, double sl, } //namespace } //namespace } //namespace - \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh index 39380c2d4..af45aba74 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh +++ b/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh @@ -3,15 +3,15 @@ Generated via evaluator_generator with: Richards water content evaluator: the standard form as a function of liquid saturation. - + Authors: Ethan Coon (ecoon@lanl.gov) */ -#ifndef AMANZI_ECOSIM_PK_BULK_DENSITY_MODEL_HH_ -#define AMANZI_ECOSIM_PK_BULK_DENSITY_MODEL_HH_ +#ifndef AMANZI_ECOSIM_BULK_DENSITY_MODEL_HH_ +#define AMANZI_ECOSIM_BULK_DENSITY_MODEL_HH_ namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { class BulkDensityModel { @@ -30,7 +30,7 @@ class BulkDensityModel { double DBulkDensityDMolarDensityIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; double DBulkDensityDSaturationGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; double DBulkDensityDMolarDensityGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - + protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); @@ -44,4 +44,4 @@ class BulkDensityModel { } //namespace } //namespace -#endif \ No newline at end of file +#endif diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc index c66f59eb4..d773890f4 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc @@ -8,7 +8,7 @@ Richards water content evaluator: the standard form as a function of liquid satu #include "hydraulic_conductivity_model.hh" namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { // Constructor from ParameterList diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh index 7f7168c02..c9255d435 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh @@ -7,14 +7,14 @@ Richards water content evaluator: the standard form as a function of liquid satu Authors: Ethan Coon (ecoon@lanl.gov) */ -#ifndef AMANZI_ECOSIM_PK_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ -#define AMANZI_ECOSIM_PK_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ +#ifndef AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ +#define AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ #include "Factory.hh" #include "EvaluatorSecondaryMonotype.hh" namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { class HydraulicConductivityModel; diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc index 25dd7695f..767dce0f1 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc @@ -3,7 +3,7 @@ Generated via evaluator_generator with: Richards water content evaluator: the standard form as a function of liquid saturation. - + Authors: Ethan Coon (ecoon@lanl.gov) */ @@ -12,7 +12,7 @@ Richards water content evaluator: the standard form as a function of liquid satu #include "hydraulic_conductivity_model.hh" namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { // Constructor from ParameterList @@ -58,4 +58,3 @@ HydraulicConductivityModel::DHydraulicConductivityDViscosityLiquid(double k, dou } //namespace } //namespace } //namespace - \ No newline at end of file diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh index 3cb3a917d..243847384 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh @@ -3,15 +3,15 @@ Generated via evaluator_generator with: Richards water content evaluator: the standard form as a function of liquid saturation. - + Authors: Ethan Coon (ecoon@lanl.gov) */ -#ifndef AMANZI_ECOSIM_PK_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ -#define AMANZI_ECOSIM_PK_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ +#ifndef AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ +#define AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ namespace Amanzi { -namespace Ecosim_pk { +namespace Ecosim { namespace Relations { class HydraulicConductivityModel { @@ -25,7 +25,7 @@ class HydraulicConductivityModel { double DHydraulicConductivityDPermeabiilty(double k, double rho, double mu) const; double DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const; double DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const; - + protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); @@ -39,4 +39,4 @@ class HydraulicConductivityModel { } //namespace } //namespace -#endif \ No newline at end of file +#endif From 4540383c28d240ff47dab21a978660e3361cd055 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 13 Apr 2023 14:05:36 -0700 Subject: [PATCH 198/582] just trying to refactor the cmake --- .../constitutive_relations/CMakeLists.old.txt | 53 ++++++++++++++++++ .../constitutive_relations/CMakeLists.txt | 56 +++++++++++-------- 2 files changed, 85 insertions(+), 24 deletions(-) create mode 100644 src/pks/ecosim_pk/constitutive_relations/CMakeLists.old.txt diff --git a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.old.txt b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.old.txt new file mode 100644 index 000000000..c3bd09b07 --- /dev/null +++ b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.old.txt @@ -0,0 +1,53 @@ +# -*- mode: cmake -*- +# +# ATS +# Constitutive relations for flow +# + + +# collect all sources + +list(APPEND subdirs bulk_density hydraulic_conductivity) + +set(ats_ecosim_relations_src_files "") +set(ats_ecosim_relations_inc_files "") + +foreach(lcv IN LISTS subdirs) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/${lcv}) + + file(GLOB subdir_sources "./${lcv}/*.cc") + set(ats_ecosim_relations_src_files ${ats_ecosim_relations_src_files} ${subdir_sources}) + + file(GLOB subdir_incs "./${lcv}/*.hh") + set(ats_ecosim_relations_inc_files ${ats_ecosim_relations_inc_files} ${subdir_incs}) + + file(GLOB registrations "./${lcv}/*_reg.hh" ) + foreach(reg_lcv IN LISTS registrations) + register_abs_evaluator_with_factory(HEADERFILE ${reg_lcv} LISTNAME ATS_ECOISIM_RELATIONS_REG) + endforeach(reg_lcv) + +endforeach(lcv) + +set(ats_ecosim_relations_link_libs + ${Teuchos_LIBRARIES} + ${Epetra_LIBRARIES} + error_handling + atk + mesh + data_structures + whetstone + solvers + state + ) + +# make the library +add_amanzi_library(ats_ecosim_relations + SOURCE ${ats_ecosim_relations_src_files} + HEADERS ${ats_ecosim_relations_inc_files} + LINK_LIBS ${ats_ecosim_relations_link_libs}) + +generate_evaluators_registration_header( + HEADERFILE ats_ecosim_relations_registration.hh + LISTNAME ATS_ECOSIM_RELATIONS_REG + INSTALL True + ) diff --git a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt index c3bd09b07..862d14c4c 100644 --- a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt +++ b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt @@ -1,32 +1,23 @@ # -*- mode: cmake -*- # # ATS -# Constitutive relations for flow +# Constitutive relations for EcoSIM # - # collect all sources - -list(APPEND subdirs bulk_density hydraulic_conductivity) - -set(ats_ecosim_relations_src_files "") -set(ats_ecosim_relations_inc_files "") - -foreach(lcv IN LISTS subdirs) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/${lcv}) - - file(GLOB subdir_sources "./${lcv}/*.cc") - set(ats_ecosim_relations_src_files ${ats_ecosim_relations_src_files} ${subdir_sources}) - - file(GLOB subdir_incs "./${lcv}/*.hh") - set(ats_ecosim_relations_inc_files ${ats_ecosim_relations_inc_files} ${subdir_incs}) - - file(GLOB registrations "./${lcv}/*_reg.hh" ) - foreach(reg_lcv IN LISTS registrations) - register_abs_evaluator_with_factory(HEADERFILE ${reg_lcv} LISTNAME ATS_ECOISIM_RELATIONS_REG) - endforeach(reg_lcv) - -endforeach(lcv) +set(ats_ecosim_relations_src_files + bulk_density/bulk_density_evaluator.cc + bulk_density/bulk_density_model.cc + hydraulic_conductivity/hydraulic_conductivity_evaluator.cc + hydraulic_conductivity/hydraulic_conductivity_model.cc +) + +set(ats_ecosim_relations_inc_files + bulk_density/bulk_density_evaluator.hh + bulk_density/bulk_density_model.hh + hydraulic_conductivity/hydraulic_conductivity_evaluator.hh + hydraulic_conductivity/hydraulic_conductivity_model.hh +) set(ats_ecosim_relations_link_libs ${Teuchos_LIBRARIES} @@ -36,9 +27,16 @@ set(ats_ecosim_relations_link_libs mesh data_structures whetstone + operators solvers + time_integration state - ) + pks + chemistry_pk + ats_pks + ats_eos + ats_operators +) # make the library add_amanzi_library(ats_ecosim_relations @@ -46,6 +44,16 @@ add_amanzi_library(ats_ecosim_relations HEADERS ${ats_ecosim_relations_inc_files} LINK_LIBS ${ats_ecosim_relations_link_libs}) +register_evaluator_with_factory( + HEADERFILE constitutive_models/bulk_density/bulk_density_evaluator_reg.hh + LISTNAME ATS_ECOSIM_RELATIONS_REG +) + +register_evaluator_with_factory( + HEADERFILE constitutive_models/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh + LISTNAME ATS_ECOSIM_RELATIONS_REG +) + generate_evaluators_registration_header( HEADERFILE ats_ecosim_relations_registration.hh LISTNAME ATS_ECOSIM_RELATIONS_REG From d6102d88097849c589e795c6d8f0821efe1fbbc9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 13 Apr 2023 16:05:36 -0700 Subject: [PATCH 199/582] minor changes to cmake --- src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt index 862d14c4c..f9c58b1a4 100644 --- a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt +++ b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt @@ -4,6 +4,9 @@ # Constitutive relations for EcoSIM # +add_subdirectory(bulk_density) +add_subdirectory(hydraulic_conductivity) + # collect all sources set(ats_ecosim_relations_src_files bulk_density/bulk_density_evaluator.cc @@ -45,12 +48,12 @@ add_amanzi_library(ats_ecosim_relations LINK_LIBS ${ats_ecosim_relations_link_libs}) register_evaluator_with_factory( - HEADERFILE constitutive_models/bulk_density/bulk_density_evaluator_reg.hh + HEADERFILE bulk_density/bulk_density_evaluator_reg.hh LISTNAME ATS_ECOSIM_RELATIONS_REG ) register_evaluator_with_factory( - HEADERFILE constitutive_models/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh + HEADERFILE hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh LISTNAME ATS_ECOSIM_RELATIONS_REG ) From 22ef1a30251c0b558c9ab0411c6857f54b27443d Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 13 Apr 2023 16:51:02 -0700 Subject: [PATCH 200/582] removing an old file --- .../constitutive_relations/CMakeLists.old.txt | 53 ------------------- 1 file changed, 53 deletions(-) delete mode 100644 src/pks/ecosim_pk/constitutive_relations/CMakeLists.old.txt diff --git a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.old.txt b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.old.txt deleted file mode 100644 index c3bd09b07..000000000 --- a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.old.txt +++ /dev/null @@ -1,53 +0,0 @@ -# -*- mode: cmake -*- -# -# ATS -# Constitutive relations for flow -# - - -# collect all sources - -list(APPEND subdirs bulk_density hydraulic_conductivity) - -set(ats_ecosim_relations_src_files "") -set(ats_ecosim_relations_inc_files "") - -foreach(lcv IN LISTS subdirs) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/${lcv}) - - file(GLOB subdir_sources "./${lcv}/*.cc") - set(ats_ecosim_relations_src_files ${ats_ecosim_relations_src_files} ${subdir_sources}) - - file(GLOB subdir_incs "./${lcv}/*.hh") - set(ats_ecosim_relations_inc_files ${ats_ecosim_relations_inc_files} ${subdir_incs}) - - file(GLOB registrations "./${lcv}/*_reg.hh" ) - foreach(reg_lcv IN LISTS registrations) - register_abs_evaluator_with_factory(HEADERFILE ${reg_lcv} LISTNAME ATS_ECOISIM_RELATIONS_REG) - endforeach(reg_lcv) - -endforeach(lcv) - -set(ats_ecosim_relations_link_libs - ${Teuchos_LIBRARIES} - ${Epetra_LIBRARIES} - error_handling - atk - mesh - data_structures - whetstone - solvers - state - ) - -# make the library -add_amanzi_library(ats_ecosim_relations - SOURCE ${ats_ecosim_relations_src_files} - HEADERS ${ats_ecosim_relations_inc_files} - LINK_LIBS ${ats_ecosim_relations_link_libs}) - -generate_evaluators_registration_header( - HEADERFILE ats_ecosim_relations_registration.hh - LISTNAME ATS_ECOSIM_RELATIONS_REG - INSTALL True - ) From 2320534e52a13335101f344263f50f84bad6acd6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 13 Apr 2023 22:33:57 -0700 Subject: [PATCH 201/582] removing gravity --- .../hydraulic_conductivity/hydraulic_conductivity_model.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc index 767dce0f1..7c20df184 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc @@ -26,7 +26,7 @@ HydraulicConductivityModel::HydraulicConductivityModel(Teuchos::ParameterList& p void HydraulicConductivityModel::InitializeFromPlist_(Teuchos::ParameterList& plist) { - g_ = plist.get("gravitational constant"); + //g_ = plist.get("gravitational constant"); } From b333d6d3a2fe6fd8ff7d6e22968b78b416941054 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 13 Apr 2023 23:11:14 -0700 Subject: [PATCH 202/582] typo --- .../hydraulic_conductivity/hydraulic_conductivity.py | 2 +- .../hydraulic_conductivity_evaluator.cc | 6 +++--- .../hydraulic_conductivity/hydraulic_conductivity_model.cc | 2 +- .../hydraulic_conductivity/hydraulic_conductivity_model.hh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py index ae7e5fa26..719208235 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py @@ -4,7 +4,7 @@ sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) from evaluator_generator import generate_evaluator -deps = [("permeabiilty","k"), +deps = [("permeabilty","k"), ("mass_density_liquid", "rho"), ("viscosity_liquid", "mu"), ] diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc index d773890f4..91debd374 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc @@ -50,8 +50,8 @@ HydraulicConductivityEvaluator::InitializeFromPlist_() Tag tag = my_keys_.front().second; // - pull Keys from plist - // dependency: permeabiilty - k_key_ = Keys::readKey(plist_, domain_name, "permeabiilty", "permeabiilty"); + // dependency: permeabilty + k_key_ = Keys::readKey(plist_, domain_name, "permeabilty", "permeabilty"); dependencies_.insert(KeyTag{ k_key_, tag }); // dependency: mass_density_liquid @@ -107,7 +107,7 @@ HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DHydraulicConductivityDPermeabiilty(k_v[0][i], rho_v[0][i], mu_v[0][i]); + result_v[0][i] = model_->DHydraulicConductivityDPermeabilty(k_v[0][i], rho_v[0][i], mu_v[0][i]); } } diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc index 7c20df184..12d1a62e5 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc @@ -38,7 +38,7 @@ HydraulicConductivityModel::HydraulicConductivity(double k, double rho, double m } double -HydraulicConductivityModel::DHydraulicConductivityDPermeabiilty(double k, double rho, double mu) const +HydraulicConductivityModel::DHydraulicConductivityDPermeabilty(double k, double rho, double mu) const { return rho; } diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh index 243847384..d4b3b06b0 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh @@ -22,7 +22,7 @@ class HydraulicConductivityModel { double HydraulicConductivity(double k, double rho, double mu) const; - double DHydraulicConductivityDPermeabiilty(double k, double rho, double mu) const; + double DHydraulicConductivityDPermeabilty(double k, double rho, double mu) const; double DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const; double DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const; From 4aa88c2faa86b37bb6e187cf71b8eecae8ba5991 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 13 Apr 2023 23:28:12 -0700 Subject: [PATCH 203/582] another typo --- .../hydraulic_conductivity/hydraulic_conductivity.py | 2 +- .../hydraulic_conductivity_evaluator.cc | 6 +++--- .../hydraulic_conductivity/hydraulic_conductivity_model.cc | 2 +- .../hydraulic_conductivity/hydraulic_conductivity_model.hh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py index 719208235..4c053ef29 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py @@ -4,7 +4,7 @@ sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) from evaluator_generator import generate_evaluator -deps = [("permeabilty","k"), +deps = [("permeability","k"), ("mass_density_liquid", "rho"), ("viscosity_liquid", "mu"), ] diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc index 91debd374..0e589aef8 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc @@ -50,8 +50,8 @@ HydraulicConductivityEvaluator::InitializeFromPlist_() Tag tag = my_keys_.front().second; // - pull Keys from plist - // dependency: permeabilty - k_key_ = Keys::readKey(plist_, domain_name, "permeabilty", "permeabilty"); + // dependency: permeability + k_key_ = Keys::readKey(plist_, domain_name, "permeability", "permeability"); dependencies_.insert(KeyTag{ k_key_, tag }); // dependency: mass_density_liquid @@ -107,7 +107,7 @@ HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DHydraulicConductivityDPermeabilty(k_v[0][i], rho_v[0][i], mu_v[0][i]); + result_v[0][i] = model_->DHydraulicConductivityDPermeability(k_v[0][i], rho_v[0][i], mu_v[0][i]); } } diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc index 12d1a62e5..976c73c4b 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc @@ -38,7 +38,7 @@ HydraulicConductivityModel::HydraulicConductivity(double k, double rho, double m } double -HydraulicConductivityModel::DHydraulicConductivityDPermeabilty(double k, double rho, double mu) const +HydraulicConductivityModel::DHydraulicConductivityDPermeability(double k, double rho, double mu) const { return rho; } diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh index d4b3b06b0..f7a07f425 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh +++ b/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh @@ -22,7 +22,7 @@ class HydraulicConductivityModel { double HydraulicConductivity(double k, double rho, double mu) const; - double DHydraulicConductivityDPermeabilty(double k, double rho, double mu) const; + double DHydraulicConductivityDPermeability(double k, double rho, double mu) const; double DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const; double DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const; From 96f1a5222eebd843ab0e4759447d1f9a888bb5e5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 13 Apr 2023 23:42:08 -0700 Subject: [PATCH 204/582] changing password on hc --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 2dfb51a01..b9f1e34d7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -257,7 +257,7 @@ void EcoSIM::Initialize() { //Initialize owned evaluators *vo_->os() << "Getting hydraulic conductivity" << std::endl; - S_->GetW(hydra_cond_key_, Tags::DEFAULT, name_).PutScalar(1.0); + S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); *vo_->os() << "recording to hydraulic" << std::endl; S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, name_).set_initialized(); From f3bf5e036f4488699503b0266bff5406eb4316ef Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 13 Apr 2023 23:53:52 -0700 Subject: [PATCH 205/582] changing more keys --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b9f1e34d7..bdfcd939a 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -259,7 +259,7 @@ void EcoSIM::Initialize() { *vo_->os() << "Getting hydraulic conductivity" << std::endl; S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); *vo_->os() << "recording to hydraulic" << std::endl; - S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, name_).set_initialized(); + S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); //S_->GetW(bulk_dens_key_, tag_next_, name_).PutScalar(1.0); //S_->GetRecordW(bulk_dens_key_, tag_next_, name_).set_initialized(); From 08540c46357903b9136bbd884cadb64d72342010 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 14 Apr 2023 14:39:31 -0700 Subject: [PATCH 206/582] moved the tcc code to main. --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 33 +++++++++++++++++++++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 ++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index bdfcd939a..88d4a22a1 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -21,6 +21,7 @@ #include "Epetra_MultiVector.h" #include "Epetra_Vector.h" #include "Epetra_SerialDenseVector.h" +#include "Epetra_SerialDenseMatrix.h" #include "Teuchos_RCPDecl.hpp" #include "Teuchos_ParameterList.hpp" @@ -72,6 +73,13 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); + //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell + + if (plist_->isParameter("component names")) { + component_names_ = plist_->get>("component names").toVector(); + num_components = component_names_.size(); + // otherwise we hopefully get them from chemistry + } //Flow poro_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); @@ -527,6 +535,10 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + //For the concentration I do not want a vector but a matrix + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(num_components,ncells_per_col_)); + //Here is where we should do the various field-to-column calls to then pass along //to the data structures that will pass the data to EcoSIM //Format is: @@ -547,6 +559,10 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,temp, col_temp.ptr()); FieldToColumn_(col,conductivity,col_cond.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); + //Fill the tcc matrix component by component? + for (int i=0; i < num_components; ++i) { + FieldToColumn_(col,tcc[i],col_tcc[i].ptr()); + } // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this @@ -557,6 +573,9 @@ void EcoSIM::CopyToEcoSIM(int col, state.porosity.data[i] = (*col_poro)[i]; state.water_content.data[i] = (*col_wc)[i]; state.temperature.data[i] = (*col_temp)[i]; + for (int j=0; i < num_components; ++j) { + state.tcc.data[j][i] = (*col_tcc)[j][i]; + } props.liquid_saturation.data[i] = (*col_l_sat)[i]; props.gas_saturation.data[i] = (*col_g_sat)[i]; @@ -570,7 +589,7 @@ void EcoSIM::CopyToEcoSIM(int col, //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; - num_components_ = tcc.NumVectors(); + //num_components_ = tcc.NumVectors(); // Auxiliary data -- block copy. /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { @@ -645,6 +664,9 @@ void EcoSIM::CopyFromEcoSIM(const int col, //auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + //For the concentration I do not want a vector but a matrix + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(num_components,ncells_per_col_)); + for (int i=0; i < ncells_per_col_; ++i) { (*col_f_dens)[i] = state.fluid_density.data[i]; @@ -652,7 +674,10 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_i_dens)[i] = state.ice_density.data[i]; (*col_poro)[i] = state.porosity.data[i]; (*col_wc)[i] = state.water_content.data[i]; - //(*col_temp)[i] = state.temperature.data[i]; + (*col_temp)[i] = state.temperature.data[i]; + for (int j=0; i < num_components; ++j) { + (*col_tcc)[j][i] = state.tcc.data[j][i]; + } (*col_l_sat)[i] = props.liquid_saturation.data[i]; (*col_g_sat)[i] = props.gas_saturation.data[i]; @@ -699,6 +724,10 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,conductivity,col_cond.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); + for (int i=0; i < num_components; ++i) { + ColumnToField_(col,tcc[i],col_tcc[i].ptr()); + } + } /* ******************************************************************* diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index cc64b8783..856650ea2 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -29,6 +29,7 @@ #include "Teuchos_ParameterList.hpp" #include "Teuchos_RCP.hpp" #include "Epetra_SerialDenseVector.h" +#include "Epetra_SerialDenseMatrix.h" #include "VerboseObject.hh" #include "TreeVector.hh" @@ -149,7 +150,6 @@ class EcoSIM : public PK_Physical { //Teuchos::RCP p_root_eval_; int number_aqueous_components_; - int num_components_; int ncells_per_col_; int num_cols_; double saved_time_; @@ -186,6 +186,8 @@ class EcoSIM : public PK_Physical { bool bgc_initialized_; bool using_energy_; bool using_gas_; + std::vector component_names_; + int num_components; private: //factory registration From e68e6b47b3ac6f87ba7d474d1be46c79a821b80e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 11:56:44 -0700 Subject: [PATCH 207/582] adding memory strucutres for tcc --- src/pks/ecosim_pk/BGCEngine.cc | 5 +- src/pks/ecosim_pk/BGCEngine.hh | 3 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 +- src/pks/ecosim_pk/data/BGC_containers.hh | 16 ++++ src/pks/ecosim_pk/data/BGC_memory.cc | 103 +++++++++++++++++++--- src/pks/ecosim_pk/data/BGC_memory.hh | 14 ++- 6 files changed, 128 insertions(+), 17 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 8ec0d3f17..ac3b47112 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -170,13 +170,14 @@ BGCEngine::Sizes() const void BGCEngine::InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int ncells_per_col_) + int ncells_per_col_, + int num_components) { std::cout << "Allocating prop" << std::endl; std::cout << "size: " << ncells_per_col_ << std::endl; AllocateBGCProperties(&sizes_, &props, ncells_per_col_); std::cout << "Allocating state" << std::endl; - AllocateBGCState(&sizes_, &state, ncells_per_col_); + AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components); std::cout << "Allocating aux" << std::endl; AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 4314a9413..cd8ddbd6e 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -54,7 +54,8 @@ class BGCEngine { void InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int ncells_per_col_); + int ncells_per_col_, + int num_components); // Frees the data structures that hold the chemical state information. void FreeState(BGCProperties& props, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 88d4a22a1..9532cf2be 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -242,7 +242,7 @@ void EcoSIM::Initialize() { //Now we call the engine's init state function which allocates the data - bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_); + bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, num_components); int ierr = 0; @@ -520,7 +520,7 @@ void EcoSIM::CopyToEcoSIM(int col, //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 28a2f3bef..c5ccbbbc4 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -64,6 +64,21 @@ extern "C" { char** data; } BGCVectorString; + typedef struct { + int rows, cols, capacity; + double** data; + } BGCMatrixDouble; + + typedef struct { + int rows, cols, capacity; + int** data; + } BGCMatrixInt; + + typedef struct { + int rows, cols, capacity; + char** data; + } BGCMatrixString; + typedef struct { int ncells_per_col_; } BGCSizes; @@ -76,6 +91,7 @@ extern "C" { BGCVectorDouble water_content; BGCVectorDouble temperature; BGCVectorDouble total_mobile; + BGCMatrixDouble total_component_concentration; } BGCState; typedef struct { diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 6987cf558..987eadd0a 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -66,19 +66,9 @@ static inline int nearest_power_of_2(int n) ** *******************************************************************************/ void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { - std::cout << "Allocating vector double size: " << size << std::endl; - std::cout << "vector" << vector << std::endl; - /* - for (int j = 0; j < *vector->size; j++){ - std::cout << "element " << j << ": " << *vector[j] << std::endl; - } - */ if (size > 0) { - std::cout << "Allocating size" << std::endl; vector->size = size; - std::cout << "Allocating capacity" << std::endl; vector->capacity = nearest_power_of_2(size); - std::cout << "setting data" << std::endl; vector->data = (double*) calloc((size_t)vector->capacity, sizeof(double)); //ALQUIMIA_ASSERT(NULL != vector->data); } else { @@ -150,6 +140,95 @@ void FreeBGCVectorString(BGCVectorString* vector) { } } /* end FreeBGCVectorString() */ +/******************************************************************************* + ** + ** BGC Matrix + ** + *******************************************************************************/ +void AllocateBGCMatrixDouble(const int rows, const int cols, BGCMatrixDouble* matrix) { + if (rows > 0 ) && (cols > 0){ + matrix->rows = rows; + matrix->cols = cols; + matrix->capacity = nearest_power_of_2(rows * cols); + matrix->data = (double*) calloc((size_t)matrix->capacity, sizeof(double)); + //ALQUIMIA_ASSERT(NULL != matrix->data); + } else { + matrix->rows = 0; + matrix->cols = 0; + matrix->capacity = 0; + matrix->data = NULL; + } +} /* end AllocateBGCmatrixDouble() */ + +void FreeBGCMatrixDouble(BGCMatrixDouble* matrix) { + if (matrix != NULL) { + free(matrix->data); + matrix->data = NULL; + matrix->rows = 0; + matrix->cols = 0; + matrix->capacity = 0; + } +} /* end FreeBGCmatrixDouble() */ + +void AllocateBGCmatrixInt(const int rows, const int cols, BGCmatrixInt* matrix) { + if (size > 0) { + matrix->rows = rows; + matrix->cols = cols; + matrix->capacity = nearest_power_of_2(rows * cols); + matrix->data = (int*) calloc((size_t)matrix->capacity, sizeof(int)); + //ALQUIMIA_ASSERT(NULL != matrix->data); + } else { + matrix->rows = 0; + matrix->cols = 0; + matrix->capacity = 0; + matrix->data = NULL; + } +} /* end AllocateBGCmatrixInt() */ + +void FreeBGCmatrixInt(BGCmatrixInt* matrix) { + if (matrix != NULL) { + free(matrix->data); + matrix->data = NULL; + matrix->rows = 0; + matrix->cols = 0; + matrix->capacity = 0; + } +} /* end FreeBGCmatrixInt() */ + +/*Not quite sure how to do the string version, so I'm punting for now as +I don't think we need it yet +void AllocateBGCmatrixString(const int rows, const int cols, BGCmatrixString* matrix) { + int i; + if (size > 0) { + matrix->rows = rows; + matrix->cols = cols; + matrix->capacity = nearest_power_of_2(rows * cols); + matrix->data = (char**) calloc((size_t)matrix->capacity, sizeof(char*)); + //ALQUIMIA_ASSERT(NULL != matrix->data); + for (i = 0; i < matrix->size; ++i) { + matrix->data[i] = (char*) calloc((size_t)kBGCMaxStringLength, sizeof(char)); + //ALQUIMIA_ASSERT(NULL != matrix->data[i]); + } + } else { + matrix->size = 0; + matrix->capacity = 0; + matrix->data = NULL; + } +} end AllocateBGCmatrixString() + +void FreeBGCmatrixString(BGCmatrixString* matrix) { + int i; + if (matrix != NULL) { + for (i = 0; i < matrix->size; ++i) { + free(matrix->data[i]); + } + free(matrix->data); + matrix->data = NULL; + matrix->size = 0; + matrix->capacity = 0; + } +} end FreeBGCmatrixString() */ + /******************************************************************************* ** ** State @@ -162,7 +241,7 @@ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ void AllocateBGCState(BGCSizes* sizes, BGCState* state, - int ncells_per_col_) { + int ncells_per_col_, int num_components) { std::cout << "Allocating State vectors with size " << ncells_per_col_ << std::endl; sizes->ncells_per_col_ = ncells_per_col_; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); @@ -174,6 +253,7 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); + AllocateBGCMatrixDouble(rows->ncells_per_col_,cols->num_components, &(state->total_component_concentration)) std::cout << "Finished state allocation" << std::endl; //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); @@ -187,6 +267,7 @@ void FreeBGCState(BGCState* state) { FreeBGCVectorDouble(&(state->porosity)); FreeBGCVectorDouble(&(state->water_content)); FreeBGCVectorDouble(&(state->temperature)); + FreeBGCMatrixDoulbe(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index 24c3aafd7..a7ab1e0c3 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -48,10 +48,22 @@ extern "C" { void AllocateBGCVectorString(const int size, BGCVectorString* vector); void FreeBGCVectorString(BGCVectorString* vector); + /* Matrix */ + void AllocateBGCMatrixDouble(const int rows, const int cols, BGCMatrixDouble* matrix); + void FreeBGCMatrixDouble(BGCMatrixDouble* matrix); + + void AllocateBGCMatrixInt(const int rows, const int cols, BGCMatrixInt* matrix); + void FreeBGCMatrixInt(BGCMatrixInt* matrix); + + + void AllocateBGCMatrixString(const int rows, const int cols, BGCMatrixString* matrix); + void FreeBGCMatrixString(BGCMatrixString* matrix); + /* State */ void AllocateBGCState(BGCSizes* sizes, BGCState* state, - int ncells_per_col_); + int ncells_per_col_, + int num_components); void FreeBGCState(BGCState* state); /* Auxiliary Data */ From c04ea2dc7292302ebd373d679e2c279e1e730f05 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 12:31:15 -0700 Subject: [PATCH 208/582] minor bug fixes --- src/pks/ecosim_pk/data/BGC_memory.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 987eadd0a..10a654b54 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -146,7 +146,7 @@ void FreeBGCVectorString(BGCVectorString* vector) { ** *******************************************************************************/ void AllocateBGCMatrixDouble(const int rows, const int cols, BGCMatrixDouble* matrix) { - if (rows > 0 ) && (cols > 0){ + if ((rows > 0 ) || (cols > 0)){ matrix->rows = rows; matrix->cols = cols; matrix->capacity = nearest_power_of_2(rows * cols); @@ -170,8 +170,8 @@ void FreeBGCMatrixDouble(BGCMatrixDouble* matrix) { } } /* end FreeBGCmatrixDouble() */ -void AllocateBGCmatrixInt(const int rows, const int cols, BGCmatrixInt* matrix) { - if (size > 0) { +void AllocateBGCMatrixInt(const int rows, const int cols, BGCMatrixInt* matrix) { + if ((rows > 0) || (cols > 0)) { matrix->rows = rows; matrix->cols = cols; matrix->capacity = nearest_power_of_2(rows * cols); @@ -185,7 +185,7 @@ void AllocateBGCmatrixInt(const int rows, const int cols, BGCmatrixInt* matrix) } } /* end AllocateBGCmatrixInt() */ -void FreeBGCmatrixInt(BGCmatrixInt* matrix) { +void FreeBGCMatrixInt(BGCmatrixInt* matrix) { if (matrix != NULL) { free(matrix->data); matrix->data = NULL; @@ -267,7 +267,7 @@ void FreeBGCState(BGCState* state) { FreeBGCVectorDouble(&(state->porosity)); FreeBGCVectorDouble(&(state->water_content)); FreeBGCVectorDouble(&(state->temperature)); - FreeBGCMatrixDoulbe(&(state->total_component_concentration)); + FreeBGCMatrixDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ From c4b249af38f4bafb24810ff2e969e1aeb7dfa4ec Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 12:45:04 -0700 Subject: [PATCH 209/582] changes to memory allocation structure for matrix --- src/pks/ecosim_pk/data/BGC_containers.hh | 4 ++-- src/pks/ecosim_pk/data/BGC_memory.cc | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index c5ccbbbc4..f889c9f76 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -65,12 +65,12 @@ extern "C" { } BGCVectorString; typedef struct { - int rows, cols, capacity; + int rows, cols, cap_rows, cap_cols; double** data; } BGCMatrixDouble; typedef struct { - int rows, cols, capacity; + int rows, cols, cap_rows, cap_cols; int** data; } BGCMatrixInt; diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 10a654b54..4a8f61cf3 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -149,8 +149,12 @@ void AllocateBGCMatrixDouble(const int rows, const int cols, BGCMatrixDouble* ma if ((rows > 0 ) || (cols > 0)){ matrix->rows = rows; matrix->cols = cols; - matrix->capacity = nearest_power_of_2(rows * cols); - matrix->data = (double*) calloc((size_t)matrix->capacity, sizeof(double)); + matrix->cap_rows = nearest_power_of_2(rows); + matrix->cap_cols = nearest_power_of_2(cols) + matrix->data = (double**) calloc((size_t)matrix->cap_rows, sizeof(double*)); + for (int i = 0; i < matrix->rows; ++i) { + matrix->data[i] = (double*) calloc((size_t)matrix->cap_cols, sizeof(double)); + } //ALQUIMIA_ASSERT(NULL != matrix->data); } else { matrix->rows = 0; @@ -174,8 +178,12 @@ void AllocateBGCMatrixInt(const int rows, const int cols, BGCMatrixInt* matrix) if ((rows > 0) || (cols > 0)) { matrix->rows = rows; matrix->cols = cols; - matrix->capacity = nearest_power_of_2(rows * cols); - matrix->data = (int*) calloc((size_t)matrix->capacity, sizeof(int)); + matrix->cap_rows = nearest_power_of_2(rows); + matrix->cap_cols = nearest_power_of_2(cols) + matrix->data = (int**) calloc((size_t)matrix->cap_rows, sizeof(int*)); + for (int i = 0; i < matrix->rows; ++i) { + matrix->data[i] = (int*) calloc((size_t)matrix->cap_cols, sizeof(int)); + } //ALQUIMIA_ASSERT(NULL != matrix->data); } else { matrix->rows = 0; From a55d99ebf601749d6156fd1a2f30b29d4e0a0d79 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 13:41:51 -0700 Subject: [PATCH 210/582] more modifications to matrix mem --- src/pks/ecosim_pk/data/BGC_containers.hh | 1 + src/pks/ecosim_pk/data/BGC_memory.cc | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index f889c9f76..b5140afc4 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -81,6 +81,7 @@ extern "C" { typedef struct { int ncells_per_col_; + int num_components; } BGCSizes; typedef struct { diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 4a8f61cf3..693f7c84b 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -159,7 +159,8 @@ void AllocateBGCMatrixDouble(const int rows, const int cols, BGCMatrixDouble* ma } else { matrix->rows = 0; matrix->cols = 0; - matrix->capacity = 0; + matrix->cap_rows = 0; + matrix->cap_cols = 0; matrix->data = NULL; } } /* end AllocateBGCmatrixDouble() */ @@ -188,12 +189,13 @@ void AllocateBGCMatrixInt(const int rows, const int cols, BGCMatrixInt* matrix) } else { matrix->rows = 0; matrix->cols = 0; - matrix->capacity = 0; + matrix->cap_rows = 0; + matrix->cap_cols = 0; matrix->data = NULL; } -} /* end AllocateBGCmatrixInt() */ +} /* end AllocateBGCMatrixInt() */ -void FreeBGCMatrixInt(BGCmatrixInt* matrix) { +void FreeBGCMatrixInt(BGCMatrixInt* matrix) { if (matrix != NULL) { free(matrix->data); matrix->data = NULL; @@ -201,7 +203,7 @@ void FreeBGCMatrixInt(BGCmatrixInt* matrix) { matrix->cols = 0; matrix->capacity = 0; } -} /* end FreeBGCmatrixInt() */ +} /* end FreeBGCMatrixInt() */ /*Not quite sure how to do the string version, so I'm punting for now as I don't think we need it yet @@ -261,7 +263,7 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); - AllocateBGCMatrixDouble(rows->ncells_per_col_,cols->num_components, &(state->total_component_concentration)) + AllocateBGCMatrixDouble(sizes->ncells_per_col_,sizes->num_components, &(state->total_component_concentration)) std::cout << "Finished state allocation" << std::endl; //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); From 97087d5a63e7f04bcc6dd4f98eed23babf8c9ff1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 13:46:01 -0700 Subject: [PATCH 211/582] minor bugfixes --- src/pks/ecosim_pk/data/BGC_memory.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 693f7c84b..d4d64f323 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -150,7 +150,7 @@ void AllocateBGCMatrixDouble(const int rows, const int cols, BGCMatrixDouble* ma matrix->rows = rows; matrix->cols = cols; matrix->cap_rows = nearest_power_of_2(rows); - matrix->cap_cols = nearest_power_of_2(cols) + matrix->cap_cols = nearest_power_of_2(cols); matrix->data = (double**) calloc((size_t)matrix->cap_rows, sizeof(double*)); for (int i = 0; i < matrix->rows; ++i) { matrix->data[i] = (double*) calloc((size_t)matrix->cap_cols, sizeof(double)); @@ -171,7 +171,8 @@ void FreeBGCMatrixDouble(BGCMatrixDouble* matrix) { matrix->data = NULL; matrix->rows = 0; matrix->cols = 0; - matrix->capacity = 0; + matrix->cap_rows = 0; + matrix->cap_cols = 0; } } /* end FreeBGCmatrixDouble() */ @@ -180,7 +181,7 @@ void AllocateBGCMatrixInt(const int rows, const int cols, BGCMatrixInt* matrix) matrix->rows = rows; matrix->cols = cols; matrix->cap_rows = nearest_power_of_2(rows); - matrix->cap_cols = nearest_power_of_2(cols) + matrix->cap_cols = nearest_power_of_2(cols); matrix->data = (int**) calloc((size_t)matrix->cap_rows, sizeof(int*)); for (int i = 0; i < matrix->rows; ++i) { matrix->data[i] = (int*) calloc((size_t)matrix->cap_cols, sizeof(int)); @@ -263,7 +264,7 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_,sizes->num_components, &(state->total_component_concentration)) + AllocateBGCMatrixDouble(sizes->ncells_per_col_,sizes->num_components, &(state->total_component_concentration)); std::cout << "Finished state allocation" << std::endl; //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); From a09a61b7703ac3ae0de14b4e8b80796c3cd68163 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 13:52:47 -0700 Subject: [PATCH 212/582] minor fix --- src/pks/ecosim_pk/data/BGC_memory.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index d4d64f323..b0a588183 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -202,7 +202,8 @@ void FreeBGCMatrixInt(BGCMatrixInt* matrix) { matrix->data = NULL; matrix->rows = 0; matrix->cols = 0; - matrix->capacity = 0; + matrix->cap_cols = 0; + matrix->cap_rows = 0; } } /* end FreeBGCMatrixInt() */ From 821fdb5d9df4dc9ac65a0fa38f96ac34644abf1c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 13:58:49 -0700 Subject: [PATCH 213/582] more minor bugs in interface --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 9532cf2be..9a82bb6b7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -574,7 +574,7 @@ void EcoSIM::CopyToEcoSIM(int col, state.water_content.data[i] = (*col_wc)[i]; state.temperature.data[i] = (*col_temp)[i]; for (int j=0; i < num_components; ++j) { - state.tcc.data[j][i] = (*col_tcc)[j][i]; + state.total_component_concentration.data[j][i] = (*col_tcc)[j][i]; } props.liquid_saturation.data[i] = (*col_l_sat)[i]; @@ -629,7 +629,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - //auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); + auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); //Attempt 5 (ELM; this should work) auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); @@ -649,7 +649,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(ncells_per_col_)); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -661,7 +661,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - //auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix @@ -676,7 +676,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_wc)[i] = state.water_content.data[i]; (*col_temp)[i] = state.temperature.data[i]; for (int j=0; i < num_components; ++j) { - (*col_tcc)[j][i] = state.tcc.data[j][i]; + (*col_tcc)[j][i] = state.total_component_concentration.data[j][i]; } (*col_l_sat)[i] = props.liquid_saturation.data[i]; @@ -720,7 +720,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,ice_density,col_i_dens.ptr()); ColumnToField_(col,gas_density,col_g_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); - //ColumnToField_(col,temp, col_temp.ptr()); + ColumnToField_(col,temp, col_temp.ptr()); ColumnToField_(col,conductivity,col_cond.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); From b7bc975c345a677ee50daa6267796021c06f9e86 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 14:39:26 -0700 Subject: [PATCH 214/582] more minor bugfixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 9a82bb6b7..5b34853db 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -520,7 +520,6 @@ void EcoSIM::CopyToEcoSIM(int col, //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -629,7 +628,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - auto& tcc = S_->GetPtrW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); + auto& tcc = S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); //Attempt 5 (ELM; this should work) auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); @@ -645,11 +644,10 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); - auto& temp = *S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false); + auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(ncells_per_col_)); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 6cf9077d5b53814ea09199d07cc70de8fa6a5c07 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 15:04:39 -0700 Subject: [PATCH 215/582] refactor how data is saved --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5b34853db..e665fe342 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -560,7 +560,13 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,cell_volume,col_vol.ptr()); //Fill the tcc matrix component by component? for (int i=0; i < num_components; ++i) { - FieldToColumn_(col,tcc[i],col_tcc[i].ptr()); + Epetra_SerialDenseVector col_comp(ncells_per_col_); + Epetra_SerialDenseVector tcc_comp(ncells_per_col_); + for (int j=0; j Date: Mon, 17 Apr 2023 15:10:59 -0700 Subject: [PATCH 216/582] maybe this will work? --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e665fe342..0ebb58bc3 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -563,8 +563,8 @@ void EcoSIM::CopyToEcoSIM(int col, Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); for (int j=0; j Date: Mon, 17 Apr 2023 15:41:15 -0700 Subject: [PATCH 217/582] trying this again --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0ebb58bc3..cf3444d3c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -563,8 +563,8 @@ void EcoSIM::CopyToEcoSIM(int col, Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); for (int j=0; jwater_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - auto& tcc = S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"); - + auto& tcc = *(*S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"))(0); //Attempt 5 (ELM; this should work) auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); From 7deee0176b3240c7401653d74db792395008627d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 15:55:05 -0700 Subject: [PATCH 218/582] trying another method of accessing tcc --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index cf3444d3c..814b68c58 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -501,7 +501,10 @@ void EcoSIM::CopyToEcoSIM(int col, { //Fill state with ATS variables that are going to be changed by EcoSIM const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& tcc = *(*S_->Get(tcc_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& tcc = *(*S_->Get(tcc_key_, water_tag).ViewComponent("cell", false))(0); + + const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); + const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); From dd36d0ad604bdee97e4a797eea4fa4db39985e6c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 15:58:42 -0700 Subject: [PATCH 219/582] more modifications to access --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 814b68c58..7170ec240 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -569,7 +569,7 @@ void EcoSIM::CopyToEcoSIM(int col, col_comp(j) = (*col_tcc)(i,j); tcc_comp(j) = tcc[i][j]; } - FieldToColumn_(col,tcc_comp,col_comp.ptr()); + FieldToColumn_(col,tcc_comp,col_comp); } // I think I need to loop over the column data and save it to the data From ac69ed6508c3f1d7217d4aaa85fd7ab88b8b1e84 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Apr 2023 16:03:12 -0700 Subject: [PATCH 220/582] changing types --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 7170ec240..f0c663cf6 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -564,7 +564,7 @@ void EcoSIM::CopyToEcoSIM(int col, //Fill the tcc matrix component by component? for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); - Epetra_SerialDenseVector tcc_comp(ncells_per_col_); + Epetra_Vector tcc_comp(ncells_per_col_); for (int j=0; j Date: Mon, 17 Apr 2023 16:09:08 -0700 Subject: [PATCH 221/582] modifying the copy back to state --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f0c663cf6..4061f07be 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -637,8 +637,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - auto& tcc = *(*S_->GetW(tcc_key_, water_tag, passwd_).ViewComponent("cell"))(0); - //Attempt 5 (ELM; this should work) + Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, water_tag)->ViewComponent("cell")); auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); @@ -732,12 +731,12 @@ void EcoSIM::CopyFromEcoSIM(const int col, for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); - Epetra_SerialDenseVector tcc_comp(ncells_per_col_); + Epetra_Vector tcc_comp(ncells_per_col_); for (int j=0; j Date: Tue, 18 Apr 2023 11:20:18 -0700 Subject: [PATCH 222/582] more modifications to tcc transfer --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4061f07be..f988bd8c9 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -567,9 +567,9 @@ void EcoSIM::CopyToEcoSIM(int col, Epetra_Vector tcc_comp(ncells_per_col_); for (int j=0; j Date: Tue, 18 Apr 2023 12:00:33 -0700 Subject: [PATCH 223/582] adding a map to the tcc vector --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f988bd8c9..f2e2f8e27 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -562,9 +562,11 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,conductivity,col_cond.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); //Fill the tcc matrix component by component? + + Epetra_BlockMap tcc_map(ncells_per_col_, 1, 0); for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); - Epetra_Vector tcc_comp(ncells_per_col_); + Epetra_Vector tcc_comp(tcc_map); for (int j=0; j Date: Tue, 18 Apr 2023 14:05:01 -0700 Subject: [PATCH 224/582] messing with the block map --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f2e2f8e27..32c8457cd 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -563,7 +563,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,cell_volume,col_vol.ptr()); //Fill the tcc matrix component by component? - Epetra_BlockMap tcc_map(ncells_per_col_, 1, 0); + Epetra_BlockMap tcc_map(ncells_per_col_, 1, 1, 0); for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_Vector tcc_comp(tcc_map); @@ -730,7 +730,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,temp, col_temp.ptr()); ColumnToField_(col,conductivity,col_cond.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); - Epetra_BlockMap tcc_map(ncells_per_col_, 1, 0); + Epetra_BlockMap tcc_map(ncells_per_col_,1 ,1, 0); for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); From b329a4b3829af1d3902204902cafb0754ae94fa7 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 18 Apr 2023 14:51:15 -0700 Subject: [PATCH 225/582] just remade a second FieldToColumn to accept two serial dense vectors --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 24 ++++++++++++++++------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 +++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 32c8457cd..5f00f87cf 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -438,6 +438,18 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, } } +void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Teuchos::Ptr vec, + Teuchos::Ptr col_vec) +{ + auto& col_iter = mesh_->cells_of_column(col); + + for (std::size_t i=0; i!=col_iter.size(); ++i) { + std::size_t vec_index = col_iter[i]; + + (*col_vec)[i] = (*vec)[vec_index]; + } +} + // helper function for pushing column back to field void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, Teuchos::Ptr col_vec) @@ -545,9 +557,7 @@ void EcoSIM::CopyToEcoSIM(int col, //to the data structures that will pass the data to EcoSIM //Format is: //FieldToColumn_(column index, dataset to copy from, vector to put the data in) - std::cout << "\nCopying Amanzi field to column vector\n"; FieldToColumn_(col,porosity,col_poro.ptr()); - std::cout << "\npushed first column\n"; FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); @@ -563,15 +573,15 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,cell_volume,col_vol.ptr()); //Fill the tcc matrix component by component? - Epetra_BlockMap tcc_map(ncells_per_col_, 1, 1, 0); + //Epetra_BlockMap tcc_map(int ncells_per_col_, 1, 1, 0); for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); - Epetra_Vector tcc_comp(tcc_map); + Epetra_SerialDenseVector tcc_comp(tcc_map); for (int j=0; j col_vec); + void FieldToColumn_(AmanziMesh::Entity_ID col, Teuchos::Ptr vec, + Teuchos::Ptr col_vec); + //void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // double* col_vec); void ColDepthDz_(AmanziMesh::Entity_ID col, From bdb4ec3f2f8c0fd044857d8ea55e35cc6b02104f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 18 Apr 2023 14:58:01 -0700 Subject: [PATCH 226/582] reworking column to field --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 18 +++++++++++++----- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5f00f87cf..592bcde1b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -460,6 +460,15 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, } } +void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::Ptr vec, + Teuchos::Ptr col_vec) +{ + auto& col_iter = mesh_->cells_of_column(col); + for (std::size_t i=0; i!=col_iter.size(); ++i) { + (*vec)[col_iter[i]] = (*col_vec)[i]; + } +} + // helper function for collecting column dz and depth void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, Teuchos::Ptr depth, @@ -576,7 +585,7 @@ void EcoSIM::CopyToEcoSIM(int col, //Epetra_BlockMap tcc_map(int ncells_per_col_, 1, 1, 0); for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); - Epetra_SerialDenseVector tcc_comp(tcc_map); + Epetra_SerialDenseVector tcc_comp(ncells_per_col_); for (int j=0; j col_vec); + + void ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::Ptr vec, + Teuchos::Ptr col_vec); //evaluator for transpiration; //I don't think I need this anymore //Teuchos::RCP p_root_eval_; From 4de224cf16db8f076ed417b25cda7e82d708f6af Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 18 Apr 2023 15:03:56 -0700 Subject: [PATCH 227/582] more pointer maddness --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 592bcde1b..5efc93721 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -588,7 +588,7 @@ void EcoSIM::CopyToEcoSIM(int col, Epetra_SerialDenseVector tcc_comp(ncells_per_col_); for (int j=0; j Date: Tue, 18 Apr 2023 15:12:06 -0700 Subject: [PATCH 228/582] yet more maddness --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5efc93721..197d9ea7b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -588,7 +588,7 @@ void EcoSIM::CopyToEcoSIM(int col, Epetra_SerialDenseVector tcc_comp(ncells_per_col_); for (int j=0; j Date: Tue, 18 Apr 2023 15:19:18 -0700 Subject: [PATCH 229/582] more --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 197d9ea7b..aa02b4e23 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -588,7 +588,7 @@ void EcoSIM::CopyToEcoSIM(int col, Epetra_SerialDenseVector tcc_comp(ncells_per_col_); for (int j=0; j Date: Tue, 18 Apr 2023 15:31:28 -0700 Subject: [PATCH 230/582] error accessing the concentration for writing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index aa02b4e23..66d83c4f7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -658,7 +658,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, water_tag)->ViewComponent("cell")); + Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, water_tag, tcc_key_)->ViewComponent("cell",false)); auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); @@ -757,7 +757,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, col_comp(j) = (*col_tcc)(i,j); tcc_comp(j) = tcc[i][j]; } - ColumnToField_(col,ptr(&tcc_comp),Teuchos::ptr(&col_comp)); + ColumnToField_(col,Teuchos::ptr(&tcc_comp),Teuchos::ptr(&col_comp)); } } From c048d259d14f5d601300f6115ef29bac62498ea9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 18 Apr 2023 16:35:32 -0700 Subject: [PATCH 231/582] added simple test to find keys --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 66d83c4f7..b50fa8197 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -71,6 +71,20 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // additionally temperature doesn't work because it is owned by energy // // + // Simple tests with the keys + std::string test_key_name_one = "porosity key"; + std::string test_key_name_two = "mass density ice key"; + + std::string test_key_suffix_one = "porosity key suffix"; + std::string test_key_suffix_two = "mass density ice key suffix"; + + if (list.isParameter(test_key_suffix_one)) { + *vo_->os() << "found porosity key" << std::endl; + } + if (list.isParameter(test_key_suffix_two)) { + *vo_->os() << "found mass density ice key" << std::endl; + } + // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell From 9bb152976164a7ccf1262ee583e7a30c20c64b09 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 18 Apr 2023 16:43:50 -0700 Subject: [PATCH 232/582] minor typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b50fa8197..5aee565fc 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -78,10 +78,10 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string test_key_suffix_one = "porosity key suffix"; std::string test_key_suffix_two = "mass density ice key suffix"; - if (list.isParameter(test_key_suffix_one)) { + if (plist_.isParameter(test_key_suffix_one)) { *vo_->os() << "found porosity key" << std::endl; } - if (list.isParameter(test_key_suffix_two)) { + if (plist_.isParameter(test_key_suffix_two)) { *vo_->os() << "found mass density ice key" << std::endl; } From 755743ec61eb23978ce1b441304175b2bc77236a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 10:38:12 -0700 Subject: [PATCH 233/582] trying a different access method --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5aee565fc..473a654a8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -78,10 +78,10 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string test_key_suffix_one = "porosity key suffix"; std::string test_key_suffix_two = "mass density ice key suffix"; - if (plist_.isParameter(test_key_suffix_one)) { + if (plist_->isParameter(test_key_suffix_one)) { *vo_->os() << "found porosity key" << std::endl; } - if (plist_.isParameter(test_key_suffix_two)) { + if (plist_->isParameter(test_key_suffix_two)) { *vo_->os() << "found mass density ice key" << std::endl; } From 68cd1c2bb64b7b61b2649db9847237700610b001 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 13:43:44 -0700 Subject: [PATCH 234/582] adding correct password for copy back --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 473a654a8..89e786299 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -672,7 +672,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->water_density())[cell] = state.water_density; // (this->porosity())[cell] = state.porosity; - Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, water_tag, tcc_key_)->ViewComponent("cell",false)); + Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); From cf110e7b7a772d4d2875a2e2496ab5cb90e496d6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 14:03:34 -0700 Subject: [PATCH 235/582] cleaning up print statements --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 18 +++++++++++++++++- src/pks/ecosim_pk/data/BGC_memory.cc | 7 ------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 89e786299..3ca7de09d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -79,11 +79,25 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string test_key_suffix_two = "mass density ice key suffix"; if (plist_->isParameter(test_key_suffix_one)) { - *vo_->os() << "found porosity key" << std::endl; + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found porosity key suffix" << std::endl; } if (plist_->isParameter(test_key_suffix_two)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found mass density ice key suffix" << std::endl; + } + if (plist_->isParameter(test_key_name_one)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found porosity key" << std::endl; + } + if (plist_->isParameter(test_key_name_two)) { + Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density ice key" << std::endl; } + if (!plist_->isParameter(test_key_name_two)) && (!plist_->isParameter(test_key_name_two)) && (!plist_->isParameter(test_key_name_two)) && (!plist_->isParameter(test_key_name_two)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "didn't find any of that" << std::endl; + } // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); @@ -278,8 +292,10 @@ void EcoSIM::Initialize() { S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); //Initialize owned evaluators + Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "Getting hydraulic conductivity" << std::endl; S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); + Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "recording to hydraulic" << std::endl; S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index b0a588183..3940f6690 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -254,11 +254,8 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCState(BGCSizes* sizes, BGCState* state, int ncells_per_col_, int num_components) { - std::cout << "Allocating State vectors with size " << ncells_per_col_ << std::endl; sizes->ncells_per_col_ = ncells_per_col_; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); - - std::cout << "Finish fluid density" << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->porosity)); @@ -266,7 +263,6 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); AllocateBGCMatrixDouble(sizes->ncells_per_col_,sizes->num_components, &(state->total_component_concentration)); - std::cout << "Finished state allocation" << std::endl; //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateBGCState() */ @@ -314,18 +310,15 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, int ncells_per_col_) { - std::cout << "Allocating Prop vectors with size" << ncells_per_col_ << std::endl; sizes->ncells_per_col_ = ncells_per_col_; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); - std::cout << "finished liquid sat" << std::endl; AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->gas_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->ice_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->elevation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->conductivity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); - std::cout << "prop alloc" << std::endl; } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { From 6e39f55e41514d3a8c70a66374492ee9cf0b75b1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 14:19:25 -0700 Subject: [PATCH 236/582] minor bugfix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3ca7de09d..c618c3998 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -94,7 +94,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density ice key" << std::endl; } - if (!plist_->isParameter(test_key_name_two)) && (!plist_->isParameter(test_key_name_two)) && (!plist_->isParameter(test_key_name_two)) && (!plist_->isParameter(test_key_name_two)) { + if (!plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "didn't find any of that" << std::endl; } @@ -295,7 +295,6 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "Getting hydraulic conductivity" << std::endl; S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); - Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "recording to hydraulic" << std::endl; S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); From a7881a80f056c947e7b9f681c33b8f7376c144ec Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 14:33:53 -0700 Subject: [PATCH 237/582] fixing the if --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index c618c3998..de503a5a1 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -94,7 +94,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density ice key" << std::endl; } - if (!plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) { + if (!plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) + { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "didn't find any of that" << std::endl; } From 29ee035a7c4ab45e242d999ea0d6751403855d47 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 14:41:25 -0700 Subject: [PATCH 238/582] whatever --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index de503a5a1..a40a28ead 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -94,11 +94,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density ice key" << std::endl; } - if (!plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) && !plist_->isParameter(test_key_name_two) - { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "didn't find any of that" << std::endl; - } // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); From bbf0f2592bd4f9b9d8cf2cc8e517a0e2d37a8bf6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 15:18:16 -0700 Subject: [PATCH 239/582] trying to check state instead --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index a40a28ead..64cf56650 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -78,22 +78,14 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string test_key_suffix_one = "porosity key suffix"; std::string test_key_suffix_two = "mass density ice key suffix"; - if (plist_->isParameter(test_key_suffix_one)) { + if (S->HasRecordSet(test_key_name_one)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found porosity key suffix" << std::endl; } - if (plist_->isParameter(test_key_suffix_two)) { + if (S->HasRecordSet(test_key_name_two)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density ice key suffix" << std::endl; } - if (plist_->isParameter(test_key_name_one)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found porosity key" << std::endl; - } - if (plist_->isParameter(test_key_name_two)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found mass density ice key" << std::endl; - } // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); From 111482dd2490f0283ef733a1aa08b4d9342f90ed Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 15:26:05 -0700 Subject: [PATCH 240/582] more messing with keys --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 24 +++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 64cf56650..2be37d76b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -72,20 +72,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // // // Simple tests with the keys - std::string test_key_name_one = "porosity key"; - std::string test_key_name_two = "mass density ice key"; - - std::string test_key_suffix_one = "porosity key suffix"; - std::string test_key_suffix_two = "mass density ice key suffix"; - - if (S->HasRecordSet(test_key_name_one)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found porosity key suffix" << std::endl; - } - if (S->HasRecordSet(test_key_name_two)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found mass density ice key suffix" << std::endl; - } // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); @@ -115,10 +101,18 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // f_ice = S_ice * porosity liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); - ice_den_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); + ice_den_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); gas_den_key_ = Keys::readKey(*plist_, domain_,"porosity", "porosity"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); + if (S->HasRecordSet(poro_key_)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found porosity key suffix" << std::endl; + } + if (S->HasRecordSet(ice_den_key_)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found mass density ice key suffix" << std::endl; + } //energy T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); conductivity_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); From df83e52ac37890c230d551693d38cc86b73d2022 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Apr 2023 15:37:40 -0700 Subject: [PATCH 241/582] more key test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 2be37d76b..a9b65202c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -101,10 +101,13 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // f_ice = S_ice * porosity liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); - ice_den_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); + ice_den_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); gas_den_key_ = Keys::readKey(*plist_, domain_,"porosity", "porosity"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "testing keys" << std::endl; + if (S->HasRecordSet(poro_key_)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found porosity key suffix" << std::endl; From f9c71734a896d8f442c503665e09c75eb1c244f1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Apr 2023 10:08:25 -0700 Subject: [PATCH 242/582] moving all the key tests --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index a9b65202c..189b8b3bc 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -104,18 +104,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, ice_den_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); gas_den_key_ = Keys::readKey(*plist_, domain_,"porosity", "porosity"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); - - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "testing keys" << std::endl; - - if (S->HasRecordSet(poro_key_)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found porosity key suffix" << std::endl; - } - if (S->HasRecordSet(ice_den_key_)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found mass density ice key suffix" << std::endl; - } //energy T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); conductivity_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); @@ -276,8 +264,19 @@ void EcoSIM::Initialize() { S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); - //Initialize owned evaluators Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "testing keys" << std::endl; + + if (S->HasRecordSet(poro_key_)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found porosity key suffix" << std::endl; + } + if (S->HasRecordSet(ice_den_key_)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found mass density ice key suffix" << std::endl; + } + + //Initialize owned evaluators *vo_->os() << "Getting hydraulic conductivity" << std::endl; S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); *vo_->os() << "recording to hydraulic" << std::endl; From 2b1e6ea6c6cbaf3ee90719a24ee6473409afb483 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Apr 2023 10:09:18 -0700 Subject: [PATCH 243/582] also adding plist print --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 189b8b3bc..de7e80e3d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -267,6 +267,8 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; + plist_->print(std::out) + if (S->HasRecordSet(poro_key_)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found porosity key suffix" << std::endl; From 3dfb39773cc524d4a73a71c0c419872fa7cbf20b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Apr 2023 10:23:57 -0700 Subject: [PATCH 244/582] minor typos --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index de7e80e3d..d8ca23e53 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -267,13 +267,13 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; - plist_->print(std::out) + plist_->print(std::cout) - if (S->HasRecordSet(poro_key_)) { + if (S_->HasRecordSet(poro_key_)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found porosity key suffix" << std::endl; } - if (S->HasRecordSet(ice_den_key_)) { + if (S_->HasRecordSet(ice_den_key_)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density ice key suffix" << std::endl; } From 045538a9fa7b68fb7ca1c7f778dbda757c80f5e8 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Apr 2023 10:29:58 -0700 Subject: [PATCH 245/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d8ca23e53..d1d9caf2f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -267,7 +267,7 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; - plist_->print(std::cout) + plist_->print(std::cout); if (S_->HasRecordSet(poro_key_)) { Teuchos::OSTab tab = vo_->getOSTab(); From bcb9d379fb412684f34afaa68cd37706effd5083 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Apr 2023 11:14:38 -0700 Subject: [PATCH 246/582] testing more key stuff --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d1d9caf2f..e108d7bb8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -278,6 +278,15 @@ void EcoSIM::Initialize() { *vo_->os() << "found mass density ice key suffix" << std::endl; } + if (S_->HasRecord(poro_key_)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found porosity key suffix" << std::endl; + } + if (S_->HasRecord(ice_den_key_)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found mass density ice key suffix" << std::endl; + } + //Initialize owned evaluators *vo_->os() << "Getting hydraulic conductivity" << std::endl; S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); From dc9b7760f0033a870323e84f3d397e27785de5a0 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Apr 2023 11:29:28 -0700 Subject: [PATCH 247/582] fix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e108d7bb8..81cb36fb1 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -278,11 +278,11 @@ void EcoSIM::Initialize() { *vo_->os() << "found mass density ice key suffix" << std::endl; } - if (S_->HasRecord(poro_key_)) { + if (S_->HasRecord(poro_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found porosity key suffix" << std::endl; } - if (S_->HasRecord(ice_den_key_)) { + if (S_->HasRecord(ice_den_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density ice key suffix" << std::endl; } From dc4fb7a01407defcac9f23bbef553abd327ec21d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Apr 2023 12:10:29 -0700 Subject: [PATCH 248/582] making more progress on key testing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 81cb36fb1..1a40ae493 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -103,6 +103,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_den_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); gas_den_key_ = Keys::readKey(*plist_, domain_,"porosity", "porosity"); + gas_den_key_test_ = Keys::readKey(*plist_, domain_, "mass density gas", "mass_density_gas"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); //energy T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); @@ -287,6 +288,14 @@ void EcoSIM::Initialize() { *vo_->os() << "found mass density ice key suffix" << std::endl; } + if (S_->HasRecord(gas_den_key_test_, Tags::DEFAULT)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found mass density ice key suffix" << std::endl; + } else { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Did not find gas key" << std::endl; + } + //Initialize owned evaluators *vo_->os() << "Getting hydraulic conductivity" << std::endl; S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); From 87eb4e3940f3009252a024b0c7746e133cee623e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Apr 2023 12:13:27 -0700 Subject: [PATCH 249/582] actually define the key --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 1d71ffd31..5c4381f50 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -173,6 +173,7 @@ class EcoSIM : public PK_Physical { Key liquid_den_key_; Key ice_den_key_; Key gas_den_key_; + Key gas_den_key_test_; Key rock_den_key_; Key T_key_; Key conductivity_key_; From 5b332dafb2996f8ea687787dd844055675b27ab4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 21 Apr 2023 12:05:26 -0700 Subject: [PATCH 250/582] added switches for presence of gas, ice, energy --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 275 ++++++++++++++-------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 +- 2 files changed, 176 insertions(+), 102 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 1a40ae493..f1538e451 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -101,8 +101,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // f_ice = S_ice * porosity liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); - ice_den_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); - gas_den_key_ = Keys::readKey(*plist_, domain_,"porosity", "porosity"); + ice_den_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); + gas_den_key_ = Keys::readKey(*plist_, domain_,"mass density gas", "mass_density_gas"); gas_den_key_test_ = Keys::readKey(*plist_, domain_, "mass density gas", "mass_density_gas"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); //energy @@ -252,48 +252,54 @@ void EcoSIM::Initialize() { S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; - plist_->print(std::cout); + //Here we put the checks for the optional keys + //Temperature, ice and gas + //plist_->print(std::cout); - if (S_->HasRecordSet(poro_key_)) { + if (S_->HasRecord(gas_den_key_test_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found porosity key suffix" << std::endl; - } - if (S_->HasRecordSet(ice_den_key_)) { + *vo_->os() << "found mass density gas key" << std::endl; + S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); + has_gas = true; + } else { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found mass density ice key suffix" << std::endl; + *vo_->os() << "Did not find gas key" << std::endl; + has_gas = false; } - if (S_->HasRecord(poro_key_, Tags::DEFAULT)) { + if (S_->HasRecord(T_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found porosity key suffix" << std::endl; - } - if (S_->HasRecord(ice_den_key_, Tags::DEFAULT)) { + *vo_->os() << "found temp key" << std::endl; + S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + has_energy = true; + } else { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found mass density ice key suffix" << std::endl; + *vo_->os() << "Did not find temp key" << std::endl; + has_energy = false; } - if (S_->HasRecord(gas_den_key_test_, Tags::DEFAULT)) { + if (S_->HasRecord(ice_den_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found mass density ice key suffix" << std::endl; + *vo_->os() << "found ice key" << std::endl; + S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); + has_ice = true; } else { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Did not find gas key" << std::endl; + *vo_->os() << "Did not find ice key" << std::endl; + has_ice = false; } //Initialize owned evaluators @@ -354,19 +360,30 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + if (has_gas) { + S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); + } + + if (has_ice) { + S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); + } + + if (has_energy) { + S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); + } + //Update owned evaluators Teuchos::RCP hydra_cond = S_->GetPtr(hydra_cond_key_, Tags::DEFAULT); S_->GetEvaluator(hydra_cond_key_, Tags::DEFAULT).Update(*S_, name_); @@ -385,14 +402,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& liquid_saturation = *(*S_->Get("saturation_liquid", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("saturation_gas", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& gas_saturation = *(*S_->Get("saturation_gas", tag_next_) - .ViewComponent("cell",false))(0); - - S_->GetEvaluator("saturation_ice", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& ice_saturation = *(*S_->Get("saturation_ice", tag_next_) - .ViewComponent("cell",false))(0); - //S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); //const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) // .ViewComponent("cell",false); @@ -409,30 +418,44 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) .ViewComponent("cell",false))(0); - //S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) - // .ViewComponent("cell",false))(0); - - //S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) - // .ViewComponent("cell",false))(0); - S_->GetEvaluator("density_rock", tag_next_).Update(*S_, name_); const Epetra_MultiVector& rock_density = *(*S_->Get("density_rock", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& temp = *(*S_->Get("temperature", tag_next_) - .ViewComponent("cell",false))(0); - - S_->GetEvaluator("thermal_conductivity", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& conductivity = *(*S_->Get("thermal_conductivity", tag_next_) - .ViewComponent("cell",false))(0); - S_->GetEvaluator("cell_volume", tag_next_).Update(*S_, name_); const Epetra_MultiVector& cell_volume = *(*S_->Get("cell_volume", tag_next_) .ViewComponent("cell",false))(0); + if (has_gas) { + S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("saturation_gas", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& gas_saturation = *(*S_->Get("saturation_gas", tag_next_) + .ViewComponent("cell",false))(0); + } + + if (has_ice) { + S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("saturation_ice", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& ice_saturation = *(*S_->Get("saturation_ice", tag_next_) + .ViewComponent("cell",false))(0); + } + + if (has_energy) { + S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& temp = *(*S_->Get("temperature", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("thermal_conductivity", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& conductivity = *(*S_->Get("thermal_conductivity", tag_next_) + .ViewComponent("cell",false))(0); + } + // loop over columns and apply the model for (AmanziMesh::Entity_ID col=0; col!=num_cols_; ++col) { @@ -555,43 +578,25 @@ void EcoSIM::CopyToEcoSIM(int col, { //Fill state with ATS variables that are going to be changed by EcoSIM const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& tcc = *(*S_->Get(tcc_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); - const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", false); const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& relative_permeability = *(*S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& temp = *S_->Get("temperature", tag_next_).ViewComponent("cell", false); - - const Epetra_Vector& conductivity = *(*S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - //For the concentration I do not want a vector but a matrix auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(num_components,ncells_per_col_)); @@ -601,21 +606,14 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(column index, dataset to copy from, vector to put the data in) FieldToColumn_(col,porosity,col_poro.ptr()); FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); - FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); - FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); //FieldToColumn_(col,elevation,col_elev.ptr()); FieldToColumn_(col,water_content,col_wc.ptr()); FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); FieldToColumn_(col,liquid_density,col_f_dens.ptr()); - FieldToColumn_(col,ice_density,col_i_dens.ptr()); - FieldToColumn_(col,gas_density,col_g_dens.ptr()); FieldToColumn_(col,rock_density,col_r_dens.ptr()); - FieldToColumn_(col,temp, col_temp.ptr()); - FieldToColumn_(col,conductivity,col_cond.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); //Fill the tcc matrix component by component? - //Epetra_BlockMap tcc_map(int ncells_per_col_, 1, 1, 0); for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); @@ -626,12 +624,43 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,Teuchos::ptr(&tcc_comp),Teuchos::ptr(&col_comp)); } + if (has_gas) { + const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); + + auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); + FieldToColumn_(col,gas_density,col_g_dens.ptr()); + } + + if (has_ice) { + const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); + + auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); + FieldToColumn_(col,ice_density,col_i_dens.ptr()); + } + + if (has_energy) { + const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& conductivity = *(*S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false))(0); + + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + FieldToColumn_(col,temp, col_temp.ptr()); + FieldToColumn_(col,conductivity,col_cond.ptr()); + } + // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this for (int i=0; i < ncells_per_col_; ++i) { state.fluid_density.data[i] = (*col_f_dens)[i]; - state.gas_density.data[i] = (*col_g_dens)[i]; - state.ice_density.data[i] = (*col_i_dens)[i]; state.porosity.data[i] = (*col_poro)[i]; state.water_content.data[i] = (*col_wc)[i]; state.temperature.data[i] = (*col_temp)[i]; @@ -640,13 +669,26 @@ void EcoSIM::CopyToEcoSIM(int col, } props.liquid_saturation.data[i] = (*col_l_sat)[i]; - props.gas_saturation.data[i] = (*col_g_sat)[i]; - props.ice_saturation.data[i] = (*col_i_sat)[i]; //props.elevation.data[i] = (*col_elev)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; props.conductivity.data[i] = (*col_cond)[i]; props.volume.data[i] = (*col_vol)[i]; + if (has_gas) { + props.gas_saturation.data[i] = (*col_g_sat)[i]; + state.gas_density.data[i] = (*col_g_dens)[i]; + } + + if (has_ice) { + state.ice_density.data[i] = (*col_i_dens)[i]; + props.ice_saturation.data[i] = (*col_i_sat)[i]; + } + + if (has_energy) { + state.temperature.data[i] = (*col_temp)[i]; + props.conductivity.data[i] = (*col_cond)[i]; + } + } //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; @@ -693,58 +735,76 @@ void EcoSIM::CopyFromEcoSIM(const int col, Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); - auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); - auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false))(0); - auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); //auto& elevation = S_->GetPtrW(elev_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell"); auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); auto& relative_permeability = *(*S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false))(0); auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); - auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); - auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); - - auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); - auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(num_components,ncells_per_col_)); + if (has_gas) { + auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); + auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); + + auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + } + + if (has_ice) { + auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); + auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); + + auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + } + + if (has_energy) { + auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); + auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); + + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + } for (int i=0; i < ncells_per_col_; ++i) { (*col_f_dens)[i] = state.fluid_density.data[i]; - (*col_g_dens)[i] = state.gas_density.data[i]; - (*col_i_dens)[i] = state.ice_density.data[i]; (*col_poro)[i] = state.porosity.data[i]; (*col_wc)[i] = state.water_content.data[i]; - (*col_temp)[i] = state.temperature.data[i]; for (int j=0; i < num_components; ++j) { (*col_tcc)[j][i] = state.total_component_concentration.data[j][i]; } - (*col_l_sat)[i] = props.liquid_saturation.data[i]; - (*col_g_sat)[i] = props.gas_saturation.data[i]; - (*col_i_sat)[i] = props.ice_saturation.data[i]; //(*col_elev)[i] = props.elevation.data[i]; (*col_rel_perm)[i] = props.relative_permeability.data[i]; (*col_cond)[i] = props.conductivity.data[i]; (*col_vol)[i] = props.volume.data[i]; + + if (has_gas) { + (*col_g_dens)[i] = state.gas_density.data[i]; + (*col_g_sat)[i] = props.gas_saturation.data[i]; + } + + if (has_ice) { + (*col_i_dens)[i] = state.ice_density.data[i]; + (*col_i_sat)[i] = props.ice_saturation.data[i]; + } + + if (has_energy) { + (*col_temp)[i] = state.temperature.data[i]; + (*col_cond)[i] = props.conductivity.data[i]; + } } @@ -783,6 +843,21 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,conductivity,col_cond.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); + if (has_gas) { + ColumnToField_(col,gas_saturation,col_g_sat.ptr()); + ColumnToField_(col,gas_density,col_g_dens.ptr()); + } + + if (has_ice) { + ColumnToField_(col,ice_saturation,col_i_sat.ptr()); + ColumnToField_(col,ice_density,col_i_dens.ptr()); + } + + if (has_energy) { + ColumnToField_(col,temp, col_temp.ptr()); + ColumnToField_(col,conductivity,col_cond.ptr()); + } + for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 5c4381f50..e46bfb878 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -191,8 +191,7 @@ class EcoSIM : public PK_Physical { BGCAuxiliaryData bgc_aux_data_; bool bgc_initialized_; - bool using_energy_; - bool using_gas_; + bool has_energy, has_gas, has_ice; std::vector component_names_; int num_components; From e6cc538cba2d2e27688c419634f4d25f8b4773b4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 24 Apr 2023 11:20:09 -0700 Subject: [PATCH 251/582] refactoring the switches for ice, gas, energy --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 29 ++++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f1538e451..b3bd38858 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -596,6 +596,12 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_));\ + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(num_components,ncells_per_col_)); @@ -628,9 +634,6 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); - auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); FieldToColumn_(col,gas_density,col_g_dens.ptr()); } @@ -639,9 +642,6 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); - auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); FieldToColumn_(col,ice_density,col_i_dens.ptr()); } @@ -650,9 +650,6 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& conductivity = *(*S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false))(0); - auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - FieldToColumn_(col,temp, col_temp.ptr()); FieldToColumn_(col,conductivity,col_cond.ptr()); } @@ -663,7 +660,6 @@ void EcoSIM::CopyToEcoSIM(int col, state.fluid_density.data[i] = (*col_f_dens)[i]; state.porosity.data[i] = (*col_poro)[i]; state.water_content.data[i] = (*col_wc)[i]; - state.temperature.data[i] = (*col_temp)[i]; for (int j=0; i < num_components; ++j) { state.total_component_concentration.data[j][i] = (*col_tcc)[j][i]; } @@ -671,7 +667,6 @@ void EcoSIM::CopyToEcoSIM(int col, props.liquid_saturation.data[i] = (*col_l_sat)[i]; //props.elevation.data[i] = (*col_elev)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; - props.conductivity.data[i] = (*col_cond)[i]; props.volume.data[i] = (*col_vol)[i]; if (has_gas) { @@ -753,29 +748,29 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(num_components,ncells_per_col_)); + auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); - auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); } if (has_ice) { auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); - auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); } if (has_energy) { auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); - auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); } for (int i=0; i < ncells_per_col_; ++i) { From 2c6b88b0665f32545289a62058ce004c539c9be6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 24 Apr 2023 11:48:37 -0700 Subject: [PATCH 252/582] removing duplicate lines --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b3bd38858..4a09af3a0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -825,17 +825,11 @@ void EcoSIM::CopyFromEcoSIM(const int col, //ColumnToField_(col,tcc,col_tcc.ptr()); ColumnToField_(col,porosity,col_poro.ptr()); ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); - ColumnToField_(col,gas_saturation,col_g_sat.ptr()); - ColumnToField_(col,ice_saturation,col_i_sat.ptr()); //ColumnToField_(col,elevation,col_elev.ptr()); ColumnToField_(col,water_content,col_wc.ptr()); ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); ColumnToField_(col,liquid_density,col_f_dens.ptr()); - ColumnToField_(col,ice_density,col_i_dens.ptr()); - ColumnToField_(col,gas_density,col_g_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); - ColumnToField_(col,temp, col_temp.ptr()); - ColumnToField_(col,conductivity,col_cond.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); if (has_gas) { From f0066afc3d596fbe7f152c546be0b235aa4a4c34 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 24 Apr 2023 12:07:20 -0700 Subject: [PATCH 253/582] trying other stuff --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4a09af3a0..0258462ed 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -758,19 +758,25 @@ void EcoSIM::CopyFromEcoSIM(const int col, if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); - + } else { + Epetra_Vector gas_saturation(ncells_per_col_); + Epetra_Vector gas_density(ncells_per_col_); } if (has_ice) { auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); - + } else { + Epetra_Vector ice_saturation(ncells_per_col_); + Epetra_Vector ice_density(ncells_per_col_); } if (has_energy) { auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); - + } else { + Epetra_Vector temp(ncells_per_col_); + Epetra_Vector conductivity(ncells_per_col_); } for (int i=0; i < ncells_per_col_; ++i) { From 315e9b55534e32d436beb665c219c99d65c41585 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 24 Apr 2023 12:53:24 -0700 Subject: [PATCH 254/582] trying another declaration change --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0258462ed..64fc87af1 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -837,21 +837,12 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,liquid_density,col_f_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); - - if (has_gas) { - ColumnToField_(col,gas_saturation,col_g_sat.ptr()); - ColumnToField_(col,gas_density,col_g_dens.ptr()); - } - - if (has_ice) { - ColumnToField_(col,ice_saturation,col_i_sat.ptr()); - ColumnToField_(col,ice_density,col_i_dens.ptr()); - } - - if (has_energy) { - ColumnToField_(col,temp, col_temp.ptr()); - ColumnToField_(col,conductivity,col_cond.ptr()); - } + ColumnToField_(col,gas_saturation,col_g_sat.ptr()); + ColumnToField_(col,gas_density,col_g_dens.ptr()); + ColumnToField_(col,ice_saturation,col_i_sat.ptr()); + ColumnToField_(col,ice_density,col_i_dens.ptr()); + ColumnToField_(col,temp, col_temp.ptr()); + ColumnToField_(col,conductivity,col_cond.ptr()); for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); From dee7a81c1c723a01fd0ddfc83d9bacdb4295239c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 24 Apr 2023 13:00:31 -0700 Subject: [PATCH 255/582] yet another scoping issue --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 64fc87af1..fd7360af0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -755,28 +755,25 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + Epetra_Vector gas_saturation(ncells_per_col_); + Epetra_Vector gas_density(ncells_per_col_); if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); - } else { - Epetra_Vector gas_saturation(ncells_per_col_); - Epetra_Vector gas_density(ncells_per_col_); } + Epetra_Vector ice_saturation(ncells_per_col_); + Epetra_Vector ice_density(ncells_per_col_); if (has_ice) { auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); - } else { - Epetra_Vector ice_saturation(ncells_per_col_); - Epetra_Vector ice_density(ncells_per_col_); } + Epetra_Vector temp(ncells_per_col_); + Epetra_Vector conductivity(ncells_per_col_); if (has_energy) { auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); - } else { - Epetra_Vector temp(ncells_per_col_); - Epetra_Vector conductivity(ncells_per_col_); } for (int i=0; i < ncells_per_col_; ++i) { From ed29fecdb7d71f96d17c27722c668b2618fa3e4a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 24 Apr 2023 13:53:22 -0700 Subject: [PATCH 256/582] wow just make this work --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 52 +++++++++++------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index fd7360af0..f32f010b6 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -755,25 +755,44 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - Epetra_Vector gas_saturation(ncells_per_col_); - Epetra_Vector gas_density(ncells_per_col_); if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); + + for (int i=0; i < ncells_per_col_; ++i) { + (*col_g_dens)[i] = state.gas_density.data[i]; + (*col_g_sat)[i] = props.gas_saturation.data[i]; + } + + ColumnToField_(col,gas_saturation,col_g_sat.ptr()); + ColumnToField_(col,gas_density,col_g_dens.ptr()); + } - Epetra_Vector ice_saturation(ncells_per_col_); - Epetra_Vector ice_density(ncells_per_col_); if (has_ice) { auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); + + for (int i=0; i < ncells_per_col_; ++i) { + (*col_i_dens)[i] = state.ice_density.data[i]; + (*col_i_sat)[i] = props.ice_saturation.data[i]; + } + + ColumnToField_(col,ice_saturation,col_i_sat.ptr()); + ColumnToField_(col,ice_density,col_i_dens.ptr()); } - Epetra_Vector temp(ncells_per_col_); - Epetra_Vector conductivity(ncells_per_col_); if (has_energy) { auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); + + for (int i=0; i < ncells_per_col_; ++i) { + (*col_temp)[i] = state.temperature.data[i]; + (*col_cond)[i] = props.conductivity.data[i]; + } + + ColumnToField_(col,temp, col_temp.ptr()); + ColumnToField_(col,conductivity,col_cond.ptr()); } for (int i=0; i < ncells_per_col_; ++i) { @@ -788,21 +807,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_rel_perm)[i] = props.relative_permeability.data[i]; (*col_cond)[i] = props.conductivity.data[i]; (*col_vol)[i] = props.volume.data[i]; - - if (has_gas) { - (*col_g_dens)[i] = state.gas_density.data[i]; - (*col_g_sat)[i] = props.gas_saturation.data[i]; - } - - if (has_ice) { - (*col_i_dens)[i] = state.ice_density.data[i]; - (*col_i_sat)[i] = props.ice_saturation.data[i]; - } - - if (has_energy) { - (*col_temp)[i] = state.temperature.data[i]; - (*col_cond)[i] = props.conductivity.data[i]; - } } @@ -834,12 +838,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,liquid_density,col_f_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); - ColumnToField_(col,gas_saturation,col_g_sat.ptr()); - ColumnToField_(col,gas_density,col_g_dens.ptr()); - ColumnToField_(col,ice_saturation,col_i_sat.ptr()); - ColumnToField_(col,ice_density,col_i_dens.ptr()); - ColumnToField_(col,temp, col_temp.ptr()); - ColumnToField_(col,conductivity,col_cond.ptr()); for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); From 7978201a378817b0934296b2582afb70510861b1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 25 Apr 2023 15:23:08 -0700 Subject: [PATCH 257/582] debugging transport --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f32f010b6..feb5bfaac 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -619,11 +619,14 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); //Fill the tcc matrix component by component? - + std::cout << "Total comp: " << num_components << "\n"; + std::cout << "Total cells: " << ncells_per_col_ << "\n"; for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); + std::cout << "component: " << i << "\n"; for (int j=0; j Date: Tue, 25 Apr 2023 15:32:20 -0700 Subject: [PATCH 258/582] trying debug again --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index feb5bfaac..4b7df7527 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -315,7 +315,6 @@ void EcoSIM::Initialize() { //Looping over the columns and initializing for (int col=0; col!=num_cols_; ++col) { - ierr = InitializeSingleColumn(col); } // verbose message @@ -576,6 +575,8 @@ void EcoSIM::CopyToEcoSIM(int col, BGCAuxiliaryData& aux_data, const Tag& water_tag) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Starting copy step" << std::endl; //Fill state with ATS variables that are going to be changed by EcoSIM const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); @@ -618,15 +619,15 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,liquid_density,col_f_dens.ptr()); FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); - //Fill the tcc matrix component by component? - std::cout << "Total comp: " << num_components << "\n"; - std::cout << "Total cells: " << ncells_per_col_ << "\n"; + + *vo_->os() << "Total Comp: " << num_components << std::endl; + *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; for (int i=0; i < num_components; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); - std::cout << "component: " << i << "\n"; + *vo_->os() << "Component: " << i << std::endl; for (int j=0; jos() << "Cell: " << j << std::endl; col_comp(j) = (*col_tcc)(i,j); tcc_comp[j] = tcc[i][j]; } From d903d50d808edf6b8a94d471e726033763ebf962 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 11:40:54 -0700 Subject: [PATCH 259/582] trying a new component num --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4b7df7527..e09bf4da7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -620,9 +620,11 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); + int tcc_num = tcc_comp->size(); + *vo_->os() << "Total Comp: " << tcc_num << std::endl; *vo_->os() << "Total Comp: " << num_components << std::endl; *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; - for (int i=0; i < num_components; ++i) { + for (int i=0; i < tcc_num; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); *vo_->os() << "Component: " << i << std::endl; @@ -843,7 +845,8 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,rock_density,col_r_dens.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); - for (int i=0; i < num_components; ++i) { + int tcc_num = tcc_comp->size(); + for (int i=0; i < tcc_num; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); for (int j=0; j Date: Wed, 26 Apr 2023 12:46:42 -0700 Subject: [PATCH 260/582] minor fix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e09bf4da7..677fde505 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -620,7 +620,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); - int tcc_num = tcc_comp->size(); + int tcc_num = tcc->size(); *vo_->os() << "Total Comp: " << tcc_num << std::endl; *vo_->os() << "Total Comp: " << num_components << std::endl; *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; @@ -666,7 +666,7 @@ void EcoSIM::CopyToEcoSIM(int col, state.fluid_density.data[i] = (*col_f_dens)[i]; state.porosity.data[i] = (*col_poro)[i]; state.water_content.data[i] = (*col_wc)[i]; - for (int j=0; i < num_components; ++j) { + for (int j=0; i < tcc_num; ++j) { state.total_component_concentration.data[j][i] = (*col_tcc)[j][i]; } @@ -761,6 +761,8 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + int tcc_num = tcc->size(); + if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); @@ -805,7 +807,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_f_dens)[i] = state.fluid_density.data[i]; (*col_poro)[i] = state.porosity.data[i]; (*col_wc)[i] = state.water_content.data[i]; - for (int j=0; i < num_components; ++j) { + for (int j=0; i < tcc_num; ++j) { (*col_tcc)[j][i] = state.total_component_concentration.data[j][i]; } (*col_l_sat)[i] = props.liquid_saturation.data[i]; @@ -845,7 +847,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,rock_density,col_r_dens.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); - int tcc_num = tcc_comp->size(); for (int i=0; i < tcc_num; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); Epetra_SerialDenseVector tcc_comp(ncells_per_col_); From 51e231834ec39d6a929439afab0eeb454410178f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 12:55:11 -0700 Subject: [PATCH 261/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 677fde505..50b58ef3e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -620,7 +620,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); - int tcc_num = tcc->size(); + int tcc_num = tcc.size(); *vo_->os() << "Total Comp: " << tcc_num << std::endl; *vo_->os() << "Total Comp: " << num_components << std::endl; *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; @@ -761,7 +761,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - int tcc_num = tcc->size(); + int tcc_num = tcc.size(); if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); From 4b9d7cbbae0aea78f76d32e2e34e2c0102f88d9d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 13:02:39 -0700 Subject: [PATCH 262/582] trying a different access method --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 50b58ef3e..411fc1d8e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -620,7 +620,8 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); - int tcc_num = tcc.size(); + //int tcc_num = tcc.size(); + int tcc_num = tcc.NumVectors(); *vo_->os() << "Total Comp: " << tcc_num << std::endl; *vo_->os() << "Total Comp: " << num_components << std::endl; *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; @@ -761,7 +762,8 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - int tcc_num = tcc.size(); + //int tcc_num = tcc.size(); + int tcc_num = tcc.NumVectors(); if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); From b519ffa954bf72bbd1f707db3c0a753ccd60595e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 13:22:15 -0700 Subject: [PATCH 263/582] more tests --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 411fc1d8e..381248cbe 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -77,12 +77,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell - if (plist_->isParameter("component names")) { - component_names_ = plist_->get>("component names").toVector(); - num_components = component_names_.size(); - // otherwise we hopefully get them from chemistry - } - //Flow poro_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); saturation_liquid_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); @@ -244,7 +238,7 @@ void EcoSIM::Initialize() { //Now we call the engine's init state function which allocates the data - bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, num_components); + bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num); int ierr = 0; @@ -580,6 +574,8 @@ void EcoSIM::CopyToEcoSIM(int col, //Fill state with ATS variables that are going to be changed by EcoSIM const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); + int tcc_num = tcc.NumVectors(); + const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", false); const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); @@ -605,7 +601,7 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(num_components,ncells_per_col_)); + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); //Here is where we should do the various field-to-column calls to then pass along //to the data structures that will pass the data to EcoSIM @@ -623,7 +619,6 @@ void EcoSIM::CopyToEcoSIM(int col, //int tcc_num = tcc.size(); int tcc_num = tcc.NumVectors(); *vo_->os() << "Total Comp: " << tcc_num << std::endl; - *vo_->os() << "Total Comp: " << num_components << std::endl; *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; for (int i=0; i < tcc_num; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); @@ -695,8 +690,6 @@ void EcoSIM::CopyToEcoSIM(int col, //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; - //num_components_ = tcc.NumVectors(); - // Auxiliary data -- block copy. /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); @@ -736,6 +729,8 @@ void EcoSIM::CopyFromEcoSIM(const int col, // (this->porosity())[cell] = state.porosity; Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); + int tcc_num = tcc.NumVectors(); + auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); //auto& elevation = S_->GetPtrW(elev_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell"); @@ -754,7 +749,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(num_components,ncells_per_col_)); + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From fed9fea4fc2de53059a12349892b3b5457a4e634 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 13:31:32 -0700 Subject: [PATCH 264/582] ats --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 381248cbe..61dc391ff 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -616,8 +616,6 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); - //int tcc_num = tcc.size(); - int tcc_num = tcc.NumVectors(); *vo_->os() << "Total Comp: " << tcc_num << std::endl; *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; for (int i=0; i < tcc_num; ++i) { @@ -757,9 +755,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - //int tcc_num = tcc.size(); - int tcc_num = tcc.NumVectors(); - if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); From d3d187ec0a56b66fd2ecc9a43adb1b5c0c54db95 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 13:35:10 -0700 Subject: [PATCH 265/582] another definition --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 61dc391ff..65b50a294 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -75,6 +75,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); + int tcc_num = tcc.NumVectors(); //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell //Flow From e607a6b81638bef577f466d2c7075f9ea476988d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 13:47:29 -0700 Subject: [PATCH 266/582] more definitions --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 65b50a294..f32fcd0cf 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -237,8 +237,11 @@ void EcoSIM::Initialize() { InitializeCVField(S_, *vo_, aux_names_[i], tag_next_, passwd_, 0.0); }*/ - //Now we call the engine's init state function which allocates the data + //Need to know the number of components to initialize data structures + const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); + int tcc_num = tcc.NumVectors(); + //Now we call the engine's init state function which allocates the data bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num); int ierr = 0; From 149c6d1d2e44dac59f72567263e8e0b92c948eac Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 13:51:11 -0700 Subject: [PATCH 267/582] more refactoring --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f32fcd0cf..5a0c6767d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -75,7 +75,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); - int tcc_num = tcc.NumVectors(); //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell //Flow @@ -238,7 +237,7 @@ void EcoSIM::Initialize() { }*/ //Need to know the number of components to initialize data structures - const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); + const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); int tcc_num = tcc.NumVectors(); //Now we call the engine's init state function which allocates the data From f0f9255307c5e51eb29779bf6d963054e28c9199 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 14:50:27 -0700 Subject: [PATCH 268/582] adding a matrix version of the FtC function --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 25 +++++++++++++++++++++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 +++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5a0c6767d..e9d9ffefd 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -502,6 +502,23 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Teuchos::Ptr col_arr) + { + int n_comp = m_arr.NumVectors(); + auto& col_iter = mesh_->cells_of_column(col); + + *vo->os() << "number of comp: "<< n_comp << std::endl; + *vo->os() << "number of cells: "<< col_iter.size() << std::endl; + for (int j=0; j!=n_comp; ++j){ + *vo->os() << "component: "<< j << std::endl; + for (std::size_t i=0; i!=col_iter.size(); ++i) { + *vo->os() << "cell: "<< i << std::endl; + (*col_arr)(i,j) = m_arr[col_iter[i]][j]; + } + } + } + // helper function for pushing column back to field void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, Teuchos::Ptr col_vec) @@ -619,7 +636,9 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); - *vo_->os() << "Total Comp: " << tcc_num << std::endl; + MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); + + /**vo_->os() << "Total Comp: " << tcc_num << std::endl; *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; for (int i=0; i < tcc_num; ++i) { Epetra_SerialDenseVector col_comp(ncells_per_col_); @@ -631,7 +650,9 @@ void EcoSIM::CopyToEcoSIM(int col, tcc_comp[j] = tcc[i][j]; } FieldToColumn_(col,Teuchos::ptr(&tcc_comp),Teuchos::ptr(&col_comp)); - } + }*/ + + if (has_gas) { const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index e46bfb878..c709c0fec 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -140,6 +140,9 @@ class EcoSIM : public PK_Physical { void FieldToColumn_(AmanziMesh::Entity_ID col, Teuchos::Ptr vec, Teuchos::Ptr col_vec); + void MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& m_arr, + Teuchos::Ptr col_arr) + //void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // double* col_vec); void ColDepthDz_(AmanziMesh::Entity_ID col, From c60d1123015f59914e38125ddf11ad7a142a9f41 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 14:53:53 -0700 Subject: [PATCH 269/582] pushing that weird cmake error --- src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt index f9c58b1a4..fcfdaea19 100644 --- a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt +++ b/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt @@ -4,8 +4,8 @@ # Constitutive relations for EcoSIM # -add_subdirectory(bulk_density) -add_subdirectory(hydraulic_conductivity) +#add_subdirectory(bulk_density) +#add_subdirectory(hydraulic_conductivity) # collect all sources set(ats_ecosim_relations_src_files From e059c5c5acedafbc8dfcaee47764c1a43c25c08d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 14:56:45 -0700 Subject: [PATCH 270/582] typos --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 ++++---- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e9d9ffefd..4fe89f002 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -508,12 +508,12 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiV int n_comp = m_arr.NumVectors(); auto& col_iter = mesh_->cells_of_column(col); - *vo->os() << "number of comp: "<< n_comp << std::endl; - *vo->os() << "number of cells: "<< col_iter.size() << std::endl; + *vo_->os() << "number of comp: "<< n_comp << std::endl; + *vo_->os() << "number of cells: "<< col_iter.size() << std::endl; for (int j=0; j!=n_comp; ++j){ - *vo->os() << "component: "<< j << std::endl; + *vo_->os() << "component: "<< j << std::endl; for (std::size_t i=0; i!=col_iter.size(); ++i) { - *vo->os() << "cell: "<< i << std::endl; + *vo_->os() << "cell: "<< i << std::endl; (*col_arr)(i,j) = m_arr[col_iter[i]][j]; } } diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index c709c0fec..6d831c9f3 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -141,7 +141,7 @@ class EcoSIM : public PK_Physical { Teuchos::Ptr col_vec); void MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& m_arr, - Teuchos::Ptr col_arr) + Teuchos::Ptr col_arr); //void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, // double* col_vec); From ce595657590783f373a306341f8ef41197eb0516 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 15:06:42 -0700 Subject: [PATCH 271/582] more prints --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4fe89f002..6c79e1840 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -514,6 +514,9 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiV *vo_->os() << "component: "<< j << std::endl; for (std::size_t i=0; i!=col_iter.size(); ++i) { *vo_->os() << "cell: "<< i << std::endl; + *vo_->os() << "cell: "<< i << std::endl; + *vo_->os() << "col arr: "<< (*col_arr)(i,j) << std::endl; + *vo_->os() << "m_arr: "<< m_arr[col_iter[i]][j] << std::endl; (*col_arr)(i,j) = m_arr[col_iter[i]][j]; } } From 054f31e0712c8e3f429a5de0ad17ba550d336f25 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 15:19:26 -0700 Subject: [PATCH 272/582] ats --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 6c79e1840..ef017ba35 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -516,7 +516,8 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiV *vo_->os() << "cell: "<< i << std::endl; *vo_->os() << "cell: "<< i << std::endl; *vo_->os() << "col arr: "<< (*col_arr)(i,j) << std::endl; - *vo_->os() << "m_arr: "<< m_arr[col_iter[i]][j] << std::endl; + //*vo_->os() << "m_arr: "<< m_arr[col_iter[i]][j] << std::endl; + *vo_->os() << "m_arr: "<< m_arr(col_iter[i],j) << std::endl; (*col_arr)(i,j) = m_arr[col_iter[i]][j]; } } From 62c4a74ca12a50bc7200c8309d5ed9edc25540b3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 15:26:39 -0700 Subject: [PATCH 273/582] more nonsense --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index ef017ba35..50841f1dd 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -510,14 +510,17 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiV *vo_->os() << "number of comp: "<< n_comp << std::endl; *vo_->os() << "number of cells: "<< col_iter.size() << std::endl; + + *vo_->os() << "Matrix rows: "<< m_arr.GlobalLength() << std::endl; + *vo_->os() << "Matrix columns: "<< m_arr.NumVectors() << std::endl; for (int j=0; j!=n_comp; ++j){ *vo_->os() << "component: "<< j << std::endl; for (std::size_t i=0; i!=col_iter.size(); ++i) { *vo_->os() << "cell: "<< i << std::endl; *vo_->os() << "cell: "<< i << std::endl; *vo_->os() << "col arr: "<< (*col_arr)(i,j) << std::endl; - //*vo_->os() << "m_arr: "<< m_arr[col_iter[i]][j] << std::endl; - *vo_->os() << "m_arr: "<< m_arr(col_iter[i],j) << std::endl; + *vo_->os() << "m_arr: "<< m_arr[j][col_iter[i]] << std::endl; + //*vo_->os() << "m_arr: "<< (*m_arr)(col_iter[i],j) << std::endl; (*col_arr)(i,j) = m_arr[col_iter[i]][j]; } } From 4102eb748cb0d834c1c184805918f069ed606011 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 15:33:55 -0700 Subject: [PATCH 274/582] flipping the indicies --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 50841f1dd..f8997d053 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -521,7 +521,7 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiV *vo_->os() << "col arr: "<< (*col_arr)(i,j) << std::endl; *vo_->os() << "m_arr: "<< m_arr[j][col_iter[i]] << std::endl; //*vo_->os() << "m_arr: "<< (*m_arr)(col_iter[i],j) << std::endl; - (*col_arr)(i,j) = m_arr[col_iter[i]][j]; + (*col_arr)(i,j) = m_arr[j][col_iter[i]]; } } } From 59136fac5a7a9896e1a4302225bb9a6f107cedc0 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 15:40:26 -0700 Subject: [PATCH 275/582] more index maddness --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f8997d053..63260280d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -692,7 +692,7 @@ void EcoSIM::CopyToEcoSIM(int col, state.porosity.data[i] = (*col_poro)[i]; state.water_content.data[i] = (*col_wc)[i]; for (int j=0; i < tcc_num; ++j) { - state.total_component_concentration.data[j][i] = (*col_tcc)[j][i]; + state.total_component_concentration.data[j][i] = (*col_tcc)(i,j); } props.liquid_saturation.data[i] = (*col_l_sat)[i]; From 4113b7c8e0d5bf3a132ed5dadf7a1c3890deb4fd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 16:02:00 -0700 Subject: [PATCH 276/582] even more index maddness --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 63260280d..e64b515c6 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -516,7 +516,6 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiV for (int j=0; j!=n_comp; ++j){ *vo_->os() << "component: "<< j << std::endl; for (std::size_t i=0; i!=col_iter.size(); ++i) { - *vo_->os() << "cell: "<< i << std::endl; *vo_->os() << "cell: "<< i << std::endl; *vo_->os() << "col arr: "<< (*col_arr)(i,j) << std::endl; *vo_->os() << "m_arr: "<< m_arr[j][col_iter[i]] << std::endl; @@ -687,14 +686,23 @@ void EcoSIM::CopyToEcoSIM(int col, // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this + // have to fill tcc separately (I think) + + *vo_->os() << "component: "<< i << std::endl; + for (int j=0; j < tcc_num; ++j) { + *vo_->os() << "component: "<< j << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "cell: "<< i << std::endl; + *vo_->os() << "col arr: "<< (*col_tcc)(i,j) << std::endl; + *vo_->os() << "m_arr: "<< state.total_component_concentration.data[j][i] << std::endl; + state.total_component_concentration.data[j][i] = (*col_tcc)(i,j); + } + } + for (int i=0; i < ncells_per_col_; ++i) { state.fluid_density.data[i] = (*col_f_dens)[i]; state.porosity.data[i] = (*col_poro)[i]; state.water_content.data[i] = (*col_wc)[i]; - for (int j=0; i < tcc_num; ++j) { - state.total_component_concentration.data[j][i] = (*col_tcc)(i,j); - } - props.liquid_saturation.data[i] = (*col_l_sat)[i]; //props.elevation.data[i] = (*col_elev)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; From 0d08b99f9879bfc43683d1586e9aef3a1483998f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 16:34:38 -0700 Subject: [PATCH 277/582] removing stuff --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e64b515c6..7483a1e0b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -688,7 +688,6 @@ void EcoSIM::CopyToEcoSIM(int col, // structures. Eventually I could probably rewrite FieldToColumn_ to do this // have to fill tcc separately (I think) - *vo_->os() << "component: "<< i << std::endl; for (int j=0; j < tcc_num; ++j) { *vo_->os() << "component: "<< j << std::endl; for (int i=0; i < ncells_per_col_; ++i) { From 4e01971891d7e0e24b462079a272b62292f1399b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 17:15:25 -0700 Subject: [PATCH 278/582] defining the column to field matrix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 49 +++++++++++++++++------ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 ++ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 7483a1e0b..d1729d649 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -544,6 +544,30 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::Ptr col_arr) { + auto& col_iter = mesh->cells_of_column(col); + + int n_comp = m_arr.NumVectors(); + auto& col_iter = mesh_->cells_of_column(col); + + *vo_->os() << "number of comp: "<< n_comp << std::endl; + *vo_->os() << "number of cells: "<< col_iter.size() << std::endl; + + *vo_->os() << "Matrix rows: "<< m_arr.GlobalLength() << std::endl; + *vo_->os() << "Matrix columns: "<< m_arr.NumVectors() << std::endl; + + for (int j=0; j!=n_comp; ++j){ + *vo_->os() << "component: "<< j << std::endl; + for (std::size_t i=0; i!=col_iter.size(); ++i) { + *vo_->os() << "cell: "<< i << std::endl; + *vo_->os() << "col arr: "<< (*col_arr)(i,j) << std::endl; + *vo_->os() << "m_arr: "<< m_arr[j][col_iter[i]] << std::endl; + + m_arr[j][col_iter[i]] = (*col_arr)(i,j); + + } + // helper function for collecting column dz and depth void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, Teuchos::Ptr depth, @@ -837,9 +861,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_f_dens)[i] = state.fluid_density.data[i]; (*col_poro)[i] = state.porosity.data[i]; (*col_wc)[i] = state.water_content.data[i]; - for (int j=0; i < tcc_num; ++j) { - (*col_tcc)[j][i] = state.total_component_concentration.data[j][i]; - } (*col_l_sat)[i] = props.liquid_saturation.data[i]; //(*col_elev)[i] = props.elevation.data[i]; (*col_rel_perm)[i] = props.relative_permeability.data[i]; @@ -847,6 +868,17 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_vol)[i] = props.volume.data[i]; } + //Take new values from Ecosim state and put them into the secondary data structure + //for backing back into amanzi state + for (int j=0; j < tcc_num; ++j) { + *vo_->os() << "component: "<< j << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "cell: "<< i << std::endl; + *vo_->os() << "col arr: "<< (*col_tcc)(i,j) << std::endl; + *vo_->os() << "m_arr: "<< state.total_component_concentration.data[j][i] << std::endl; + (*col_tcc)(i,j) = state.total_component_concentration.data[j][i]; + } + } //Here is where the auxiliary data is filled need to try to change this to columns //This may not be trivial @@ -877,16 +909,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,rock_density,col_r_dens.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); - for (int i=0; i < tcc_num; ++i) { - Epetra_SerialDenseVector col_comp(ncells_per_col_); - Epetra_SerialDenseVector tcc_comp(ncells_per_col_); - for (int j=0; j vec, Teuchos::Ptr col_vec); + + void MatrixColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector& m_arr, + Teuchos::Ptr col_arr); //evaluator for transpiration; //I don't think I need this anymore //Teuchos::RCP p_root_eval_; From 2cfe605601484bf546a267a78159f43d96ad5796 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 17:21:06 -0700 Subject: [PATCH 279/582] typos --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d1729d649..e4a682cff 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -546,7 +546,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::Ptr col_arr) { - auto& col_iter = mesh->cells_of_column(col); + auto& col_iter = mesh_->cells_of_column(col); int n_comp = m_arr.NumVectors(); auto& col_iter = mesh_->cells_of_column(col); @@ -565,6 +565,8 @@ void EcoSIM::MatrixColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector& *vo_->os() << "m_arr: "<< m_arr[j][col_iter[i]] << std::endl; m_arr[j][col_iter[i]] = (*col_arr)(i,j); + } + } } From 485e69a0fe870f74210a1e32fb462d2bbc65a58c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Apr 2023 17:23:41 -0700 Subject: [PATCH 280/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e4a682cff..180e7c749 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -546,7 +546,6 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::Ptr col_arr) { - auto& col_iter = mesh_->cells_of_column(col); int n_comp = m_arr.NumVectors(); auto& col_iter = mesh_->cells_of_column(col); From 36059c665385aaf3a6e9babc077b95e23bc83c38 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 27 Apr 2023 15:45:05 -0700 Subject: [PATCH 281/582] initial commit of trying to integrate the ecosim driver --- src/pks/ecosim_pk/BGCEngine.cc | 37 ++++++++---- src/pks/ecosim_pk/BGCEngine.hh | 4 ++ src/pks/ecosim_pk/ecosim_interface.h | 68 ++++++++++++++++++++++ src/pks/ecosim_pk/ecosim_wrappers.F90 | 83 +++++++++++++++++++++++++++ 4 files changed, 181 insertions(+), 11 deletions(-) create mode 100644 src/pks/ecosim_pk/ecosim_interface.h create mode 100644 src/pks/ecosim_pk/ecosim_wrappers.F90 diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index ac3b47112..02a84f06f 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -83,6 +83,10 @@ BGCEngine::BGCEngine(const std::string& engineName, msg << "BGCEngine: Unsupported bgc engine: '" << bgc_engine_name_ << "'\n"; msg << " Only option for now is 'EcoSIM'.\n"; Exceptions::amanzi_throw(msg); + + CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_, &bgc_status_); + + bgc_.Setup(bgc_engine_inputfile_.c_str()) } // All alquimia function calls require a status object. @@ -141,7 +145,7 @@ BGCEngine::BGCEngine(const std::string& engineName, BGCEngine::~BGCEngine() { - //chem_.Shutdown(&engine_state_, &chem_status_); + bgc_.Shutdown(&engine_state_, &bgc_status_); //FreeAlquimiaProblemMetaData(&chem_metadata_); // As there are no chemical conditions, am I just deleting variables? @@ -155,9 +159,9 @@ BGCEngine::~BGCEngine() delete iter->second; }*/ - //FreeBGCProperties(&props); - //FreeBGCState(&state); - //FreeBGCAuxiliaryData(&aux_data); + FreeBGCProperties(&props); + FreeBGCState(&state); + FreeBGCAuxiliaryData(&aux_data); //FreeAlquimiaEngineStatus(&chem_status_); } @@ -205,13 +209,13 @@ bool BGCEngine::Advance(const double delta_time, { // Advance the chemical reaction all operator-split-like. - /*chem_.ReactionStepOperatorSplit(&engine_state_, - delta_time, - &(const_cast(mat_props)), - &chem_state, - &aux_data, - &chem_status_); - */ + bgc_.Advance(&engine_state_, + delta_time, + &(const_cast(mat_props)), + &chem_state, + &aux_data, + &chem_status_); + //This is alquimia's advance function which we won't need //calling EcoSIM advance driver @@ -221,6 +225,17 @@ bool BGCEngine::Advance(const double delta_time, } +void CreateBGCInterface(const char* const engine_name, + BGCInterface* interface, + BGCEngineStatus* status) + { + + interface->Setup = &ecosim_setup; + interface->Shutdown = &ecosim_shutdown; + interface->Advance = &ecosim_advance; + + } + //For now I don't need any of the rest of this code yet. Just commenting //out in case I need it later. diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index cd8ddbd6e..3c8aabfe6 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -85,6 +85,10 @@ class BGCEngine { void CopyBGCProperties(const BGCProperties* const source, BGCProperties* destination); + void CreateBGCInterface(const char* const engine_name, + BGCInterface* interface, + BGCEngineStatus* status); + private: // bgc data structures. diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h new file mode 100644 index 000000000..cee78acd7 --- /dev/null +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -0,0 +1,68 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** Alquimia is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + +#ifndef ALQUIMIA_PFLOTRAN_INTERFACE_H_ +#define ALQUIMIA_PFLOTRAN_INTERFACE_H_ + +/******************************************************************************* + ** + ** C declarations of the pflotran alquimia interface + ** + ******************************************************************************/ + +#include "alquimia/alquimia_interface.h" +#include "alquimia/alquimia_containers.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +void ecosim_setup( + const char* input_filename, + bool hands_off, + void* pft_engine_state, + BGCSizes* sizes, + BGCEngineFunctionality* functionality, + BGCEngineStatus* status +); + +void ecosim_advance( + void* pft_engine_state, + double delta_t, + BGCProperties* material_properties, + BGCState* state, + BGCAuxiliaryData* aux_data, + BGCEngineStatus* status +); + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 new file mode 100644 index 000000000..650f7d87c --- /dev/null +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -0,0 +1,83 @@ +! +!There needs to be a wrapper for the eocsim f90 driver +!as there are differences between how gfortran and intel compilers +!handle mangling conventions. +! +! Copied from the alquimia wrapper: +! **************************************************************************** ! +! +! PFloTran Alquimia Inteface Wrappers +! +! Author: Benjamin Andre +! +! Different fortran compilers use different name mangling conventions +! for fortran modules: +! +! gfortran : ___modulename_MOD_procedurename +! +! intel : _modulename_mp_procedurename_ +! +! as a consequence we can't put the alquimia interface into a +! module and call it directly from C/C++. Instead we use +! some simple wrapper functions. +! +! Notes: +! +! * Function call signatures are dictated by the alquimia API! +! +! * alquimia data structures defined in AlquimiaContainers_module +! (alquimia_containers.F90) are dictated by the alquimia API. +! +! **************************************************************************** ! + +subroutine EcoSIM_Setup(input_filename, hands_off, & + pft_engine_state, sizes, functionality, status) bind(C) + + use, intrinsic :: iso_c_binding + + use BGCContainers_module + use ATSCPLMod, only : ATS2EcoSIMData, Init_EcoSIM + + implicit none + + ! function parameters + character(kind=c_char), dimension(*), intent(in) :: input_filename + logical (c_bool), value, intent(in) :: hands_off + type (c_ptr), intent(out) :: pft_engine_state + type (BGCSizes), intent(out) :: sizes + type (BGCEngineFunctionality), intent(out) :: functionality + type (BGCEngineStatus), intent(out) :: status + + call ATS2EcoSIMData(filter_col,data_1d,var_1d,data_2d,var_2d,data_3d,var_3d) + call Init_EcoSIM(jz,js,ncol) + +end subroutine EcoSIM_Setup + +! **************************************************************************** ! + +subroutine EcoSIM_Advance( & + pft_engine_state, & + delta_t, & + properties, & + state, & + aux_data, & + status) bind(C) + + use, intrinsic :: iso_c_binding + + use BGCContainers_module + use ATSCPLMod, only : Run_EcoSIM_one_step + + implicit none + + ! function parameters + type (c_ptr), intent(inout) :: pft_engine_state + real (c_double), value, intent(in) :: delta_t + type (BGCProperties), intent(in) :: properties + type (BGCState), intent(inout) :: state + type (BGCAuxiliaryData), intent(inout) :: aux_data + type (BGCEngineStatus), intent(out) :: status + + call Run_EcoSIM_one_step() + +end subroutine EcoSIM_Advance From e5f47f87fed140800afe093210caa322a0ed5842 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 17 May 2023 14:05:19 -0700 Subject: [PATCH 282/582] fixing some definitions of the Engine --- src/pks/ecosim_pk/BGCEngine.cc | 17 +++++++++--- src/pks/ecosim_pk/BGCEngine.hh | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 02a84f06f..fc82690d0 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -211,10 +211,8 @@ bool BGCEngine::Advance(const double delta_time, // Advance the chemical reaction all operator-split-like. bgc_.Advance(&engine_state_, delta_time, - &(const_cast(mat_props)), - &chem_state, - &aux_data, - &chem_status_); + &state, + &aux_data); //This is alquimia's advance function which we won't need //calling EcoSIM advance driver @@ -555,5 +553,16 @@ const AlquimiaSizes& ChemistryEngine::Sizes() const return sizes_; }*/ +void CreateBGCInterface(const char* const engine_name, + BGCInterface* interface, + BGCEngineStatus* status) { + //Now here is where I should put the links to the actual Setup, Shutdown + //Functions for the dirver + interface->Setup = NULL; + interface->Shutdown = NULL; + interface->Advance = NULL; + +} /* end CreateAlquimiaInterface() */ + } // namespace } // namespace diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 3c8aabfe6..8e5cc732e 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -34,6 +34,54 @@ namespace EcoSIM { class BGCEngine { public: + //This is the main struct which will hold the data for the engine including + //its set up and shutdown regions + typedef struct { + /* read data files/structures, initialize memory, basis management + (includes reading database, swapping basis, etc.) */ + void (*Setup)( + const char* input_filename, + bool hands_off, + void* pft_engine_state, + BGCSizes* sizes, + BGCEngineFunctionality* functionality, + BGCEngineStatus* status); + + /* gracefully shutdown the engine, cleanup memory */ + void (*Shutdown)( + void* pft_engine_state, + BGCEngineStatus* status); + + /* constrain processing for boundary/initial constraints. Called + once for each IC/BC. */ + /*void (*Setup)( + void* pft_engine_state, + BGCGeochemicalCondition* condition, + BGCProperties* props, + BGCState* state, + BGCAuxiliaryData* aux_data, + BGCEngineStatus* status);*/ + + /* take one (or more?) reaction steps in operator split mode */ + void (*Advance)( + void* pft_engine_state, + double delta_t, + BGCProperties* props, + BGCState* state, + BGCAuxiliaryData* aux_data, + BGCEngineStatus* status); + + /* Access to user selected geochemical data for output, i.e. pH, + mineral SI, reaction rates */ + /*void (*GetAuxiliaryOutput)( + void* pft_engine_state, + BGCProperties* props, + BGCState* state, + BGCAuxiliaryData* aux_data, + BGCAuxiliaryOutputData* aux_out, + BGCEngineStatus* status);*/ + } BGCInterface; + // Constructs a chemistry engine using the given engine (backend) name and input file. BGCEngine(const std::string& engineName, const std::string& inputFile); From ecfc70c02b0b5d2e7b49e58cca20505238124798 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 17 May 2023 14:13:17 -0700 Subject: [PATCH 283/582] more definition fixes --- src/pks/ecosim_pk/BGCEngine.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 8e5cc732e..1663053c3 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -142,6 +142,11 @@ class BGCEngine { // bgc data structures. bool bgc_initialized_; void* engine_state_; + BGCEngineFunctionality functionality_; + BGCSizes sizes_; + BGCInterface bgc_; + BGCEngineStatus bgc_status_; + BGCProblemMetaData bgc_metadata_; BGCSizes sizes_; /*AlquimiaEngineFunctionality functionality_; From c68012257209733b44c87123050ded4cf8dca802 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 17 May 2023 14:33:13 -0700 Subject: [PATCH 284/582] more random fixes --- src/pks/ecosim_pk/BGCEngine.cc | 28 +++++++++++----------------- src/pks/ecosim_pk/BGCEngine.hh | 25 ++++++++++++++----------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index fc82690d0..c3fd65a90 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -84,9 +84,12 @@ BGCEngine::BGCEngine(const std::string& engineName, msg << " Only option for now is 'EcoSIM'.\n"; Exceptions::amanzi_throw(msg); - CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_, &bgc_status_); + CreateBGCInterface(bgc_engine_name_.c_str(), + &bgc_, + //&bgc_status_ + ); - bgc_.Setup(bgc_engine_inputfile_.c_str()) + bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_) } // All alquimia function calls require a status object. @@ -145,7 +148,9 @@ BGCEngine::BGCEngine(const std::string& engineName, BGCEngine::~BGCEngine() { - bgc_.Shutdown(&engine_state_, &bgc_status_); + bgc_.Shutdown(&engine_state_, + //&bgc_status_ + ); //FreeAlquimiaProblemMetaData(&chem_metadata_); // As there are no chemical conditions, am I just deleting variables? @@ -159,9 +164,9 @@ BGCEngine::~BGCEngine() delete iter->second; }*/ - FreeBGCProperties(&props); - FreeBGCState(&state); - FreeBGCAuxiliaryData(&aux_data); + //FreeBGCProperties(&props); + //FreeBGCState(&state); + //FreeBGCAuxiliaryData(&aux_data); //FreeAlquimiaEngineStatus(&chem_status_); } @@ -553,16 +558,5 @@ const AlquimiaSizes& ChemistryEngine::Sizes() const return sizes_; }*/ -void CreateBGCInterface(const char* const engine_name, - BGCInterface* interface, - BGCEngineStatus* status) { - //Now here is where I should put the links to the actual Setup, Shutdown - //Functions for the dirver - interface->Setup = NULL; - interface->Shutdown = NULL; - interface->Advance = NULL; - -} /* end CreateAlquimiaInterface() */ - } // namespace } // namespace diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 1663053c3..556d6db9a 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -41,16 +41,18 @@ class BGCEngine { (includes reading database, swapping basis, etc.) */ void (*Setup)( const char* input_filename, - bool hands_off, - void* pft_engine_state, + //bool hands_off, + //void* pft_engine_state, BGCSizes* sizes, - BGCEngineFunctionality* functionality, - BGCEngineStatus* status); + //BGCEngineFunctionality* functionality, + //BGCEngineStatus* status + ); /* gracefully shutdown the engine, cleanup memory */ void (*Shutdown)( void* pft_engine_state, - BGCEngineStatus* status); + //BGCEngineStatus* status + ); /* constrain processing for boundary/initial constraints. Called once for each IC/BC. */ @@ -69,7 +71,8 @@ class BGCEngine { BGCProperties* props, BGCState* state, BGCAuxiliaryData* aux_data, - BGCEngineStatus* status); + //BGCEngineStatus* status + ); /* Access to user selected geochemical data for output, i.e. pH, mineral SI, reaction rates */ @@ -135,20 +138,20 @@ class BGCEngine { void CreateBGCInterface(const char* const engine_name, BGCInterface* interface, - BGCEngineStatus* status); + //BGCEngineStatus* status + ); private: // bgc data structures. bool bgc_initialized_; void* engine_state_; - BGCEngineFunctionality functionality_; + //BGCEngineFunctionality functionality_; BGCSizes sizes_; BGCInterface bgc_; - BGCEngineStatus bgc_status_; - BGCProblemMetaData bgc_metadata_; + //BGCEngineStatus bgc_status_; + //BGCProblemMetaData bgc_metadata_; - BGCSizes sizes_; /*AlquimiaEngineFunctionality functionality_; AlquimiaSizes sizes_; AlquimiaInterface chem_; From faba4fe0aa9ff9e03ee0ce30e226273d5c47cb79 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 17 May 2023 15:43:31 -0700 Subject: [PATCH 285/582] fixes --- src/pks/ecosim_pk/BGCEngine.cc | 8 ++------ src/pks/ecosim_pk/BGCEngine.hh | 17 ++++------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index c3fd65a90..effe865e7 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -85,9 +85,7 @@ BGCEngine::BGCEngine(const std::string& engineName, Exceptions::amanzi_throw(msg); CreateBGCInterface(bgc_engine_name_.c_str(), - &bgc_, - //&bgc_status_ - ); + &bgc_); bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_) } @@ -148,9 +146,7 @@ BGCEngine::BGCEngine(const std::string& engineName, BGCEngine::~BGCEngine() { - bgc_.Shutdown(&engine_state_, - //&bgc_status_ - ); + bgc_.Shutdown(&engine_state_); //FreeAlquimiaProblemMetaData(&chem_metadata_); // As there are no chemical conditions, am I just deleting variables? diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 556d6db9a..1f6f6242e 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -43,16 +43,11 @@ class BGCEngine { const char* input_filename, //bool hands_off, //void* pft_engine_state, - BGCSizes* sizes, - //BGCEngineFunctionality* functionality, - //BGCEngineStatus* status - ); + BGCSizes* sizes); /* gracefully shutdown the engine, cleanup memory */ void (*Shutdown)( - void* pft_engine_state, - //BGCEngineStatus* status - ); + void* pft_engine_state); /* constrain processing for boundary/initial constraints. Called once for each IC/BC. */ @@ -70,9 +65,7 @@ class BGCEngine { double delta_t, BGCProperties* props, BGCState* state, - BGCAuxiliaryData* aux_data, - //BGCEngineStatus* status - ); + BGCAuxiliaryData* aux_data); /* Access to user selected geochemical data for output, i.e. pH, mineral SI, reaction rates */ @@ -137,9 +130,7 @@ class BGCEngine { BGCProperties* destination); void CreateBGCInterface(const char* const engine_name, - BGCInterface* interface, - //BGCEngineStatus* status - ); + BGCInterface* interface); private: From 7a8947a4cb74637b2fbd3c8743537ca5c6ca427e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 17 May 2023 22:05:21 -0700 Subject: [PATCH 286/582] engine --- src/pks/ecosim_pk/BGCEngine.cc | 6 ++---- src/pks/ecosim_pk/BGCEngine.hh | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index effe865e7..8428a782c 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -87,7 +87,7 @@ BGCEngine::BGCEngine(const std::string& engineName, CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_); - bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_) + bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_); } // All alquimia function calls require a status object. @@ -224,9 +224,7 @@ bool BGCEngine::Advance(const double delta_time, } -void CreateBGCInterface(const char* const engine_name, - BGCInterface* interface, - BGCEngineStatus* status) +void CreateBGCInterface(const char* const engine_name) { interface->Setup = &ecosim_setup; diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 1f6f6242e..2393dc3b5 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -129,8 +129,7 @@ class BGCEngine { void CopyBGCProperties(const BGCProperties* const source, BGCProperties* destination); - void CreateBGCInterface(const char* const engine_name, - BGCInterface* interface); + void CreateBGCInterface(const char* const engine_name); private: From cb64402a37596798ac12a0f0709758d8e48b1dab Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 11:20:24 -0700 Subject: [PATCH 287/582] BGC engine fixes, should be good to go other than implementing driver --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- src/pks/ecosim_pk/BGCEngine.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 8428a782c..0059722d1 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -224,7 +224,7 @@ bool BGCEngine::Advance(const double delta_time, } -void CreateBGCInterface(const char* const engine_name) +void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) { interface->Setup = &ecosim_setup; diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 2393dc3b5..81b7d86a5 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -129,7 +129,7 @@ class BGCEngine { void CopyBGCProperties(const BGCProperties* const source, BGCProperties* destination); - void CreateBGCInterface(const char* const engine_name); + void CreateBGCInterface(const char* const engine_name, BGCInterface* interface); private: From 4e8d5ec93f8304b9fbfe3486b180e30c7a8a7994 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 12:26:41 -0700 Subject: [PATCH 288/582] moving the create interface code around --- src/pks/ecosim_pk/BGCEngine.cc | 5 +-- src/pks/ecosim_pk/BGCEngine.hh | 44 ------------------------ src/pks/ecosim_pk/data/BGC_containers.cc | 43 +++++++++++++++++++++++ src/pks/ecosim_pk/data/BGC_containers.hh | 42 ++++++++++++++++++++++ 4 files changed, 88 insertions(+), 46 deletions(-) create mode 100644 src/pks/ecosim_pk/data/BGC_containers.cc diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 0059722d1..b25df380b 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -212,6 +212,7 @@ bool BGCEngine::Advance(const double delta_time, // Advance the chemical reaction all operator-split-like. bgc_.Advance(&engine_state_, delta_time, + &props, &state, &aux_data); @@ -224,7 +225,7 @@ bool BGCEngine::Advance(const double delta_time, } -void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) +/*void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) { interface->Setup = &ecosim_setup; @@ -232,7 +233,7 @@ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) interface->Advance = &ecosim_advance; } - +*/ //For now I don't need any of the rest of this code yet. Just commenting //out in case I need it later. diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 81b7d86a5..209bce6c5 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -34,50 +34,6 @@ namespace EcoSIM { class BGCEngine { public: - //This is the main struct which will hold the data for the engine including - //its set up and shutdown regions - typedef struct { - /* read data files/structures, initialize memory, basis management - (includes reading database, swapping basis, etc.) */ - void (*Setup)( - const char* input_filename, - //bool hands_off, - //void* pft_engine_state, - BGCSizes* sizes); - - /* gracefully shutdown the engine, cleanup memory */ - void (*Shutdown)( - void* pft_engine_state); - - /* constrain processing for boundary/initial constraints. Called - once for each IC/BC. */ - /*void (*Setup)( - void* pft_engine_state, - BGCGeochemicalCondition* condition, - BGCProperties* props, - BGCState* state, - BGCAuxiliaryData* aux_data, - BGCEngineStatus* status);*/ - - /* take one (or more?) reaction steps in operator split mode */ - void (*Advance)( - void* pft_engine_state, - double delta_t, - BGCProperties* props, - BGCState* state, - BGCAuxiliaryData* aux_data); - - /* Access to user selected geochemical data for output, i.e. pH, - mineral SI, reaction rates */ - /*void (*GetAuxiliaryOutput)( - void* pft_engine_state, - BGCProperties* props, - BGCState* state, - BGCAuxiliaryData* aux_data, - BGCAuxiliaryOutputData* aux_out, - BGCEngineStatus* status);*/ - } BGCInterface; - // Constructs a chemistry engine using the given engine (backend) name and input file. BGCEngine(const std::string& engineName, const std::string& inputFile); diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc new file mode 100644 index 000000000..96fd16699 --- /dev/null +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -0,0 +1,43 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** Alquimia is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + +#include "BGC_containers.h" + +/* Its kind of silly to have this as a separate code at this point, but this +will in theory become the switching code if we add other bgc +codes, in alquimia this switches between CrunchFlow and PFloTran*/ + +void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) + { + + interface->Setup = &ecosim_setup; + interface->Shutdown = &ecosim_shutdown; + interface->Advance = &ecosim_advance; + + } /* end CreateAlquimiaInterface() */ diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index b5140afc4..c3ab29d99 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -109,6 +109,48 @@ extern "C" { BGCVectorInt aux_ints; /* [-] */ BGCVectorDouble aux_doubles; /* [-] */ } BGCAuxiliaryData; + + typedef struct { + /* read data files/structures, initialize memory, basis management + (includes reading database, swapping basis, etc.) */ + void (*Setup)( + const char* input_filename, + //bool hands_off, + //void* pft_engine_state, + BGCSizes* sizes); + + /* gracefully shutdown the engine, cleanup memory */ + void (*Shutdown)( + void* pft_engine_state); + + /* constrain processing for boundary/initial constraints. Called + once for each IC/BC. */ + /*void (*Setup)( + void* pft_engine_state, + BGCGeochemicalCondition* condition, + BGCProperties* props, + BGCState* state, + BGCAuxiliaryData* aux_data, + BGCEngineStatus* status);*/ + + /* take one (or more?) reaction steps in operator split mode */ + void (*Advance)( + void* pft_engine_state, + double delta_t, + BGCProperties* props, + BGCState* state, + BGCAuxiliaryData* aux_data); + + /* Access to user selected geochemical data for output, i.e. pH, + mineral SI, reaction rates */ + /*void (*GetAuxiliaryOutput)( + void* pft_engine_state, + BGCProperties* props, + BGCState* state, + BGCAuxiliaryData* aux_data, + BGCAuxiliaryOutputData* aux_out, + BGCEngineStatus* status);*/ + } BGCInterface; /* typedef struct { int error; From ae2f30c4c8fd055b03081d15da48d4ea05200b04 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 12:31:55 -0700 Subject: [PATCH 289/582] minor typo fix --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index b25df380b..0bb8e568d 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -203,7 +203,7 @@ void BGCEngine::FreeState(BGCProperties& props, } bool BGCEngine::Advance(const double delta_time, - const BGCProperties& props, + BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, int& num_iterations) From b4ca51ffe2a982abce8a369feeea1afd020f07a4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 12:37:16 -0700 Subject: [PATCH 290/582] forgot to change the header as well --- src/pks/ecosim_pk/BGCEngine.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 209bce6c5..44aa227e7 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -73,7 +73,7 @@ class BGCEngine { // returned by GetSpeciesNames. Returns true if the advance is successful, // false if it fails. bool Advance(const double delta_time, - const BGCProperties& props, + BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, int& num_iterations); From 42ddba531ee2aa5d0d632767d6831376c439690a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 12:41:57 -0700 Subject: [PATCH 291/582] changed the cmake file to include new source --- src/pks/ecosim_pk/data/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index cd99a852c..0f59e30a2 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -8,6 +8,7 @@ set(ats_ecosim_data_src_files BGC_constants.cc BGC_memory.cc + BGC_containers.cc ) set(ats_ecosim_data_inc_files BGC_constants.hh From aac702cb04b07087c59db91b765ff2bd9d58d432 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 12:53:53 -0700 Subject: [PATCH 292/582] bugfix --- src/pks/ecosim_pk/data/BGC_containers.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index 96fd16699..877eadc55 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -27,10 +27,10 @@ ** Authors: Benjamin Andre */ -#include "BGC_containers.h" +#include "BGC_containers.hh" /* Its kind of silly to have this as a separate code at this point, but this -will in theory become the switching code if we add other bgc +will in theory become the switching code if we add other bgc codes, in alquimia this switches between CrunchFlow and PFloTran*/ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) From f3c97504727b36c434cba70fd0903da682df4eef Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 14:05:24 -0700 Subject: [PATCH 293/582] just making the interface null to make it compile --- src/pks/ecosim_pk/data/BGC_containers.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index 877eadc55..cfc519645 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -36,8 +36,12 @@ codes, in alquimia this switches between CrunchFlow and PFloTran*/ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) { - interface->Setup = &ecosim_setup; - interface->Shutdown = &ecosim_shutdown; - interface->Advance = &ecosim_advance; + interface->Setup = NULL; + interface->Shutdown = NULL; + interface->Advance = NULL; + + //interface->Setup = &ecosim_setup; + //interface->Shutdown = &ecosim_shutdown; + //interface->Advance = &ecosim_advance; } /* end CreateAlquimiaInterface() */ From ea226ecdfaef659391ff8ba72efbfc0bc8be6970 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 14:49:48 -0700 Subject: [PATCH 294/582] saving the function calls differently --- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/data/BGC_containers.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 44aa227e7..aa097e5d7 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -85,7 +85,7 @@ class BGCEngine { void CopyBGCProperties(const BGCProperties* const source, BGCProperties* destination); - void CreateBGCInterface(const char* const engine_name, BGCInterface* interface); + void CreateBGCInterface(char* engine_name, BGCInterface* interface); private: diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index cfc519645..09e9044ec 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -33,7 +33,7 @@ will in theory become the switching code if we add other bgc codes, in alquimia this switches between CrunchFlow and PFloTran*/ -void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) +void CreateBGCInterface(char* engine_name, BGCInterface* interface) { interface->Setup = NULL; From 3b30900922bd939cdabaff88dcf58217fb35e9b7 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 15:10:02 -0700 Subject: [PATCH 295/582] minor engine bugfixes and changes to interface --- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/ecosim_interface.h | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index aa097e5d7..bf2fbbb5b 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -85,7 +85,7 @@ class BGCEngine { void CopyBGCProperties(const BGCProperties* const source, BGCProperties* destination); - void CreateBGCInterface(char* engine_name, BGCInterface* interface); + void CreateBGCInterface(const char* engine_name, BGCInterface* interface); private: diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index cee78acd7..081861f9c 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -27,17 +27,13 @@ ** Authors: Benjamin Andre */ -#ifndef ALQUIMIA_PFLOTRAN_INTERFACE_H_ -#define ALQUIMIA_PFLOTRAN_INTERFACE_H_ - /******************************************************************************* ** - ** C declarations of the pflotran alquimia interface + ** C declarations of the ecosim interface ** ******************************************************************************/ -#include "alquimia/alquimia_interface.h" -#include "alquimia/alquimia_containers.h" +#include "data/bgc_containers.h" #ifdef __cplusplus extern "C" { @@ -45,24 +41,17 @@ extern "C" { void ecosim_setup( const char* input_filename, - bool hands_off, - void* pft_engine_state, - BGCSizes* sizes, - BGCEngineFunctionality* functionality, - BGCEngineStatus* status + BGCSizes* sizes ); void ecosim_advance( void* pft_engine_state, double delta_t, - BGCProperties* material_properties, BGCState* state, BGCAuxiliaryData* aux_data, - BGCEngineStatus* status + BGCEngineStatus* status ); -#endif - #ifdef __cplusplus } #endif /* __cplusplus */ From 6805ea3e4504375cdaa8618a1d812e94c5a3dfbf Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 15:39:40 -0700 Subject: [PATCH 296/582] relocating CreateBGCInterface to the correct place --- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/data/BGC_containers.hh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index bf2fbbb5b..bba8b7f7b 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -85,7 +85,7 @@ class BGCEngine { void CopyBGCProperties(const BGCProperties* const source, BGCProperties* destination); - void CreateBGCInterface(const char* engine_name, BGCInterface* interface); + //void CreateBGCInterface(const char* engine_name, BGCInterface* interface); private: diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index c3ab29d99..0bd889f9b 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -151,6 +151,8 @@ extern "C" { BGCAuxiliaryOutputData* aux_out, BGCEngineStatus* status);*/ } BGCInterface; + + void CreateBGCInterface(const char* const engine_name, BGCInterface* interface); /* typedef struct { int error; From 73ef730a4338bb06419ea295e96c748d61a09a6c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 18 May 2023 16:02:13 -0700 Subject: [PATCH 297/582] trying this again --- src/pks/ecosim_pk/data/BGC_containers.cc | 2 +- src/pks/ecosim_pk/ecosim_wrappers.F90 | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index 09e9044ec..cfc519645 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -33,7 +33,7 @@ will in theory become the switching code if we add other bgc codes, in alquimia this switches between CrunchFlow and PFloTran*/ -void CreateBGCInterface(char* engine_name, BGCInterface* interface) +void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) { interface->Setup = NULL; diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 650f7d87c..cad123465 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -49,8 +49,11 @@ subroutine EcoSIM_Setup(input_filename, hands_off, & type (BGCEngineStatus), intent(out) :: status call ATS2EcoSIMData(filter_col,data_1d,var_1d,data_2d,var_2d,data_3d,var_3d) + call Init_EcoSIM(jz,js,ncol) + call EcoSIM2ATSData() + end subroutine EcoSIM_Setup ! **************************************************************************** ! @@ -78,6 +81,10 @@ subroutine EcoSIM_Advance( & type (BGCAuxiliaryData), intent(inout) :: aux_data type (BGCEngineStatus), intent(out) :: status + call ATS2EcoSIMData(filter_col,data_1d,var_1d,data_2d,var_2d,data_3d,var_3d) + call Run_EcoSIM_one_step() + call EcoSIM2ATSData() + end subroutine EcoSIM_Advance From 6a7438b7a0d600e34d7670a2cbe817a5bd93a9aa Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 23 May 2023 12:44:23 -0700 Subject: [PATCH 298/582] renaming some variables for consitency and and adding h_cond --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 43 ++++++++++++++--------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 180e7c749..0bac7c2b1 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -101,7 +101,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); //energy T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); - conductivity_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); + therm_cond_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); //Other cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); @@ -278,7 +278,7 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found temp key" << std::endl; S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(therm_cond_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); has_energy = true; } else { @@ -362,7 +362,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); if (has_gas) { @@ -377,7 +376,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { if (has_energy) { S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(conductivity_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(therm_cond_key_, Tags::DEFAULT).Update(*S_, name_); } //Update owned evaluators @@ -448,7 +447,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false))(0); S_->GetEvaluator("thermal_conductivity", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& conductivity = *(*S_->Get("thermal_conductivity", tag_next_) + const Epetra_MultiVector& thermal_conductivity = *(*S_->Get("thermal_conductivity", tag_next_) .ViewComponent("cell",false))(0); } @@ -634,6 +633,7 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -641,7 +641,7 @@ void EcoSIM::CopyToEcoSIM(int col, //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -650,6 +650,8 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_));\ auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + //For the concentration I do not want a vector but a matrix auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); @@ -663,9 +665,10 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(col,elevation,col_elev.ptr()); FieldToColumn_(col,water_content,col_wc.ptr()); FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); - FieldToColumn_(col,liquid_density,col_f_dens.ptr()); + FieldToColumn_(col,liquid_density,col_l_dens.ptr()); FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); + FieldToColumn_(col,hydraulic_conductivity,col_h_cond.ptr()); MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); @@ -703,10 +706,10 @@ void EcoSIM::CopyToEcoSIM(int col, if (has_energy) { const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& conductivity = *(*S_->Get(conductivity_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& thermal_conductivity = *(*S_->Get(therm_cond_key_, water_tag).ViewComponent("cell", false))(0); FieldToColumn_(col,temp, col_temp.ptr()); - FieldToColumn_(col,conductivity,col_cond.ptr()); + FieldToColumn_(col,thermal_conductivity,col_cond.ptr()); } // I think I need to loop over the column data and save it to the data @@ -724,9 +727,10 @@ void EcoSIM::CopyToEcoSIM(int col, } for (int i=0; i < ncells_per_col_; ++i) { - state.fluid_density.data[i] = (*col_f_dens)[i]; + state.liquid_density.data[i] = (*col_l_dens)[i]; state.porosity.data[i] = (*col_poro)[i]; state.water_content.data[i] = (*col_wc)[i]; + state.hydraulic_conductivity.data[i] = (*col_h_cond)[i]; props.liquid_saturation.data[i] = (*col_l_sat)[i]; //props.elevation.data[i] = (*col_elev)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; @@ -744,7 +748,7 @@ void EcoSIM::CopyToEcoSIM(int col, if (has_energy) { state.temperature.data[i] = (*col_temp)[i]; - props.conductivity.data[i] = (*col_cond)[i]; + props.thermal_conductivity.data[i] = (*col_cond)[i]; } } @@ -800,13 +804,15 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); + auto& hydraulic_conductivity = *(*S_->GetW(hydra_cond_key_, Amanzi::Tags::NEXT, hydra_cond_key_.ViewComponent("cell",false))(0); + auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_f_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix @@ -817,6 +823,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); @@ -847,7 +854,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, if (has_energy) { auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); - auto& conductivity = *(*S_->GetW(conductivity_key_, Amanzi::Tags::NEXT, conductivity_key_).ViewComponent("cell",false))(0); + auto& thermal_conductivity = *(*S_->GetW(therm_cond_key_, Amanzi::Tags::NEXT, therm_cond_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_temp)[i] = state.temperature.data[i]; @@ -855,17 +862,18 @@ void EcoSIM::CopyFromEcoSIM(const int col, } ColumnToField_(col,temp, col_temp.ptr()); - ColumnToField_(col,conductivity,col_cond.ptr()); + ColumnToField_(col,thermal_conductivity,col_cond.ptr()); } for (int i=0; i < ncells_per_col_; ++i) { - (*col_f_dens)[i] = state.fluid_density.data[i]; + (*col_l_dens)[i] = state.liquid_density.data[i]; (*col_poro)[i] = state.porosity.data[i]; (*col_wc)[i] = state.water_content.data[i]; (*col_l_sat)[i] = props.liquid_saturation.data[i]; //(*col_elev)[i] = props.elevation.data[i]; (*col_rel_perm)[i] = props.relative_permeability.data[i]; - (*col_cond)[i] = props.conductivity.data[i]; + (*col_cond)[i] = props.thermal_conductivity.data[i]; + (*col_h_cond)[i] = state.hydraulic_conductivity.data[i]; (*col_vol)[i] = props.volume.data[i]; } @@ -906,9 +914,10 @@ void EcoSIM::CopyFromEcoSIM(const int col, //ColumnToField_(col,elevation,col_elev.ptr()); ColumnToField_(col,water_content,col_wc.ptr()); ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); - ColumnToField_(col,liquid_density,col_f_dens.ptr()); + ColumnToField_(col,liquid_density,col_l_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); + ColumnToField_(col,hydraulic_conductivity,col_h_cond.ptr()); MatrixColumnToField_(col, tcc, col_tcc.ptr()); } diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 61e1489e2..ddd0ca0a8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -182,7 +182,7 @@ class EcoSIM : public PK_Physical { Key gas_den_key_test_; Key rock_den_key_; Key T_key_; - Key conductivity_key_; + Key therm_cond_key_; Key cv_key_; Key min_vol_frac_key_; Key ecosim_aux_data_key_; From 0daa69698430eddfd1f66b25b0ca8bb4228d5bcd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 23 May 2023 14:52:15 -0700 Subject: [PATCH 299/582] moved the F90 containers code to EcoSIM --- src/pks/ecosim_pk/data/BGC_containers.F90 | 133 ---------------------- 1 file changed, 133 deletions(-) delete mode 100644 src/pks/ecosim_pk/data/BGC_containers.F90 diff --git a/src/pks/ecosim_pk/data/BGC_containers.F90 b/src/pks/ecosim_pk/data/BGC_containers.F90 deleted file mode 100644 index 9308ce759..000000000 --- a/src/pks/ecosim_pk/data/BGC_containers.F90 +++ /dev/null @@ -1,133 +0,0 @@ - -! -! Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -! through Lawrence Berkeley National Laboratory (subject to receipt of any -! required approvals from the U.S. Dept. of Energy). All rights reserved. -! -! Alquimia is available under a BSD license. See LICENSE.txt for more -! information. -! -! If you have questions about your rights to use or distribute this software, -! please contact Berkeley Lab's Technology Transfer and Intellectual Property -! Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -! -! NOTICE. This software was developed under funding from the U.S. Department -! of Energy. As such, the U.S. Government has been granted for itself and -! others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -! license in the Software to reproduce, prepare derivative works, and perform -! publicly and display publicly. Beginning five (5) years after the date -! permission to assert copyright is obtained from the U.S. Department of Energy, -! and subject to any subsequent five (5) year renewals, the U.S. Government is -! granted for itself and others acting on its behalf a paid-up, nonexclusive, -! irrevocable, worldwide license in the Software to reproduce, prepare derivative -! works, distribute copies to the public, perform publicly and display publicly, -! and to permit others to do so. -! -! Authors: Benjamin Andre -! - -! **************************************************************************** ! -! -! Alquimia Containers module -! -! Author: Benjamin Andre -! -! WARNINGS: -! -! * The alquimia data structures defined in the this are dictated by -! the alquimia API! Do NOT change them unless you make -! corresponding changes to the c containers (and doc). -! -! * The order of the data members matters! If num_primary is the -! first member and num_minerals is the third, then they must be in -! those positions on both the c and fortran side of the interface! -! -! * The names of the containers and their members should be the same -! for both c and fortran. The language interface doesn't require -! this, but it makes it easier for the reader to understand what is -! going on. -! -! **************************************************************************** ! - -module BGCContainers_module - - use, intrinsic :: iso_c_binding - - implicit none - - integer (c_int), parameter :: kBGCMaxStringLength = 512 - integer (c_int), parameter :: kBGCMaxWordLength = 32 - - integer (c_int), parameter :: kBGCNoError = 0 - integer (c_int), parameter :: kBGCErrorInvalidEngine = 1 - integer (c_int), parameter :: kBGCErrorUnknownConstraintName = 2 - integer (c_int), parameter :: kBGCErrorUnsupportedFunctionality = 3 - integer (c_int), parameter :: kBGCErrorEngineIntegrity = 4577 - - character (13), parameter :: kBGCStringTotalAqueous = 'total_aqueous' - character (12), parameter :: kBGCStringTotalSorbed = 'total_sorbed' - character (25), parameter :: kBGCStringTotalAqueousPlusSorbed = 'total_aqueous_plus_sorbed' - character (4), parameter :: kBGCStringFree = 'free' - character (2), parameter :: kBGCStringPH = 'pH' - character (7), parameter :: kBGCStringMineral = 'mineral' - character (3), parameter :: kBGCStringGas = 'gas' - character (6), parameter :: kBGCStringCharge = 'charge' - - type, public, bind(c) :: BGCVectorDouble - integer (c_int) :: size - integer (c_int) :: capacity - type (c_ptr) :: data - end type BGCVectorDouble - - type, public, bind(c) :: BGCVectorInt - integer (c_int) :: size - integer (c_int) :: capacity - type (c_ptr) :: data - end type BGCVectorInt - - type, public, bind(c) :: BGCVectorString - integer (c_int) :: size - integer (c_int) :: capacity - type (c_ptr) :: data - end type BGCVectorString - - type, public, bind(c) :: BGCSizes - integer (c_int) :: num_primary - integer (c_int) :: num_sorbed - integer (c_int) :: num_minerals - integer (c_int) :: num_aqueous_complexes - integer (c_int) :: num_aqueous_kinetics - integer (c_int) :: num_surface_sites - integer (c_int) :: num_ion_exchange_sites - integer (c_int) :: num_isotherm_species - integer (c_int) :: num_aux_integers - integer (c_int) :: num_aux_doubles - end type BGCSizes - - type, public, bind(c) :: BGCState - ! I think I have to write the data as vector doubles - type (BGCVectorDouble) :: fluid_density - type (BGCVectorDouble) :: gas_density - type (BGCVectorDouble) :: ice_density - type (BGCVectorDouble) :: porosity - type (BGCVectorDouble) :: water_content - type (BGCVectorDouble) :: temperature - type (BGCVectorDouble) :: total_mobile - end type BGCState - - type, public, bind(c) :: BGCProperties - type (BGCVectorDouble) :: liquid_saturation - type (BGCVectorDouble) :: gas_saturation - type (BGCVectorDouble) :: ice_saturation - type (BGCVectorDouble) :: elevation - type (BGCVectorDouble) :: relative_permeability - type (BGCVectorDouble) :: conductivity - type (BGCVectorDouble) :: volume - end type BGCProperties - - type, public, bind(c) :: BGCAuxiliaryData - type (BGCVectorInt) :: aux_ints - type (BGCVectorDouble) :: aux_doubles - end type BGCAuxiliaryData - -end module BGCContainers_module From e400030d507111a19daf886897678cae4018b77e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 24 May 2023 11:14:03 -0700 Subject: [PATCH 300/582] modifications to the ecosim wrapper of the interface --- src/pks/ecosim_pk/CMakeLists.txt | 2 ++ src/pks/ecosim_pk/ecosim_interface.h | 4 ++-- src/pks/ecosim_pk/ecosim_wrappers.F90 | 14 ++++---------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 836cb22b2..87ca5eee8 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -16,11 +16,13 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/h set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc + ecosim_wrappers.F90 ) set(ats_ecosim_inc_files EcoSIM_ATS_interface.hh BGCEngine.hh + ecosim_interface.h ) set(ats_ecosim_link_libs diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index 081861f9c..848136278 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -33,7 +33,7 @@ ** ******************************************************************************/ -#include "data/bgc_containers.h" +#include "data/BGC_containers.hh" #ifdef __cplusplus extern "C" { @@ -47,9 +47,9 @@ void ecosim_setup( void ecosim_advance( void* pft_engine_state, double delta_t, + BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, - BGCEngineStatus* status ); #ifdef __cplusplus diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index cad123465..038d37f19 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,23 +30,18 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_Setup(input_filename, hands_off, & - pft_engine_state, sizes, functionality, status) bind(C) +subroutine EcoSIM_Setup(input_filename, sizes) bind(C) use, intrinsic :: iso_c_binding use BGCContainers_module - use ATSCPLMod, only : ATS2EcoSIMData, Init_EcoSIM + use ATSCPLMod implicit none ! function parameters character(kind=c_char), dimension(*), intent(in) :: input_filename - logical (c_bool), value, intent(in) :: hands_off - type (c_ptr), intent(out) :: pft_engine_state type (BGCSizes), intent(out) :: sizes - type (BGCEngineFunctionality), intent(out) :: functionality - type (BGCEngineStatus), intent(out) :: status call ATS2EcoSIMData(filter_col,data_1d,var_1d,data_2d,var_2d,data_3d,var_3d) @@ -63,8 +58,7 @@ subroutine EcoSIM_Advance( & delta_t, & properties, & state, & - aux_data, & - status) bind(C) + aux_data) bind(C) use, intrinsic :: iso_c_binding @@ -86,5 +80,5 @@ subroutine EcoSIM_Advance( & call Run_EcoSIM_one_step() call EcoSIM2ATSData() - + end subroutine EcoSIM_Advance From a50584a9f50f8d2e4bfcba25f9357e1b80f66fd3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 24 May 2023 14:16:41 -0700 Subject: [PATCH 301/582] defining the new variables in containers --- src/pks/ecosim_pk/data/BGC_containers.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 0bd889f9b..001f22180 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -85,13 +85,14 @@ extern "C" { } BGCSizes; typedef struct { - BGCVectorDouble fluid_density; + BGCVectorDouble liquid_density; BGCVectorDouble gas_density; BGCVectorDouble ice_density; BGCVectorDouble porosity; BGCVectorDouble water_content; BGCVectorDouble temperature; BGCVectorDouble total_mobile; + BGCVectorDouble hydraulic_conductivity; BGCMatrixDouble total_component_concentration; } BGCState; @@ -101,7 +102,7 @@ extern "C" { BGCVectorDouble ice_saturation; BGCVectorDouble elevation; BGCVectorDouble relative_permeability; - BGCVectorDouble conductivity; + BGCVectorDouble thermal_conductivity; BGCVectorDouble volume; } BGCProperties; From 1654283b7e20f36962f69c37c0f370bc72b8c2b5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 24 May 2023 14:21:48 -0700 Subject: [PATCH 302/582] changed variables in memory files --- src/pks/ecosim_pk/data/BGC_memory.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 3940f6690..699190ef8 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -255,13 +255,13 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCState(BGCSizes* sizes, BGCState* state, int ncells_per_col_, int num_components) { sizes->ncells_per_col_ = ncells_per_col_; - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->fluid_density)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->liquid_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->gas_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->porosity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); - + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->hydraulic_conductivity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_,sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); @@ -269,12 +269,13 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, void FreeBGCState(BGCState* state) { if (state != NULL) { - FreeBGCVectorDouble(&(state->fluid_density)); + FreeBGCVectorDouble(&(state->liquid_density)); FreeBGCVectorDouble(&(state->gas_density)); FreeBGCVectorDouble(&(state->ice_density)); FreeBGCVectorDouble(&(state->porosity)); FreeBGCVectorDouble(&(state->water_content)); FreeBGCVectorDouble(&(state->temperature)); + FreeBGCVectorDouble(&(state->hydraulic_conductivity)); FreeBGCMatrixDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ @@ -317,7 +318,7 @@ void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->ice_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->elevation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->conductivity)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->thermal_conductivity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); } /* end AllocateAlquimiaProperties() */ @@ -328,7 +329,7 @@ void FreeBGCProperties(BGCProperties* props) { FreeBGCVectorDouble(&(props->ice_saturation)); FreeBGCVectorDouble(&(props->elevation)); FreeBGCVectorDouble(&(props->relative_permeability)); - FreeBGCVectorDouble(&(props->conductivity)); + FreeBGCVectorDouble(&(props->thermal_conductivity)); FreeBGCVectorDouble(&(props->volume)); } } /* end FreeAlquimiaProperties() */ From 6f076a69b3802cd7c0513cc90a1bedd22351a6bd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 24 May 2023 14:32:41 -0700 Subject: [PATCH 303/582] additional fixes --- src/pks/ecosim_pk/BGCEngine.cc | 5 +++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 0bb8e568d..ee2608301 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -34,12 +34,13 @@ namespace { //Here are the major function that the engine will need void CopyBGCState(BGCState* dest, BGCState* src) { - memcpy(dest->fluid_density.data, src->fluid_density.data, sizeof(double) * src->fluid_density.size); + memcpy(dest->liquid_density.data, src->liquid_density.data, sizeof(double) * src->liquid_density.size); memcpy(dest->gas_density.data, src->gas_density.data, sizeof(double) * src->gas_density.size); memcpy(dest->ice_density.data, src->ice_density.data, sizeof(double) * src->ice_density.size); memcpy(dest->porosity.data, src->porosity.data, sizeof(double) * src->porosity.size); memcpy(dest->water_content.data, src->water_content.data, sizeof(double) * src->water_content.size); memcpy(dest->temperature.data, src->temperature.data, sizeof(double) * src->temperature.size); + memcpy(dest->hydraulic_conductivity.data, src->hydraulic_conductivity.data, sizeof(double) * src->hydraulic_conductivity.size); //memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); //dest->water_density = src->water_density; @@ -55,7 +56,7 @@ void CopyBGCProperties(BGCProperties* dest, BGCProperties* src) memcpy(dest->ice_saturation.data, src->ice_saturation.data, sizeof(double) * src->ice_saturation.size); memcpy(dest->elevation.data, src->elevation.data, sizeof(double) * src->elevation.size); memcpy(dest->relative_permeability.data, src->relative_permeability.data, sizeof(double) * src->relative_permeability.size); - memcpy(dest->conductivity.data, src->conductivity.data, sizeof(double) * src->conductivity.size); + memcpy(dest->thermal_conductivity.data, src->thermal_conductivity.data, sizeof(double) * src->thermal_conductivity.size); memcpy(dest->volume.data, src->volume.data, sizeof(double) * src->volume.size); } diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0bac7c2b1..0e3e30dc4 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -804,7 +804,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); - auto& hydraulic_conductivity = *(*S_->GetW(hydra_cond_key_, Amanzi::Tags::NEXT, hydra_cond_key_.ViewComponent("cell",false))(0); + auto& hydraulic_conductivity = *(*S_->GetW(hydra_cond_key_, Amanzi::Tags::NEXT, hydra_cond_key_).ViewComponent("cell",false))(0); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -858,7 +858,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, for (int i=0; i < ncells_per_col_; ++i) { (*col_temp)[i] = state.temperature.data[i]; - (*col_cond)[i] = props.conductivity.data[i]; + (*col_cond)[i] = props.thermal_conductivity.data[i]; } ColumnToField_(col,temp, col_temp.ptr()); From 51518d1828ec82c30ae5e7a3c2b4506338317364 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 24 May 2023 17:11:49 -0700 Subject: [PATCH 304/582] changes to cmake files to link ecosim --- src/executables/CMakeLists.txt | 1 + src/pks/ecosim_pk/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/executables/CMakeLists.txt b/src/executables/CMakeLists.txt index a548c0e78..2b6073454 100644 --- a/src/executables/CMakeLists.txt +++ b/src/executables/CMakeLists.txt @@ -144,6 +144,7 @@ set(tpl_link_libs ${HYPRE_LIBRARIES} ${HDF5_LIBRARIES} ${CLM_LIBRARIES} + ${ECOSIM_LIBRARIES} ) add_amanzi_library(ats_executable diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 87ca5eee8..ace647121 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -8,6 +8,7 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/data) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/bulk_density) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity) +include_directories(${ECOSIM_INCLUDE_DIRS}) # ATS EcoSIM pk # For adding F90 files add the F90 file to the ecosim source files and @@ -28,6 +29,7 @@ set(ats_ecosim_inc_files set(ats_ecosim_link_libs ${Teuchos_LIBRARIES} ${Epetra_LIBRARIES} + ${ECOSIM_LIBRARIES} error_handling atk mesh From 42dc9216f8080746718dc9e43de65504c240d9f6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Sun, 28 May 2023 17:45:11 -0700 Subject: [PATCH 305/582] changes to wrapper --- src/pks/ecosim_pk/ecosim_wrappers.F90 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 038d37f19..483306bbd 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -35,15 +35,19 @@ subroutine EcoSIM_Setup(input_filename, sizes) bind(C) use, intrinsic :: iso_c_binding use BGCContainers_module - use ATSCPLMod + use ATSCPLMod, only : ATS2EcoSIMData, Init_EcoSIM, EcoSIM2ATSData implicit none ! function parameters character(kind=c_char), dimension(*), intent(in) :: input_filename type (BGCSizes), intent(out) :: sizes + type (BGCState), intent(in) :: state + type (BGCAuxiliaryData), intent(in) :: aux_data + type (BGCProperties), intent(in) :: prop + integer :: ncol - call ATS2EcoSIMData(filter_col,data_1d,var_1d,data_2d,var_2d,data_3d,var_3d) + call ATS2EcoSIMData(ncol, state, aux_data, prop) call Init_EcoSIM(jz,js,ncol) @@ -61,9 +65,10 @@ subroutine EcoSIM_Advance( & aux_data) bind(C) use, intrinsic :: iso_c_binding + use BGCContainers_module use BGCContainers_module - use ATSCPLMod, only : Run_EcoSIM_one_step + use ATSCPLMod, only : Run_EcoSIM_one_step, ATS2EcoSIMData, EcoSIM2ATSData implicit none From 506e9f69dc568e55e0d34ecfefc0d126e805b9e1 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 31 May 2023 15:04:23 -0700 Subject: [PATCH 306/582] changes to paths and code --- src/pks/ecosim_pk/CMakeLists.txt | 10 +++++++++- src/pks/ecosim_pk/ecosim_wrappers.F90 | 15 +++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index ace647121..3e45dbfab 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -8,8 +8,12 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/data) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/bulk_density) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity) +include_directories(${TPL_INSTALL_PREFIX}/ecosim/f90src/ATSUtils/) + include_directories(${ECOSIM_INCLUDE_DIRS}) +message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") + # ATS EcoSIM pk # For adding F90 files add the F90 file to the ecosim source files and # inc files. The inc file also needs a header @@ -18,7 +22,11 @@ set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 - ) + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + ) set(ats_ecosim_inc_files EcoSIM_ATS_interface.hh diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 483306bbd..8fa0c74db 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,7 +30,7 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_Setup(input_filename, sizes) bind(C) +subroutine EcoSIM_Setup(input_filename, sizes, prop, state, aux_data) bind(C) use, intrinsic :: iso_c_binding @@ -45,7 +45,7 @@ subroutine EcoSIM_Setup(input_filename, sizes) bind(C) type (BGCState), intent(in) :: state type (BGCAuxiliaryData), intent(in) :: aux_data type (BGCProperties), intent(in) :: prop - integer :: ncol + integer :: ncol, jz, js call ATS2EcoSIMData(ncol, state, aux_data, prop) @@ -60,13 +60,11 @@ end subroutine EcoSIM_Setup subroutine EcoSIM_Advance( & pft_engine_state, & delta_t, & - properties, & + prop, & state, & aux_data) bind(C) use, intrinsic :: iso_c_binding - use BGCContainers_module - use BGCContainers_module use ATSCPLMod, only : Run_EcoSIM_one_step, ATS2EcoSIMData, EcoSIM2ATSData @@ -75,12 +73,13 @@ subroutine EcoSIM_Advance( & ! function parameters type (c_ptr), intent(inout) :: pft_engine_state real (c_double), value, intent(in) :: delta_t - type (BGCProperties), intent(in) :: properties + type (BGCProperties), intent(in) :: prop type (BGCState), intent(inout) :: state type (BGCAuxiliaryData), intent(inout) :: aux_data - type (BGCEngineStatus), intent(out) :: status + !type (BGCEngineStatus), intent(out) :: status + integer :: ncol - call ATS2EcoSIMData(filter_col,data_1d,var_1d,data_2d,var_2d,data_3d,var_3d) + call ATS2EcoSIMData(ncol, state, aux_data, prop) call Run_EcoSIM_one_step() From e303a89ef7d01a44c032f6484afaa7fb7feeda36 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 31 May 2023 15:54:44 -0700 Subject: [PATCH 307/582] added some testing to make sure things are running --- src/pks/ecosim_pk/BGCEngine.cc | 17 +++++++++------ src/pks/ecosim_pk/BGCEngine.hh | 2 ++ src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 25 ++--------------------- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index ee2608301..52cdf3298 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -84,10 +84,13 @@ BGCEngine::BGCEngine(const std::string& engineName, msg << "BGCEngine: Unsupported bgc engine: '" << bgc_engine_name_ << "'\n"; msg << " Only option for now is 'EcoSIM'.\n"; Exceptions::amanzi_throw(msg); - + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Creating the BGC Engine interface" << std::endl; CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_); + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Running bgc engine setup" << std::endl; bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_); } @@ -179,12 +182,13 @@ void BGCEngine::InitState(BGCProperties& props, int ncells_per_col_, int num_components) { - std::cout << "Allocating prop" << std::endl; - std::cout << "size: " << ncells_per_col_ << std::endl; + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Allocating Properties" << std::endl; + *vo_->os() << "Size of columns: " << ncells_per_col_ << std::endl; AllocateBGCProperties(&sizes_, &props, ncells_per_col_); - std::cout << "Allocating state" << std::endl; + *vo_->os() << "Allocating State" << std::endl; AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components); - std::cout << "Allocating aux" << std::endl; + *vo_->os() << "Allocating aux" << std::endl; AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); @@ -209,7 +213,8 @@ bool BGCEngine::Advance(const double delta_time, BGCAuxiliaryData& aux_data, int& num_iterations) { - + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Running BGC Engine Advance" << std::endl; // Advance the chemical reaction all operator-split-like. bgc_.Advance(&engine_state_, delta_time, diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index bba8b7f7b..3075b2781 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -23,6 +23,8 @@ #include "BGC_memory.hh" #include "BGC_containers.hh" #include "BGC_constants.hh" + +#include "VerboseObject.hh" /*#include "alquimia/alquimia_util.h" #include "alquimia/alquimia_constants.h" #include "alquimia/alquimia_containers.h" diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0e3e30dc4..1b163c3cf 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -300,9 +300,9 @@ void EcoSIM::Initialize() { } //Initialize owned evaluators - *vo_->os() << "Getting hydraulic conductivity" << std::endl; + //*vo_->os() << "Getting hydraulic conductivity" << std::endl; S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); - *vo_->os() << "recording to hydraulic" << std::endl; + //*vo_->os() << "recording to hydraulic" << std::endl; S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); //S_->GetW(bulk_dens_key_, tag_next_, name_).PutScalar(1.0); @@ -507,18 +507,8 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiV int n_comp = m_arr.NumVectors(); auto& col_iter = mesh_->cells_of_column(col); - *vo_->os() << "number of comp: "<< n_comp << std::endl; - *vo_->os() << "number of cells: "<< col_iter.size() << std::endl; - - *vo_->os() << "Matrix rows: "<< m_arr.GlobalLength() << std::endl; - *vo_->os() << "Matrix columns: "<< m_arr.NumVectors() << std::endl; for (int j=0; j!=n_comp; ++j){ - *vo_->os() << "component: "<< j << std::endl; for (std::size_t i=0; i!=col_iter.size(); ++i) { - *vo_->os() << "cell: "<< i << std::endl; - *vo_->os() << "col arr: "<< (*col_arr)(i,j) << std::endl; - *vo_->os() << "m_arr: "<< m_arr[j][col_iter[i]] << std::endl; - //*vo_->os() << "m_arr: "<< (*m_arr)(col_iter[i],j) << std::endl; (*col_arr)(i,j) = m_arr[j][col_iter[i]]; } } @@ -549,19 +539,8 @@ void EcoSIM::MatrixColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector& int n_comp = m_arr.NumVectors(); auto& col_iter = mesh_->cells_of_column(col); - *vo_->os() << "number of comp: "<< n_comp << std::endl; - *vo_->os() << "number of cells: "<< col_iter.size() << std::endl; - - *vo_->os() << "Matrix rows: "<< m_arr.GlobalLength() << std::endl; - *vo_->os() << "Matrix columns: "<< m_arr.NumVectors() << std::endl; - for (int j=0; j!=n_comp; ++j){ - *vo_->os() << "component: "<< j << std::endl; for (std::size_t i=0; i!=col_iter.size(); ++i) { - *vo_->os() << "cell: "<< i << std::endl; - *vo_->os() << "col arr: "<< (*col_arr)(i,j) << std::endl; - *vo_->os() << "m_arr: "<< m_arr[j][col_iter[i]] << std::endl; - m_arr[j][col_iter[i]] = (*col_arr)(i,j); } } From a59302d02b461c39ca4c3b00c2a02040691a2102 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 31 May 2023 17:53:19 -0700 Subject: [PATCH 308/582] defining vo --- src/pks/ecosim_pk/BGCEngine.cc | 1 - src/pks/ecosim_pk/BGCEngine.hh | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 52cdf3298..abc885b70 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -89,7 +89,6 @@ BGCEngine::BGCEngine(const std::string& engineName, CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_); - Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "Running bgc engine setup" << std::endl; bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_); } diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 3075b2781..69fc4e68f 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -106,6 +106,7 @@ class BGCEngine { AlquimiaEngineStatus chem_status_; AlquimiaProblemMetaData chem_metadata_;*/ + Teuchos::RCP vo_; // Back-end engine name and input file. std::string bgc_engine_name_; std::string bgc_engine_inputfile_; From a9c9e794b7855d3ed662593f0b5bef8b7989a23a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 31 May 2023 21:39:26 -0700 Subject: [PATCH 309/582] getting rid of vo --- src/pks/ecosim_pk/BGCEngine.cc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index abc885b70..881f265f0 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -81,15 +81,14 @@ BGCEngine::BGCEngine(const std::string& engineName, if (bgc_engine_name_ != "EcoSIM") { - msg << "BGCEngine: Unsupported bgc engine: '" << bgc_engine_name_ << "'\n"; - msg << " Only option for now is 'EcoSIM'.\n"; + std::cout << "BGCEngine: Unsupported bgc engine: '" << bgc_engine_name_ << std::endl; + std::cout << " Only option for now is 'EcoSIM'" << std::endl; Exceptions::amanzi_throw(msg); - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Creating the BGC Engine interface" << std::endl; + std::cout << "Creating the BGC Engine interface" << std::endl; CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_); - *vo_->os() << "Running bgc engine setup" << std::endl; + std::cout << "Running bgc engine setup" << std::endl; bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_); } @@ -181,13 +180,12 @@ void BGCEngine::InitState(BGCProperties& props, int ncells_per_col_, int num_components) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Allocating Properties" << std::endl; - *vo_->os() << "Size of columns: " << ncells_per_col_ << std::endl; + std::cout << "Allocating Properties" << std::endl; + std::cout << "Size of columns: " << ncells_per_col_ << std::endl; AllocateBGCProperties(&sizes_, &props, ncells_per_col_); - *vo_->os() << "Allocating State" << std::endl; + std::cout << "Allocating State" << std::endl; AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components); - *vo_->os() << "Allocating aux" << std::endl; + std::cout << "Allocating aux" << std::endl; AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); @@ -212,8 +210,7 @@ bool BGCEngine::Advance(const double delta_time, BGCAuxiliaryData& aux_data, int& num_iterations) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Running BGC Engine Advance" << std::endl; + std::cout << "Running BGC Engine Advance" << std::endl; // Advance the chemical reaction all operator-split-like. bgc_.Advance(&engine_state_, delta_time, From 5584018dab5d0f439e39417ecc30a34c39f19bfc Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 31 May 2023 22:08:21 -0700 Subject: [PATCH 310/582] actually linking the engine in. --- src/pks/ecosim_pk/BGCEngine.cc | 3 +-- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 21 ++++----------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 881f265f0..9ab14220a 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -212,8 +212,7 @@ bool BGCEngine::Advance(const double delta_time, { std::cout << "Running BGC Engine Advance" << std::endl; // Advance the chemical reaction all operator-split-like. - bgc_.Advance(&engine_state_, - delta_time, + bgc_.Advance(delta_time, &props, &state, &aux_data); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 1b163c3cf..6ae2d3692 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -908,10 +908,7 @@ int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - /* ******************************************************************* - * Here is where we will put the call to the BGC engine's set ICs for - * EcoSIM function - ******************************************************************* */ + bgc_engine_->BGCEngine(engineName, inputFile) CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); @@ -935,23 +932,13 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) // should use the same tag as transport. See #673 CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - int num_iterations = 0; + int num_iterations = 1; /***************************************************************** ADVANCE CALL GOES HERE - ****************************************************************** + *******************************************************************/ - if (ecosim_mat_props_.saturation > saturation_tolerance_) { - bool success = bgc_engine_->Advance(dt, bgc_props_, bgc_state_, + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_aux_data_, num_iterations); - if (not success) { - if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "no convergence in cell: " << mesh_->cell_map(false).GID(cell) << std::endl; - } - return -1; - } - } - */ // Move the information back into Amanzi's state, updating the given total concentration vector. CopyEcoSIMStateToAmanzi(col, From 51bea4d94160bcd35193f2719d93515c7eb50d90 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 11:47:23 -0700 Subject: [PATCH 311/582] many fixes to the linking to actually transfer the data correctly --- src/pks/ecosim_pk/BGCEngine.cc | 25 +++++++++++++++++++++-- src/pks/ecosim_pk/BGCEngine.hh | 6 ++++++ src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 +++- src/pks/ecosim_pk/data/BGC_containers.cc | 12 +++++------ src/pks/ecosim_pk/ecosim_interface.h | 9 +++++--- src/pks/ecosim_pk/ecosim_wrappers.F90 | 10 ++++++--- 6 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 9ab14220a..d25958900 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -88,8 +88,8 @@ BGCEngine::BGCEngine(const std::string& engineName, CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_); - std::cout << "Running bgc engine setup" << std::endl; - bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_); + //std::cout << "Running bgc engine setup" << std::endl; + //bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_); } // All alquimia function calls require a status object. @@ -204,6 +204,27 @@ void BGCEngine::FreeState(BGCProperties& props, //FreeAlquimiaAuxiliaryOutputData(&aux_output); } +bool BGCEngine::Setup(const double delta_time, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data, + int& num_iterations) +{ + std::cout << "Running BGC Engine Setup" << std::endl; + // Advance the chemical reaction all operator-split-like. + bgc_.Advance(delta_time, + &props, + &state, + &aux_data); + + //This is alquimia's advance function which we won't need + //calling EcoSIM advance driver + + /************************* + EcoSIMAdvance(); + *************************/ +} + bool BGCEngine::Advance(const double delta_time, BGCProperties& props, BGCState& state, diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 69fc4e68f..7918e775e 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -70,6 +70,12 @@ class BGCEngine { AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ + bool Setup(const double delta_time, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data, + int& num_iterations); + // Advances the species represented by the given array of concentrations, replacing old values // with new values. The order of the concentrations in the array matches that of the species names // returned by GetSpeciesNames. Returns true if the advance is successful, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 6ae2d3692..01bac8dc4 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -908,8 +908,10 @@ int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - bgc_engine_->BGCEngine(engineName, inputFile) + int num_iterations = 1; + bgc_engine_->Setup(dt, bgc_props_, bgc_state_, + bgc_aux_data_, num_iterations); CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); // ETC: hacking to get consistent solution -- if there is no water diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index cfc519645..ee069705b 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -36,12 +36,12 @@ codes, in alquimia this switches between CrunchFlow and PFloTran*/ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) { - interface->Setup = NULL; - interface->Shutdown = NULL; - interface->Advance = NULL; + //interface->Setup = NULL; + //interface->Shutdown = NULL; + //interface->Advance = NULL; - //interface->Setup = &ecosim_setup; - //interface->Shutdown = &ecosim_shutdown; - //interface->Advance = &ecosim_advance; + interface->Setup = &ecosim_setup; + interface->Shutdown = &ecosim_shutdown; + interface->Advance = &ecosim_advance; } /* end CreateAlquimiaInterface() */ diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index 848136278..13caa2f85 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -40,16 +40,19 @@ extern "C" { #endif /* __cplusplus */ void ecosim_setup( - const char* input_filename, - BGCSizes* sizes + double delta_t, + BGCProperties* properties, + BGCState* state, + BGCAuxiliaryData* aux_data, + int num_iterations ); void ecosim_advance( - void* pft_engine_state, double delta_t, BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, + int num_iterations ); #ifdef __cplusplus diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 8fa0c74db..be327d204 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,7 +30,8 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_Setup(input_filename, sizes, prop, state, aux_data) bind(C) +subroutine EcoSIM_Setup(delta_t, props, state, aux_data, & + num_iterations) bind(C) use, intrinsic :: iso_c_binding @@ -46,6 +47,8 @@ subroutine EcoSIM_Setup(input_filename, sizes, prop, state, aux_data) bind(C) type (BGCAuxiliaryData), intent(in) :: aux_data type (BGCProperties), intent(in) :: prop integer :: ncol, jz, js + real (c_double), value, intent(in) :: delta_t + integer, intent(in) :: num_iterations call ATS2EcoSIMData(ncol, state, aux_data, prop) @@ -58,11 +61,11 @@ end subroutine EcoSIM_Setup ! **************************************************************************** ! subroutine EcoSIM_Advance( & - pft_engine_state, & delta_t, & prop, & state, & - aux_data) bind(C) + aux_data, & + num_iterations) bind(C) use, intrinsic :: iso_c_binding use BGCContainers_module @@ -78,6 +81,7 @@ subroutine EcoSIM_Advance( & type (BGCAuxiliaryData), intent(inout) :: aux_data !type (BGCEngineStatus), intent(out) :: status integer :: ncol + integer, intent(in) :: num_iterations call ATS2EcoSIMData(ncol, state, aux_data, prop) From f5ed3c525ae8eb0de18276de9321bff1a716beae Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 12:52:35 -0700 Subject: [PATCH 312/582] added the wrapper header --- src/pks/ecosim_pk/data/BGC_containers.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index ee069705b..892e28f40 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -29,6 +29,8 @@ #include "BGC_containers.hh" +#include "ecosim_interface.h" + /* Its kind of silly to have this as a separate code at this point, but this will in theory become the switching code if we add other bgc codes, in alquimia this switches between CrunchFlow and PFloTran*/ From f452928497309e1492719b298b3f80ff63e33eb9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 12:56:58 -0700 Subject: [PATCH 313/582] uh? --- src/pks/ecosim_pk/data/BGC_containers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index 892e28f40..395f8fd44 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -29,7 +29,7 @@ #include "BGC_containers.hh" -#include "ecosim_interface.h" +#include "../ecosim_interface.h" /* Its kind of silly to have this as a separate code at this point, but this will in theory become the switching code if we add other bgc From e69fd0a72b6db678d347bfa075c4ed9e094d2dfe Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 14:33:48 -0700 Subject: [PATCH 314/582] modifying the function call in containers --- src/pks/ecosim_pk/data/BGC_containers.hh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 001f22180..4f3618d56 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -115,10 +115,11 @@ extern "C" { /* read data files/structures, initialize memory, basis management (includes reading database, swapping basis, etc.) */ void (*Setup)( - const char* input_filename, - //bool hands_off, - //void* pft_engine_state, - BGCSizes* sizes); + double delta_t, + BGCProperties* properties, + BGCState* state, + BGCAuxiliaryData* aux_data, + int num_iterations); /* gracefully shutdown the engine, cleanup memory */ void (*Shutdown)( @@ -136,11 +137,11 @@ extern "C" { /* take one (or more?) reaction steps in operator split mode */ void (*Advance)( - void* pft_engine_state, - double delta_t, - BGCProperties* props, - BGCState* state, - BGCAuxiliaryData* aux_data); + double delta_t, + BGCProperties* properties, + BGCState* state, + BGCAuxiliaryData* aux_data, + int num_iterations); /* Access to user selected geochemical data for output, i.e. pH, mineral SI, reaction rates */ From 5549280b9ecee10fc95e930acf1ad9700b6f572f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 15:00:40 -0700 Subject: [PATCH 315/582] added calls for shutdown --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- src/pks/ecosim_pk/data/BGC_containers.hh | 3 +-- src/pks/ecosim_pk/ecosim_interface.h | 2 ++ src/pks/ecosim_pk/ecosim_wrappers.F90 | 24 ++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index d25958900..6d0db76b7 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -148,7 +148,7 @@ BGCEngine::BGCEngine(const std::string& engineName, BGCEngine::~BGCEngine() { - bgc_.Shutdown(&engine_state_); + bgc_.Shutdown(); //FreeAlquimiaProblemMetaData(&chem_metadata_); // As there are no chemical conditions, am I just deleting variables? diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 4f3618d56..3a945f661 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -122,8 +122,7 @@ extern "C" { int num_iterations); /* gracefully shutdown the engine, cleanup memory */ - void (*Shutdown)( - void* pft_engine_state); + void (*Shutdown)(); /* constrain processing for boundary/initial constraints. Called once for each IC/BC. */ diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index 13caa2f85..1156580a1 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -47,6 +47,8 @@ void ecosim_setup( int num_iterations ); +void ecosim_shutdown(); + void ecosim_advance( double delta_t, BGCProperties* properties, diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index be327d204..666967890 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -60,6 +60,30 @@ end subroutine EcoSIM_Setup ! **************************************************************************** ! +subroutine EcoSIM_Shutdown() bind(C) + + !For now this does nothing, but it should clear all + !the data structures + use, intrinsic :: iso_c_binding + + use BGCContainers_module + + implicit none + + ! function parameters + character(kind=c_char), dimension(*), intent(in) :: input_filename + type (BGCSizes), intent(out) :: sizes + type (BGCState), intent(in) :: state + type (BGCAuxiliaryData), intent(in) :: aux_data + type (BGCProperties), intent(in) :: prop + integer :: ncol, jz, js + real (c_double), value, intent(in) :: delta_t + integer, intent(in) :: num_iterations + +end subroutine EcoSIM_Setup + +! **************************************************************************** ! + subroutine EcoSIM_Advance( & delta_t, & prop, & From 4677a464c1280a6a85659b8856f69daa464195fe Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 15:08:01 -0700 Subject: [PATCH 316/582] various bugfixes --- src/pks/ecosim_pk/BGCEngine.cc | 6 ++++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- src/pks/ecosim_pk/ecosim_wrappers.F90 | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 6d0db76b7..ef99192f4 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -215,7 +215,8 @@ bool BGCEngine::Setup(const double delta_time, bgc_.Advance(delta_time, &props, &state, - &aux_data); + &aux_data + num_iterations); //This is alquimia's advance function which we won't need //calling EcoSIM advance driver @@ -236,7 +237,8 @@ bool BGCEngine::Advance(const double delta_time, bgc_.Advance(delta_time, &props, &state, - &aux_data); + &aux_data + num_iterations); //This is alquimia's advance function which we won't need //calling EcoSIM advance driver diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 01bac8dc4..e300a0cb0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -904,7 +904,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, /* ******************************************************************* * This helper performs initialization on a single column within Amanzi's state. ******************************************************************* */ -int EcoSIM::InitializeSingleColumn(int col) +int EcoSIM::InitializeSingleColumn(double dt, int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index ddd0ca0a8..a5f870215 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -112,7 +112,7 @@ class EcoSIM : public PK_Physical { const BGCAuxiliaryData& aux_data, const Tag& water_tag = Tags::DEFAULT); - int InitializeSingleColumn(int col); + int InitializeSingleColumn(double dt, int col); int AdvanceSingleColumn(double dt, int col); diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 666967890..c78b68a44 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -80,7 +80,7 @@ subroutine EcoSIM_Shutdown() bind(C) real (c_double), value, intent(in) :: delta_t integer, intent(in) :: num_iterations -end subroutine EcoSIM_Setup +end subroutine EcoSIM_Shutdown ! **************************************************************************** ! From 431a2f7461a5c73644282db038ffcb2c47f2cd51 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 15:24:54 -0700 Subject: [PATCH 317/582] more minor bugfixes --- src/pks/ecosim_pk/BGCEngine.cc | 7 +++---- src/pks/ecosim_pk/BGCEngine.hh | 3 +-- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- src/pks/ecosim_pk/data/BGC_containers.hh | 1 - src/pks/ecosim_pk/ecosim_interface.h | 1 - src/pks/ecosim_pk/ecosim_wrappers.F90 | 14 +++++++------- 7 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index ef99192f4..2c3f3b23e 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -212,10 +212,9 @@ bool BGCEngine::Setup(const double delta_time, { std::cout << "Running BGC Engine Setup" << std::endl; // Advance the chemical reaction all operator-split-like. - bgc_.Advance(delta_time, - &props, + bgc_.Stup(&props, &state, - &aux_data + &aux_data, num_iterations); //This is alquimia's advance function which we won't need @@ -237,7 +236,7 @@ bool BGCEngine::Advance(const double delta_time, bgc_.Advance(delta_time, &props, &state, - &aux_data + &aux_data, num_iterations); //This is alquimia's advance function which we won't need diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 7918e775e..1e40dea45 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -70,8 +70,7 @@ class BGCEngine { AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ - bool Setup(const double delta_time, - BGCProperties& props, + bool Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, int& num_iterations); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e300a0cb0..40aa5d322 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -904,13 +904,13 @@ void EcoSIM::CopyFromEcoSIM(const int col, /* ******************************************************************* * This helper performs initialization on a single column within Amanzi's state. ******************************************************************* */ -int EcoSIM::InitializeSingleColumn(double dt, int col) +int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 1; - bgc_engine_->Setup(dt, bgc_props_, bgc_state_, + bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_aux_data_, num_iterations); CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index a5f870215..ddd0ca0a8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -112,7 +112,7 @@ class EcoSIM : public PK_Physical { const BGCAuxiliaryData& aux_data, const Tag& water_tag = Tags::DEFAULT); - int InitializeSingleColumn(double dt, int col); + int InitializeSingleColumn(int col); int AdvanceSingleColumn(double dt, int col); diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 3a945f661..f3c9714b1 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -115,7 +115,6 @@ extern "C" { /* read data files/structures, initialize memory, basis management (includes reading database, swapping basis, etc.) */ void (*Setup)( - double delta_t, BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index 1156580a1..9cb82ef1c 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -40,7 +40,6 @@ extern "C" { #endif /* __cplusplus */ void ecosim_setup( - double delta_t, BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index c78b68a44..4456a70d2 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,7 +30,7 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_Setup(delta_t, props, state, aux_data, & +subroutine EcoSIM_Setup(props, state, aux_data, & num_iterations) bind(C) use, intrinsic :: iso_c_binding @@ -45,12 +45,12 @@ subroutine EcoSIM_Setup(delta_t, props, state, aux_data, & type (BGCSizes), intent(out) :: sizes type (BGCState), intent(in) :: state type (BGCAuxiliaryData), intent(in) :: aux_data - type (BGCProperties), intent(in) :: prop + type (BGCProperties), intent(in) :: props integer :: ncol, jz, js real (c_double), value, intent(in) :: delta_t integer, intent(in) :: num_iterations - call ATS2EcoSIMData(ncol, state, aux_data, prop) + call ATS2EcoSIMData(ncol, state, aux_data, props call Init_EcoSIM(jz,js,ncol) @@ -75,7 +75,7 @@ subroutine EcoSIM_Shutdown() bind(C) type (BGCSizes), intent(out) :: sizes type (BGCState), intent(in) :: state type (BGCAuxiliaryData), intent(in) :: aux_data - type (BGCProperties), intent(in) :: prop + type (BGCProperties), intent(in) :: props integer :: ncol, jz, js real (c_double), value, intent(in) :: delta_t integer, intent(in) :: num_iterations @@ -86,7 +86,7 @@ end subroutine EcoSIM_Shutdown subroutine EcoSIM_Advance( & delta_t, & - prop, & + props, & state, & aux_data, & num_iterations) bind(C) @@ -100,14 +100,14 @@ subroutine EcoSIM_Advance( & ! function parameters type (c_ptr), intent(inout) :: pft_engine_state real (c_double), value, intent(in) :: delta_t - type (BGCProperties), intent(in) :: prop + type (BGCProperties), intent(in) :: props type (BGCState), intent(inout) :: state type (BGCAuxiliaryData), intent(inout) :: aux_data !type (BGCEngineStatus), intent(out) :: status integer :: ncol integer, intent(in) :: num_iterations - call ATS2EcoSIMData(ncol, state, aux_data, prop) + call ATS2EcoSIMData(ncol, state, aux_data, props) call Run_EcoSIM_one_step() From 899b99292b950d4a9e5687a817d2ff61efdad18b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 15:35:15 -0700 Subject: [PATCH 318/582] more minor bugfixes --- src/pks/ecosim_pk/BGCEngine.cc | 3 +-- src/pks/ecosim_pk/ecosim_wrappers.F90 | 21 +++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 2c3f3b23e..6b064c647 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -204,8 +204,7 @@ void BGCEngine::FreeState(BGCProperties& props, //FreeAlquimiaAuxiliaryOutputData(&aux_output); } -bool BGCEngine::Setup(const double delta_time, - BGCProperties& props, +bool BGCEngine::Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, int& num_iterations) diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 4456a70d2..deb633055 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -42,15 +42,14 @@ subroutine EcoSIM_Setup(props, state, aux_data, & ! function parameters character(kind=c_char), dimension(*), intent(in) :: input_filename - type (BGCSizes), intent(out) :: sizes + type (BGCSizes), intent(in) :: sizes type (BGCState), intent(in) :: state type (BGCAuxiliaryData), intent(in) :: aux_data type (BGCProperties), intent(in) :: props integer :: ncol, jz, js - real (c_double), value, intent(in) :: delta_t integer, intent(in) :: num_iterations - call ATS2EcoSIMData(ncol, state, aux_data, props + call ATS2EcoSIMData(ncol, state, aux_data, props) call Init_EcoSIM(jz,js,ncol) @@ -71,14 +70,13 @@ subroutine EcoSIM_Shutdown() bind(C) implicit none ! function parameters - character(kind=c_char), dimension(*), intent(in) :: input_filename - type (BGCSizes), intent(out) :: sizes - type (BGCState), intent(in) :: state - type (BGCAuxiliaryData), intent(in) :: aux_data - type (BGCProperties), intent(in) :: props - integer :: ncol, jz, js - real (c_double), value, intent(in) :: delta_t - integer, intent(in) :: num_iterations + !character(kind=c_char), dimension(*), intent(in) :: input_filename + !type (BGCSizes), intent(out) :: sizes + !type (BGCState), intent(in) :: state + !type (BGCAuxiliaryData), intent(in) :: aux_data + !type (BGCProperties), intent(in) :: props + !integer :: ncol, jz, js + !integer, intent(in) :: num_iterations end subroutine EcoSIM_Shutdown @@ -98,7 +96,6 @@ subroutine EcoSIM_Advance( & implicit none ! function parameters - type (c_ptr), intent(inout) :: pft_engine_state real (c_double), value, intent(in) :: delta_t type (BGCProperties), intent(in) :: props type (BGCState), intent(inout) :: state From a4481a7230eaead0cb32c0c19ddbb7ec8a276534 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 15:50:37 -0700 Subject: [PATCH 319/582] yet more minor fixes --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- src/pks/ecosim_pk/ecosim_wrappers.F90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 6b064c647..9ddbe89d5 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -211,7 +211,7 @@ bool BGCEngine::Setup(BGCProperties& props, { std::cout << "Running BGC Engine Setup" << std::endl; // Advance the chemical reaction all operator-split-like. - bgc_.Stup(&props, + bgc_.Setup(&props, &state, &aux_data, num_iterations); diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index deb633055..a0a718cb6 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -41,8 +41,8 @@ subroutine EcoSIM_Setup(props, state, aux_data, & implicit none ! function parameters - character(kind=c_char), dimension(*), intent(in) :: input_filename - type (BGCSizes), intent(in) :: sizes + !character(kind=c_char), dimension(*), intent(in) :: input_filename + type (BGCSizes), intent(out) :: sizes type (BGCState), intent(in) :: state type (BGCAuxiliaryData), intent(in) :: aux_data type (BGCProperties), intent(in) :: props From d64e317bffe130ec916147803f1ee4a8347cd60e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 15:55:11 -0700 Subject: [PATCH 320/582] hmm I don't actually use the sizes --- src/pks/ecosim_pk/ecosim_wrappers.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index a0a718cb6..7291d457d 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -42,7 +42,7 @@ subroutine EcoSIM_Setup(props, state, aux_data, & ! function parameters !character(kind=c_char), dimension(*), intent(in) :: input_filename - type (BGCSizes), intent(out) :: sizes + !type (BGCSizes), intent(out) :: sizes type (BGCState), intent(in) :: state type (BGCAuxiliaryData), intent(in) :: aux_data type (BGCProperties), intent(in) :: props From 1de534a6d6d5be0da8343f260b60a80ef94e0d9b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Jun 2023 21:05:55 -0700 Subject: [PATCH 321/582] adding some messages to the wrapper --- src/pks/ecosim_pk/ecosim_wrappers.F90 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 7291d457d..c26724084 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -49,10 +49,16 @@ subroutine EcoSIM_Setup(props, state, aux_data, & integer :: ncol, jz, js integer, intent(in) :: num_iterations + write(*,*) "starting driver transfer ATS2EcoSIMData" + call ATS2EcoSIMData(ncol, state, aux_data, props) + write(*,*) "starting driver Init_EcoSIM" + call Init_EcoSIM(jz,js,ncol) + write(*,*) "starting driver transfer EcoSIM2ATSData" + call EcoSIM2ATSData() end subroutine EcoSIM_Setup From ab2882fc19b32ebf01ebdd50b232ca1842f5baef Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 2 Jun 2023 10:49:05 -0700 Subject: [PATCH 322/582] removing some calls and adding in the column --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- src/pks/ecosim_pk/ecosim_interface.h | 6 ++++-- src/pks/ecosim_pk/ecosim_wrappers.F90 | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 40aa5d322..5bb0673d4 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -911,7 +911,7 @@ int EcoSIM::InitializeSingleColumn(int col) int num_iterations = 1; bgc_engine_->Setup(bgc_props_, bgc_state_, - bgc_aux_data_, num_iterations); + bgc_aux_data_, num_iterations, col); CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); // ETC: hacking to get consistent solution -- if there is no water @@ -940,7 +940,7 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) *******************************************************************/ bgc_engine_->Advance(dt, bgc_props_, bgc_state_, - bgc_aux_data_, num_iterations); + bgc_aux_data_, num_iterations, col); // Move the information back into Amanzi's state, updating the given total concentration vector. CopyEcoSIMStateToAmanzi(col, diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index 9cb82ef1c..f69042b03 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -43,7 +43,8 @@ void ecosim_setup( BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, - int num_iterations + int num_iterations, + int ncol ); void ecosim_shutdown(); @@ -53,7 +54,8 @@ void ecosim_advance( BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, - int num_iterations + int num_iterations, + int ncol ); #ifdef __cplusplus diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index c26724084..ed60bc1ef 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -31,7 +31,7 @@ ! **************************************************************************** ! subroutine EcoSIM_Setup(props, state, aux_data, & - num_iterations) bind(C) + num_iterations, ncol) bind(C) use, intrinsic :: iso_c_binding @@ -55,11 +55,11 @@ subroutine EcoSIM_Setup(props, state, aux_data, & write(*,*) "starting driver Init_EcoSIM" - call Init_EcoSIM(jz,js,ncol) + !call Init_EcoSIM(jz,js,ncol) write(*,*) "starting driver transfer EcoSIM2ATSData" - call EcoSIM2ATSData() + !call EcoSIM2ATSData() end subroutine EcoSIM_Setup @@ -93,7 +93,8 @@ subroutine EcoSIM_Advance( & props, & state, & aux_data, & - num_iterations) bind(C) + num_iterations, & + ncol) bind(C) use, intrinsic :: iso_c_binding use BGCContainers_module From e7a9979056495cdde93ba5be416228ac0464e5fd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 2 Jun 2023 11:07:18 -0700 Subject: [PATCH 323/582] definitions in containers --- src/pks/ecosim_pk/data/BGC_containers.hh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index f3c9714b1..94942d25e 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -118,7 +118,8 @@ extern "C" { BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, - int num_iterations); + int num_iterations, + int ncol); /* gracefully shutdown the engine, cleanup memory */ void (*Shutdown)(); @@ -139,7 +140,8 @@ extern "C" { BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, - int num_iterations); + int num_iterations + int ncol); /* Access to user selected geochemical data for output, i.e. pH, mineral SI, reaction rates */ From 1bc760f85768dceeee6b852ac0f0c1a2e7d64c85 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 2 Jun 2023 11:10:19 -0700 Subject: [PATCH 324/582] typo --- src/pks/ecosim_pk/data/BGC_containers.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 94942d25e..6ba2ca4a4 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -140,7 +140,7 @@ extern "C" { BGCProperties* properties, BGCState* state, BGCAuxiliaryData* aux_data, - int num_iterations + int num_iterations, int ncol); /* Access to user selected geochemical data for output, i.e. pH, From 95bb3f460fcfd5ddd3835504ad0c74f7f9237426 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 2 Jun 2023 11:20:39 -0700 Subject: [PATCH 325/582] adding defs to engine --- src/pks/ecosim_pk/BGCEngine.cc | 12 ++++++++---- src/pks/ecosim_pk/BGCEngine.hh | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 9ddbe89d5..c62b20744 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -207,14 +207,16 @@ void BGCEngine::FreeState(BGCProperties& props, bool BGCEngine::Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations) + int& num_iterations, + int& ncol) { std::cout << "Running BGC Engine Setup" << std::endl; // Advance the chemical reaction all operator-split-like. bgc_.Setup(&props, &state, &aux_data, - num_iterations); + num_iterations, + ncol); //This is alquimia's advance function which we won't need //calling EcoSIM advance driver @@ -228,7 +230,8 @@ bool BGCEngine::Advance(const double delta_time, BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations) + int& num_iterations + int& ncol) { std::cout << "Running BGC Engine Advance" << std::endl; // Advance the chemical reaction all operator-split-like. @@ -236,7 +239,8 @@ bool BGCEngine::Advance(const double delta_time, &props, &state, &aux_data, - num_iterations); + num_iterations, + ncol); //This is alquimia's advance function which we won't need //calling EcoSIM advance driver diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 1e40dea45..d69bac8ed 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -73,7 +73,8 @@ class BGCEngine { bool Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations); + int& num_iterations, + int& ncol); // Advances the species represented by the given array of concentrations, replacing old values // with new values. The order of the concentrations in the array matches that of the species names @@ -83,7 +84,8 @@ class BGCEngine { BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations); + int& num_iterations, + int& ncol); //Functions from the alquimia util section, I don't think I need the full code so I think //I can just copy these functions over From 3a7513d65691900f2f8a380ae5890d132c7242d2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 2 Jun 2023 11:25:41 -0700 Subject: [PATCH 326/582] ugh --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index c62b20744..38aea6c58 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -230,7 +230,7 @@ bool BGCEngine::Advance(const double delta_time, BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations + int& num_iterations, int& ncol) { std::cout << "Running BGC Engine Advance" << std::endl; From d1263982c193c0025065623342f077bdb11fec09 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Sat, 3 Jun 2023 14:56:55 -0700 Subject: [PATCH 327/582] adding the fortran definitions for memory allocation functions --- src/pks/ecosim_pk/data/CMakeLists.txt | 1 + .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 218 ++++++++++++++++++ src/pks/ecosim_pk/ecosim_wrappers.F90 | 4 +- 3 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index 0f59e30a2..964dbf9f1 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -9,6 +9,7 @@ set(ats_ecosim_data_src_files BGC_constants.cc BGC_memory.cc BGC_containers.cc + bgc_fortran_memory_mod.F90 ) set(ats_ecosim_data_inc_files BGC_constants.hh diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 new file mode 100644 index 000000000..7857298b5 --- /dev/null +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -0,0 +1,218 @@ +!It seems like the memory allocation functions need to know how do define the +!memory even if you do not do memory allocation in F90, so this code writes +!versions of the memory allocation functions + +module bgc_fortran_memory_mod + + + use BGCContainers_module, only : BGCSizes,BGCProperties,& + BGCState,BGCAuxiliaryData + use iso_c_binding, only : c_funptr + + implicit none + + type, bind(c) :: BGCInterface + + type(c_funptr) :: Setup + type(c_funptr) :: Shutdown + type(c_funptr) :: ProcessCondition + type(c_funptr) :: ReactionStepOperatorSplit + type(c_funptr) :: GetAuxiliaryOutput + type(c_funptr) :: GetProblemMetaData + + end type BGCInterface + + type, public :: BGCFortranInterface + type(BGCInterface) :: c_interface + + contains + procedure, public :: CreateInterface => Create_Fortran_BGC_Interface + procedure, public :: Setup => BGC_Fortran_setup + procedure, public :: Shutdown => BGC_Fortran_Shutdown + procedure, public :: ProcessCondition => BGC_Fortran_ProcessCondition + procedure, public :: ReactionStepOperatorSplit => BGC_Fortran_ReactionStepOperatorSplit + procedure, public :: GetAuxiliaryOutput => BGC_Fortran_GetAuxiliaryOutput + procedure, public :: GetProblemMetaData => BGC_Fortran_GetProblemMetaData + end type BGCFortranInterface + + interface + subroutine CreateBGCInterface(engine_name, bgc_interface, status) bind(C, name='CreateBGCInterface') + use iso_C_binding, only: c_char + IMPORT + implicit none + character(kind=c_char) :: engine_name(*) + type(BGCInterface) :: bgc_interface + end subroutine + end interface + + ! Memory allocation subroutines + + interface + subroutine AllocateBGCState(sizes, state) bind(C, name='AllocateBGCState') + use BGCContainers_module, only : BGCSizes, BGCState + implicit none + type(BGCSizes) :: sizes + type(BGCState) :: state + end subroutine + end interface + interface + subroutine FreeBGCState(state) bind(C, name='FreeBGCState') + use BGCContainers_module, only : BGCState + implicit none + type(BGCState) :: state + end subroutine + end interface + + interface + subroutine AllocateBGCProperties(sizes, props) bind(C, name='AllocateBGCProperties') + use BGCContainers_module, only : BGCSizes, BGCProperties + implicit none + type(BGCSizes) :: sizes + type(BGCProperties) :: props + end subroutine + end interface + interface + subroutine FreeBGCProperties(props) bind(C, name='FreeBGCProperties') + use BGCContainers_module, only : BGCProperties + implicit none + type(BGCProperties) :: props + end subroutine + end interface + + interface + subroutine AllocateBGCAuxiliaryData(sizes, aux_data) bind(C, name='AllocateBGCAuxiliaryData') + use BGCContainers_module, only : BGCSizes, BGCAuxiliaryData + implicit none + type(BGCSizes) :: sizes + type(BGCAuxiliaryData) :: aux_data + end subroutine + end interface + interface + subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') + use BGCContainers_module, only : BGCAuxiliaryData + implicit none + type(BGCAuxiliaryData) :: aux_data + end subroutine + end interface + + ! The following subroutines are methods of the engine itself + + interface + subroutine Setup(props, state, aux_data, num_iterations, ncol) bind(C) + + use, intrinsic :: iso_c_binding, only: c_char, c_bool, c_ptr, c_int + use BGCContainers_module, only : BGCEngineStatus,BGCEngineFunctionality,BGCSizes + IMPORT + implicit none + + real(c_int),VALUE :: num_iterations + real(c_int),VALUE :: ncol + + type(BGCProperties) :: props + type(BGCState) :: state + type(BGCAuxiliaryData) :: aux_data + type(BGCEngineStatus) :: status + + end subroutine + end interface + + + !gracefully shutdown the engine, cleanup memory + interface + subroutine Shutdown() bind(C) + use, intrinsic :: iso_c_binding, only : c_ptr + + implicit none + + end subroutine + end interface + + ! take one (or more?) reaction steps in operator split mode + interface + subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C) + use, intrinsic :: iso_c_binding, only : c_ptr, c_double, c_int + use BGCContainers_module, only : BGCSizes,BGCProperties,& + BGCState,BGCAuxiliaryData + implicit none + + real(c_double),VALUE :: delta_t + real(c_int),VALUE :: num_iterations + real(c_int),VALUE :: ncol + + type(BGCProperties) :: props + type(BGCState) :: state + type(BGCAuxiliaryData) :: aux_data + type(BGCEngineStatus) :: status + end subroutine + end interface + + contains + + subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) + use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer + use BGCContainers_module, only : BGCSizes, BGCProperties,& + BGCState, BGCAuxiliaryData + + implicit none + class(BGCFortranInterface) :: this + + real(c_double) :: delta_t + real(c_int) :: n_col + real(c_int) :: num_iterations + type(BGCProperties) :: props + type(BGCState) :: state + type(BGCAuxiliaryData) :: aux_data + type(BGCEngineStatus) :: status + + procedure(Setup), pointer :: engine_Setup + + call c_f_procpointer(this%c_interface%Setup,engine_Setup) + call engine_Setup(props, state, aux_data, num_interations, ncol) + end subroutine + + subroutine BGC_Fortran_Shutdown(this) + use, intrinsic :: iso_c_binding, only : c_ptr,c_f_procpointer + + implicit none + class(BGCFortranInterface) :: this + procedure(Shutdown), pointer :: engine_Shutdown + + call c_f_procpointer(this%c_interface%Shutdown,engine_Shutdown) + call engine_shutdown() + + end subroutine BGC_Fortran_Shutdown + + subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterations, ncol) + use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer + use BGCContainers_module, only : BGCSizes, BGCProperties,& + BGCState, BGCAuxiliaryData + + implicit none + class(BGCFortranInterface) :: this + + real(c_double) :: delta_t + real(c_int) :: n_col + real(c_int) :: num_iterations + type(BGCProperties) :: props + type(BGCState) :: state + type(BGCAuxiliaryData) :: aux_data + type(BGCEngineStatus) :: status + + procedure(Advance), pointer :: engine_Advance + + call c_f_procpointer(this%c_interface%Advance,engine_Advance) + call engine_Advance(delta_t, props, state, aux_data, num_interations, ncol) + end subroutine + + subroutine Create_Fortran_BGC_Interface(this,engine_name, status) + use BGCContainers_module, only : BGCEngineStatus,kBGCMaxStringLength + use iso_C_binding, only: c_char,c_null_char + implicit none + class(BGCFortranInterface) :: this + character(kind=c_char,len=kBGCMaxStringLength) :: engine_name + type(BGCEngineStatus) :: status + + call CreateBGCInterface(trim(engine_name)//C_NULL_CHAR, this%c_interface, status) + end subroutine + +end module bgc_fortran_interface_mod diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index ed60bc1ef..074f1a352 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -43,8 +43,8 @@ subroutine EcoSIM_Setup(props, state, aux_data, & ! function parameters !character(kind=c_char), dimension(*), intent(in) :: input_filename !type (BGCSizes), intent(out) :: sizes - type (BGCState), intent(in) :: state - type (BGCAuxiliaryData), intent(in) :: aux_data + type (BGCState), intent(inout) :: state + type (BGCAuxiliaryData), intent(inout) :: aux_data type (BGCProperties), intent(in) :: props integer :: ncol, jz, js integer, intent(in) :: num_iterations From 84948e4eaa179682c65de76081e53e498083f1ce Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Sat, 3 Jun 2023 15:10:25 -0700 Subject: [PATCH 328/582] changes to linked files --- src/pks/ecosim_pk/data/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index 964dbf9f1..380a514f5 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -10,6 +10,10 @@ set(ats_ecosim_data_src_files BGC_memory.cc BGC_containers.cc bgc_fortran_memory_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 ) set(ats_ecosim_data_inc_files BGC_constants.hh From 373ce3d784d70c4def85ef94ecba82f31b9e5e30 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Sun, 4 Jun 2023 15:07:47 -0700 Subject: [PATCH 329/582] bugfixes to the memory interface --- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 7857298b5..f3f40f847 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -101,17 +101,16 @@ subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') subroutine Setup(props, state, aux_data, num_iterations, ncol) bind(C) use, intrinsic :: iso_c_binding, only: c_char, c_bool, c_ptr, c_int - use BGCContainers_module, only : BGCEngineStatus,BGCEngineFunctionality,BGCSizes + use BGCContainers_module, only : BGCSizes IMPORT implicit none - real(c_int),VALUE :: num_iterations - real(c_int),VALUE :: ncol + integer(c_int),VALUE :: num_iterations + integer(c_int),VALUE :: ncol type(BGCProperties) :: props type(BGCState) :: state type(BGCAuxiliaryData) :: aux_data - type(BGCEngineStatus) :: status end subroutine end interface @@ -136,13 +135,12 @@ subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C implicit none real(c_double),VALUE :: delta_t - real(c_int),VALUE :: num_iterations - real(c_int),VALUE :: ncol + integer(c_int),VALUE :: num_iterations + integer(c_int),VALUE :: ncol type(BGCProperties) :: props type(BGCState) :: state type(BGCAuxiliaryData) :: aux_data - type(BGCEngineStatus) :: status end subroutine end interface @@ -157,12 +155,11 @@ subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) class(BGCFortranInterface) :: this real(c_double) :: delta_t - real(c_int) :: n_col - real(c_int) :: num_iterations + integer(c_int) :: n_col + integer(c_int) :: num_iterations type(BGCProperties) :: props type(BGCState) :: state type(BGCAuxiliaryData) :: aux_data - type(BGCEngineStatus) :: status procedure(Setup), pointer :: engine_Setup @@ -191,12 +188,11 @@ subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterat class(BGCFortranInterface) :: this real(c_double) :: delta_t - real(c_int) :: n_col - real(c_int) :: num_iterations + integer(c_int) :: n_col + integer(c_int) :: num_iterations type(BGCProperties) :: props type(BGCState) :: state type(BGCAuxiliaryData) :: aux_data - type(BGCEngineStatus) :: status procedure(Advance), pointer :: engine_Advance @@ -205,14 +201,13 @@ subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterat end subroutine subroutine Create_Fortran_BGC_Interface(this,engine_name, status) - use BGCContainers_module, only : BGCEngineStatus,kBGCMaxStringLength + use BGCContainers_module, only :kBGCMaxStringLength use iso_C_binding, only: c_char,c_null_char implicit none class(BGCFortranInterface) :: this character(kind=c_char,len=kBGCMaxStringLength) :: engine_name - type(BGCEngineStatus) :: status - call CreateBGCInterface(trim(engine_name)//C_NULL_CHAR, this%c_interface, status) + call CreateBGCInterface(trim(engine_name)//C_NULL_CHAR, this%c_interface) end subroutine -end module bgc_fortran_interface_mod +end module bgc_fortran_memory_mod From a20081642a440c862523458583c748b1eb0e94b3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Sun, 4 Jun 2023 15:19:11 -0700 Subject: [PATCH 330/582] more minor bugfixes --- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index f3f40f847..421f17824 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -15,10 +15,7 @@ module bgc_fortran_memory_mod type(c_funptr) :: Setup type(c_funptr) :: Shutdown - type(c_funptr) :: ProcessCondition - type(c_funptr) :: ReactionStepOperatorSplit - type(c_funptr) :: GetAuxiliaryOutput - type(c_funptr) :: GetProblemMetaData + type(c_funptr) :: Advance end type BGCInterface @@ -27,16 +24,13 @@ module bgc_fortran_memory_mod contains procedure, public :: CreateInterface => Create_Fortran_BGC_Interface - procedure, public :: Setup => BGC_Fortran_setup + procedure, public :: Setup => BGC_Fortran_Setup procedure, public :: Shutdown => BGC_Fortran_Shutdown - procedure, public :: ProcessCondition => BGC_Fortran_ProcessCondition - procedure, public :: ReactionStepOperatorSplit => BGC_Fortran_ReactionStepOperatorSplit - procedure, public :: GetAuxiliaryOutput => BGC_Fortran_GetAuxiliaryOutput - procedure, public :: GetProblemMetaData => BGC_Fortran_GetProblemMetaData + procedure, public :: Advance => BGC_Fortran_Advance end type BGCFortranInterface interface - subroutine CreateBGCInterface(engine_name, bgc_interface, status) bind(C, name='CreateBGCInterface') + subroutine CreateBGCInterface(engine_name, bgc_interface) bind(C, name='CreateBGCInterface') use iso_C_binding, only: c_char IMPORT implicit none @@ -155,7 +149,7 @@ subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) class(BGCFortranInterface) :: this real(c_double) :: delta_t - integer(c_int) :: n_col + integer(c_int) :: ncol integer(c_int) :: num_iterations type(BGCProperties) :: props type(BGCState) :: state @@ -164,7 +158,7 @@ subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) procedure(Setup), pointer :: engine_Setup call c_f_procpointer(this%c_interface%Setup,engine_Setup) - call engine_Setup(props, state, aux_data, num_interations, ncol) + call engine_Setup(props, state, aux_data, num_iterations, ncol) end subroutine subroutine BGC_Fortran_Shutdown(this) @@ -188,7 +182,7 @@ subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterat class(BGCFortranInterface) :: this real(c_double) :: delta_t - integer(c_int) :: n_col + integer(c_int) :: ncol integer(c_int) :: num_iterations type(BGCProperties) :: props type(BGCState) :: state @@ -197,10 +191,10 @@ subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterat procedure(Advance), pointer :: engine_Advance call c_f_procpointer(this%c_interface%Advance,engine_Advance) - call engine_Advance(delta_t, props, state, aux_data, num_interations, ncol) + call engine_Advance(delta_t, props, state, aux_data, num_iterations, ncol) end subroutine - subroutine Create_Fortran_BGC_Interface(this,engine_name, status) + subroutine Create_Fortran_BGC_Interface(this,engine_name) use BGCContainers_module, only :kBGCMaxStringLength use iso_C_binding, only: c_char,c_null_char implicit none From f81d04297cc54f6d7de359a692bc200291a62788 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 5 Jun 2023 11:10:52 -0700 Subject: [PATCH 331/582] maybe an issue with terminating the subroutines? --- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 421f17824..2e2e844f6 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -109,34 +109,33 @@ subroutine Setup(props, state, aux_data, num_iterations, ncol) bind(C) end subroutine end interface + !gracefully shutdown the engine, cleanup memory + interface + subroutine Shutdown() bind(C) + use, intrinsic :: iso_c_binding, only : c_ptr - !gracefully shutdown the engine, cleanup memory - interface - subroutine Shutdown() bind(C) - use, intrinsic :: iso_c_binding, only : c_ptr - - implicit none + implicit none - end subroutine - end interface + end subroutine + end interface - ! take one (or more?) reaction steps in operator split mode - interface - subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C) - use, intrinsic :: iso_c_binding, only : c_ptr, c_double, c_int - use BGCContainers_module, only : BGCSizes,BGCProperties,& - BGCState,BGCAuxiliaryData - implicit none + ! take one (or more?) reaction steps in operator split mode + interface + subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C) + use, intrinsic :: iso_c_binding, only : c_ptr, c_double, c_int + use BGCContainers_module, only : BGCSizes,BGCProperties,& + BGCState,BGCAuxiliaryData + implicit none - real(c_double),VALUE :: delta_t - integer(c_int),VALUE :: num_iterations - integer(c_int),VALUE :: ncol + real(c_double),VALUE :: delta_t + integer(c_int),VALUE :: num_iterations + integer(c_int),VALUE :: ncol - type(BGCProperties) :: props - type(BGCState) :: state - type(BGCAuxiliaryData) :: aux_data - end subroutine - end interface + type(BGCProperties) :: props + type(BGCState) :: state + type(BGCAuxiliaryData) :: aux_data + end subroutine + end interface contains @@ -159,7 +158,8 @@ subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) call c_f_procpointer(this%c_interface%Setup,engine_Setup) call engine_Setup(props, state, aux_data, num_iterations, ncol) - end subroutine + + end subroutine BGC_Fortran_Setup subroutine BGC_Fortran_Shutdown(this) use, intrinsic :: iso_c_binding, only : c_ptr,c_f_procpointer @@ -192,7 +192,7 @@ subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterat call c_f_procpointer(this%c_interface%Advance,engine_Advance) call engine_Advance(delta_t, props, state, aux_data, num_iterations, ncol) - end subroutine + end subroutine BGC_Fortran_Advance subroutine Create_Fortran_BGC_Interface(this,engine_name) use BGCContainers_module, only :kBGCMaxStringLength @@ -202,6 +202,7 @@ subroutine Create_Fortran_BGC_Interface(this,engine_name) character(kind=c_char,len=kBGCMaxStringLength) :: engine_name call CreateBGCInterface(trim(engine_name)//C_NULL_CHAR, this%c_interface) + end subroutine end module bgc_fortran_memory_mod From c4d7118e2e65d82fdf65f8d72ebd7fb0f8d33cf1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 5 Jun 2023 14:07:43 -0700 Subject: [PATCH 332/582] Added a simple tester for the ecosim wrapper --- src/pks/ecosim_pk/BGCEngine.cc | 8 ++++- src/pks/ecosim_pk/BGCEngine.hh | 2 ++ src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 ++ src/pks/ecosim_pk/data/BGC_containers.cc | 1 + src/pks/ecosim_pk/data/BGC_containers.hh | 4 +++ .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 32 +++++++++++++++++++ src/pks/ecosim_pk/ecosim_interface.h | 4 +++ src/pks/ecosim_pk/ecosim_wrappers.F90 | 14 ++++++++ 8 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 38aea6c58..4bf54c851 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -204,11 +204,17 @@ void BGCEngine::FreeState(BGCProperties& props, //FreeAlquimiaAuxiliaryOutputData(&aux_output); } +void BGCEngine::DataTest(BGCProperties& props) { + + std::cout << "Data test for props" << std::endl; + bgc_.DataTest(&props); +} + bool BGCEngine::Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, int& num_iterations, - int& ncol) + int& ncol); { std::cout << "Running BGC Engine Setup" << std::endl; // Advance the chemical reaction all operator-split-like. diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index d69bac8ed..3225fd29f 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -70,6 +70,8 @@ class BGCEngine { AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ + void DataTest(BGCProperties& props); + bool Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5bb0673d4..77182f302 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -908,6 +908,8 @@ int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + bgc_engine_->DataTest(bgc_props_); + int num_iterations = 1; bgc_engine_->Setup(bgc_props_, bgc_state_, diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index 395f8fd44..cf8d3e854 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -42,6 +42,7 @@ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) //interface->Shutdown = NULL; //interface->Advance = NULL; + interface->DataTest = &ecosim_datatest; interface->Setup = &ecosim_setup; interface->Shutdown = &ecosim_shutdown; interface->Advance = &ecosim_advance; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 6ba2ca4a4..af4af6114 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -114,6 +114,10 @@ extern "C" { typedef struct { /* read data files/structures, initialize memory, basis management (includes reading database, swapping basis, etc.) */ + void (*DataTest)( + BGCProperties* props + ); + void (*Setup)( BGCProperties* properties, BGCState* state, diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 2e2e844f6..39ce6cdd5 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -13,6 +13,7 @@ module bgc_fortran_memory_mod type, bind(c) :: BGCInterface + type(c_funptr) :: DataTest type(c_funptr) :: Setup type(c_funptr) :: Shutdown type(c_funptr) :: Advance @@ -24,6 +25,7 @@ module bgc_fortran_memory_mod contains procedure, public :: CreateInterface => Create_Fortran_BGC_Interface + procedure, public :: DataTest => BGC_Fortran_DataTest procedure, public :: Setup => BGC_Fortran_Setup procedure, public :: Shutdown => BGC_Fortran_Shutdown procedure, public :: Advance => BGC_Fortran_Advance @@ -91,6 +93,20 @@ subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') ! The following subroutines are methods of the engine itself + interface + + subroutine DataTest(props) bind(C) + use, intrinsic :: iso_c_binding + use BGCContainers_module, only : BGCProperties + IMPORT + implicit none + + type(BGCProperties) :: props + + end subroutine + end interface + + interface subroutine Setup(props, state, aux_data, num_iterations, ncol) bind(C) @@ -139,6 +155,22 @@ subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C contains + subroutine BGC_Fortran_DataTest(this, props) + use, intrinsic :: iso_c_binding + use BGCContainers_module, only : BGCProperties + + implicit none + class(BGCFortranInterface) :: this + + type(BGCProperties) :: props + + procedure(DataTest), pointer :: engine_DataTest + + call c_f_procpointer(this%c_interface%Setup,engine_DataTest) + call engine_DataTest(props, state, aux_data, num_iterations, ncol) + + end subroutine BGC_Fortran_DataTest + subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer use BGCContainers_module, only : BGCSizes, BGCProperties,& diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index f69042b03..7a4c266ac 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -39,6 +39,10 @@ extern "C" { #endif /* __cplusplus */ +void ecosim_datatest( + BGCProperties* properties +); + void ecosim_setup( BGCProperties* properties, BGCState* state, diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 074f1a352..986274903 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,6 +30,20 @@ ! ! **************************************************************************** ! +subroutine EcoSIM_DataTest(props) bind(c) + + use, intrinsic :: iso_c_binding + + use BGCContainers_module + + implicit none + + type (BGCProperties), intent(in) :: props + + write(*,*) "Okay the properties work" + +end subroutine EcoSIM_DataTest + subroutine EcoSIM_Setup(props, state, aux_data, & num_iterations, ncol) bind(C) From 7cf54e5305b4e4ba1db924cb62fea91a1c6508d3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 5 Jun 2023 16:54:12 -0700 Subject: [PATCH 333/582] minor bugfix --- src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 39ce6cdd5..0968fe44d 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -167,7 +167,7 @@ subroutine BGC_Fortran_DataTest(this, props) procedure(DataTest), pointer :: engine_DataTest call c_f_procpointer(this%c_interface%Setup,engine_DataTest) - call engine_DataTest(props, state, aux_data, num_iterations, ncol) + call engine_DataTest(props) end subroutine BGC_Fortran_DataTest From ea6cba9624dd21bfa7ccf1c200e1abd511276ccd Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 5 Jun 2023 17:12:43 -0700 Subject: [PATCH 334/582] minor bugfix --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 4bf54c851..dd2408c96 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -214,7 +214,7 @@ bool BGCEngine::Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, int& num_iterations, - int& ncol); + int& ncol) { std::cout << "Running BGC Engine Setup" << std::endl; // Advance the chemical reaction all operator-split-like. From bf38f5c1ff976032f1e0677ec9fd718df66fdbc7 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 5 Jun 2023 17:15:32 -0700 Subject: [PATCH 335/582] trying int instead --- src/pks/ecosim_pk/BGCEngine.cc | 6 +++--- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/data/BGC_containers.hh | 2 +- src/pks/ecosim_pk/ecosim_interface.h | 2 +- src/pks/ecosim_pk/ecosim_wrappers.F90 | 5 +++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 4bf54c851..de5e642a4 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -204,17 +204,17 @@ void BGCEngine::FreeState(BGCProperties& props, //FreeAlquimiaAuxiliaryOutputData(&aux_output); } -void BGCEngine::DataTest(BGCProperties& props) { +void BGCEngine::DataTest(int& ncol) { std::cout << "Data test for props" << std::endl; - bgc_.DataTest(&props); + bgc_.DataTest(&ncol); } bool BGCEngine::Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, int& num_iterations, - int& ncol); + int& ncol) { std::cout << "Running BGC Engine Setup" << std::endl; // Advance the chemical reaction all operator-split-like. diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 3225fd29f..855a3f46e 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -70,7 +70,7 @@ class BGCEngine { AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ - void DataTest(BGCProperties& props); + void DataTest(int& ncol); bool Setup(BGCProperties& props, BGCState& state, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 77182f302..f7041d7cb 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -908,7 +908,7 @@ int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - bgc_engine_->DataTest(bgc_props_); + bgc_engine_->DataTest(col); int num_iterations = 1; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index af4af6114..d2cb0071d 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -115,7 +115,7 @@ extern "C" { /* read data files/structures, initialize memory, basis management (includes reading database, swapping basis, etc.) */ void (*DataTest)( - BGCProperties* props + int ncol ); void (*Setup)( diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index 7a4c266ac..48992a848 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -40,7 +40,7 @@ extern "C" { #endif /* __cplusplus */ void ecosim_datatest( - BGCProperties* properties + int ncol ); void ecosim_setup( diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 986274903..252887986 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,7 +30,7 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_DataTest(props) bind(c) +subroutine EcoSIM_DataTest(ncol) bind(c) use, intrinsic :: iso_c_binding @@ -38,7 +38,8 @@ subroutine EcoSIM_DataTest(props) bind(c) implicit none - type (BGCProperties), intent(in) :: props + !type (BGCProperties), intent(in) :: props + integer, intent(in) :: ncol write(*,*) "Okay the properties work" From fb9a393d6d6deca9bf96be2c6ac0b2fbdbf38d58 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 6 Jun 2023 11:16:57 -0700 Subject: [PATCH 336/582] minor change to function call --- src/pks/ecosim_pk/BGCEngine.cc | 4 ++-- src/pks/ecosim_pk/BGCEngine.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index de5e642a4..ff50b2d8c 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -204,10 +204,10 @@ void BGCEngine::FreeState(BGCProperties& props, //FreeAlquimiaAuxiliaryOutputData(&aux_output); } -void BGCEngine::DataTest(int& ncol) { +void BGCEngine::DataTest(int ncol) { std::cout << "Data test for props" << std::endl; - bgc_.DataTest(&ncol); + bgc_.DataTest(ncol); } bool BGCEngine::Setup(BGCProperties& props, diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 855a3f46e..a1b8ff784 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -70,7 +70,7 @@ class BGCEngine { AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ - void DataTest(int& ncol); + void DataTest(int ncol); bool Setup(BGCProperties& props, BGCState& state, From 5080890f1c5c691be5e0a9022919504037daed80 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 6 Jun 2023 12:11:55 -0700 Subject: [PATCH 337/582] minor changes to the data test to keep the data consistent --- src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 4 ++-- src/pks/ecosim_pk/ecosim_wrappers.F90 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 0968fe44d..87b7f50b7 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -162,12 +162,12 @@ subroutine BGC_Fortran_DataTest(this, props) implicit none class(BGCFortranInterface) :: this - type(BGCProperties) :: props + integer(c_int) :: ncol procedure(DataTest), pointer :: engine_DataTest call c_f_procpointer(this%c_interface%Setup,engine_DataTest) - call engine_DataTest(props) + call engine_DataTest(ncol) end subroutine BGC_Fortran_DataTest diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 252887986..16881d285 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -39,9 +39,9 @@ subroutine EcoSIM_DataTest(ncol) bind(c) implicit none !type (BGCProperties), intent(in) :: props - integer, intent(in) :: ncol + integer (c_int), value, intent(in) :: ncol - write(*,*) "Okay the properties work" + write(*,*) "Okay the int passing works" end subroutine EcoSIM_DataTest From c40224975950dea1f1095a799455086bf441676c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 6 Jun 2023 12:33:07 -0700 Subject: [PATCH 338/582] minor bugfix --- src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 87b7f50b7..20fbd83e1 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -155,9 +155,9 @@ subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C contains - subroutine BGC_Fortran_DataTest(this, props) + subroutine BGC_Fortran_DataTest(this, ncol) use, intrinsic :: iso_c_binding - use BGCContainers_module, only : BGCProperties + !use BGCContainers_module, only : BGCProperties implicit none class(BGCFortranInterface) :: this From bb9c5e292313b24e7991fe1008e063bb7ec3cac4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 6 Jun 2023 12:38:50 -0700 Subject: [PATCH 339/582] yet more fixes --- src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 20fbd83e1..28524ad75 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -95,13 +95,14 @@ subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') interface - subroutine DataTest(props) bind(C) + subroutine DataTest(ncol) bind(C) use, intrinsic :: iso_c_binding use BGCContainers_module, only : BGCProperties IMPORT implicit none - type(BGCProperties) :: props + integer(c_int), value :: ncol + !type(BGCProperties) :: props end subroutine end interface From 8f82c580e768e7f3d5d7ed10d081a9bc3492c814 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 10:34:43 -0700 Subject: [PATCH 340/582] changing capitalization because it may matter? --- src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 6 +++--- src/pks/ecosim_pk/ecosim_wrappers.F90 | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 28524ad75..6027d5c57 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -11,7 +11,7 @@ module bgc_fortran_memory_mod implicit none - type, bind(c) :: BGCInterface + type, bind(C) :: BGCInterface type(c_funptr) :: DataTest type(c_funptr) :: Setup @@ -33,7 +33,7 @@ module bgc_fortran_memory_mod interface subroutine CreateBGCInterface(engine_name, bgc_interface) bind(C, name='CreateBGCInterface') - use iso_C_binding, only: c_char + use iso_c_binding, only: c_char IMPORT implicit none character(kind=c_char) :: engine_name(*) @@ -229,7 +229,7 @@ end subroutine BGC_Fortran_Advance subroutine Create_Fortran_BGC_Interface(this,engine_name) use BGCContainers_module, only :kBGCMaxStringLength - use iso_C_binding, only: c_char,c_null_char + use iso_c_binding, only: c_char,c_null_char implicit none class(BGCFortranInterface) :: this character(kind=c_char,len=kBGCMaxStringLength) :: engine_name diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 16881d285..726f4acc1 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,7 +30,7 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_DataTest(ncol) bind(c) +subroutine EcoSIM_DataTest(ncol) bind(C) use, intrinsic :: iso_c_binding @@ -38,7 +38,6 @@ subroutine EcoSIM_DataTest(ncol) bind(c) implicit none - !type (BGCProperties), intent(in) :: props integer (c_int), value, intent(in) :: ncol write(*,*) "Okay the int passing works" From e693a8e7f2002c81f88c76cfbcadb6773ccb6af8 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 10:55:05 -0700 Subject: [PATCH 341/582] trying another data test --- src/pks/ecosim_pk/BGCEngine.cc | 6 +++--- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/data/BGC_containers.hh | 1 - src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 14 ++++---------- src/pks/ecosim_pk/ecosim_interface.h | 1 - src/pks/ecosim_pk/ecosim_wrappers.F90 | 4 ++-- 7 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index ff50b2d8c..0e78e59ef 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -204,10 +204,10 @@ void BGCEngine::FreeState(BGCProperties& props, //FreeAlquimiaAuxiliaryOutputData(&aux_output); } -void BGCEngine::DataTest(int ncol) { +void BGCEngine::DataTest() { - std::cout << "Data test for props" << std::endl; - bgc_.DataTest(ncol); + std::cout << "Data test for calling function" << std::endl; + bgc_.DataTest(); } bool BGCEngine::Setup(BGCProperties& props, diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index a1b8ff784..1479fa84c 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -70,7 +70,7 @@ class BGCEngine { AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ - void DataTest(int ncol); + void DataTest(); bool Setup(BGCProperties& props, BGCState& state, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f7041d7cb..829b85e70 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -908,7 +908,7 @@ int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - bgc_engine_->DataTest(col); + bgc_engine_->DataTest(); int num_iterations = 1; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index d2cb0071d..c1c9eabbf 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -115,7 +115,6 @@ extern "C" { /* read data files/structures, initialize memory, basis management (includes reading database, swapping basis, etc.) */ void (*DataTest)( - int ncol ); void (*Setup)( diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 6027d5c57..d7073d368 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -95,14 +95,11 @@ subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') interface - subroutine DataTest(ncol) bind(C) + subroutine DataTest() bind(C) use, intrinsic :: iso_c_binding - use BGCContainers_module, only : BGCProperties IMPORT implicit none - integer(c_int), value :: ncol - !type(BGCProperties) :: props end subroutine end interface @@ -156,19 +153,16 @@ subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C contains - subroutine BGC_Fortran_DataTest(this, ncol) + subroutine BGC_Fortran_DataTest(this) use, intrinsic :: iso_c_binding - !use BGCContainers_module, only : BGCProperties implicit none class(BGCFortranInterface) :: this - integer(c_int) :: ncol - procedure(DataTest), pointer :: engine_DataTest call c_f_procpointer(this%c_interface%Setup,engine_DataTest) - call engine_DataTest(ncol) + call engine_DataTest() end subroutine BGC_Fortran_DataTest @@ -202,7 +196,7 @@ subroutine BGC_Fortran_Shutdown(this) procedure(Shutdown), pointer :: engine_Shutdown call c_f_procpointer(this%c_interface%Shutdown,engine_Shutdown) - call engine_shutdown() + call engine_Shutdown() end subroutine BGC_Fortran_Shutdown diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index 48992a848..4e68adeab 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -40,7 +40,6 @@ extern "C" { #endif /* __cplusplus */ void ecosim_datatest( - int ncol ); void ecosim_setup( diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 726f4acc1..f0d473980 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -38,9 +38,9 @@ subroutine EcoSIM_DataTest(ncol) bind(C) implicit none - integer (c_int), value, intent(in) :: ncol + !integer (c_int), value, intent(in) :: ncol - write(*,*) "Okay the int passing works" + write(*,*) "Okay calling the function works." end subroutine EcoSIM_DataTest From 2cc8598032b0c3c05aeecd16e5c7ba47226e0bb5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 11:19:40 -0700 Subject: [PATCH 342/582] minor typo --- src/pks/ecosim_pk/ecosim_wrappers.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index f0d473980..4586df555 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,7 +30,7 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_DataTest(ncol) bind(C) +subroutine EcoSIM_DataTest() bind(C) use, intrinsic :: iso_c_binding From d41741a8c3d78a46acbc007663951198423cae4c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 13:03:23 -0700 Subject: [PATCH 343/582] trying the simplest version of the test I can find --- src/pks/ecosim_pk/CMakeLists.txt | 9 ++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 +- src/pks/ecosim_pk/ecosim_mod_test.F90 | 14 ++++++ src/pks/ecosim_pk/ecosim_mod_test_wrapper.c | 42 ++++++++++++++++++ src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 47 +++++++++++++++++++++ 5 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 src/pks/ecosim_pk/ecosim_mod_test.F90 create mode 100644 src/pks/ecosim_pk/ecosim_mod_test_wrapper.c create mode 100644 src/pks/ecosim_pk/ecosim_mod_test_wrapper.h diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 3e45dbfab..a44c7f184 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -22,13 +22,16 @@ set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 + ecosim_mod_test_wrapper.c + ecosim_mod_test.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 ) set(ats_ecosim_inc_files + ecosim_mod_test_wrapper.h EcoSIM_ATS_interface.hh BGCEngine.hh ecosim_interface.h diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 829b85e70..89635b8b0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -908,7 +908,9 @@ int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - bgc_engine_->DataTest(); + std::cout << "running wrapper" << std::endl; + ecosim_datatest_wrapper(); + //bgc_engine_->DataTest(); int num_iterations = 1; diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 new file mode 100644 index 000000000..76f1a622d --- /dev/null +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -0,0 +1,14 @@ +! +! This is a simple test module to test +! running F90 code within the interface +! + +subroutine EcoSIM_DataTest() bind(C) + + use, intrinsic :: iso_c_binding + + implicit none + + write(*,*) "Okay calling the function works." + +end subroutine EcoSIM_DataTest diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c new file mode 100644 index 000000000..8697f59e7 --- /dev/null +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c @@ -0,0 +1,42 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** Alquimia is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + +/******************************************************************************* + ** + ** C declarations of the ecosim interface + ** + ******************************************************************************/ + +#include "ecosim_mod_test_wrapper.h" + +extern void ecosim_datatest(); + +void ecosim_datatest_wrapper() { + ecosim_datatest(); +} diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h new file mode 100644 index 000000000..dc530206b --- /dev/null +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -0,0 +1,47 @@ +/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ + +/* +** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, +** through Lawrence Berkeley National Laboratory (subject to receipt of any +** required approvals from the U.S. Dept. of Energy). All rights reserved. +** +** Alquimia is available under a BSD license. See LICENSE.txt for more +** information. +** +** If you have questions about your rights to use or distribute this software, +** please contact Berkeley Lab's Technology Transfer and Intellectual Property +** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). +** +** NOTICE. This software was developed under funding from the U.S. Department +** of Energy. As such, the U.S. Government has been granted for itself and +** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide +** license in the Software to reproduce, prepare derivative works, and perform +** publicly and display publicly. Beginning five (5) years after the date +** permission to assert copyright is obtained from the U.S. Department of Energy, +** and subject to any subsequent five (5) year renewals, the U.S. Government is +** granted for itself and others acting on its behalf a paid-up, nonexclusive, +** irrevocable, worldwide license in the Software to reproduce, prepare derivative +** works, distribute copies to the public, perform publicly and display publicly, +** and to permit others to do so. +** +** Authors: Benjamin Andre +*/ + +/******************************************************************************* + ** + ** C declarations of the ecosim interface + ** + ******************************************************************************/ + +#ifndef ECOSIM_MOD_TEST_WRAPPER_H +#define ECOSIM_MOD_TEST_WRAPPER_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +void ecosim_datatest(); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ From dbd85c224598be8a030d54d4766118ad41708ef1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 13:19:15 -0700 Subject: [PATCH 344/582] typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index ddd0ca0a8..bb10b3333 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -41,6 +41,7 @@ #include "PK_Factory.hh" #include "pk_physical_default.hh" #include "PK_Physical.hh" +#include "ecosim_mod_test_wrapper.h" namespace Amanzi { From 4e196a6c570e22e5380ffad217fcba8822074d65 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 13:30:49 -0700 Subject: [PATCH 345/582] syntax changes --- src/pks/ecosim_pk/ecosim_mod_test.F90 | 13 ++++++++----- src/pks/ecosim_pk/ecosim_mod_test_wrapper.c | 4 ++-- src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 76f1a622d..2bca18492 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -3,12 +3,15 @@ ! running F90 code within the interface ! -subroutine EcoSIM_DataTest() bind(C) +module ecosim_datatest_mod + implicit none +contains + subroutine ecosim_datatest() bind(C) - use, intrinsic :: iso_c_binding + use, intrinsic :: iso_c_binding - implicit none + write(*,*) "Okay calling the function works." - write(*,*) "Okay calling the function works." + end subroutine EcoSIM_DataTest -end subroutine EcoSIM_DataTest +end module ecosim_datatest_mod diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c index 8697f59e7..357ff31b0 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c @@ -35,8 +35,8 @@ #include "ecosim_mod_test_wrapper.h" -extern void ecosim_datatest(); +extern void ecosim_datatest_(); void ecosim_datatest_wrapper() { - ecosim_datatest(); + ecosim_datatest_(); } diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h index dc530206b..b6401c1b5 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -45,3 +45,5 @@ void ecosim_datatest(); #ifdef __cplusplus } #endif /* __cplusplus */ + +#endif From 60b053ae8c4fe85fd8e3c4d9339baaa63f86b91c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 14:30:45 -0700 Subject: [PATCH 346/582] minor fix to declarations --- src/pks/ecosim_pk/ecosim_mod_test.F90 | 2 +- src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 2bca18492..6d16f0c38 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -12,6 +12,6 @@ subroutine ecosim_datatest() bind(C) write(*,*) "Okay calling the function works." - end subroutine EcoSIM_DataTest + end subroutine ecosim_datatest end module ecosim_datatest_mod diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h index b6401c1b5..7bb89ce8d 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -40,7 +40,7 @@ extern "C" { #endif /* __cplusplus */ -void ecosim_datatest(); +void ecosim_datatest_wrapper(); #ifdef __cplusplus } From fa7c8f3c1e1a8fd9cf883f97c4ea208faf05012a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 14:43:51 -0700 Subject: [PATCH 347/582] removing multiple definitions of the data test --- src/pks/ecosim_pk/ecosim_wrappers.F90 | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 4586df555..074f1a352 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,20 +30,6 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_DataTest() bind(C) - - use, intrinsic :: iso_c_binding - - use BGCContainers_module - - implicit none - - !integer (c_int), value, intent(in) :: ncol - - write(*,*) "Okay calling the function works." - -end subroutine EcoSIM_DataTest - subroutine EcoSIM_Setup(props, state, aux_data, & num_iterations, ncol) bind(C) From 2fb48f5e3f8ead391a7a16e2f8e631c9516abb75 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 15:12:08 -0700 Subject: [PATCH 348/582] changing the mangling conventions --- src/pks/ecosim_pk/ecosim_interface.h | 3 --- src/pks/ecosim_pk/ecosim_mod_test_wrapper.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index 4e68adeab..f69042b03 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -39,9 +39,6 @@ extern "C" { #endif /* __cplusplus */ -void ecosim_datatest( -); - void ecosim_setup( BGCProperties* properties, BGCState* state, diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c index 357ff31b0..8697f59e7 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c @@ -35,8 +35,8 @@ #include "ecosim_mod_test_wrapper.h" -extern void ecosim_datatest_(); +extern void ecosim_datatest(); void ecosim_datatest_wrapper() { - ecosim_datatest_(); + ecosim_datatest(); } From e9fd5cac33ca4121739e21f7de7a9391b4503cd5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 15:19:12 -0700 Subject: [PATCH 349/582] removing previous definitions --- src/pks/ecosim_pk/BGCEngine.cc | 4 +- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/data/BGC_containers.cc | 2 +- src/pks/ecosim_pk/data/BGC_containers.hh | 4 +- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 44 +++++++++---------- 5 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 0e78e59ef..0bdd56767 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -204,11 +204,11 @@ void BGCEngine::FreeState(BGCProperties& props, //FreeAlquimiaAuxiliaryOutputData(&aux_output); } -void BGCEngine::DataTest() { +/*void BGCEngine::DataTest() { std::cout << "Data test for calling function" << std::endl; bgc_.DataTest(); -} +}*/ bool BGCEngine::Setup(BGCProperties& props, BGCState& state, diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 1479fa84c..cf9641234 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -70,7 +70,7 @@ class BGCEngine { AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ - void DataTest(); + //void DataTest(); bool Setup(BGCProperties& props, BGCState& state, diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index cf8d3e854..94cd7ae78 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -42,7 +42,7 @@ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) //interface->Shutdown = NULL; //interface->Advance = NULL; - interface->DataTest = &ecosim_datatest; + //interface->DataTest = &ecosim_datatest; interface->Setup = &ecosim_setup; interface->Shutdown = &ecosim_shutdown; interface->Advance = &ecosim_advance; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index c1c9eabbf..d7cbba51f 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -114,8 +114,8 @@ extern "C" { typedef struct { /* read data files/structures, initialize memory, basis management (includes reading database, swapping basis, etc.) */ - void (*DataTest)( - ); + //void (*DataTest)( + //); void (*Setup)( BGCProperties* properties, diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index d7073d368..fdef08e32 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -13,7 +13,7 @@ module bgc_fortran_memory_mod type, bind(C) :: BGCInterface - type(c_funptr) :: DataTest + !type(c_funptr) :: DataTest type(c_funptr) :: Setup type(c_funptr) :: Shutdown type(c_funptr) :: Advance @@ -25,7 +25,7 @@ module bgc_fortran_memory_mod contains procedure, public :: CreateInterface => Create_Fortran_BGC_Interface - procedure, public :: DataTest => BGC_Fortran_DataTest + !procedure, public :: DataTest => BGC_Fortran_DataTest procedure, public :: Setup => BGC_Fortran_Setup procedure, public :: Shutdown => BGC_Fortran_Shutdown procedure, public :: Advance => BGC_Fortran_Advance @@ -93,16 +93,13 @@ subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') ! The following subroutines are methods of the engine itself - interface - - subroutine DataTest() bind(C) - use, intrinsic :: iso_c_binding - IMPORT - implicit none - - - end subroutine - end interface + !interface + ! subroutine DataTest() bind(C) + ! use, intrinsic :: iso_c_binding + ! IMPORT + ! implicit none + ! end subroutine + !end interface interface @@ -153,18 +150,17 @@ subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C contains - subroutine BGC_Fortran_DataTest(this) - use, intrinsic :: iso_c_binding - - implicit none - class(BGCFortranInterface) :: this - - procedure(DataTest), pointer :: engine_DataTest - - call c_f_procpointer(this%c_interface%Setup,engine_DataTest) - call engine_DataTest() - - end subroutine BGC_Fortran_DataTest + !subroutine BGC_Fortran_DataTest(this) + ! use, intrinsic :: iso_c_binding + ! + ! implicit none + ! class(BGCFortranInterface) :: this + ! procedure(DataTest), pointer :: engine_DataTest + ! + ! call c_f_procpointer(this%c_interface%Setup,engine_DataTest) + ! call engine_DataTest() + ! + !end subroutine BGC_Fortran_DataTest subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer From 4d69bfabcbd1d36af89376b12f6de0a7a1e707b1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 16:56:34 -0700 Subject: [PATCH 350/582] changed to print an int --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/ecosim_mod_test.F90 | 6 ++++-- src/pks/ecosim_pk/ecosim_mod_test_wrapper.c | 6 +++--- src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 89635b8b0..9417f12e8 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -909,7 +909,7 @@ int EcoSIM::InitializeSingleColumn(int col) CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); std::cout << "running wrapper" << std::endl; - ecosim_datatest_wrapper(); + ecosim_datatest_wrapper(col); //bgc_engine_->DataTest(); int num_iterations = 1; diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 6d16f0c38..2b33a51e6 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -6,11 +6,13 @@ module ecosim_datatest_mod implicit none contains - subroutine ecosim_datatest() bind(C) + subroutine ecosim_datatest(col) bind(C) use, intrinsic :: iso_c_binding + integer (c_int), value, intent(in) :: col - write(*,*) "Okay calling the function works." + write(*,*) "Okay calling the ncol function works." + write(*,*) "num col is: ", col end subroutine ecosim_datatest diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c index 8697f59e7..797057af4 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c @@ -35,8 +35,8 @@ #include "ecosim_mod_test_wrapper.h" -extern void ecosim_datatest(); +extern void ecosim_datatest(int* col); -void ecosim_datatest_wrapper() { - ecosim_datatest(); +void ecosim_datatest_wrapper(int* col) { + ecosim_datatest(col); } diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h index 7bb89ce8d..f348f6233 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -40,7 +40,7 @@ extern "C" { #endif /* __cplusplus */ -void ecosim_datatest_wrapper(); +void ecosim_datatest_wrapper(int* col); #ifdef __cplusplus } From 550b0b0e3d3824b01cf65a52f8cb0b70e1308940 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 17:01:50 -0700 Subject: [PATCH 351/582] pointer nonsense --- src/pks/ecosim_pk/ecosim_mod_test_wrapper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c index 797057af4..857647c4b 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c @@ -35,8 +35,8 @@ #include "ecosim_mod_test_wrapper.h" -extern void ecosim_datatest(int* col); +extern void ecosim_datatest(int col); -void ecosim_datatest_wrapper(int* col) { +void ecosim_datatest_wrapper(int col) { ecosim_datatest(col); } From c9f27af7734c37e219a64d947ca9d29e65de8add Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 17:27:54 -0700 Subject: [PATCH 352/582] more pointer nonsense --- src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h index f348f6233..56caee1c3 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -40,7 +40,7 @@ extern "C" { #endif /* __cplusplus */ -void ecosim_datatest_wrapper(int* col); +void ecosim_datatest_wrapper(int col); #ifdef __cplusplus } From ca727797c59daf7fda83ad4a00156e6a2edd62bb Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 17:51:38 -0700 Subject: [PATCH 353/582] adding the properties calls --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/ecosim_mod_test.F90 | 24 +++++++++++++++++++-- src/pks/ecosim_pk/ecosim_mod_test_wrapper.c | 6 +++--- src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 9417f12e8..04990fb80 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -909,7 +909,7 @@ int EcoSIM::InitializeSingleColumn(int col) CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); std::cout << "running wrapper" << std::endl; - ecosim_datatest_wrapper(col); + ecosim_datatest_wrapper(col, bgc_props_); //bgc_engine_->DataTest(); int num_iterations = 1; diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 2b33a51e6..4244ec095 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -4,14 +4,34 @@ ! module ecosim_datatest_mod + use BGCContainers_module, only : BGCProperties, BGCSizes + implicit none + +interface + subroutine AllocateBGCProperties(sizes, props) bind(C, name='AllocateBGCProperties') + use BGCContainers_module, only : BGCSizes, BGCProperties + implicit none + type(BGCSizes) :: sizes + type(BGCProperties) :: props + end subroutine +end interface +interface + subroutine FreeBGCProperties(props) bind(C, name='FreeBGCProperties') + use BGCContainers_module, only : BGCProperties + implicit none + type(BGCProperties) :: props + end subroutine +end interface + contains - subroutine ecosim_datatest(col) bind(C) + subroutine ecosim_datatest(col, props) bind(C) use, intrinsic :: iso_c_binding integer (c_int), value, intent(in) :: col + type(BGCProperties) :: props - write(*,*) "Okay calling the ncol function works." + write(*,*) "Okay calling the props function works." write(*,*) "num col is: ", col end subroutine ecosim_datatest diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c index 857647c4b..d98dde187 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c @@ -35,8 +35,8 @@ #include "ecosim_mod_test_wrapper.h" -extern void ecosim_datatest(int col); +extern void ecosim_datatest(int col, BGCProperties props); -void ecosim_datatest_wrapper(int col) { - ecosim_datatest(col); +void ecosim_datatest_wrapper(int col, BGCProperties props) { + ecosim_datatest(col, props); } diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h index 56caee1c3..bd410fd1d 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -40,7 +40,7 @@ extern "C" { #endif /* __cplusplus */ -void ecosim_datatest_wrapper(int col); +void ecosim_datatest_wrapper(int col, BGCProperties props); #ifdef __cplusplus } From 18a4375175cef3e4faae9359d1d6d8d320224638 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 8 Jun 2023 17:58:34 -0700 Subject: [PATCH 354/582] adding the right headers --- src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h index bd410fd1d..ea06de0be 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -40,6 +40,8 @@ extern "C" { #endif /* __cplusplus */ +#include "data/BGC_containers.hh" + void ecosim_datatest_wrapper(int col, BGCProperties props); #ifdef __cplusplus From 5796a3565d0a035ccb8d904c41df5964ddfab895 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 9 Jun 2023 10:44:32 -0700 Subject: [PATCH 355/582] printing the data from props --- src/pks/ecosim_pk/ecosim_mod_test.F90 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 4244ec095..09b0eeac8 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -33,6 +33,12 @@ subroutine ecosim_datatest(col, props) bind(C) write(*,*) "Okay calling the props function works." write(*,*) "num col is: ", col + write(*,*) "printing the BGCProps data: " + do i = 1, props%size + write(*,*) props%volume%data(i) + end do + + write(*,*) end subroutine ecosim_datatest From 5390455b51a9204d835aca7f979f7f6d259d75b1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 9 Jun 2023 10:49:47 -0700 Subject: [PATCH 356/582] typo --- src/pks/ecosim_pk/ecosim_mod_test.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 09b0eeac8..8221babbf 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -34,7 +34,7 @@ subroutine ecosim_datatest(col, props) bind(C) write(*,*) "Okay calling the props function works." write(*,*) "num col is: ", col write(*,*) "printing the BGCProps data: " - do i = 1, props%size + do i = 1, props%volume%size write(*,*) props%volume%data(i) end do From 415edf8943fc80c0578f77f7c2b02c6b637e2aa7 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 12 Jun 2023 10:48:51 -0700 Subject: [PATCH 357/582] printing size --- src/pks/ecosim_pk/ecosim_mod_test.F90 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 8221babbf..54b733425 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -30,15 +30,21 @@ subroutine ecosim_datatest(col, props) bind(C) use, intrinsic :: iso_c_binding integer (c_int), value, intent(in) :: col type(BGCProperties) :: props + integer :: i + integer :: len write(*,*) "Okay calling the props function works." write(*,*) "num col is: ", col write(*,*) "printing the BGCProps data: " - do i = 1, props%volume%size - write(*,*) props%volume%data(i) - end do + + len = props%volume%size - write(*,*) + write(*,*) "the length is: ", len + !do i = 1, props%volume%size + ! write(*,*) props%volume%data(i) + !end do + + write(*,*) "the properties are finished" end subroutine ecosim_datatest From 44fa7d1098bb8e527ad46ac48d4c5d034e78ec2e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 12 Jun 2023 10:53:57 -0700 Subject: [PATCH 358/582] printing the size in the c++ side as well --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 04990fb80..62145cac7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -909,6 +909,8 @@ int EcoSIM::InitializeSingleColumn(int col) CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); std::cout << "running wrapper" << std::endl; + std::cout << "size: " << bgc_props_.volume.size << std::endl; + ecosim_datatest_wrapper(col, bgc_props_); //bgc_engine_->DataTest(); From 9f00275e795173469cb132df7f8ab9b13273d8a1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 12 Jun 2023 11:37:52 -0700 Subject: [PATCH 359/582] trying a couple modifications --- src/pks/ecosim_pk/CMakeLists.txt | 1 + src/pks/ecosim_pk/ecosim_mod_test.F90 | 20 ++------------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index a44c7f184..47ef0cfcc 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -24,6 +24,7 @@ set(ats_ecosim_src_files ecosim_wrappers.F90 ecosim_mod_test_wrapper.c ecosim_mod_test.F90 + data/bgc_fortran_memory_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 54b733425..e968a4d1a 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -8,22 +8,6 @@ module ecosim_datatest_mod implicit none -interface - subroutine AllocateBGCProperties(sizes, props) bind(C, name='AllocateBGCProperties') - use BGCContainers_module, only : BGCSizes, BGCProperties - implicit none - type(BGCSizes) :: sizes - type(BGCProperties) :: props - end subroutine -end interface -interface - subroutine FreeBGCProperties(props) bind(C, name='FreeBGCProperties') - use BGCContainers_module, only : BGCProperties - implicit none - type(BGCProperties) :: props - end subroutine -end interface - contains subroutine ecosim_datatest(col, props) bind(C) @@ -36,10 +20,10 @@ subroutine ecosim_datatest(col, props) bind(C) write(*,*) "Okay calling the props function works." write(*,*) "num col is: ", col write(*,*) "printing the BGCProps data: " - + len = props%volume%size - write(*,*) "the length is: ", len + write(*,*) "the length is: ", len !do i = 1, props%volume%size ! write(*,*) props%volume%data(i) !end do From 707696b25a6de6d3f0b180ce2f70afce6a8170fd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 12 Jun 2023 15:48:20 -0700 Subject: [PATCH 360/582] testing the size setting modules --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 51 ++++++++++--------- src/pks/ecosim_pk/ecosim_mod_test.F90 | 29 ++++++++++- 3 files changed, 54 insertions(+), 28 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 62145cac7..4151eb5ba 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -911,7 +911,7 @@ int EcoSIM::InitializeSingleColumn(int col) std::cout << "running wrapper" << std::endl; std::cout << "size: " << bgc_props_.volume.size << std::endl; - ecosim_datatest_wrapper(col, bgc_props_); + ecosim_datatest_wrapper(col, bgc_props_, bgc_sizes_); //bgc_engine_->DataTest(); int num_iterations = 1; diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index fdef08e32..4df873a7f 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -106,7 +106,8 @@ subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') subroutine Setup(props, state, aux_data, num_iterations, ncol) bind(C) use, intrinsic :: iso_c_binding, only: c_char, c_bool, c_ptr, c_int - use BGCContainers_module, only : BGCSizes + use BGCContainers_module, only : BGCSizes,BGCProperties,& + BGCState,BGCAuxiliaryData IMPORT implicit none @@ -162,39 +163,39 @@ subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C ! !end subroutine BGC_Fortran_DataTest - subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) - use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer - use BGCContainers_module, only : BGCSizes, BGCProperties,& - BGCState, BGCAuxiliaryData + subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) + use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer + use BGCContainers_module, only : BGCSizes, BGCProperties,& + BGCState, BGCAuxiliaryData - implicit none - class(BGCFortranInterface) :: this + implicit none + class(BGCFortranInterface) :: this - real(c_double) :: delta_t - integer(c_int) :: ncol - integer(c_int) :: num_iterations - type(BGCProperties) :: props - type(BGCState) :: state - type(BGCAuxiliaryData) :: aux_data + real(c_double) :: delta_t + integer(c_int) :: ncol + integer(c_int) :: num_iterations + type(BGCProperties) :: props + type(BGCState) :: state + type(BGCAuxiliaryData) :: aux_data - procedure(Setup), pointer :: engine_Setup + procedure(Setup), pointer :: engine_Setup - call c_f_procpointer(this%c_interface%Setup,engine_Setup) - call engine_Setup(props, state, aux_data, num_iterations, ncol) + call c_f_procpointer(this%c_interface%Setup,engine_Setup) + call engine_Setup(props, state, aux_data, num_iterations, ncol) - end subroutine BGC_Fortran_Setup + end subroutine BGC_Fortran_Setup - subroutine BGC_Fortran_Shutdown(this) - use, intrinsic :: iso_c_binding, only : c_ptr,c_f_procpointer + subroutine BGC_Fortran_Shutdown(this) + use, intrinsic :: iso_c_binding, only : c_ptr,c_f_procpointer - implicit none - class(BGCFortranInterface) :: this - procedure(Shutdown), pointer :: engine_Shutdown + implicit none + class(BGCFortranInterface) :: this + procedure(Shutdown), pointer :: engine_Shutdown - call c_f_procpointer(this%c_interface%Shutdown,engine_Shutdown) - call engine_Shutdown() + call c_f_procpointer(this%c_interface%Shutdown,engine_Shutdown) + call engine_Shutdown() - end subroutine BGC_Fortran_Shutdown + end subroutine BGC_Fortran_Shutdown subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterations, ncol) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index e968a4d1a..c62439a4b 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -8,15 +8,27 @@ module ecosim_datatest_mod implicit none + public :: & + ecosim_datatest + + private :: & + SetBGCSizes + contains - subroutine ecosim_datatest(col, props) bind(C) + subroutine ecosim_datatest(col, props, sizes) bind(C) use, intrinsic :: iso_c_binding + integer (c_int), value, intent(in) :: col - type(BGCProperties) :: props + type(BGCProperties), intent(in) :: props + type(BGCSizes), intent(out) :: sizes integer :: i integer :: len + write(*,*) "calling set sizes" + + call SetBGCSizes(sizes) + write(*,*) "Okay calling the props function works." write(*,*) "num col is: ", col write(*,*) "printing the BGCProps data: " @@ -32,4 +44,17 @@ subroutine ecosim_datatest(col, props) bind(C) end subroutine ecosim_datatest + subroutine SetBGCSizes(sizes) + + use AlquimiaContainers_module, only : BGCSizes + + implicit none + + type (AlquimiaSizes), intent(out) :: sizes + + sizes%ncells_per_col_ = 100 + sizes%num_components = 1 + + end subroutine SetBGCSizes + end module ecosim_datatest_mod From 7799de2d4b81d07212628f6eab10a6f7f8ae7440 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 12 Jun 2023 15:57:49 -0700 Subject: [PATCH 361/582] fixing typos and definitions --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 1 + src/pks/ecosim_pk/ecosim_mod_test.F90 | 4 ++-- src/pks/ecosim_pk/ecosim_mod_test_wrapper.c | 6 +++--- src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index bb10b3333..c9e624f40 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -196,6 +196,7 @@ class EcoSIM : public PK_Physical { BGCState bgc_state_; BGCProperties bgc_props_; BGCAuxiliaryData bgc_aux_data_; + BGCSizes bgc_sizes_; bool bgc_initialized_; bool has_energy, has_gas, has_ice; diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index c62439a4b..307800842 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -46,11 +46,11 @@ end subroutine ecosim_datatest subroutine SetBGCSizes(sizes) - use AlquimiaContainers_module, only : BGCSizes + use BGCContainers_module, only : BGCSizes implicit none - type (AlquimiaSizes), intent(out) :: sizes + type (BGCSizes), intent(out) :: sizes sizes%ncells_per_col_ = 100 sizes%num_components = 1 diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c index d98dde187..dc1dfb1cb 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c @@ -35,8 +35,8 @@ #include "ecosim_mod_test_wrapper.h" -extern void ecosim_datatest(int col, BGCProperties props); +extern void ecosim_datatest(int col, BGCProperties props, BGCSizes sizes); -void ecosim_datatest_wrapper(int col, BGCProperties props) { - ecosim_datatest(col, props); +void ecosim_datatest_wrapper(int col, BGCProperties props, BGCSizes sizes) { + ecosim_datatest(col, props, sizes); } diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h index ea06de0be..e97377626 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -42,7 +42,7 @@ extern "C" { #include "data/BGC_containers.hh" -void ecosim_datatest_wrapper(int col, BGCProperties props); +void ecosim_datatest_wrapper(int col, BGCProperties props, BGCSizes sizes); #ifdef __cplusplus } From 4da6ddd61f2a7f3bb50de61ab35047e41659a90a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 12 Jun 2023 16:54:46 -0700 Subject: [PATCH 362/582] changes some pointer things --- src/pks/ecosim_pk/ecosim_mod_test.F90 | 10 +++++----- src/pks/ecosim_pk/ecosim_mod_test_wrapper.c | 4 ++-- src/pks/ecosim_pk/ecosim_mod_test_wrapper.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index 307800842..fa0711ff9 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -46,14 +46,14 @@ end subroutine ecosim_datatest subroutine SetBGCSizes(sizes) - use BGCContainers_module, only : BGCSizes + use BGCContainers_module, only : BGCSizes - implicit none + implicit none - type (BGCSizes), intent(out) :: sizes + type (BGCSizes), intent(out) :: sizes - sizes%ncells_per_col_ = 100 - sizes%num_components = 1 + sizes%num_components = 1 + sizes%ncells_per_col_ = 100 end subroutine SetBGCSizes diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c index dc1dfb1cb..8048ab0ba 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c @@ -35,8 +35,8 @@ #include "ecosim_mod_test_wrapper.h" -extern void ecosim_datatest(int col, BGCProperties props, BGCSizes sizes); +extern void ecosim_datatest(int col, BGCProperties* props, BGCSizes* sizes); -void ecosim_datatest_wrapper(int col, BGCProperties props, BGCSizes sizes) { +void ecosim_datatest_wrapper(int col, BGCProperties* props, BGCSizes* sizes) { ecosim_datatest(col, props, sizes); } diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h index e97377626..04c7faeed 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h +++ b/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h @@ -42,7 +42,7 @@ extern "C" { #include "data/BGC_containers.hh" -void ecosim_datatest_wrapper(int col, BGCProperties props, BGCSizes sizes); +void ecosim_datatest_wrapper(int col, BGCProperties* props, BGCSizes* sizes); #ifdef __cplusplus } From 77638a55ab027c0133d7786b8224c660831cd790 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 12 Jun 2023 16:58:15 -0700 Subject: [PATCH 363/582] adding some tests --- src/pks/ecosim_pk/ecosim_mod_test.F90 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index fa0711ff9..b5b1e668a 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -4,8 +4,6 @@ ! module ecosim_datatest_mod - use BGCContainers_module, only : BGCProperties, BGCSizes - implicit none public :: & @@ -18,7 +16,8 @@ module ecosim_datatest_mod subroutine ecosim_datatest(col, props, sizes) bind(C) use, intrinsic :: iso_c_binding - + use BGCContainers_module, only : BGCSizes, & + BGCProperties integer (c_int), value, intent(in) :: col type(BGCProperties), intent(in) :: props type(BGCSizes), intent(out) :: sizes @@ -26,6 +25,8 @@ subroutine ecosim_datatest(col, props, sizes) bind(C) integer :: len write(*,*) "calling set sizes" + write(*,*) "does sizes exist?" + write(*,*) sizes%num_components call SetBGCSizes(sizes) From f4a659f69845aac983e264dda988efcf003167d9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 14:02:31 -0700 Subject: [PATCH 364/582] modifications to pointers, and adding the data loop --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/ecosim_mod_test.F90 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4151eb5ba..fd653f5b2 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -911,7 +911,7 @@ int EcoSIM::InitializeSingleColumn(int col) std::cout << "running wrapper" << std::endl; std::cout << "size: " << bgc_props_.volume.size << std::endl; - ecosim_datatest_wrapper(col, bgc_props_, bgc_sizes_); + ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); //bgc_engine_->DataTest(); int num_iterations = 1; diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index b5b1e668a..b29aa2bfc 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -37,9 +37,9 @@ subroutine ecosim_datatest(col, props, sizes) bind(C) len = props%volume%size write(*,*) "the length is: ", len - !do i = 1, props%volume%size - ! write(*,*) props%volume%data(i) - !end do + do i = 1, len + write(*,*) props%volume%data(i) + end do write(*,*) "the properties are finished" From 14408c57d41877671424b289d6f6bf25bd0889df Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 14:18:49 -0700 Subject: [PATCH 365/582] added definitions --- src/pks/ecosim_pk/ecosim_mod_test.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index b29aa2bfc..e54e4eead 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -4,6 +4,8 @@ ! module ecosim_datatest_mod + use BGCContainers_module, only : BGCSizes, & + BGCProperties implicit none public :: & From ff06549ae7ad912cb3e493bdd919292e29d116ec Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 14:53:54 -0700 Subject: [PATCH 366/582] accessing data with c_f_pointer and alloating data --- src/pks/ecosim_pk/CMakeLists.txt | 2 +- src/pks/ecosim_pk/ecosim_mod_test.F90 | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 47ef0cfcc..5872264ac 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -8,7 +8,7 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/data) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/bulk_density) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity) -include_directories(${TPL_INSTALL_PREFIX}/ecosim/f90src/ATSUtils/) +#include_directories(${TPL_INSTALL_PREFIX}/ecosim/f90src/ATSUtils/) include_directories(${ECOSIM_INCLUDE_DIRS}) diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim_pk/ecosim_mod_test.F90 index e54e4eead..cabf297c3 100644 --- a/src/pks/ecosim_pk/ecosim_mod_test.F90 +++ b/src/pks/ecosim_pk/ecosim_mod_test.F90 @@ -25,6 +25,8 @@ subroutine ecosim_datatest(col, props, sizes) bind(C) type(BGCSizes), intent(out) :: sizes integer :: i integer :: len + integer(c_int), pointer :: idata(:) + real (c_double), pointer :: data(:) write(*,*) "calling set sizes" write(*,*) "does sizes exist?" @@ -38,9 +40,10 @@ subroutine ecosim_datatest(col, props, sizes) bind(C) len = props%volume%size + call c_f_pointer(props%volume%data, data, (/len/)) write(*,*) "the length is: ", len do i = 1, len - write(*,*) props%volume%data(i) + write(*,*) data(i) end do write(*,*) "the properties are finished" From 094100bb02296c411d3c37ae6c985ac203a923d4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 16:51:56 -0700 Subject: [PATCH 367/582] changes to pointer calls in Engine --- src/pks/ecosim_pk/BGCEngine.cc | 8 ++++---- src/pks/ecosim_pk/BGCEngine.hh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 0bdd56767..d0742af0a 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -213,8 +213,8 @@ void BGCEngine::FreeState(BGCProperties& props, bool BGCEngine::Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations, - int& ncol) + int num_iterations, + int ncol) { std::cout << "Running BGC Engine Setup" << std::endl; // Advance the chemical reaction all operator-split-like. @@ -236,8 +236,8 @@ bool BGCEngine::Advance(const double delta_time, BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations, - int& ncol) + int num_iterations, + int ncol) { std::cout << "Running BGC Engine Advance" << std::endl; // Advance the chemical reaction all operator-split-like. diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index cf9641234..688d09893 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -75,8 +75,8 @@ class BGCEngine { bool Setup(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations, - int& ncol); + int num_iterations, + int ncol); // Advances the species represented by the given array of concentrations, replacing old values // with new values. The order of the concentrations in the array matches that of the species names @@ -86,8 +86,8 @@ class BGCEngine { BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, - int& num_iterations, - int& ncol); + int num_iterations, + int ncol); //Functions from the alquimia util section, I don't think I need the full code so I think //I can just copy these functions over From 602eb0cd6a08bd2ea9774042feaecf32c299d177 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 17:13:02 -0700 Subject: [PATCH 368/582] more changes to function calls --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 +++---- src/pks/ecosim_pk/ecosim_wrappers.F90 | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index fd653f5b2..db2227a27 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -916,8 +916,7 @@ int EcoSIM::InitializeSingleColumn(int col) int num_iterations = 1; - bgc_engine_->Setup(bgc_props_, bgc_state_, - bgc_aux_data_, num_iterations, col); + bgc_engine_->Setup(&bgc_props_, &bgc_state_, &bgc_sizes_, num_iterations, col); CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); // ETC: hacking to get consistent solution -- if there is no water @@ -945,8 +944,8 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) ADVANCE CALL GOES HERE *******************************************************************/ - bgc_engine_->Advance(dt, bgc_props_, bgc_state_, - bgc_aux_data_, num_iterations, col); + bgc_engine_->Advance(dt, &bgc_props_, &bgc_state_, + &bgc_aux_data_, num_iterations, col); // Move the information back into Amanzi's state, updating the given total concentration vector. CopyEcoSIMStateToAmanzi(col, diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 074f1a352..2fb26dfe4 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,7 +30,7 @@ ! ! **************************************************************************** ! -subroutine EcoSIM_Setup(props, state, aux_data, & +subroutine EcoSIM_Setup(props, state, sizes, & num_iterations, ncol) bind(C) use, intrinsic :: iso_c_binding @@ -42,16 +42,16 @@ subroutine EcoSIM_Setup(props, state, aux_data, & ! function parameters !character(kind=c_char), dimension(*), intent(in) :: input_filename - !type (BGCSizes), intent(out) :: sizes + type (BGCSizes), intent(out) :: sizes type (BGCState), intent(inout) :: state - type (BGCAuxiliaryData), intent(inout) :: aux_data + !type (BGCAuxiliaryData), intent(inout) :: aux_data type (BGCProperties), intent(in) :: props integer :: ncol, jz, js integer, intent(in) :: num_iterations write(*,*) "starting driver transfer ATS2EcoSIMData" - call ATS2EcoSIMData(ncol, state, aux_data, props) + call ATS2EcoSIMData(ncol, state, props, sizes) write(*,*) "starting driver Init_EcoSIM" From 42fe3def7703265624599e98948de534e5985c69 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 17:14:13 -0700 Subject: [PATCH 369/582] removing the test wrapper --- src/pks/ecosim_pk/CMakeLists.txt | 2 -- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 5872264ac..da2e7e4bc 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -22,8 +22,6 @@ set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 - ecosim_mod_test_wrapper.c - ecosim_mod_test.F90 data/bgc_fortran_memory_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index db2227a27..926e3a163 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -911,7 +911,7 @@ int EcoSIM::InitializeSingleColumn(int col) std::cout << "running wrapper" << std::endl; std::cout << "size: " << bgc_props_.volume.size << std::endl; - ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); + //ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); //bgc_engine_->DataTest(); int num_iterations = 1; From fac183e8914d06d4e5d9dd2184dd4d8c513fd817 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 20:29:35 -0700 Subject: [PATCH 370/582] more pointer stuff --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 926e3a163..bd685f032 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -916,7 +916,7 @@ int EcoSIM::InitializeSingleColumn(int col) int num_iterations = 1; - bgc_engine_->Setup(&bgc_props_, &bgc_state_, &bgc_sizes_, num_iterations, col); + bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); // ETC: hacking to get consistent solution -- if there is no water @@ -944,8 +944,8 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) ADVANCE CALL GOES HERE *******************************************************************/ - bgc_engine_->Advance(dt, &bgc_props_, &bgc_state_, - &bgc_aux_data_, num_iterations, col); + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, + bgc_aux_data_, num_iterations, col); // Move the information back into Amanzi's state, updating the given total concentration vector. CopyEcoSIMStateToAmanzi(col, From af824192581fb4966353a512aa252ad52af2c294 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 22:41:14 -0700 Subject: [PATCH 371/582] modified engine to pass sizes --- src/pks/ecosim_pk/BGCEngine.cc | 8 ++++---- src/pks/ecosim_pk/BGCEngine.hh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index d0742af0a..ad53843d5 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -212,7 +212,7 @@ void BGCEngine::FreeState(BGCProperties& props, bool BGCEngine::Setup(BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data, + BGCSizes& sizes, int num_iterations, int ncol) { @@ -220,7 +220,7 @@ bool BGCEngine::Setup(BGCProperties& props, // Advance the chemical reaction all operator-split-like. bgc_.Setup(&props, &state, - &aux_data, + &sizes, num_iterations, ncol); @@ -235,7 +235,7 @@ bool BGCEngine::Setup(BGCProperties& props, bool BGCEngine::Advance(const double delta_time, BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data, + BGCSizes% sizes, int num_iterations, int ncol) { @@ -244,7 +244,7 @@ bool BGCEngine::Advance(const double delta_time, bgc_.Advance(delta_time, &props, &state, - &aux_data, + &sizes, num_iterations, ncol); diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 688d09893..fdd9aed36 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -74,7 +74,7 @@ class BGCEngine { bool Setup(BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data, + BGCSizes& sizes, int num_iterations, int ncol); @@ -85,7 +85,7 @@ class BGCEngine { bool Advance(const double delta_time, BGCProperties& props, BGCState& state, - BGCAuxiliaryData& aux_data, + BGCSizes& sizes, int num_iterations, int ncol); From f4679c5356a64dde41990a2de268cd6c55e4585a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 23:11:29 -0700 Subject: [PATCH 372/582] Many modifications to make sure sizes is defined everywhere --- src/pks/ecosim_pk/BGCEngine.cc | 2 +- src/pks/ecosim_pk/data/BGC_containers.hh | 4 +-- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 28 +++++++++---------- src/pks/ecosim_pk/ecosim_interface.h | 4 +-- src/pks/ecosim_pk/ecosim_wrappers.F90 | 4 +-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index ad53843d5..ab2bf85e6 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -235,7 +235,7 @@ bool BGCEngine::Setup(BGCProperties& props, bool BGCEngine::Advance(const double delta_time, BGCProperties& props, BGCState& state, - BGCSizes% sizes, + BGCSizes& sizes, int num_iterations, int ncol) { diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index d7cbba51f..f067d5f5a 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -120,7 +120,7 @@ extern "C" { void (*Setup)( BGCProperties* properties, BGCState* state, - BGCAuxiliaryData* aux_data, + BGCSizes* sizes, int num_iterations, int ncol); @@ -142,7 +142,7 @@ extern "C" { double delta_t, BGCProperties* properties, BGCState* state, - BGCAuxiliaryData* aux_data, + BGCSizes* sizes, int num_iterations, int ncol); diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 4df873a7f..7a884c3c1 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -103,11 +103,11 @@ subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') interface - subroutine Setup(props, state, aux_data, num_iterations, ncol) bind(C) + subroutine Setup(props, state, sizes, num_iterations, ncol) bind(C) use, intrinsic :: iso_c_binding, only: c_char, c_bool, c_ptr, c_int use BGCContainers_module, only : BGCSizes,BGCProperties,& - BGCState,BGCAuxiliaryData + BGCState IMPORT implicit none @@ -116,7 +116,7 @@ subroutine Setup(props, state, aux_data, num_iterations, ncol) bind(C) type(BGCProperties) :: props type(BGCState) :: state - type(BGCAuxiliaryData) :: aux_data + type(BGCSizes) :: sizes end subroutine end interface @@ -133,10 +133,10 @@ subroutine Shutdown() bind(C) ! take one (or more?) reaction steps in operator split mode interface - subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C) + subroutine Advance(delta_t, props, state, sizes, num_iterations, ncol) bind(C) use, intrinsic :: iso_c_binding, only : c_ptr, c_double, c_int use BGCContainers_module, only : BGCSizes,BGCProperties,& - BGCState,BGCAuxiliaryData + BGCState implicit none real(c_double),VALUE :: delta_t @@ -145,7 +145,7 @@ subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C type(BGCProperties) :: props type(BGCState) :: state - type(BGCAuxiliaryData) :: aux_data + type(BGCSizes) :: sizes end subroutine end interface @@ -163,10 +163,10 @@ subroutine Advance(delta_t, props, state, aux_data, num_iterations, ncol) bind(C ! !end subroutine BGC_Fortran_DataTest - subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) + subroutine BGC_Fortran_Setup(this, props, state, size, num_iterations, ncol) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer use BGCContainers_module, only : BGCSizes, BGCProperties,& - BGCState, BGCAuxiliaryData + BGCState implicit none class(BGCFortranInterface) :: this @@ -176,12 +176,12 @@ subroutine BGC_Fortran_Setup(this, props, state, aux_data, num_iterations, ncol) integer(c_int) :: num_iterations type(BGCProperties) :: props type(BGCState) :: state - type(BGCAuxiliaryData) :: aux_data + type(BGCSizes) :: sizes procedure(Setup), pointer :: engine_Setup call c_f_procpointer(this%c_interface%Setup,engine_Setup) - call engine_Setup(props, state, aux_data, num_iterations, ncol) + call engine_Setup(props, state, sizes, num_iterations, ncol) end subroutine BGC_Fortran_Setup @@ -197,10 +197,10 @@ subroutine BGC_Fortran_Shutdown(this) end subroutine BGC_Fortran_Shutdown - subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterations, ncol) + subroutine BGC_Fortran_Advance(this, delta_t, props, state, sizes, num_iterations, ncol) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer use BGCContainers_module, only : BGCSizes, BGCProperties,& - BGCState, BGCAuxiliaryData + BGCState implicit none class(BGCFortranInterface) :: this @@ -210,12 +210,12 @@ subroutine BGC_Fortran_Advance(this, delta_t, props, state, aux_data, num_iterat integer(c_int) :: num_iterations type(BGCProperties) :: props type(BGCState) :: state - type(BGCAuxiliaryData) :: aux_data + type(BGCSizes) :: sizes procedure(Advance), pointer :: engine_Advance call c_f_procpointer(this%c_interface%Advance,engine_Advance) - call engine_Advance(delta_t, props, state, aux_data, num_iterations, ncol) + call engine_Advance(delta_t, props, state, sizes, num_iterations, ncol) end subroutine BGC_Fortran_Advance subroutine Create_Fortran_BGC_Interface(this,engine_name) diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index f69042b03..a653b8bc0 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -42,7 +42,7 @@ extern "C" { void ecosim_setup( BGCProperties* properties, BGCState* state, - BGCAuxiliaryData* aux_data, + BGCSizes* sizes, int num_iterations, int ncol ); @@ -53,7 +53,7 @@ void ecosim_advance( double delta_t, BGCProperties* properties, BGCState* state, - BGCAuxiliaryData* aux_data, + BGCSizes* sizes, int num_iterations, int ncol ); diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 2fb26dfe4..bc884da9d 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -106,12 +106,12 @@ subroutine EcoSIM_Advance( & real (c_double), value, intent(in) :: delta_t type (BGCProperties), intent(in) :: props type (BGCState), intent(inout) :: state - type (BGCAuxiliaryData), intent(inout) :: aux_data + type (BGCSizes), intent(out) :: sizes !type (BGCEngineStatus), intent(out) :: status integer :: ncol integer, intent(in) :: num_iterations - call ATS2EcoSIMData(ncol, state, aux_data, props) + call ATS2EcoSIMData(ncol, state, props, sizes) call Run_EcoSIM_one_step() From a3861edf334317c9c9994855b8a6425fe5e23e5c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 23:16:15 -0700 Subject: [PATCH 373/582] minor typo --- src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 7a884c3c1..f6eb49c0a 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -163,7 +163,7 @@ subroutine Advance(delta_t, props, state, sizes, num_iterations, ncol) bind(C) ! !end subroutine BGC_Fortran_DataTest - subroutine BGC_Fortran_Setup(this, props, state, size, num_iterations, ncol) + subroutine BGC_Fortran_Setup(this, props, state, sizes, num_iterations, ncol) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer use BGCContainers_module, only : BGCSizes, BGCProperties,& BGCState From 2f9f489d27e89dc1982d8232f788a457c7fdb0d2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 23:20:50 -0700 Subject: [PATCH 374/582] more minor fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/ecosim_wrappers.F90 | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index bd685f032..f07a0e230 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -945,7 +945,7 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) *******************************************************************/ bgc_engine_->Advance(dt, bgc_props_, bgc_state_, - bgc_aux_data_, num_iterations, col); + bgc_sizes_, num_iterations, col); // Move the information back into Amanzi's state, updating the given total concentration vector. CopyEcoSIMStateToAmanzi(col, diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index bc884da9d..a9caa1152 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -92,7 +92,6 @@ subroutine EcoSIM_Advance( & delta_t, & props, & state, & - aux_data, & num_iterations, & ncol) bind(C) From 509a723df696d108446a855dd204c9ab9f00ee09 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jun 2023 23:24:54 -0700 Subject: [PATCH 375/582] fix --- src/pks/ecosim_pk/ecosim_wrappers.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index a9caa1152..34a396e83 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -92,6 +92,7 @@ subroutine EcoSIM_Advance( & delta_t, & props, & state, & + sizes, & num_iterations, & ncol) bind(C) From 01383fa679a0316fce03ab031c9975d5087e37ef Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 14 Jun 2023 12:13:34 -0700 Subject: [PATCH 376/582] adding back in the engine version of the data test --- src/pks/ecosim_pk/BGCEngine.cc | 4 +- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 +-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 + src/pks/ecosim_pk/data/BGC_containers.cc | 2 +- src/pks/ecosim_pk/data/BGC_containers.hh | 3 +- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 40 +++++++++---------- src/pks/ecosim_pk/ecosim_interface.h | 2 + src/pks/ecosim_pk/ecosim_wrappers.F90 | 17 +++++++- 9 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index ab2bf85e6..ba9c471ef 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -204,11 +204,11 @@ void BGCEngine::FreeState(BGCProperties& props, //FreeAlquimiaAuxiliaryOutputData(&aux_output); } -/*void BGCEngine::DataTest() { +void BGCEngine::DataTest() { std::cout << "Data test for calling function" << std::endl; bgc_.DataTest(); -}*/ +} bool BGCEngine::Setup(BGCProperties& props, BGCState& state, diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index fdd9aed36..1bb8fe44b 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -70,7 +70,7 @@ class BGCEngine { AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ - //void DataTest(); + void DataTest(); bool Setup(BGCProperties& props, BGCState& state, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index f07a0e230..e1c38241b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -908,11 +908,10 @@ int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - std::cout << "running wrapper" << std::endl; - std::cout << "size: " << bgc_props_.volume.size << std::endl; + std::cout << "running data test" << std::endl; //ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); - //bgc_engine_->DataTest(); + bgc_engine_->DataTest(); int num_iterations = 1; diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index c9e624f40..0962aef75 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -91,6 +91,8 @@ class EcoSIM : public PK_Physical { virtual std::string name(){return "EcoSIM for ATS";}; + //This is not in the Alquimia_PK, for whatever reason it is defined in + //The Chemistry_PK even though it isn't used there, and then included Teuchos::RCP bgc_engine() { return bgc_engine_; } /*void CopyToEcoSIM(int col, diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index 94cd7ae78..cf8d3e854 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -42,7 +42,7 @@ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) //interface->Shutdown = NULL; //interface->Advance = NULL; - //interface->DataTest = &ecosim_datatest; + interface->DataTest = &ecosim_datatest; interface->Setup = &ecosim_setup; interface->Shutdown = &ecosim_shutdown; interface->Advance = &ecosim_advance; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index f067d5f5a..8605cab00 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -114,8 +114,7 @@ extern "C" { typedef struct { /* read data files/structures, initialize memory, basis management (includes reading database, swapping basis, etc.) */ - //void (*DataTest)( - //); + void (*DataTest)(); void (*Setup)( BGCProperties* properties, diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index f6eb49c0a..4395fec6a 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -13,7 +13,7 @@ module bgc_fortran_memory_mod type, bind(C) :: BGCInterface - !type(c_funptr) :: DataTest + type(c_funptr) :: DataTest type(c_funptr) :: Setup type(c_funptr) :: Shutdown type(c_funptr) :: Advance @@ -25,7 +25,7 @@ module bgc_fortran_memory_mod contains procedure, public :: CreateInterface => Create_Fortran_BGC_Interface - !procedure, public :: DataTest => BGC_Fortran_DataTest + procedure, public :: DataTest => BGC_Fortran_DataTest procedure, public :: Setup => BGC_Fortran_Setup procedure, public :: Shutdown => BGC_Fortran_Shutdown procedure, public :: Advance => BGC_Fortran_Advance @@ -93,13 +93,13 @@ subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') ! The following subroutines are methods of the engine itself - !interface - ! subroutine DataTest() bind(C) - ! use, intrinsic :: iso_c_binding - ! IMPORT - ! implicit none - ! end subroutine - !end interface + interface + subroutine DataTest() bind(C) + use, intrinsic :: iso_c_binding + IMPORT + implicit none + end subroutine + end interface interface @@ -151,17 +151,17 @@ subroutine Advance(delta_t, props, state, sizes, num_iterations, ncol) bind(C) contains - !subroutine BGC_Fortran_DataTest(this) - ! use, intrinsic :: iso_c_binding - ! - ! implicit none - ! class(BGCFortranInterface) :: this - ! procedure(DataTest), pointer :: engine_DataTest - ! - ! call c_f_procpointer(this%c_interface%Setup,engine_DataTest) - ! call engine_DataTest() - ! - !end subroutine BGC_Fortran_DataTest + subroutine BGC_Fortran_DataTest(this) + use, intrinsic :: iso_c_binding + + implicit none + class(BGCFortranInterface) :: this + procedure(DataTest), pointer :: engine_DataTest + + call c_f_procpointer(this%c_interface%Setup,engine_DataTest) + call engine_DataTest() + + end subroutine BGC_Fortran_DataTest subroutine BGC_Fortran_Setup(this, props, state, sizes, num_iterations, ncol) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim_pk/ecosim_interface.h index a653b8bc0..823e12acf 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim_pk/ecosim_interface.h @@ -39,6 +39,8 @@ extern "C" { #endif /* __cplusplus */ +void ecosim_datatest(); + void ecosim_setup( BGCProperties* properties, BGCState* state, diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 34a396e83..3d845c3cb 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -30,6 +30,17 @@ ! ! **************************************************************************** ! +subroutine EcoSIM_DataTest() bind(c) + use, intrinsic :: iso_c_binding + + implicit none + + write(*,*) "in the data test" + + end subroutine EcoSIM_DataTest + +! **************************************************************************** ! + subroutine EcoSIM_Setup(props, state, sizes, & num_iterations, ncol) bind(C) @@ -46,8 +57,10 @@ subroutine EcoSIM_Setup(props, state, sizes, & type (BGCState), intent(inout) :: state !type (BGCAuxiliaryData), intent(inout) :: aux_data type (BGCProperties), intent(in) :: props - integer :: ncol, jz, js + integer, intent(in) :: ncol integer, intent(in) :: num_iterations + integer :: jz + integer :: js write(*,*) "starting driver transfer ATS2EcoSIMData" @@ -108,7 +121,7 @@ subroutine EcoSIM_Advance( & type (BGCState), intent(inout) :: state type (BGCSizes), intent(out) :: sizes !type (BGCEngineStatus), intent(out) :: status - integer :: ncol + integer, intent(in) :: ncol integer, intent(in) :: num_iterations call ATS2EcoSIMData(ncol, state, props, sizes) From 6517ae169b7de83a93083d4c4b2a0b4bb40fa17a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 14 Jun 2023 12:43:22 -0700 Subject: [PATCH 377/582] I don't think it actually creates the engine interface. Fixing --- src/pks/ecosim_pk/BGCEngine.cc | 18 ++++++++++-------- src/pks/ecosim_pk/data/BGC_containers.cc | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index ba9c471ef..9b5307a2b 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -76,6 +76,11 @@ BGCEngine::BGCEngine(const std::string& engineName, { Errors::Message msg; + std::cout << "Engine name is: " << engineName << std::endl; + std::cout << "Creating the BGC Engine interface" << std::endl; + CreateBGCInterface(bgc_engine_name_.c_str(), + &bgc_); + /* bool hands_off = false; if (bgc_engine_name_ == "EcoSIM") hands_off = true; @@ -87,10 +92,7 @@ BGCEngine::BGCEngine(const std::string& engineName, std::cout << "Creating the BGC Engine interface" << std::endl; CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_); - - //std::cout << "Running bgc engine setup" << std::endl; - //bgc_.Setup(bgc_engine_inputfile_.c_str(),&sizes_); - } + }*/ // All alquimia function calls require a status object. // AllocateAlquimiaEngineStatus is in the alquimia code in alquimia_memory.c @@ -212,7 +214,7 @@ void BGCEngine::DataTest() { bool BGCEngine::Setup(BGCProperties& props, BGCState& state, - BGCSizes& sizes, + BGCSizes& sizes_, int num_iterations, int ncol) { @@ -220,7 +222,7 @@ bool BGCEngine::Setup(BGCProperties& props, // Advance the chemical reaction all operator-split-like. bgc_.Setup(&props, &state, - &sizes, + &sizes_, num_iterations, ncol); @@ -235,7 +237,7 @@ bool BGCEngine::Setup(BGCProperties& props, bool BGCEngine::Advance(const double delta_time, BGCProperties& props, BGCState& state, - BGCSizes& sizes, + BGCSizes& sizes_, int num_iterations, int ncol) { @@ -244,7 +246,7 @@ bool BGCEngine::Advance(const double delta_time, bgc_.Advance(delta_time, &props, &state, - &sizes, + &sizes_, num_iterations, ncol); diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index cf8d3e854..b1fc463de 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -41,7 +41,8 @@ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) //interface->Setup = NULL; //interface->Shutdown = NULL; //interface->Advance = NULL; - + std::cout << "Creating Interface" << std::endl; + interface->DataTest = &ecosim_datatest; interface->Setup = &ecosim_setup; interface->Shutdown = &ecosim_shutdown; From 09c6e601a35a100148be44e85dc0954fffbbcba9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 14 Jun 2023 12:48:48 -0700 Subject: [PATCH 378/582] bug --- src/pks/ecosim_pk/data/BGC_containers.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim_pk/data/BGC_containers.cc index b1fc463de..cf8d3e854 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.cc +++ b/src/pks/ecosim_pk/data/BGC_containers.cc @@ -41,8 +41,7 @@ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) //interface->Setup = NULL; //interface->Shutdown = NULL; //interface->Advance = NULL; - std::cout << "Creating Interface" << std::endl; - + interface->DataTest = &ecosim_datatest; interface->Setup = &ecosim_setup; interface->Shutdown = &ecosim_shutdown; From 63c9c505b7fe64756581ecb274484dfb8de44e8f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 21 Jun 2023 14:19:38 -0700 Subject: [PATCH 379/582] adding in the atmospheric abundances --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 43 +++++++++++++++++++++++ src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 ++ src/pks/ecosim_pk/data/BGC_containers.hh | 7 ++++ 3 files changed, 52 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e1c38241b..4424a0dea 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -112,6 +112,15 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); //bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); + //Atmospheric abundance keys + atm_n2_ = plist_->get("atmospheric N2"); + atm_o2_ = plist_->get("atmospheric O2"); + atm_co2_ = plist_->get("atmospheric CO2"); + atm_ch4_ = plist_->get("atmospheric CH4"); + atm_n2o_ = plist_->get("atmospheric N2O"); + atm_h2_ = plist_->get("atmospheric H2"); + atm_nh3e_ = plist_->get("atmospheric NH3"); + // parameters // initial timestep dt_ = plist_->get("initial time step", 1.); @@ -255,6 +264,15 @@ void EcoSIM::Initialize() { S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); + //atm abundances + S_->GetEvaluator(key_atm_n2, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_o2, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_co2, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_ch4, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_n2o, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_h2, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_nh3, Tags::DEFAULT).Update(*S_, name_); + Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; @@ -364,6 +382,15 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + //atm abundances + S_->GetEvaluator(key_atm_n2, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_o2, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_co2, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_ch4, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_n2o, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_h2, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(key_atm_nh3, Tags::DEFAULT).Update(*S_, name_); + if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -431,6 +458,12 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false))(0); } + //Atm abundances + S_->GetEvaluator("atm_n2", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& atm_n2 = *(*S_->Get("atm_n2", tag_next_) + .ViewComponent("cell",false))(0); + + if (has_ice) { S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) @@ -730,6 +763,16 @@ void EcoSIM::CopyToEcoSIM(int col, props.thermal_conductivity.data[i] = (*col_cond)[i]; } + //Fill the atmospheric abundances + //NOTE: probably want to add an if statement here to only do this only once + + props.atm_n2 = atm_n2_; + props.atm_o2 = atm_o2_; + props.atm_co2 = atm_co2_; + props.atm_ch42 = atm_ch4_; + props.atm_n2o = atm_n2o_; + props.atm_h2 = atm_h2_; + props.atm_nh3 = atm_nh3_; } //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 0962aef75..99a75a031 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -194,6 +194,8 @@ class EcoSIM : public PK_Physical { Teuchos::RCP bgc_engine_; + double atm_n2_, atm_o2_, atm_co2_, atm_ch4, atm_n2o_, atm_h2_, atm_nh3_; + private: BGCState bgc_state_; BGCProperties bgc_props_; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 8605cab00..784092edd 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -104,6 +104,13 @@ extern "C" { BGCVectorDouble relative_permeability; BGCVectorDouble thermal_conductivity; BGCVectorDouble volume; + double atm_n2; + double atm_o2; + double atm_co2; + double atm_ch4; + double atm_n2o; + double atm_h2; + double atm_nh3; } BGCProperties; typedef struct { From 8278100b6a63ade996d78a573dd65d9f923eaffd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 21 Jun 2023 14:39:16 -0700 Subject: [PATCH 380/582] various bugfixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 22 ++-------------------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4424a0dea..45c5bb887 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -119,7 +119,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, atm_ch4_ = plist_->get("atmospheric CH4"); atm_n2o_ = plist_->get("atmospheric N2O"); atm_h2_ = plist_->get("atmospheric H2"); - atm_nh3e_ = plist_->get("atmospheric NH3"); + atm_nh3_ = plist_->get("atmospheric NH3"); // parameters // initial timestep @@ -264,15 +264,6 @@ void EcoSIM::Initialize() { S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); - //atm abundances - S_->GetEvaluator(key_atm_n2, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_o2, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_co2, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_ch4, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_n2o, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_h2, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_nh3, Tags::DEFAULT).Update(*S_, name_); - Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; @@ -382,15 +373,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); - //atm abundances - S_->GetEvaluator(key_atm_n2, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_o2, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_co2, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_ch4, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_n2o, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_h2, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(key_atm_nh3, Tags::DEFAULT).Update(*S_, name_); - if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -769,7 +751,7 @@ void EcoSIM::CopyToEcoSIM(int col, props.atm_n2 = atm_n2_; props.atm_o2 = atm_o2_; props.atm_co2 = atm_co2_; - props.atm_ch42 = atm_ch4_; + props.atm_ch4 = atm_ch4_; props.atm_n2o = atm_n2o_; props.atm_h2 = atm_h2_; props.atm_nh3 = atm_nh3_; diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 99a75a031..a37377b37 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -194,7 +194,7 @@ class EcoSIM : public PK_Physical { Teuchos::RCP bgc_engine_; - double atm_n2_, atm_o2_, atm_co2_, atm_ch4, atm_n2o_, atm_h2_, atm_nh3_; + double atm_n2_, atm_o2_, atm_co2_, atm_ch4_, atm_n2o_, atm_h2_, atm_nh3_; private: BGCState bgc_state_; From bab9ea69d622b91f81899fb5e63a86e1eaa3cd31 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 22 Jun 2023 13:51:56 -0700 Subject: [PATCH 381/582] adding the surface properties to the code --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 69 ++++++++++++++++++++++- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 6 ++ src/pks/ecosim_pk/data/BGC_containers.hh | 6 ++ 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 45c5bb887..9361b851a 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -112,6 +112,17 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); //bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); + //Surface balance items + sw_key_ = + Keys::readKey(plist, domain_surf_, "incoming shortwave radiation", "incoming_shortwave_radiation"); + lw_key_ = + Keys::readKey(plist, domain_, "incoming longwave radiation", "incoming_longwave_radiation"); + air_temp_key_ = Keys::readKey(plist, domain_surf_, "air temperature", "air_temperature"); + vp_air_key_ = Keys::readKey(plist, domain_surf_, "vapor pressure air", "vapor_pressure_air"); + wind_speed_key_ = Keys::readKey(plist, domain_surf_, "wind speed", "wind_speed"); + prain_key_ = Keys::readKey(plist, domain_surf_, "precipitation rain", "precipitation_rain"); + //psnow_key_ = Keys::readKey(plist, domain_surf_, "precipitation snow", "precipitation"); + //Atmospheric abundance keys atm_n2_ = plist_->get("atmospheric N2"); atm_o2_ = plist_->get("atmospheric O2"); @@ -267,6 +278,14 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; + //Surface properties from met data + S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); + //Here we put the checks for the optional keys //Temperature, ice and gas //plist_->print(std::cout); @@ -373,6 +392,14 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + //Surface data from met data + S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); + if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -441,10 +468,29 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { } //Atm abundances - S_->GetEvaluator("atm_n2", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& atm_n2 = *(*S_->Get("atm_n2", tag_next_) + S_->GetEvaluator("incoming_shortwave_radiation", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& sw_rad = *(*S_->Get("incoming_shortwave_radiation", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("incoming_longwave_radiation", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& lw_rad = *(*S_->Get("incoming_longwave_radiation", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("air_temperature", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& t_air = *(*S_->Get("air_temperature", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("vapor_pressure_air", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& p_vap = *(*S_->Get("vapor_pressure_air", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("wind_speed", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& v_wind = *(*S_->Get("wind_speed", tag_next_) .ViewComponent("cell",false))(0); + S_->GetEvaluator("precipitation_rain", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& p_rain = *(*S_->Get("precipitation_rain", tag_next_) + .ViewComponent("cell",false))(0); if (has_ice) { S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); @@ -629,6 +675,16 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); + //I think I can access the surface variables with col variable and it should + //be what I want + const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& precipitation = *(*S_->Get(prain_key_, water_tag).ViewComponent("cell", false))(0); + + //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -745,9 +801,16 @@ void EcoSIM::CopyToEcoSIM(int col, props.thermal_conductivity.data[i] = (*col_cond)[i]; } + //fill surface variables + props.shortwave_radiation = shortwave_radiation[col]; + props.longwave_radiation = longwave_radiation[col]; + props.air_temperature = air_temperature[col]; + props.vapor_pressure_air = vapor_pressure_air[col]; + props.wind_speed = wind_speed[col]; + props.precipitation = precipitation[col]; + //Fill the atmospheric abundances //NOTE: probably want to add an if statement here to only do this only once - props.atm_n2 = atm_n2_; props.atm_o2 = atm_o2_; props.atm_co2 = atm_co2_; diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index a37377b37..f8ac0e34c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -191,6 +191,12 @@ class EcoSIM : public PK_Physical { Key ecosim_aux_data_key_; Key bulk_dens_key_; Key hydra_cond_key_; + Key sw_key_; + Key lw_key_; + Key air_temp_key_; + Key vp_air_key_; + Key wind_speed_key_; + Key prain_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 784092edd..d3e434c42 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -104,6 +104,12 @@ extern "C" { BGCVectorDouble relative_permeability; BGCVectorDouble thermal_conductivity; BGCVectorDouble volume; + double shortwave_radiation; + double longwave_radiation; + double air_temperature; + double vapor_pressure_air; + double wind_speed; + double precipitation; double atm_n2; double atm_o2; double atm_co2; From 321233a630f7959d6b926b2b28404bcfee6b8f24 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 22 Jun 2023 14:21:27 -0700 Subject: [PATCH 382/582] bugfix --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 9361b851a..d0ba7974a 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -114,13 +114,13 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //Surface balance items sw_key_ = - Keys::readKey(plist, domain_surf_, "incoming shortwave radiation", "incoming_shortwave_radiation"); + Keys::readKey(*plist_, domain_surf_, "incoming shortwave radiation", "incoming_shortwave_radiation"); lw_key_ = - Keys::readKey(plist, domain_, "incoming longwave radiation", "incoming_longwave_radiation"); - air_temp_key_ = Keys::readKey(plist, domain_surf_, "air temperature", "air_temperature"); - vp_air_key_ = Keys::readKey(plist, domain_surf_, "vapor pressure air", "vapor_pressure_air"); - wind_speed_key_ = Keys::readKey(plist, domain_surf_, "wind speed", "wind_speed"); - prain_key_ = Keys::readKey(plist, domain_surf_, "precipitation rain", "precipitation_rain"); + Keys::readKey(*plist_,domain_surf_, "incoming longwave radiation", "incoming_longwave_radiation"); + air_temp_key_ = Keys::readKey(*plist_, domain_surf_, "air temperature", "air_temperature"); + vp_air_key_ = Keys::readKey(*plist_, domain_surf_, "vapor pressure air", "vapor_pressure_air"); + wind_speed_key_ = Keys::readKey(*plist_, domain_surf_, "wind speed", "wind_speed"); + prain_key_ = Keys::readKey(*plist_, domain_surf_, "precipitation rain", "precipitation_rain"); //psnow_key_ = Keys::readKey(plist, domain_surf_, "precipitation snow", "precipitation"); //Atmospheric abundance keys From 4b7ec9c3a0218d920066c2230852bf37d50e6a80 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 27 Jun 2023 13:23:28 -0700 Subject: [PATCH 383/582] changed tags on surface evaluators --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d0ba7974a..bad120187 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -279,12 +279,12 @@ void EcoSIM::Initialize() { *vo_->os() << "testing keys" << std::endl; //Surface properties from met data - S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(sw_key_, tag_next_).Update(*S_, name_); + S_->GetEvaluator(lw_key_, tag_next_).Update(*S_, name_); + S_->GetEvaluator(air_temp_key_, tag_next_).Update(*S_, name_); + S_->GetEvaluator(vp_air_key_, tag_next_).Update(*S_, name_); + S_->GetEvaluator(wind_speed_key_, tag_next_).Update(*S_, name_); + S_->GetEvaluator(prain_key_, tag_next_).Update(*S_, name_); //Here we put the checks for the optional keys //Temperature, ice and gas From 00b7d8c3b7b21bddf34121beb4ce25580091fd9e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 27 Jun 2023 13:48:30 -0700 Subject: [PATCH 384/582] changing to tag current --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index bad120187..30b637139 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -279,12 +279,12 @@ void EcoSIM::Initialize() { *vo_->os() << "testing keys" << std::endl; //Surface properties from met data - S_->GetEvaluator(sw_key_, tag_next_).Update(*S_, name_); - S_->GetEvaluator(lw_key_, tag_next_).Update(*S_, name_); - S_->GetEvaluator(air_temp_key_, tag_next_).Update(*S_, name_); - S_->GetEvaluator(vp_air_key_, tag_next_).Update(*S_, name_); - S_->GetEvaluator(wind_speed_key_, tag_next_).Update(*S_, name_); - S_->GetEvaluator(prain_key_, tag_next_).Update(*S_, name_); + S_->GetEvaluator(sw_key_, Tags::CURRENT).Update(*S_, name_); + S_->GetEvaluator(lw_key_, Tags::CURRENT).Update(*S_, name_); + S_->GetEvaluator(air_temp_key_, Tags::CURRENT).Update(*S_, name_); + S_->GetEvaluator(vp_air_key_, Tags::CURRENT).Update(*S_, name_); + S_->GetEvaluator(wind_speed_key_, Tags::CURRENT).Update(*S_, name_); + S_->GetEvaluator(prain_key_, Tags::CURRENT).Update(*S_, name_); //Here we put the checks for the optional keys //Temperature, ice and gas From 04fdf5dc5316f272c2ce87317f63d7fc166e954f Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 28 Jun 2023 16:51:12 -0700 Subject: [PATCH 385/582] minor fixes for the surface runs --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 30b637139..bafc91bd9 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -279,12 +279,12 @@ void EcoSIM::Initialize() { *vo_->os() << "testing keys" << std::endl; //Surface properties from met data - S_->GetEvaluator(sw_key_, Tags::CURRENT).Update(*S_, name_); - S_->GetEvaluator(lw_key_, Tags::CURRENT).Update(*S_, name_); - S_->GetEvaluator(air_temp_key_, Tags::CURRENT).Update(*S_, name_); - S_->GetEvaluator(vp_air_key_, Tags::CURRENT).Update(*S_, name_); - S_->GetEvaluator(wind_speed_key_, Tags::CURRENT).Update(*S_, name_); - S_->GetEvaluator(prain_key_, Tags::CURRENT).Update(*S_, name_); + S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); //Here we put the checks for the optional keys //Temperature, ice and gas @@ -920,7 +920,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, } if (has_energy) { - auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "energy").ViewComponent("cell",false))(0); + auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "subsurface energy").ViewComponent("cell",false))(0); auto& thermal_conductivity = *(*S_->GetW(therm_cond_key_, Amanzi::Tags::NEXT, therm_cond_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { From 71a0f594eb560ec1a9c3a812a3f32f72f03581f0 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 29 Jun 2023 11:14:13 -0700 Subject: [PATCH 386/582] added some simple testing of data --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index bafc91bd9..8e5a07033 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -281,7 +281,7 @@ void EcoSIM::Initialize() { //Surface properties from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); @@ -944,14 +944,24 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_vol)[i] = props.volume.data[i]; } + *vo_->os() << "printing volume: " << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "i "<< i << "col[i]: " << (*col_vol)[i] << " data[i]: " << props.volume.data[i] << std::endl; + } + + *vo_->os() << "printing water content: " << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "i "<< i << "col[i]: " << (*col_wc)[i] << " data[i]: " << state.water_content.data[i] << std::endl; + } + //Take new values from Ecosim state and put them into the secondary data structure //for backing back into amanzi state for (int j=0; j < tcc_num; ++j) { - *vo_->os() << "component: "<< j << std::endl; + //*vo_->os() << "component: "<< j << std::endl; for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "cell: "<< i << std::endl; - *vo_->os() << "col arr: "<< (*col_tcc)(i,j) << std::endl; - *vo_->os() << "m_arr: "<< state.total_component_concentration.data[j][i] << std::endl; + //*vo_->os() << "cell: "<< i << std::endl; + //*vo_->os() << "col arr: "<< (*col_tcc)(i,j) << std::endl; + //*vo_->os() << "m_arr: "<< state.total_component_concentration.data[j][i] << std::endl; (*col_tcc)(i,j) = state.total_component_concentration.data[j][i]; } } From 7c6aabd92618617fadfaf1d6f4d03a78e20ddb4f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 29 Jun 2023 13:12:32 -0700 Subject: [PATCH 387/582] test to compare data at the beginning and end --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 8e5a07033..4a995e0a0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -702,7 +702,8 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - + auto col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); @@ -722,6 +723,9 @@ void EcoSIM::CopyToEcoSIM(int col, MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); + + FieldToColumn_(col,cell_volume,col_vol_save.ptr()); + FieldToColumn_(col,water_content,col_wc_save.ptr()); /**vo_->os() << "Total Comp: " << tcc_num << std::endl; *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; for (int i=0; i < tcc_num; ++i) { @@ -892,6 +896,9 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); @@ -946,12 +953,12 @@ void EcoSIM::CopyFromEcoSIM(const int col, *vo_->os() << "printing volume: " << std::endl; for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "i "<< i << "col[i]: " << (*col_vol)[i] << " data[i]: " << props.volume.data[i] << std::endl; + *vo_->os() << "i "<< i << " col[i]: " << (*col_vol_save)[i] << " data[i]: " << props.volume.data[i] << std::endl; } *vo_->os() << "printing water content: " << std::endl; for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "i "<< i << "col[i]: " << (*col_wc)[i] << " data[i]: " << state.water_content.data[i] << std::endl; + *vo_->os() << "i "<< i << " col[i]: " << (*col_wc_save)[i] << " data[i]: " << state.water_content.data[i] << std::endl; } //Take new values from Ecosim state and put them into the secondary data structure From 3ac315f3f605078bc52470a0a3385f36ac4fef0b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 29 Jun 2023 13:32:59 -0700 Subject: [PATCH 388/582] over wrote test array accidentally --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4a995e0a0..0b7b38501 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -896,9 +896,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); From 354ca55a110c4f818fe1d1331519656012f0cca9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 29 Jun 2023 13:42:14 -0700 Subject: [PATCH 389/582] adding to header so it's global? --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0b7b38501..cd3fa8824 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -702,8 +702,8 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + Teuchos::RCP col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + Teuchos::RCP col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index f8ac0e34c..b7dcdf778 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -208,6 +208,9 @@ class EcoSIM : public PK_Physical { BGCAuxiliaryData bgc_aux_data_; BGCSizes bgc_sizes_; + Teuchos::RCP col_vol_save; + Teuchos::RCP col_wc_save; + bool bgc_initialized_; bool has_energy, has_gas, has_ice; std::vector component_names_; From cff02ebb44df114f56fedc5587c871732cdd3d1f Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 29 Jun 2023 15:30:04 -0700 Subject: [PATCH 390/582] fixed the data holders for test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index cd3fa8824..3707b7797 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -702,8 +702,8 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - Teuchos::RCP col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - Teuchos::RCP col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //For the concentration I do not want a vector but a matrix auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); From f5ff1da5b8f47697ffac084ed31579aa4e98570a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 29 Jun 2023 16:07:46 -0700 Subject: [PATCH 391/582] added copy back to wrapper --- src/pks/ecosim_pk/ecosim_wrappers.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 3d845c3cb..42062c28e 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -39,7 +39,7 @@ subroutine EcoSIM_DataTest() bind(c) end subroutine EcoSIM_DataTest -! **************************************************************************** ! +! **************************************************************************** ! subroutine EcoSIM_Setup(props, state, sizes, & num_iterations, ncol) bind(C) @@ -72,7 +72,7 @@ subroutine EcoSIM_Setup(props, state, sizes, & write(*,*) "starting driver transfer EcoSIM2ATSData" - !call EcoSIM2ATSData() + call EcoSIM2ATSData(ncol, state, sizes) end subroutine EcoSIM_Setup From 5ecc58a27c923aecb3f762a2b3da9ab58f6ce075 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Jul 2023 14:53:26 -0700 Subject: [PATCH 392/582] Added new variables including bulk density, elevation, ect. --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 70 ++++++++++++++--------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 1 + src/pks/ecosim_pk/data/BGC_containers.hh | 5 ++ src/pks/ecosim_pk/data/BGC_memory.cc | 4 ++ 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3707b7797..051ba6914 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -82,7 +82,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_liquid_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); saturation_gas_key_ = Keys::readKey(*plist_,domain_,"saturation gas", "saturation_gas"); saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); - //elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); @@ -110,7 +109,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //Evaluator keys hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); - //bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); + bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); //Surface balance items sw_key_ = @@ -121,6 +120,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, vp_air_key_ = Keys::readKey(*plist_, domain_surf_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surf_, "wind speed", "wind_speed"); prain_key_ = Keys::readKey(*plist_, domain_surf_, "precipitation rain", "precipitation_rain"); + f_wp_key_ = Keys::readKey(plist_, domain_, "plant wilting factor", "plant_wilting_factor"); + elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); //psnow_key_ = Keys::readKey(plist, domain_surf_, "precipitation snow", "precipitation"); //Atmospheric abundance keys @@ -225,7 +226,7 @@ void EcoSIM::Setup() { requireAtCurrent(hydra_cond_key_, tag_current_, *S_, name_); - /*requireAtNext(bulk_dens_key_, tag_next_, *S_) + requireAtNext(bulk_dens_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); @@ -269,7 +270,6 @@ void EcoSIM::Initialize() { S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); - //S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -285,6 +285,8 @@ void EcoSIM::Initialize() { S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); //Here we put the checks for the optional keys //Temperature, ice and gas @@ -328,13 +330,11 @@ void EcoSIM::Initialize() { } //Initialize owned evaluators - //*vo_->os() << "Getting hydraulic conductivity" << std::endl; S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); - //*vo_->os() << "recording to hydraulic" << std::endl; S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); - //S_->GetW(bulk_dens_key_, tag_next_, name_).PutScalar(1.0); - //S_->GetRecordW(bulk_dens_key_, tag_next_, name_).set_initialized(); + S_->GetW(bulk_dens_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); + S_->GetRecordW(bulk_dens_key_, Tags::DEFAULT, "bulk_density").set_initialized(); int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -384,7 +384,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); - //S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); @@ -399,6 +398,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); @@ -419,8 +420,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { Teuchos::RCP hydra_cond = S_->GetPtr(hydra_cond_key_, Tags::DEFAULT); S_->GetEvaluator(hydra_cond_key_, Tags::DEFAULT).Update(*S_, name_); - //Teuchos::RCP bulk_dens = S_->GetPtr(bulk_dens_key_, Tags::DEFAULT); - //S_->GetEvaluator(bulk_dens_key_, Tags::DEFAULT).Update(*S_, name_); + Teuchos::RCP bulk_dens = S_->GetPtr(bulk_dens_key_, Tags::DEFAULT); + S_->GetEvaluator(bulk_dens_key_, Tags::DEFAULT).Update(*S_, name_); AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -433,10 +434,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& liquid_saturation = *(*S_->Get("saturation_liquid", tag_next_) .ViewComponent("cell",false))(0); - //S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) - // .ViewComponent("cell",false); - S_->GetEvaluator("water_content", tag_next_).Update(*S_, name_); const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); @@ -492,6 +489,14 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& p_rain = *(*S_->Get("precipitation_rain", tag_next_) .ViewComponent("cell",false))(0); + S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("plant_wilting_factor", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) + .ViewComponent("cell",false); + if (has_ice) { S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) @@ -667,14 +672,13 @@ void EcoSIM::CopyToEcoSIM(int col, int tcc_num = tcc.NumVectors(); const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& elevation = *S_->Get(elev_key_, water_tag).ViewComponent("cell", false); const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& relative_permeability = *(*S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); - + const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydra_cond_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); //I think I can access the surface variables with col variable and it should //be what I want const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); @@ -683,12 +687,12 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& precipitation = *(*S_->Get(prain_key_, water_tag).ViewComponent("cell", false))(0); - + const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -697,10 +701,13 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_));\ + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_depth = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -713,17 +720,16 @@ void EcoSIM::CopyToEcoSIM(int col, //FieldToColumn_(column index, dataset to copy from, vector to put the data in) FieldToColumn_(col,porosity,col_poro.ptr()); FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); - //FieldToColumn_(col,elevation,col_elev.ptr()); FieldToColumn_(col,water_content,col_wc.ptr()); FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); FieldToColumn_(col,liquid_density,col_l_dens.ptr()); FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); FieldToColumn_(col,hydraulic_conductivity,col_h_cond.ptr()); + FieldToColumn_(col,bulk_density,col_b_dens.ptr()); MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); - FieldToColumn_(col,cell_volume,col_vol_save.ptr()); FieldToColumn_(col,water_content,col_wc_save.ptr()); /**vo_->os() << "Total Comp: " << tcc_num << std::endl; @@ -740,8 +746,6 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,Teuchos::ptr(&tcc_comp),Teuchos::ptr(&col_comp)); }*/ - - if (has_gas) { const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); @@ -766,6 +770,10 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,thermal_conductivity,col_cond.ptr()); } + //Initializing depth here, because it's calculated by a function and not saved in state + //it works a bit differently: + ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); + // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this // have to fill tcc separately (I think) @@ -785,10 +793,12 @@ void EcoSIM::CopyToEcoSIM(int col, state.porosity.data[i] = (*col_poro)[i]; state.water_content.data[i] = (*col_wc)[i]; state.hydraulic_conductivity.data[i] = (*col_h_cond)[i]; + state.bulk_density.data[i] = (*col_b_dens)[i]; props.liquid_saturation.data[i] = (*col_l_sat)[i]; - //props.elevation.data[i] = (*col_elev)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; props.volume.data[i] = (*col_vol)[i]; + props.depth.data[i] = (*col_depth)[i]; + props.dz.data[i] = (*col_dz)[i]; if (has_gas) { props.gas_saturation.data[i] = (*col_g_sat)[i]; @@ -812,6 +822,8 @@ void EcoSIM::CopyToEcoSIM(int col, props.vapor_pressure_air = vapor_pressure_air[col]; props.wind_speed = wind_speed[col]; props.precipitation = precipitation[col]; + props.plant_wilting_factor = plant_wilting_factor[col] + props.elevation = elevation[col] //Fill the atmospheric abundances //NOTE: probably want to add an if statement here to only do this only once @@ -876,7 +888,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); auto& hydraulic_conductivity = *(*S_->GetW(hydra_cond_key_, Amanzi::Tags::NEXT, hydra_cond_key_).ViewComponent("cell",false))(0); - + auto& bulk_density = *(*S_->GetW(bulk_dens_key_), Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -895,6 +907,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); @@ -945,6 +958,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_rel_perm)[i] = props.relative_permeability.data[i]; (*col_cond)[i] = props.thermal_conductivity.data[i]; (*col_h_cond)[i] = state.hydraulic_conductivity.data[i]; + (*col_b_dens)[i] = state.bulk_density.data[i]; (*col_vol)[i] = props.volume.data[i]; } @@ -999,7 +1013,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,rock_density,col_r_dens.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); ColumnToField_(col,hydraulic_conductivity,col_h_cond.ptr()); - + ColumnToField_(col,bulk_density,col_b_dens.ptr()); MatrixColumnToField_(col, tcc, col_tcc.ptr()); } diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index b7dcdf778..8df45ab2e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -197,6 +197,7 @@ class EcoSIM : public PK_Physical { Key vp_air_key_; Key wind_speed_key_; Key prain_key_; + Key f_wp_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index d3e434c42..d29a6fd06 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -93,6 +93,7 @@ extern "C" { BGCVectorDouble temperature; BGCVectorDouble total_mobile; BGCVectorDouble hydraulic_conductivity; + BGCVectorDouble bulk_density BGCMatrixDouble total_component_concentration; } BGCState; @@ -104,12 +105,16 @@ extern "C" { BGCVectorDouble relative_permeability; BGCVectorDouble thermal_conductivity; BGCVectorDouble volume; + BGCVectorDouble depth; + BGCVectorDouble dz; double shortwave_radiation; double longwave_radiation; double air_temperature; double vapor_pressure_air; double wind_speed; double precipitation; + double plant_wilting_factor; + double elevation double atm_n2; double atm_o2; double atm_co2; diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 699190ef8..b7233fe4f 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -262,6 +262,7 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->hydraulic_conductivity)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->bulk_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_,sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); @@ -276,6 +277,7 @@ void FreeBGCState(BGCState* state) { FreeBGCVectorDouble(&(state->water_content)); FreeBGCVectorDouble(&(state->temperature)); FreeBGCVectorDouble(&(state->hydraulic_conductivity)); + FreeBGCVectorDouble(&(state->bulk_density)); FreeBGCMatrixDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ @@ -320,6 +322,8 @@ void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->thermal_conductivity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->depth)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->dz)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { From 47277b6057a1a60ee47c9a9002db265ec3d565e2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Jul 2023 15:48:12 -0700 Subject: [PATCH 393/582] bug fix --- src/pks/ecosim_pk/data/BGC_containers.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index d29a6fd06..4815d90e3 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -93,7 +93,7 @@ extern "C" { BGCVectorDouble temperature; BGCVectorDouble total_mobile; BGCVectorDouble hydraulic_conductivity; - BGCVectorDouble bulk_density + BGCVectorDouble bulk_density; BGCMatrixDouble total_component_concentration; } BGCState; @@ -114,7 +114,7 @@ extern "C" { double wind_speed; double precipitation; double plant_wilting_factor; - double elevation + double elevation; double atm_n2; double atm_o2; double atm_co2; From ad2b12f5b30a83d09176dbc0379144582a8c339e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Jul 2023 16:09:48 -0700 Subject: [PATCH 394/582] minor typo --- src/pks/ecosim_pk/data/BGC_containers.hh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 4815d90e3..0446ea9db 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -101,7 +101,6 @@ extern "C" { BGCVectorDouble liquid_saturation; BGCVectorDouble gas_saturation; BGCVectorDouble ice_saturation; - BGCVectorDouble elevation; BGCVectorDouble relative_permeability; BGCVectorDouble thermal_conductivity; BGCVectorDouble volume; From 42a3ca2dc02b0f5b74b4e799a77cd141e3a5ede6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Jul 2023 16:21:04 -0700 Subject: [PATCH 395/582] changes to memory --- src/pks/ecosim_pk/data/BGC_memory.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index b7233fe4f..704bb53d3 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -318,7 +318,6 @@ void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->gas_saturation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->ice_saturation)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->elevation)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->thermal_conductivity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); @@ -331,7 +330,6 @@ void FreeBGCProperties(BGCProperties* props) { FreeBGCVectorDouble(&(props->liquid_saturation)); FreeBGCVectorDouble(&(props->gas_saturation)); FreeBGCVectorDouble(&(props->ice_saturation)); - FreeBGCVectorDouble(&(props->elevation)); FreeBGCVectorDouble(&(props->relative_permeability)); FreeBGCVectorDouble(&(props->thermal_conductivity)); FreeBGCVectorDouble(&(props->volume)); From fe9d6f0ac0f3ac34fc7e7179e01b6b8957d9b70d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Jul 2023 16:36:56 -0700 Subject: [PATCH 396/582] removing some stufff --- src/pks/ecosim_pk/BGCEngine.cc | 1 - src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 9b5307a2b..02b03c342 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -54,7 +54,6 @@ void CopyBGCProperties(BGCProperties* dest, BGCProperties* src) memcpy(dest->liquid_saturation.data, src->liquid_saturation.data, sizeof(double) * src->liquid_saturation.size); memcpy(dest->gas_saturation.data, src->gas_saturation.data, sizeof(double) * src->gas_saturation.size); memcpy(dest->ice_saturation.data, src->ice_saturation.data, sizeof(double) * src->ice_saturation.size); - memcpy(dest->elevation.data, src->elevation.data, sizeof(double) * src->elevation.size); memcpy(dest->relative_permeability.data, src->relative_permeability.data, sizeof(double) * src->relative_permeability.size); memcpy(dest->thermal_conductivity.data, src->thermal_conductivity.data, sizeof(double) * src->thermal_conductivity.size); memcpy(dest->volume.data, src->volume.data, sizeof(double) * src->volume.size); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 051ba6914..3ebd43586 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -120,7 +120,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, vp_air_key_ = Keys::readKey(*plist_, domain_surf_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surf_, "wind speed", "wind_speed"); prain_key_ = Keys::readKey(*plist_, domain_surf_, "precipitation rain", "precipitation_rain"); - f_wp_key_ = Keys::readKey(plist_, domain_, "plant wilting factor", "plant_wilting_factor"); + f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); //psnow_key_ = Keys::readKey(plist, domain_surf_, "precipitation snow", "precipitation"); @@ -230,8 +230,7 @@ void EcoSIM::Setup() { .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); - - requireAtCurrent(bulk_dens_key_, tag_current_, *S_, name_);*/ + requireAtCurrent(bulk_dens_key_, tag_current_, *S_, name_); if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { From 711ee3d0a4d55098478e90f9762526e8e7d9fd95 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Jul 2023 16:44:02 -0700 Subject: [PATCH 397/582] typos --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3ebd43586..121a3cda7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -821,7 +821,7 @@ void EcoSIM::CopyToEcoSIM(int col, props.vapor_pressure_air = vapor_pressure_air[col]; props.wind_speed = wind_speed[col]; props.precipitation = precipitation[col]; - props.plant_wilting_factor = plant_wilting_factor[col] + props.plant_wilting_factor = plant_wilting_factor[col]; props.elevation = elevation[col] //Fill the atmospheric abundances @@ -887,7 +887,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); auto& hydraulic_conductivity = *(*S_->GetW(hydra_cond_key_, Amanzi::Tags::NEXT, hydra_cond_key_).ViewComponent("cell",false))(0); - auto& bulk_density = *(*S_->GetW(bulk_dens_key_), Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); + auto& bulk_density = *(*S_->GetW(bulk_dens_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); From 799055e4a03b63a1bdebf55226b32b1be0286b18 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 10 Jul 2023 16:53:23 -0700 Subject: [PATCH 398/582] why --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 121a3cda7..695551c3d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -822,7 +822,7 @@ void EcoSIM::CopyToEcoSIM(int col, props.wind_speed = wind_speed[col]; props.precipitation = precipitation[col]; props.plant_wilting_factor = plant_wilting_factor[col]; - props.elevation = elevation[col] + props.elevation = elevation[col]; //Fill the atmospheric abundances //NOTE: probably want to add an if statement here to only do this only once From ba1c8fad9b026cb5e6cf78e5c9f169a683e11f3d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 11 Jul 2023 15:31:21 -0700 Subject: [PATCH 399/582] just getting rid of plant wilting factor since I don't need it --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 695551c3d..14a9d88c7 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -84,6 +84,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); + suc_key_ = Keys::readKey //densities //If we need bulk density do we need volume fractions of each quantity? @@ -120,8 +121,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, vp_air_key_ = Keys::readKey(*plist_, domain_surf_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surf_, "wind speed", "wind_speed"); prain_key_ = Keys::readKey(*plist_, domain_surf_, "precipitation rain", "precipitation_rain"); - f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); - elev_key_ = Keys::readKey(*plist_, domain_, "elevation", "elevation"); + //f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); + elev_key_ = Keys::readKey(*plist_, domain_surf_, "elevation", "elevation"); //psnow_key_ = Keys::readKey(plist, domain_surf_, "precipitation snow", "precipitation"); //Atmospheric abundance keys @@ -284,7 +285,7 @@ void EcoSIM::Initialize() { S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); //Here we put the checks for the optional keys @@ -397,7 +398,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); if (has_gas) { @@ -488,9 +489,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& p_rain = *(*S_->Get("precipitation_rain", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); + /*S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("plant_wilting_factor", tag_next_) - .ViewComponent("cell",false))(0); + .ViewComponent("cell",false))(0);*/ S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) @@ -686,7 +687,7 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& precipitation = *(*S_->Get(prain_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data @@ -821,7 +822,7 @@ void EcoSIM::CopyToEcoSIM(int col, props.vapor_pressure_air = vapor_pressure_air[col]; props.wind_speed = wind_speed[col]; props.precipitation = precipitation[col]; - props.plant_wilting_factor = plant_wilting_factor[col]; + //props.plant_wilting_factor = plant_wilting_factor[col]; props.elevation = elevation[col]; //Fill the atmospheric abundances From dd1178a628cc9f00d703cd51a12b8ac2a0b79719 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 11 Jul 2023 15:35:29 -0700 Subject: [PATCH 400/582] oops --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 14a9d88c7..afbfb4c13 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -84,7 +84,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); - suc_key_ = Keys::readKey + //suc_key_ = Keys::readKey //densities //If we need bulk density do we need volume fractions of each quantity? From 9148bd8b2e8b8e7fab8ef6554b2b0582bcf4d69a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 11 Jul 2023 16:37:44 -0700 Subject: [PATCH 401/582] added suction, aspect and slope. --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 41 +++++++++++++++++++++-- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 3 ++ src/pks/ecosim_pk/data/BGC_containers.hh | 3 ++ src/pks/ecosim_pk/data/BGC_memory.cc | 2 ++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index afbfb4c13..36415c797 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -84,7 +84,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); - //suc_key_ = Keys::readKey + suc_key_ = Keys::readKey(*plist_,domain_,"suction","suction_head"); //densities //If we need bulk density do we need volume fractions of each quantity? @@ -121,8 +121,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, vp_air_key_ = Keys::readKey(*plist_, domain_surf_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surf_, "wind speed", "wind_speed"); prain_key_ = Keys::readKey(*plist_, domain_surf_, "precipitation rain", "precipitation_rain"); - //f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); elev_key_ = Keys::readKey(*plist_, domain_surf_, "elevation", "elevation"); + aspect_key_ = Keys::readKey(*plist_, domain_surf_, "aspect", "aspect"); + slope_key_ = Keys::readKey(*plist_, domain_surf_, "slope magnitude", "slope_magnitude"); + + //f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); //psnow_key_ = Keys::readKey(plist, domain_surf_, "precipitation snow", "precipitation"); //Atmospheric abundance keys @@ -274,6 +277,7 @@ void EcoSIM::Initialize() { S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; @@ -287,6 +291,8 @@ void EcoSIM::Initialize() { S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); //Here we put the checks for the optional keys //Temperature, ice and gas @@ -390,6 +396,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); //Surface data from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -400,6 +407,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); @@ -442,6 +451,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) .ViewComponent("cell",false))(0); + S_->GetEvaluator("suction_head", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& suction_head = *(*S_->Get("suction_head", tag_next_) + .ViewComponent("cell",false))(0); + S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) .ViewComponent("cell",false))(0); @@ -497,6 +510,15 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) .ViewComponent("cell",false); + S_->GetEvaluator("aspect", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& aspect = *S_->Get("aspect", tag_next_) + .ViewComponent("cell",false); + + + S_->GetEvaluator("slope", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& slope = *S_->Get("slope", tag_next_) + .ViewComponent("cell",false); + if (has_ice) { S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) @@ -678,7 +700,9 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydra_cond_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& rooting_depth = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); //I think I can access the surface variables with col variable and it should //be what I want const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); @@ -689,13 +713,16 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& precipitation = *(*S_->Get(prain_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& slope = *(*S_->Get(slope_key, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -721,6 +748,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,porosity,col_poro.ptr()); FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,water_content,col_wc.ptr()); + FieldToColumn_(col,suction_head,col_suc.ptr()); FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); FieldToColumn_(col,liquid_density,col_l_dens.ptr()); FieldToColumn_(col,rock_density,col_r_dens.ptr()); @@ -794,6 +822,7 @@ void EcoSIM::CopyToEcoSIM(int col, state.water_content.data[i] = (*col_wc)[i]; state.hydraulic_conductivity.data[i] = (*col_h_cond)[i]; state.bulk_density.data[i] = (*col_b_dens)[i]; + state.suction_head.data[i] = (*col_suc)[i]; props.liquid_saturation.data[i] = (*col_l_sat)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; props.volume.data[i] = (*col_vol)[i]; @@ -824,6 +853,8 @@ void EcoSIM::CopyToEcoSIM(int col, props.precipitation = precipitation[col]; //props.plant_wilting_factor = plant_wilting_factor[col]; props.elevation = elevation[col]; + props.aspect = aspect[col]; + props.slope = slope[col]; //Fill the atmospheric abundances //NOTE: probably want to add an if statement here to only do this only once @@ -883,6 +914,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); //auto& elevation = S_->GetPtrW(elev_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell"); auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); + auto& suction_head = *(*S_->GetW(suc_key_, Amanzi::Tags::NEXT, suc_key_).ViewComponent("cell",false))(0); auto& relative_permeability = *(*S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false))(0); auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); @@ -894,6 +926,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -953,6 +986,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_l_dens)[i] = state.liquid_density.data[i]; (*col_poro)[i] = state.porosity.data[i]; (*col_wc)[i] = state.water_content.data[i]; + (*col_suc)[i] = state.suction_head.data[i]; (*col_l_sat)[i] = props.liquid_saturation.data[i]; //(*col_elev)[i] = props.elevation.data[i]; (*col_rel_perm)[i] = props.relative_permeability.data[i]; @@ -1008,6 +1042,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); //ColumnToField_(col,elevation,col_elev.ptr()); ColumnToField_(col,water_content,col_wc.ptr()); + ColumnToField_(col,suction_head,col_suc.ptr()); ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); ColumnToField_(col,liquid_density,col_l_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 8df45ab2e..9b2415cec 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -198,6 +198,9 @@ class EcoSIM : public PK_Physical { Key wind_speed_key_; Key prain_key_; Key f_wp_key_; + Key suc_key_; + Key aspect_key_; + Key slope_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 0446ea9db..019b50566 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -90,6 +90,7 @@ extern "C" { BGCVectorDouble ice_density; BGCVectorDouble porosity; BGCVectorDouble water_content; + BGCVectorDouble suction_head; BGCVectorDouble temperature; BGCVectorDouble total_mobile; BGCVectorDouble hydraulic_conductivity; @@ -114,6 +115,8 @@ extern "C" { double precipitation; double plant_wilting_factor; double elevation; + double aspect; + double slope; double atm_n2; double atm_o2; double atm_co2; diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 704bb53d3..e93e520bb 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -260,6 +260,7 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->ice_density)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->porosity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->water_content)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->suction_head)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->temperature)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->hydraulic_conductivity)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(state->bulk_density)); @@ -275,6 +276,7 @@ void FreeBGCState(BGCState* state) { FreeBGCVectorDouble(&(state->ice_density)); FreeBGCVectorDouble(&(state->porosity)); FreeBGCVectorDouble(&(state->water_content)); + FreeBGCVectorDouble(&(state->suction_head)); FreeBGCVectorDouble(&(state->temperature)); FreeBGCVectorDouble(&(state->hydraulic_conductivity)); FreeBGCVectorDouble(&(state->bulk_density)); From 9517e7777a0d5004afef7324321b25f7b673c667 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 12 Jul 2023 13:10:24 -0700 Subject: [PATCH 402/582] minor fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 ++-- src/pks/ecosim_pk/ecosim_wrappers.F90 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 36415c797..dd793e562 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -714,12 +714,12 @@ void EcoSIM::CopyToEcoSIM(int col, //const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& slope = *(*S_->Get(slope_key, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim_pk/ecosim_wrappers.F90 index 42062c28e..9c838ba11 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim_pk/ecosim_wrappers.F90 @@ -126,8 +126,8 @@ subroutine EcoSIM_Advance( & call ATS2EcoSIMData(ncol, state, props, sizes) - call Run_EcoSIM_one_step() + !call Run_EcoSIM_one_step() - call EcoSIM2ATSData() + call EcoSIM2ATSData(ncol, state, sizes) end subroutine EcoSIM_Advance From 922671a4f43d32a5e199865766de1a2710456079 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Jul 2023 13:18:52 -0700 Subject: [PATCH 403/582] adding test for the suction key --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index dd793e562..6711e6cd0 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -269,6 +269,11 @@ void EcoSIM::Initialize() { int ierr = 0; + if (!S->HasField(suc_key_)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "has suction key." << std::endl; + } + // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); @@ -277,7 +282,7 @@ void EcoSIM::Initialize() { S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; @@ -396,7 +401,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); //Surface data from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -451,9 +456,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("suction_head", tag_next_).Update(*S_, name_); + /*S_->GetEvaluator("suction_head", tag_next_).Update(*S_, name_); const Epetra_MultiVector& suction_head = *(*S_->Get("suction_head", tag_next_) - .ViewComponent("cell",false))(0); + .ViewComponent("cell",false))(0);*/ S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) @@ -700,7 +705,7 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydra_cond_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& rooting_depth = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); //I think I can access the surface variables with col variable and it should @@ -719,7 +724,7 @@ void EcoSIM::CopyToEcoSIM(int col, //Define the column vectors to hold the data auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -748,7 +753,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,porosity,col_poro.ptr()); FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,water_content,col_wc.ptr()); - FieldToColumn_(col,suction_head,col_suc.ptr()); + //FieldToColumn_(col,suction_head,col_suc.ptr()); FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); FieldToColumn_(col,liquid_density,col_l_dens.ptr()); FieldToColumn_(col,rock_density,col_r_dens.ptr()); @@ -822,7 +827,7 @@ void EcoSIM::CopyToEcoSIM(int col, state.water_content.data[i] = (*col_wc)[i]; state.hydraulic_conductivity.data[i] = (*col_h_cond)[i]; state.bulk_density.data[i] = (*col_b_dens)[i]; - state.suction_head.data[i] = (*col_suc)[i]; + //state.suction_head.data[i] = (*col_suc)[i]; props.liquid_saturation.data[i] = (*col_l_sat)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; props.volume.data[i] = (*col_vol)[i]; @@ -914,7 +919,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); //auto& elevation = S_->GetPtrW(elev_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell"); auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); - auto& suction_head = *(*S_->GetW(suc_key_, Amanzi::Tags::NEXT, suc_key_).ViewComponent("cell",false))(0); + //auto& suction_head = *(*S_->GetW(suc_key_, Amanzi::Tags::NEXT, suc_key_).ViewComponent("cell",false))(0); auto& relative_permeability = *(*S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false))(0); auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); @@ -986,7 +991,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_l_dens)[i] = state.liquid_density.data[i]; (*col_poro)[i] = state.porosity.data[i]; (*col_wc)[i] = state.water_content.data[i]; - (*col_suc)[i] = state.suction_head.data[i]; + //(*col_suc)[i] = state.suction_head.data[i]; (*col_l_sat)[i] = props.liquid_saturation.data[i]; //(*col_elev)[i] = props.elevation.data[i]; (*col_rel_perm)[i] = props.relative_permeability.data[i]; From 854ec723e34bbacbf3428ae478c18f7e5cb35032 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Jul 2023 14:45:00 -0700 Subject: [PATCH 404/582] minor bug with the structs --- src/pks/ecosim_pk/data/BGC_containers.hh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 019b50566..c0cf400dd 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -92,7 +92,6 @@ extern "C" { BGCVectorDouble water_content; BGCVectorDouble suction_head; BGCVectorDouble temperature; - BGCVectorDouble total_mobile; BGCVectorDouble hydraulic_conductivity; BGCVectorDouble bulk_density; BGCMatrixDouble total_component_concentration; From 37f486d19e9050f4f19caf93261c8f57d7665841 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Jul 2023 16:33:03 -0700 Subject: [PATCH 405/582] testing the block map printing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 6711e6cd0..b14c8248a 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -444,6 +444,13 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) .ViewComponent("cell",false))(0); + *vo_->os() << "Printing porositry Map" << std::endl; + const Epetra_BlockMap& blockMap = *(porosity.Map()); + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << " Num global elements: " << blockMap.NumGlobalElements() << std::endl; + *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; + *vo_->os() << " Index base: " << blockMap.IndexBase() << std::endl; + S_->GetEvaluator("saturation_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_saturation = *(*S_->Get("saturation_liquid", tag_next_) .ViewComponent("cell",false))(0); From 130dad49599c555c6d91a4aef8e04767cfb50a1c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Jul 2023 16:38:52 -0700 Subject: [PATCH 406/582] minor changes adding suction test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b14c8248a..202e10229 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -269,9 +269,12 @@ void EcoSIM::Initialize() { int ierr = 0; - if (!S->HasField(suc_key_)) { + if (S->HasRecord(suc_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "has suction key." << std::endl; + } else { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Does not have suction key at default." << std::endl; } // Ensure dependencies are filled From ca7555dc7e81117df875c1b61d29ae3b8ff93f89 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Jul 2023 16:47:27 -0700 Subject: [PATCH 407/582] bugfixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 202e10229..9dba6f262 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -269,7 +269,7 @@ void EcoSIM::Initialize() { int ierr = 0; - if (S->HasRecord(suc_key_, Tags::DEFAULT)) { + if (S_->HasRecord(suc_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "has suction key." << std::endl; } else { @@ -448,7 +448,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false))(0); *vo_->os() << "Printing porositry Map" << std::endl; - const Epetra_BlockMap& blockMap = *(porosity.Map()); + const Epetra_BlockMap* blockMap = porosity.Map(); Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << " Num global elements: " << blockMap.NumGlobalElements() << std::endl; *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; @@ -1057,7 +1057,7 @@ void EcoSIM::CopyFromEcoSIM(const int col, ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); //ColumnToField_(col,elevation,col_elev.ptr()); ColumnToField_(col,water_content,col_wc.ptr()); - ColumnToField_(col,suction_head,col_suc.ptr()); + //ColumnToField_(col,suction_head,col_suc.ptr()); ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); ColumnToField_(col,liquid_density,col_l_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); From 54c3215fdd02268af05ed2f120ec73249e607381 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 12 Jul 2023 17:57:01 -0700 Subject: [PATCH 408/582] even more testing! --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 9dba6f262..b81df2feb 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -269,6 +269,9 @@ void EcoSIM::Initialize() { int ierr = 0; + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "printing bool:" << std::endl; + *vo_->os() << (S_->HasRecord(suc_key_, Tags::DEFAULT)) << std::endl; if (S_->HasRecord(suc_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "has suction key." << std::endl; @@ -290,6 +293,16 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; + const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) + .ViewComponent("cell",false))(0); + + *vo_->os() << "Printing porositry Map" << std::endl; + const Epetra_BlockMap* blockMap = porosity.Map(); + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << " Num global elements: " << blockMap.NumGlobalElements() << std::endl; + *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; + *vo_->os() << " Index base: " << blockMap.IndexBase() << std::endl; + //Surface properties from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -447,13 +460,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) .ViewComponent("cell",false))(0); - *vo_->os() << "Printing porositry Map" << std::endl; - const Epetra_BlockMap* blockMap = porosity.Map(); - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << " Num global elements: " << blockMap.NumGlobalElements() << std::endl; - *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; - *vo_->os() << " Index base: " << blockMap.IndexBase() << std::endl; - S_->GetEvaluator("saturation_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_saturation = *(*S_->Get("saturation_liquid", tag_next_) .ViewComponent("cell",false))(0); From 809b866c7465617bb28863daba0884d684ef42ca Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 13 Jul 2023 09:48:15 -0700 Subject: [PATCH 409/582] various minor fixes to make the code work along with the tests --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b81df2feb..2635df981 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -290,15 +290,15 @@ void EcoSIM::Initialize() { S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); - Teuchos::OSTab tab = vo_->getOSTab(); + //Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) .ViewComponent("cell",false))(0); *vo_->os() << "Printing porositry Map" << std::endl; - const Epetra_BlockMap* blockMap = porosity.Map(); - Teuchos::OSTab tab = vo_->getOSTab(); + const Epetra_BlockMap blockMap = porosity.Map(); + //Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << " Num global elements: " << blockMap.NumGlobalElements() << std::endl; *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; *vo_->os() << " Index base: " << blockMap.IndexBase() << std::endl; From 7309e2b51e0d9b7cedf92517af12bdd266447ef8 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 13 Jul 2023 10:02:59 -0700 Subject: [PATCH 410/582] further testing of processes and suction key --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 2635df981..2970e33aa 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -279,6 +279,20 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "Does not have suction key at default." << std::endl; } + if (S_->HasRecord(suc_key_, Tags::CURRENT)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "has suction key at current" << std::endl; + } else { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Does not have suction key at current" << std::endl; + } + if (S_->HasRecord(suc_key_, Tags::NEXT)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "has suction key at next" << std::endl; + } else { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Does not have suction key at next" << std::endl; + } // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); @@ -303,6 +317,13 @@ void EcoSIM::Initialize() { *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; *vo_->os() << " Index base: " << blockMap.IndexBase() << std::endl; + const int* myGlobalElements = blockMap.MyGlobalElements(); + int numMyElements = blockMap.NumMyElements(); + *vo_->os() << "Processor " << comm.MyPID() << " has the following elements:" << std::endl; + for (int i = 0; i < numMyElements; ++i) { + *vo_->os() << " " << myGlobalElements[i] << std::endl; + } + //Surface properties from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); From 94965986ac4feee3bdb16f244291106ea80fcd05 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Fri, 14 Jul 2023 14:12:13 -0700 Subject: [PATCH 411/582] changes to code --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 2970e33aa..b92bc12ad 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -22,6 +22,8 @@ #include "Epetra_Vector.h" #include "Epetra_SerialDenseVector.h" #include "Epetra_SerialDenseMatrix.h" +#include "Epetra_MpiComm.h" +#include "Epetra_Map.h" #include "Teuchos_RCPDecl.hpp" #include "Teuchos_ParameterList.hpp" @@ -307,15 +309,29 @@ void EcoSIM::Initialize() { //Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "testing keys" << std::endl; - const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) + const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); - *vo_->os() << "Printing porositry Map" << std::endl; - const Epetra_BlockMap blockMap = porosity.Map(); + *vo_->os() << "Printing WC Map" << std::endl; + const Epetra_BlockMap blockMap = water_content.Map(); + //Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << " Num global elements: " << blockMap.NumGlobalElements() << std::endl; *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; *vo_->os() << " Index base: " << blockMap.IndexBase() << std::endl; + if (blockMap.LinearMap()==true) { + *vo_->os() << " Map is linear." << std::endl; + } else { + *vo_->os() << " Map is NOT linear." << std::endl; + } + + if (blockMap.DistributedGlobal()==true) { + *vo_->os() << " Map is Distributed." << std::endl; + } else { + *vo_->os() << " Map is NOT Distributed." << std::endl; + } + + Epetra_MpiComm comm(MPI_COMM_WORLD); const int* myGlobalElements = blockMap.MyGlobalElements(); int numMyElements = blockMap.NumMyElements(); From 2b1329f85be1232065f7f212248490d3b271a571 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 14 Jul 2023 14:29:06 -0700 Subject: [PATCH 412/582] adding rooting fraction and wilting point --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 39 +++++++++++++++-------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 1 + src/pks/ecosim_pk/data/BGC_containers.hh | 2 ++ src/pks/ecosim_pk/data/BGC_memory.cc | 6 ++++ 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index b92bc12ad..c5f0fe9d9 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -109,7 +109,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); - + f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); + f_root_key_ = Keys::readKey(*plist_, domain_, "rooting depth fraction", "rooting_depth_fraction"); //Evaluator keys hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); @@ -304,6 +305,8 @@ void EcoSIM::Initialize() { S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); //Teuchos::OSTab tab = vo_->getOSTab(); @@ -314,7 +317,7 @@ void EcoSIM::Initialize() { *vo_->os() << "Printing WC Map" << std::endl; const Epetra_BlockMap blockMap = water_content.Map(); - + //Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << " Num global elements: " << blockMap.NumGlobalElements() << std::endl; *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; @@ -347,7 +350,6 @@ void EcoSIM::Initialize() { S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); - //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); @@ -454,6 +456,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); //Surface data from met data @@ -525,6 +529,14 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& cell_volume = *(*S_->Get("cell_volume", tag_next_) .ViewComponent("cell",false))(0); + S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("plant_wilting_factor", tag_next_) + .ViewComponent("cell",false))(0); + + S_->GetEvaluator("rooting_depth_fraction", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("rooting_depth_fraction", tag_next_) + .ViewComponent("cell",false))(0); + if (has_gas) { S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) @@ -560,10 +572,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& p_rain = *(*S_->Get("precipitation_rain", tag_next_) .ViewComponent("cell",false))(0); - /*S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("plant_wilting_factor", tag_next_) - .ViewComponent("cell",false))(0);*/ - S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) .ViewComponent("cell",false); @@ -760,7 +768,8 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydra_cond_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& rooting_depth = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& rooting_depth = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); //I think I can access the surface variables with col variable and it should //be what I want const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); @@ -769,7 +778,6 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& precipitation = *(*S_->Get(prain_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); @@ -793,6 +801,8 @@ void EcoSIM::CopyToEcoSIM(int col, auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_depth = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_rf = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -813,6 +823,8 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,cell_volume,col_vol.ptr()); FieldToColumn_(col,hydraulic_conductivity,col_h_cond.ptr()); FieldToColumn_(col,bulk_density,col_b_dens.ptr()); + FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); + FieldToColumn_(col,rooting_depth_fraction,col_rf.ptr()); MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); @@ -863,7 +875,7 @@ void EcoSIM::CopyToEcoSIM(int col, // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this // have to fill tcc separately (I think) - + /* for (int j=0; j < tcc_num; ++j) { *vo_->os() << "component: "<< j << std::endl; for (int i=0; i < ncells_per_col_; ++i) { @@ -872,7 +884,7 @@ void EcoSIM::CopyToEcoSIM(int col, *vo_->os() << "m_arr: "<< state.total_component_concentration.data[j][i] << std::endl; state.total_component_concentration.data[j][i] = (*col_tcc)(i,j); } - } + }*/ for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[i] = (*col_l_dens)[i]; @@ -881,6 +893,8 @@ void EcoSIM::CopyToEcoSIM(int col, state.hydraulic_conductivity.data[i] = (*col_h_cond)[i]; state.bulk_density.data[i] = (*col_b_dens)[i]; //state.suction_head.data[i] = (*col_suc)[i]; + props.plant_wilting_factor.data[i] = (*col_wp)[i]; + props.rooting_depth_fraction.data[i] = (*col_rf)[i]; props.liquid_saturation.data[i] = (*col_l_sat)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; props.volume.data[i] = (*col_vol)[i]; @@ -909,7 +923,6 @@ void EcoSIM::CopyToEcoSIM(int col, props.vapor_pressure_air = vapor_pressure_air[col]; props.wind_speed = wind_speed[col]; props.precipitation = precipitation[col]; - //props.plant_wilting_factor = plant_wilting_factor[col]; props.elevation = elevation[col]; props.aspect = aspect[col]; props.slope = slope[col]; @@ -970,7 +983,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); - //auto& elevation = S_->GetPtrW(elev_key_, Amanzi::Tags::NEXT, passwd_).ViewComponent("cell"); auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); //auto& suction_head = *(*S_->GetW(suc_key_, Amanzi::Tags::NEXT, suc_key_).ViewComponent("cell",false))(0); auto& relative_permeability = *(*S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false))(0); @@ -982,7 +994,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - //auto col_elev = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 9b2415cec..944d7b1a2 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -198,6 +198,7 @@ class EcoSIM : public PK_Physical { Key wind_speed_key_; Key prain_key_; Key f_wp_key_; + Key f_root_key_ Key suc_key_; Key aspect_key_; Key slope_key_; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index c0cf400dd..4fe3cf62b 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -106,6 +106,8 @@ extern "C" { BGCVectorDouble volume; BGCVectorDouble depth; BGCVectorDouble dz; + BGCVectorDouble plant_wilting_factor; + BGCVectorDouble rooting_depth_fraction; double shortwave_radiation; double longwave_radiation; double air_temperature; diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index e93e520bb..b8ccea736 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -325,6 +325,8 @@ void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->depth)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->dz)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->plant_wilting_factor)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->rooting_depth_fraction)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { @@ -335,6 +337,10 @@ void FreeBGCProperties(BGCProperties* props) { FreeBGCVectorDouble(&(props->relative_permeability)); FreeBGCVectorDouble(&(props->thermal_conductivity)); FreeBGCVectorDouble(&(props->volume)); + FreeBGCVectorDouble(&(props->depth)); + FreeBGCVectorDouble(&(props->dz)); + FreeBGCVectorDouble(&(props->plant_wilting_factor)); + FreeBGCVectorDouble(&(props->rooting_depth_fraction)); } } /* end FreeAlquimiaProperties() */ From a3859e6cf7b89482d13d85159107fc0037c990ef Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 18 Jul 2023 13:33:17 -0700 Subject: [PATCH 413/582] various minor fixes --- src/pks/ecosim_pk/data/BGC_containers.hh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 4fe3cf62b..2a9eee5cc 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -114,7 +114,6 @@ extern "C" { double vapor_pressure_air; double wind_speed; double precipitation; - double plant_wilting_factor; double elevation; double aspect; double slope; From caf52cd2b21ef6ccc4da9f3a1785bf930fee64c5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 18 Jul 2023 13:45:18 -0700 Subject: [PATCH 414/582] added some more tests for parallelization --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 47 +++++++---------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index c5f0fe9d9..0c4f767ec 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -109,7 +109,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); - f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); + //f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); f_root_key_ = Keys::readKey(*plist_, domain_, "rooting depth fraction", "rooting_depth_fraction"); //Evaluator keys hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); @@ -305,7 +305,7 @@ void EcoSIM::Initialize() { S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); @@ -315,33 +315,12 @@ void EcoSIM::Initialize() { const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); - *vo_->os() << "Printing WC Map" << std::endl; - const Epetra_BlockMap blockMap = water_content.Map(); - //Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << " Num global elements: " << blockMap.NumGlobalElements() << std::endl; - *vo_->os() << " Num my elements: " << blockMap.NumMyElements() << std::endl; - *vo_->os() << " Index base: " << blockMap.IndexBase() << std::endl; - if (blockMap.LinearMap()==true) { - *vo_->os() << " Map is linear." << std::endl; - } else { - *vo_->os() << " Map is NOT linear." << std::endl; - } + ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - if (blockMap.DistributedGlobal()==true) { - *vo_->os() << " Map is Distributed." << std::endl; - } else { - *vo_->os() << " Map is NOT Distributed." << std::endl; - } - - Epetra_MpiComm comm(MPI_COMM_WORLD); - - const int* myGlobalElements = blockMap.MyGlobalElements(); - int numMyElements = blockMap.NumMyElements(); - *vo_->os() << "Processor " << comm.MyPID() << " has the following elements:" << std::endl; - for (int i = 0; i < numMyElements; ++i) { - *vo_->os() << " " << myGlobalElements[i] << std::endl; - } + *vo_->os() << "Global Columns: " << ncols_global << std::endl; + *vo_->os() << "Local Columns: " << ncols_local << std::endl; //Surface properties from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -456,7 +435,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); @@ -529,12 +508,12 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& cell_volume = *(*S_->Get("cell_volume", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); + /*S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("plant_wilting_factor", tag_next_) - .ViewComponent("cell",false))(0); + .ViewComponent("cell",false))(0);*/ S_->GetEvaluator("rooting_depth_fraction", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("rooting_depth_fraction", tag_next_) + const Epetra_MultiVector& rooting_depth_fraction = *(*S_->Get("rooting_depth_fraction", tag_next_) .ViewComponent("cell",false))(0); if (has_gas) { @@ -769,7 +748,7 @@ void EcoSIM::CopyToEcoSIM(int col, //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); //I think I can access the surface variables with col variable and it should //be what I want const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); @@ -823,7 +802,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,cell_volume,col_vol.ptr()); FieldToColumn_(col,hydraulic_conductivity,col_h_cond.ptr()); FieldToColumn_(col,bulk_density,col_b_dens.ptr()); - FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); + //FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); FieldToColumn_(col,rooting_depth_fraction,col_rf.ptr()); MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); @@ -893,7 +872,7 @@ void EcoSIM::CopyToEcoSIM(int col, state.hydraulic_conductivity.data[i] = (*col_h_cond)[i]; state.bulk_density.data[i] = (*col_b_dens)[i]; //state.suction_head.data[i] = (*col_suc)[i]; - props.plant_wilting_factor.data[i] = (*col_wp)[i]; + //props.plant_wilting_factor.data[i] = (*col_wp)[i]; props.rooting_depth_fraction.data[i] = (*col_rf)[i]; props.liquid_saturation.data[i] = (*col_l_sat)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; From 0251217e26ba18f5df7fdc82735e6d7bc6522db6 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 18 Jul 2023 13:55:42 -0700 Subject: [PATCH 415/582] minor fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0c4f767ec..43b908386 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -747,7 +747,7 @@ void EcoSIM::CopyToEcoSIM(int col, const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydra_cond_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& rooting_depth = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); //I think I can access the surface variables with col variable and it should //be what I want diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 944d7b1a2..95dcb8f3f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -167,6 +167,8 @@ class EcoSIM : public PK_Physical { int number_aqueous_components_; int ncells_per_col_; int num_cols_; + int ncols_local; + int ncols_global; double saved_time_; double current_time_; @@ -198,7 +200,7 @@ class EcoSIM : public PK_Physical { Key wind_speed_key_; Key prain_key_; Key f_wp_key_; - Key f_root_key_ + Key f_root_key_; Key suc_key_; Key aspect_key_; Key slope_key_; From 16c15b0ba9c54b0a1bdbbad5c80ee381e9cf95e4 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 18 Jul 2023 14:15:24 -0700 Subject: [PATCH 416/582] more minor fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 43b908386..7891a8f63 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -109,8 +109,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); - //f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); - f_root_key_ = Keys::readKey(*plist_, domain_, "rooting depth fraction", "rooting_depth_fraction"); + f_wp_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); + f_root_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); //Evaluator keys hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); @@ -305,7 +305,7 @@ void EcoSIM::Initialize() { S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); - //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); @@ -435,7 +435,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); - //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); @@ -446,7 +446,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); - //S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); @@ -510,11 +509,11 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { /*S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("plant_wilting_factor", tag_next_) - .ViewComponent("cell",false))(0);*/ + .ViewComponent("cell",false))(0); S_->GetEvaluator("rooting_depth_fraction", tag_next_).Update(*S_, name_); const Epetra_MultiVector& rooting_depth_fraction = *(*S_->Get("rooting_depth_fraction", tag_next_) - .ViewComponent("cell",false))(0); + .ViewComponent("cell",false))(0);*/ if (has_gas) { S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); @@ -748,7 +747,7 @@ void EcoSIM::CopyToEcoSIM(int col, //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); //I think I can access the surface variables with col variable and it should //be what I want const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); @@ -802,7 +801,7 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,cell_volume,col_vol.ptr()); FieldToColumn_(col,hydraulic_conductivity,col_h_cond.ptr()); FieldToColumn_(col,bulk_density,col_b_dens.ptr()); - //FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); + FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); FieldToColumn_(col,rooting_depth_fraction,col_rf.ptr()); MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); @@ -872,7 +871,7 @@ void EcoSIM::CopyToEcoSIM(int col, state.hydraulic_conductivity.data[i] = (*col_h_cond)[i]; state.bulk_density.data[i] = (*col_b_dens)[i]; //state.suction_head.data[i] = (*col_suc)[i]; - //props.plant_wilting_factor.data[i] = (*col_wp)[i]; + props.plant_wilting_factor.data[i] = (*col_wp)[i]; props.rooting_depth_fraction.data[i] = (*col_rf)[i]; props.liquid_saturation.data[i] = (*col_l_sat)[i]; props.relative_permeability.data[i] = (*col_rel_perm)[i]; From 7ed2cd62d3fd63bd3f43544a8dc87848d5c13861 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 18 Jul 2023 15:01:27 -0700 Subject: [PATCH 417/582] cleaning up print statements --- src/pks/ecosim_pk/BGCEngine.cc | 9 ---- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 51 ++--------------------- 2 files changed, 4 insertions(+), 56 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 02b03c342..23db47780 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -75,8 +75,6 @@ BGCEngine::BGCEngine(const std::string& engineName, { Errors::Message msg; - std::cout << "Engine name is: " << engineName << std::endl; - std::cout << "Creating the BGC Engine interface" << std::endl; CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_); /* @@ -181,12 +179,8 @@ void BGCEngine::InitState(BGCProperties& props, int ncells_per_col_, int num_components) { - std::cout << "Allocating Properties" << std::endl; - std::cout << "Size of columns: " << ncells_per_col_ << std::endl; AllocateBGCProperties(&sizes_, &props, ncells_per_col_); - std::cout << "Allocating State" << std::endl; AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components); - std::cout << "Allocating aux" << std::endl; AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); @@ -207,7 +201,6 @@ void BGCEngine::FreeState(BGCProperties& props, void BGCEngine::DataTest() { - std::cout << "Data test for calling function" << std::endl; bgc_.DataTest(); } @@ -217,7 +210,6 @@ bool BGCEngine::Setup(BGCProperties& props, int num_iterations, int ncol) { - std::cout << "Running BGC Engine Setup" << std::endl; // Advance the chemical reaction all operator-split-like. bgc_.Setup(&props, &state, @@ -240,7 +232,6 @@ bool BGCEngine::Advance(const double delta_time, int num_iterations, int ncol) { - std::cout << "Running BGC Engine Advance" << std::endl; // Advance the chemical reaction all operator-split-like. bgc_.Advance(delta_time, &props, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 7891a8f63..5e340d15f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -310,7 +310,6 @@ void EcoSIM::Initialize() { //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); //Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "testing keys" << std::endl; const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); @@ -319,8 +318,10 @@ void EcoSIM::Initialize() { ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - *vo_->os() << "Global Columns: " << ncols_global << std::endl; - *vo_->os() << "Local Columns: " << ncols_local << std::endl; + //Using cout because it prints for every process instead of just + //rank 0 (might be a way to use vo, but not implemented) + std::cout << "Global Columns: " << ncols_global << std::endl; + std::cout << "Local Columns: " << ncols_local << std::endl; //Surface properties from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -417,7 +418,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // dt_prev_ = dt; //} - std::cout << "\nBegin Advance\n"; Teuchos::OSTab out = vo_->getOSTab(); if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "----------------------------------------------------------------" << std::endl @@ -591,10 +591,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //Copy to EcoSIM structures - std::cout << "\nAdvancing col "<< col <<"\n"; AdvanceSingleColumn(dt, col); - std::cout << "\nfinished advancing column\n"; - } // end loop over columns // mark primaries as changed @@ -605,7 +602,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //return failed; - std::cout << "\nEnd Advance\n"; } // helper function for pushing field to column @@ -808,19 +804,6 @@ void EcoSIM::CopyToEcoSIM(int col, FieldToColumn_(col,cell_volume,col_vol_save.ptr()); FieldToColumn_(col,water_content,col_wc_save.ptr()); - /**vo_->os() << "Total Comp: " << tcc_num << std::endl; - *vo_->os() << "Total cells: " << ncells_per_col_ << std::endl; - for (int i=0; i < tcc_num; ++i) { - Epetra_SerialDenseVector col_comp(ncells_per_col_); - Epetra_SerialDenseVector tcc_comp(ncells_per_col_); - *vo_->os() << "Component: " << i << std::endl; - for (int j=0; jos() << "Cell: " << j << std::endl; - col_comp(j) = (*col_tcc)(i,j); - tcc_comp[j] = tcc[i][j]; - } - FieldToColumn_(col,Teuchos::ptr(&tcc_comp),Teuchos::ptr(&col_comp)); - }*/ if (has_gas) { const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); @@ -853,16 +836,6 @@ void EcoSIM::CopyToEcoSIM(int col, // I think I need to loop over the column data and save it to the data // structures. Eventually I could probably rewrite FieldToColumn_ to do this // have to fill tcc separately (I think) - /* - for (int j=0; j < tcc_num; ++j) { - *vo_->os() << "component: "<< j << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "cell: "<< i << std::endl; - *vo_->os() << "col arr: "<< (*col_tcc)(i,j) << std::endl; - *vo_->os() << "m_arr: "<< state.total_component_concentration.data[j][i] << std::endl; - state.total_component_concentration.data[j][i] = (*col_tcc)(i,j); - } - }*/ for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[i] = (*col_l_dens)[i]; @@ -1043,24 +1016,10 @@ void EcoSIM::CopyFromEcoSIM(const int col, (*col_vol)[i] = props.volume.data[i]; } - *vo_->os() << "printing volume: " << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "i "<< i << " col[i]: " << (*col_vol_save)[i] << " data[i]: " << props.volume.data[i] << std::endl; - } - - *vo_->os() << "printing water content: " << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "i "<< i << " col[i]: " << (*col_wc_save)[i] << " data[i]: " << state.water_content.data[i] << std::endl; - } - //Take new values from Ecosim state and put them into the secondary data structure //for backing back into amanzi state for (int j=0; j < tcc_num; ++j) { - //*vo_->os() << "component: "<< j << std::endl; for (int i=0; i < ncells_per_col_; ++i) { - //*vo_->os() << "cell: "<< i << std::endl; - //*vo_->os() << "col arr: "<< (*col_tcc)(i,j) << std::endl; - //*vo_->os() << "m_arr: "<< state.total_component_concentration.data[j][i] << std::endl; (*col_tcc)(i,j) = state.total_component_concentration.data[j][i]; } } @@ -1106,8 +1065,6 @@ int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - std::cout << "running data test" << std::endl; - //ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); bgc_engine_->DataTest(); From 62b1fd9cf98b137f7de03c439d573acd82b5c7d9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 18 Jul 2023 15:31:46 -0700 Subject: [PATCH 418/582] test looping over procs --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 5e340d15f..adfbf9ef9 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -318,10 +318,24 @@ void EcoSIM::Initialize() { ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + *vo_->os() << "total processes: " << ncols_global << std::endl; + //Trying to loop over processors now: + int numProcesses, p_rank; + MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + for (int k = 0; k < numProcesses; ++k) { + MPI_Barrier(MPI_COMM_WORLD); + if (rank = =k) { + std::cout << "on processor " << rank << std::endl; + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + } + } + //Using cout because it prints for every process instead of just //rank 0 (might be a way to use vo, but not implemented) - std::cout << "Global Columns: " << ncols_global << std::endl; - std::cout << "Local Columns: " << ncols_local << std::endl; + //std::cout << "Global Columns: " << ncols_global << std::endl; + //std::cout << "Local Columns: " << ncols_local << std::endl; + //Surface properties from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); From bd93217bcdd25b6b2d0e1018fd03f67a8e2d7b15 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 19 Jul 2023 08:51:40 -0700 Subject: [PATCH 419/582] minor fixes to the mpi test --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index adfbf9ef9..53850fa5b 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -322,12 +322,13 @@ void EcoSIM::Initialize() { //Trying to loop over processors now: int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); for (int k = 0; k < numProcesses; ++k) { MPI_Barrier(MPI_COMM_WORLD); - if (rank = =k) { - std::cout << "on processor " << rank << std::endl; + if (p_rank==k) { + std::cout << "on processor " << p_rank << std::endl; ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << ncols_local << std::endl; } } From 52635677c4666cd0cbe41d24919c22bd61cf9479 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 19 Jul 2023 09:10:14 -0700 Subject: [PATCH 420/582] minor changes to print statements --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 4 +++- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 53850fa5b..0050805f2 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -317,8 +317,10 @@ void EcoSIM::Initialize() { ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total processes: " << ncols_global << std::endl; + *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; + *vo_->os() << "total columns from num_entities: " << ncols_global << std::endl; //Trying to loop over processors now: int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 95dcb8f3f..dec191f59 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -169,6 +169,7 @@ class EcoSIM : public PK_Physical { int num_cols_; int ncols_local; int ncols_global; + int ncols_global_ptype; double saved_time_; double current_time_; From 2d18b3774336e54c5585e6df66ab663784998e62 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Jul 2023 09:16:17 -0700 Subject: [PATCH 421/582] added the initial refactoring of the code to loop over processes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 519 +++++++++++++++++++--- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 4 + 2 files changed, 458 insertions(+), 65 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0050805f2..3535cb5a9 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -126,7 +126,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, prain_key_ = Keys::readKey(*plist_, domain_surf_, "precipitation rain", "precipitation_rain"); elev_key_ = Keys::readKey(*plist_, domain_surf_, "elevation", "elevation"); aspect_key_ = Keys::readKey(*plist_, domain_surf_, "aspect", "aspect"); - slope_key_ = Keys::readKey(*plist_, domain_surf_, "slope magnitude", "slope_magnitude"); + slope_key_ = Keys::readKey(*plist_, domain_surf_, "slope", "slope_magnitude"); //f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); //psnow_key_ = Keys::readKey(plist, domain_surf_, "precipitation snow", "precipitation"); @@ -314,32 +314,6 @@ void EcoSIM::Initialize() { const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); - - ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - - *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; - *vo_->os() << "total columns from num_entities: " << ncols_global << std::endl; - //Trying to loop over processors now: - int numProcesses, p_rank; - MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); - MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); - for (int k = 0; k < numProcesses; ++k) { - MPI_Barrier(MPI_COMM_WORLD); - if (p_rank==k) { - std::cout << "on processor " << p_rank << std::endl; - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << ncols_local << std::endl; - } - } - - //Using cout because it prints for every process instead of just - //rank 0 (might be a way to use vo, but not implemented) - //std::cout << "Global Columns: " << ncols_global << std::endl; - //std::cout << "Local Columns: " << ncols_local << std::endl; - - //Surface properties from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -402,9 +376,32 @@ void EcoSIM::Initialize() { int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //Looping over the columns and initializing - for (int col=0; col!=num_cols_; ++col) { + /*for (int col=0; col!=num_cols_; ++col) { ierr = InitializeSingleColumn(col); + }*/ + + //loop over processes instead: + ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + + *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; + *vo_->os() << "total columns from num_entities: " << ncols_global << std::endl; + //Trying to loop over processors now: + int numProcesses, p_rank; + MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); + MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); + for (int k = 0; k < numProcesses; ++k) { + MPI_Barrier(MPI_COMM_WORLD); + if (p_rank==k) { + std::cout << "on processor " << p_rank << std::endl; + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << ncols_local << std::endl; + + InitializeSingleProcess(p_rank); + } } + // verbose message if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); @@ -543,41 +540,40 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { } //Atm abundances - S_->GetEvaluator("incoming_shortwave_radiation", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& sw_rad = *(*S_->Get("incoming_shortwave_radiation", tag_next_) + S_->GetEvaluator("surface-incoming_shortwave_radiation", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& sw_rad = *(*S_->Get("surface-incoming_shortwave_radiation", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("incoming_longwave_radiation", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& lw_rad = *(*S_->Get("incoming_longwave_radiation", tag_next_) + S_->GetEvaluator("surface-incoming_longwave_radiation", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& lw_rad = *(*S_->Get("surface-incoming_longwave_radiation", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("air_temperature", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& t_air = *(*S_->Get("air_temperature", tag_next_) + S_->GetEvaluator("surface-air_temperature", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& t_air = *(*S_->Get("surface-air_temperature", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("vapor_pressure_air", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& p_vap = *(*S_->Get("vapor_pressure_air", tag_next_) + S_->GetEvaluator("surface-vapor_pressure_air", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& p_vap = *(*S_->Get("surface-vapor_pressure_air", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("wind_speed", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& v_wind = *(*S_->Get("wind_speed", tag_next_) + S_->GetEvaluator("surface-wind_speed", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& v_wind = *(*S_->Get("surface-wind_speed", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("precipitation_rain", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& p_rain = *(*S_->Get("precipitation_rain", tag_next_) + S_->GetEvaluator("surface-precipitation_rain", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& p_rain = *(*S_->Get("surface-precipitation_rain", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("elevation", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& elevation = *S_->Get("elevation", tag_next_) + S_->GetEvaluator("surface-elevation", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& elevation = *S_->Get("surface-elevation", tag_next_) .ViewComponent("cell",false); - S_->GetEvaluator("aspect", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& aspect = *S_->Get("aspect", tag_next_) + S_->GetEvaluator("surface-aspect", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& aspect = *S_->Get("surface-aspect", tag_next_) .ViewComponent("cell",false); - - S_->GetEvaluator("slope", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& slope = *S_->Get("slope", tag_next_) + S_->GetEvaluator("surface-slope_magnitude", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& slope = *S_->Get("surface-slope_magnitude", tag_next_) .ViewComponent("cell",false); if (has_ice) { @@ -600,24 +596,27 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false))(0); } - // loop over columns and apply the model - for (AmanziMesh::Entity_ID col=0; col!=num_cols_; ++col) { - - auto& col_iter = mesh_->cells_of_column(col); - ncells_per_col_ = col_iter.size(); - - //Copy to EcoSIM structures - - AdvanceSingleColumn(dt, col); - } // end loop over columns - - // mark primaries as changed + //loop over processes instead: + ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - // Compute the next time step. - // * will we need to do this? * - //ComputeNextTimeStep(); + *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; + *vo_->os() << "total columns from num_entities: " << ncols_global << std::endl; + //Trying to loop over processors now: + int numProcesses, p_rank; + MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); + MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); + for (int k = 0; k < numProcesses; ++k) { + MPI_Barrier(MPI_COMM_WORLD); + if (p_rank==k) { + std::cout << "on processor " << p_rank << std::endl; + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << ncols_local << std::endl; - //return failed; + AdvanceSingleProcess(p_rank); + } + } } @@ -905,6 +904,12 @@ void EcoSIM::CopyToEcoSIM(int col, props.atm_h2 = atm_h2_; props.atm_nh3 = atm_nh3_; } + + for (int j=0; j < tcc_num; ++j) { + for (int i=0; i < ncells_per_col_; ++i) { + state.total_component_concentration.data[j][i] = (*col_tcc)(i,j); + } + } //mat_props.volume = mesh_->cell_volume(cell;z //mat_props.saturation = water_saturation[0][cell]; @@ -968,8 +973,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - //For the concentration I do not want a vector but a matrix - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -979,6 +982,8 @@ void EcoSIM::CopyFromEcoSIM(const int col, auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); + if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); @@ -1075,6 +1080,346 @@ void EcoSIM::CopyFromEcoSIM(const int col, MatrixColumnToField_(col, tcc, col_tcc.ptr()); } +//Copy to EcoSIM +void EcoSIM::CopyToEcoSIM_process(int proc_rank, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data, + const Tag& water_tag) +{ + //This is the copy function for a loop over a single process instead of a single column + //Fill state with ATS variables that are going to be changed by EcoSIM + const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); + int tcc_num = tcc.NumVectors(); + + const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& relative_permeability = *(*S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydra_cond_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); + //I think I can access the surface variables with col variable and it should + //be what I want + const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& precipitation = *(*S_->Get(prain_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); + + auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_depth = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_rf = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(tcc_num,ncells_per_col_)); + + //Maybe loop over number of processes, then number of columns on that process and append them to their respective datasets? + //Here is where we should do the various field-to-column calls to then pass along + //to the data structures that will pass the data to EcoSIM + //Format is: + //FieldToColumn_(column index, dataset to copy from, vector to put the data in) + + //Gather columns on this process: + ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + + *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; + *vo_->os() << "total columns from num_entities: " << ncols_global_ptype << std::endl; + //Trying to loop over processors now: + int p_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); + MPI_Barrier(MPI_COMM_WORLD); + + std::cout << "on processor " << p_rank << std::endl; + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << ncols_local << std::endl; + + //Loop over columns on this process + for (int col=0; col!=ncols_local; ++col) { + FieldToColumn_(col,porosity,col_poro.ptr()); + FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); + FieldToColumn_(col,water_content,col_wc.ptr()); + FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); + FieldToColumn_(col,liquid_density,col_l_dens.ptr()); + FieldToColumn_(col,rock_density,col_r_dens.ptr()); + FieldToColumn_(col,cell_volume,col_vol.ptr()); + FieldToColumn_(col,hydraulic_conductivity,col_h_cond.ptr()); + FieldToColumn_(col,bulk_density,col_b_dens.ptr()); + FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); + FieldToColumn_(col,rooting_depth_fraction,col_rf.ptr()); + + //Have to make like a tensor version here + FieldToColumn_(col, tcc, col_tcc.ptr()); + + if (has_gas) { + const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); + + FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); + FieldToColumn_(col,gas_density,col_g_dens.ptr()); + } + + if (has_ice) { + const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); + + FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); + FieldToColumn_(col,ice_density,col_i_dens.ptr()); + } + + if (has_energy) { + const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& thermal_conductivity = *(*S_->Get(therm_cond_key_, water_tag).ViewComponent("cell", false))(0); + + FieldToColumn_(col,temp, col_temp.ptr()); + FieldToColumn_(col,thermal_conductivity,col_cond.ptr()); + } + + //Initializing depth here, because it's calculated by a function and not saved in state + //it works a bit differently: + ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); + for (int i=0; i < ncells_per_col_; ++i) { + state.liquid_density.data[col][i] = (*col_l_dens)[i]; + state.porosity.data[col][i] = (*col_poro)[i]; + state.water_content.data[col][i] = (*col_wc)[i]; + state.hydraulic_conductivity.data[col][i] = (*col_h_cond)[i]; + state.bulk_density.data[col][i] = (*col_b_dens)[i]; + //state.suction_head.data[i] = (*col_suc)[i]; + props.plant_wilting_factor.data[col][i] = (*col_wp)[i]; + props.rooting_depth_fraction.data[col][i] = (*col_rf)[i]; + props.liquid_saturation.data[col][i] = (*col_l_sat)[i]; + props.relative_permeability.data[col][i] = (*col_rel_perm)[i]; + props.volume.data[col][i] = (*col_vol)[i]; + props.depth.data[col][i] = (*col_depth)[i]; + props.dz.data[col][i] = (*col_dz)[i]; + + if (has_gas) { + props.gas_saturation.data[col][i] = (*col_g_sat)[i]; + state.gas_density.data[col][i] = (*col_g_dens)[i]; + } + + if (has_ice) { + state.ice_density.data[col][i] = (*col_i_dens)[i]; + props.ice_saturation.data[col][i] = (*col_i_sat)[i]; + } + + if (has_energy) { + state.temperature.data[col][i] = (*col_temp)[i]; + props.thermal_conductivity.data[col][i] = (*col_cond)[i]; + } + } + + //fill surface variables + props.shortwave_radiation[col] = shortwave_radiation[col]; + props.longwave_radiation[col] = longwave_radiation[col]; + props.air_temperature[col] = air_temperature[col]; + props.vapor_pressure_air[col] = vapor_pressure_air[col]; + props.wind_speed[col] = wind_speed[col]; + props.precipitation[col] = precipitation[col]; + props.elevation[col] = elevation[col]; + props.aspect[col] = aspect[col]; + props.slope[col] = slope[col]; + } + + for (int component=0; component < tcc_num; ++component) { + for (int i=0; i < ncells_per_col_; ++i) { + state.total_component_concentration.data[col][component][i] = (*col_tcc)(i,component); + } + } + + //Fill the atmospheric abundances + //NOTE: probably want to add an if statement here to only do this only once + props.atm_n2 = atm_n2_; + props.atm_o2 = atm_o2_; + props.atm_co2 = atm_co2_; + props.atm_ch4 = atm_ch4_; + props.atm_n2o = atm_n2o_; + props.atm_h2 = atm_h2_; + props.atm_nh3 = atm_nh3_; + //mat_props.volume = mesh_->cell_volume(cell;z + //mat_props.saturation = water_saturation[0][cell]; + + // Auxiliary data -- block copy. + /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { + aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); + int num_aux_ints = bgc_engine_->Sizes().num_aux_integers; + int num_aux_doubles = bgc_engine_->Sizes().num_aux_doubles; + + for (int i = 0; i < num_aux_ints; i++) { + double* cell_aux_ints = (*aux_data_)[i]; + aux_data.aux_ints.data[i] = (int)cell_aux_ints[cell]; + } + for (int i = 0; i < num_aux_doubles; i++) { + double* cell_aux_doubles = (*aux_data_)[i + num_aux_ints]; + aux_data.aux_doubles.data[i] = cell_aux_doubles[cell]; + } + }*/ +} + +void EcoSIM::CopyFromEcoSIM_process(const int col, + const BGCProperties& props, + const BGCState& state, + const BGCAuxiliaryData& aux_data, + const Tag& water_tag) +{ + // If the chemistry has modified the porosity and/or density, it needs to + // be updated here. + // (this->water_density())[cell] = state.water_density; + // (this->porosity())[cell] = state.porosity; + + Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); + int tcc_num = tcc.NumVectors(); + + auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); + auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); + auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); + //auto& suction_head = *(*S_->GetW(suc_key_, Amanzi::Tags::NEXT, suc_key_).ViewComponent("cell",false))(0); + auto& relative_permeability = *(*S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false))(0); + auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); + auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); + auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); + auto& hydraulic_conductivity = *(*S_->GetW(hydra_cond_key_, Amanzi::Tags::NEXT, hydra_cond_key_).ViewComponent("cell",false))(0); + auto& bulk_density = *(*S_->GetW(bulk_dens_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); + + auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); + + //Gather columns on this process: + ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + + *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; + *vo_->os() << "total columns from num_entities: " << ncols_global_ptype << std::endl; + //Trying to loop over processors now: + int p_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); + MPI_Barrier(MPI_COMM_WORLD); + + std::cout << "on processor " << p_rank << std::endl; + ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << ncols_local << std::endl; + + //Loop over columns on this process + for (int col=0; col!=ncols_local; ++col) { + + if (has_gas) { + const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); + + for (int i=0; i < ncells_per_col_; ++i) { + (*col_g_dens)[i] = state.gas_density.data[col][i]; + (*col_g_sat)[i] = props.gas_saturation.data[col][i]; + } + + FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); + FieldToColumn_(col,gas_density,col_g_dens.ptr()); + } + + if (has_ice) { + const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); + + for (int i=0; i < ncells_per_col_; ++i) { + (*col_i_dens)[i] = state.ice_density.data[col][i]; + (*col_i_sat)[i] = props.ice_saturation.data[col][i]; + } + + ColumnToField_(col,ice_saturation,col_i_sat.ptr()); + ColumnToField_(col,ice_density,col_i_dens.ptr()); + } + + if (has_energy) { + const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& thermal_conductivity = *(*S_->Get(therm_cond_key_, water_tag).ViewComponent("cell", false))(0); + + for (int i=0; i < ncells_per_col_; ++i) { + (*col_temp)[i] = state.temperature.data[col][i]; + (*col_cond)[i] = props.thermal_conductivity.data[col][i]; + } + + ColumnToField_(col,temp, col_temp.ptr()); + ColumnToField_(col,thermal_conductivity,col_cond.ptr()); + } + + for (int i=0; i < ncells_per_col_; ++i) { + (*col_l_dens)[i] = state.liquid_density.data[col][i]; + (*col_poro)[i] = state.porosity.data[col][i]; + (*col_wc)[i] = state.water_content.data[col][i]; + (*col_h_cond)[i] = state.hydraulic_conductivity.data[col][i]; + (*col_b_dens)[i] = state.bulk_density.data[col][i]; + + if (has_gas) { + (*col_g_dens)[i] = state.gas_density.data[col][i]; + } + + if (has_ice) { + (*col_i_dens)[i] = state.ice_density.data[col][i]; + } + + if (has_energy) { + (*col_temp)[i] = state.temperature.data[col][i]; + } + } + + ColumnToField_(col,porosity,col_poro.ptr()); + ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); + ColumnToField_(col,water_content,col_wc.ptr()); + ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); + ColumnToField_(col,liquid_density,col_l_dens.ptr()); + ColumnToField_(col,rock_density,col_r_dens.ptr()); + ColumnToField_(col,cell_volume,col_vol.ptr()); + ColumnToField_(col,hydraulic_conductivity,col_h_cond.ptr()); + ColumnToField_(col,bulk_density,col_b_dens.ptr()); + ColumnToField_(col,plant_wilting_factor,col_wp.ptr()); + ColumnToField_(col,rooting_depth_fraction,col_rf.ptr()); + } + +} + /* ******************************************************************* * This helper performs initialization on a single column within Amanzi's state. ******************************************************************* */ @@ -1125,5 +1470,49 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) return num_iterations; } +int EcoSIM::InitializeSingleProcess(int proc) +{ + CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + + //ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); + bgc_engine_->DataTest(); + + int num_iterations = 1; + + bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); + CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + + // ETC: hacking to get consistent solution -- if there is no water + // (e.g. surface system, we still need to call EnforceCondition() as it also + // gets aux data set up correctly. But the concentrations need to be + // overwritten as 0 to get expected output. Therefore we manually overwrite + // this now. Previously this happened due to a bug in ATS's reactive + // transport coupler -- happy accidents. + //if (alq_mat_props_.saturation <= saturation_tolerance_) + // for (int i=0; i!=aqueous_components_->NumVectors(); ++i) (*aqueous_components_)[i][cell] = 0.; + //return 0; +} + +int EcoSIM::AdvanceSingleProcess(double dt, int proc) +{ + // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but + // should use the same tag as transport. See #673 + CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + + int num_iterations = 1; +/***************************************************************** + ADVANCE CALL GOES HERE + *******************************************************************/ + + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, + bgc_sizes_, num_iterations, col); + + // Move the information back into Amanzi's state, updating the given total concentration vector. + CopyFromEcoSIM_process(proc, + bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + + return num_iterations; +} + } // namespace EcoSIM } // namespace Amanzi diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index dec191f59..3bd3cda01 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -119,6 +119,10 @@ class EcoSIM : public PK_Physical { int AdvanceSingleColumn(double dt, int col); + int InitializeSingleProcess(int col); + + int AdvanceSingleProcess(double dt, int col); + void CopyEcoSIMStateToAmanzi( const int cell, const BGCProperties& props, From b32319aefb92399349fc959193e19c0fc4bef74c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Jul 2023 09:18:11 -0700 Subject: [PATCH 422/582] Forgot to update the header --- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 3bd3cda01..b4f543cc4 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -115,13 +115,26 @@ class EcoSIM : public PK_Physical { const BGCAuxiliaryData& aux_data, const Tag& water_tag = Tags::DEFAULT); + //Helper functions from Alquimia + void CopyToEcoSIM_process(int proc, + BGCProperties& props, + BGCState& state, + BGCAuxiliaryData& aux_data, + const Tag& water_tag = Tags::DEFAULT); + + void CopyFromEcoSIM_process(const int proc, + const BGCProperties& props, + const BGCState& state, + const BGCAuxiliaryData& aux_data, + const Tag& water_tag = Tags::DEFAULT); + int InitializeSingleColumn(int col); int AdvanceSingleColumn(double dt, int col); - int InitializeSingleProcess(int col); + int InitializeSingleProcess(int proc); - int AdvanceSingleProcess(double dt, int col); + int AdvanceSingleProcess(double dt, int proc); void CopyEcoSIMStateToAmanzi( const int cell, From f57e672242147dab310c4d023f46654cbfa827ff Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Jul 2023 10:26:49 -0700 Subject: [PATCH 423/582] just cleaning up print statements --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 131 ++-------------------- 1 file changed, 9 insertions(+), 122 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 3535cb5a9..05862512a 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -32,7 +32,7 @@ #include "exceptions.hh" #include "Mesh.hh" -// include evaluators here +// include custom evaluators here #include "hydraulic_conductivity_evaluator.hh" #include "bulk_density_evaluator.hh" @@ -51,30 +51,10 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, ncells_per_col_(-1), saved_time_(0.0) { - //grab the relevant domains, surface is needed to find the columns later + //grab the surface and subsurface domains domain_ = plist_->get("domain name", "domain"); domain_surf_ = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); - // obtain key of fields - // grid position (X,Y,Z) - can we just pass Z and assume X and Y are 0? - // Aspect in geometric format - // water table depth - There's a water table evaluator in - // /src/constitutive_relations/column_integrators/ but I don't see it used - // anywhere can we just use it here? - - - //For now a few of the evaluators don't work because they are no initialized - // I've commented out elevation and replaced others with something that does - //exist: - // - // mass_density_ice - // mass_gas_density - // - // additionally temperature doesn't work because it is owned by energy - // - // - // Simple tests with the keys - // transport tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell @@ -87,20 +67,12 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); suc_key_ = Keys::readKey(*plist_,domain_,"suction","suction_head"); - - //densities - //If we need bulk density do we need volume fractions of each quantity? - //This can be computed from the saturations and porosity (I think) via: - // f_rock = (1 - porosity) - // f_liq = S_liq * porosity - // f_gas = S_gas * porosity - // f_ice = S_ice * porosity - liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_den_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); gas_den_key_ = Keys::readKey(*plist_, domain_,"mass density gas", "mass_density_gas"); gas_den_key_test_ = Keys::readKey(*plist_, domain_, "mass density gas", "mass_density_gas"); rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); + //energy T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); therm_cond_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); @@ -111,7 +83,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); f_wp_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); f_root_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); - //Evaluator keys + + //Custom Evaluator keys hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); @@ -128,9 +101,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, aspect_key_ = Keys::readKey(*plist_, domain_surf_, "aspect", "aspect"); slope_key_ = Keys::readKey(*plist_, domain_surf_, "slope", "slope_magnitude"); - //f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); - //psnow_key_ = Keys::readKey(plist, domain_surf_, "precipitation snow", "precipitation"); - //Atmospheric abundance keys atm_n2_ = plist_->get("atmospheric N2"); atm_o2_ = plist_->get("atmospheric O2"); @@ -140,17 +110,9 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, atm_h2_ = plist_->get("atmospheric H2"); atm_nh3_ = plist_->get("atmospheric NH3"); - // parameters - // initial timestep dt_ = plist_->get("initial time step", 1.); - //Heat capacity looks like the default units are molar heat capacity c_m_ = plist_->get("heat capacity [J mol^-1 K^-1]"); - //They also sometimes use a version of heat capacity that is just this - //quantity times 1e-6: - //ka_ = 1.e-6 * plist_.get("heat capacity [J kg^-1 K^-1]"); - //Unclear what we need - //This initialized the engine (found in BGCEngine.cc) This is the code that //actually points to the driver if (!plist_->isParameter("engine")) { @@ -249,19 +211,6 @@ void EcoSIM::Setup() { // -- Initialize owned (dependent) variables. void EcoSIM::Initialize() { - //Now we have to initalize the variables (i.e. give them initial values) - //In our PK it will only be done for variables owned by the PK - //Keeping an example of how it's done generically here: - //S_->GetW("co2_decomposition", tag_next_, name_).PutScalar(0.); - //S_->GetRecordW("co2_decomposition", tag_next_, name_).set_initialized(); - - //In alquimia they initialize the axuiliary data via a function called InitializeCVField - //which can be found in Amanzi/src/PKs/PK_Physical.cc: - - // initialize fields as soon as possible - /*for (size_t i = 0; i < aux_names_.size(); ++i) { - InitializeCVField(S_, *vo_, aux_names_[i], tag_next_, passwd_, 0.0); - }*/ //Need to know the number of components to initialize data structures const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); @@ -309,11 +258,6 @@ void EcoSIM::Initialize() { S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); - //Teuchos::OSTab tab = vo_->getOSTab(); - - const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) - .ViewComponent("cell",false))(0); - //Surface properties from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -325,10 +269,6 @@ void EcoSIM::Initialize() { S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); - //Here we put the checks for the optional keys - //Temperature, ice and gas - //plist_->print(std::cout); - if (S_->HasRecord(gas_den_key_test_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density gas key" << std::endl; @@ -946,10 +886,6 @@ void EcoSIM::CopyFromEcoSIM(const int col, const BGCAuxiliaryData& aux_data, const Tag& water_tag) { - // If the chemistry has modified the porosity and/or density, it needs to - // be updated here. - // (this->water_density())[cell] = state.water_density; - // (this->porosity())[cell] = state.porosity; Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); int tcc_num = tcc.NumVectors(); @@ -1104,8 +1040,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); - //I think I can access the surface variables with col variable and it should - //be what I want + const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); @@ -1139,12 +1074,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(tcc_num,ncells_per_col_)); - //Maybe loop over number of processes, then number of columns on that process and append them to their respective datasets? - //Here is where we should do the various field-to-column calls to then pass along - //to the data structures that will pass the data to EcoSIM - //Format is: - //FieldToColumn_(column index, dataset to copy from, vector to put the data in) - //Gather columns on this process: ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -1202,9 +1131,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(col,thermal_conductivity,col_cond.ptr()); } - //Initializing depth here, because it's calculated by a function and not saved in state - //it works a bit differently: + // This is for computing depth ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); + for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[col][i] = (*col_l_dens)[i]; state.porosity.data[col][i] = (*col_poro)[i]; @@ -1263,24 +1192,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.atm_n2o = atm_n2o_; props.atm_h2 = atm_h2_; props.atm_nh3 = atm_nh3_; - //mat_props.volume = mesh_->cell_volume(cell;z - //mat_props.saturation = water_saturation[0][cell]; - // Auxiliary data -- block copy. - /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { - aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); - int num_aux_ints = bgc_engine_->Sizes().num_aux_integers; - int num_aux_doubles = bgc_engine_->Sizes().num_aux_doubles; - - for (int i = 0; i < num_aux_ints; i++) { - double* cell_aux_ints = (*aux_data_)[i]; - aux_data.aux_ints.data[i] = (int)cell_aux_ints[cell]; - } - for (int i = 0; i < num_aux_doubles; i++) { - double* cell_aux_doubles = (*aux_data_)[i + num_aux_ints]; - aux_data.aux_doubles.data[i] = cell_aux_doubles[cell]; - } - }*/ } void EcoSIM::CopyFromEcoSIM_process(const int col, @@ -1289,10 +1201,6 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, const BGCAuxiliaryData& aux_data, const Tag& water_tag) { - // If the chemistry has modified the porosity and/or density, it needs to - // be updated here. - // (this->water_density())[cell] = state.water_density; - // (this->porosity())[cell] = state.porosity; Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); int tcc_num = tcc.NumVectors(); @@ -1435,15 +1343,6 @@ int EcoSIM::InitializeSingleColumn(int col) bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - // ETC: hacking to get consistent solution -- if there is no water - // (e.g. surface system, we still need to call EnforceCondition() as it also - // gets aux data set up correctly. But the concentrations need to be - // overwritten as 0 to get expected output. Therefore we manually overwrite - // this now. Previously this happened due to a bug in ATS's reactive - // transport coupler -- happy accidents. - //if (alq_mat_props_.saturation <= saturation_tolerance_) - // for (int i=0; i!=aqueous_components_->NumVectors(); ++i) (*aqueous_components_)[i][cell] = 0.; - //return 0; } /* ******************************************************************* @@ -1482,15 +1381,6 @@ int EcoSIM::InitializeSingleProcess(int proc) bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - // ETC: hacking to get consistent solution -- if there is no water - // (e.g. surface system, we still need to call EnforceCondition() as it also - // gets aux data set up correctly. But the concentrations need to be - // overwritten as 0 to get expected output. Therefore we manually overwrite - // this now. Previously this happened due to a bug in ATS's reactive - // transport coupler -- happy accidents. - //if (alq_mat_props_.saturation <= saturation_tolerance_) - // for (int i=0; i!=aqueous_components_->NumVectors(); ++i) (*aqueous_components_)[i][cell] = 0.; - //return 0; } int EcoSIM::AdvanceSingleProcess(double dt, int proc) @@ -1500,11 +1390,8 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 1; -/***************************************************************** - ADVANCE CALL GOES HERE - *******************************************************************/ - bgc_engine_->Advance(dt, bgc_props_, bgc_state_, + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); // Move the information back into Amanzi's state, updating the given total concentration vector. From 708e5a17c8f4c9cb8dc77a1c84615ebf87a18a3d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 20 Jul 2023 14:23:24 -0700 Subject: [PATCH 424/582] finished refactoring the memory modules to accept higher-order data --- src/pks/ecosim_pk/data/BGC_containers.hh | 60 ++++++ src/pks/ecosim_pk/data/BGC_memory.cc | 242 ++++++++++++++++++----- 2 files changed, 256 insertions(+), 46 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 2a9eee5cc..a97461185 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -79,11 +79,70 @@ extern "C" { char** data; } BGCMatrixString; + typedef struct { + int rows, cols, procs, cap_rows, cap_cols, cap_procs; + double*** data; + } BGCTensorDouble; + + typedef struct { + int rows, cols, procs, cap_rows, cap_cols, cap_procs; + int*** data; + } BGCTensorInt; + + typedef struct { + int rows, cols, procs, capacity; + char*** data; + } BGCTensorString; + typedef struct { int ncells_per_col_; int num_components; + int num_procs; } BGCSizes; + typedef struct { + BGCMatrixDouble liquid_density; + BGCMatrixDouble gas_density; + BGCMatrixDouble ice_density; + BGCMatrixDouble porosity; + BGCMatrixDouble water_content; + BGCMatrixDouble suction_head; + BGCMatrixDouble temperature; + BGCMatrixDouble hydraulic_conductivity; + BGCMatrixDouble bulk_density; + BGCTensorDouble total_component_concentration; + } BGCState; + + typedef struct { + BGCMatrixDouble liquid_saturation; + BGCMatrixDouble gas_saturation; + BGCMatrixDouble ice_saturation; + BGCMatrixDouble relative_permeability; + BGCMatrixDouble thermal_conductivity; + BGCMatrixDouble volume; + BGCMatrixDouble depth; + BGCMatrixDouble dz; + BGCMatrixDouble plant_wilting_factor; + BGCMatrixDouble rooting_depth_fraction; + BGCVectorDouble shortwave_radiation; + BGCVectorDouble longwave_radiation; + BGCVectorDouble air_temperature; + BGCVectorDouble vapor_pressure_air; + BGCVectorDouble wind_speed; + BGCVectorDouble precipitation; + BGCVectorDouble elevation; + BGCVectorDouble aspect; + BGCVectorDouble slope; + double atm_n2; + double atm_o2; + double atm_co2; + double atm_ch4; + double atm_n2o; + double atm_h2; + double atm_nh3; + } BGCProperties; + + /* typedef struct { BGCVectorDouble liquid_density; BGCVectorDouble gas_density; @@ -125,6 +184,7 @@ extern "C" { double atm_h2; double atm_nh3; } BGCProperties; + */ typedef struct { BGCVectorInt aux_ints; /* [-] */ diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index b8ccea736..0a4e3465e 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -62,7 +62,7 @@ static inline int nearest_power_of_2(int n) /******************************************************************************* ** - ** Alquimia Vectors + ** BGC Vectors ** *******************************************************************************/ void AllocateBGCVectorDouble(const int size, BGCVectorDouble* vector) { @@ -207,39 +207,89 @@ void FreeBGCMatrixInt(BGCMatrixInt* matrix) { } } /* end FreeBGCMatrixInt() */ -/*Not quite sure how to do the string version, so I'm punting for now as -I don't think we need it yet -void AllocateBGCmatrixString(const int rows, const int cols, BGCmatrixString* matrix) { - int i; - if (size > 0) { - matrix->rows = rows; - matrix->cols = cols; - matrix->capacity = nearest_power_of_2(rows * cols); - matrix->data = (char**) calloc((size_t)matrix->capacity, sizeof(char*)); - //ALQUIMIA_ASSERT(NULL != matrix->data); - for (i = 0; i < matrix->size; ++i) { - matrix->data[i] = (char*) calloc((size_t)kBGCMaxStringLength, sizeof(char)); - //ALQUIMIA_ASSERT(NULL != matrix->data[i]); +/******************************************************************************* + ** + ** BGC Tensor + ** + *******************************************************************************/ + +void AllocateBGCTensorDouble(const int rows, const int cols, const int procs, BGCTensorDouble* tensor) { + if ((rows > 0 ) || (cols > 0) || (procs > 0)){ + tensor->rows = rows; + tensor->cols = cols; + tensor->procs = procs; + + tensor->cap_rows = nearest_power_of_2(rows); + tensor->cap_cols = nearest_power_of_2(cols); + tensor->cap_procs = nearest_power_of_2(procs); + + tensor->data = (double***) calloc((size_t)tensor->cap_rows, sizeof(double**)); + for (int i = 0; i < tensor->rows; ++i) { + tensor->data[i] = (double**) calloc((size_t)tensor->cap_cols, sizeof(double*)); + for (int j = 0; j < tensor->procs; j++) { + tensor->data[i][j] = (double*) calloc((size_t)tensor->cap_procs, sizeof(double)); + } } + //ALQUIMIA_ASSERT(NULL != matrix->data); } else { - matrix->size = 0; - matrix->capacity = 0; - matrix->data = NULL; + tensor->rows = 0; + tensor->cols = 0; + tensor->procs = 0; + tensor->cap_rows = 0; + tensor->cap_cols = 0; + tensor->data = NULL; } -} end AllocateBGCmatrixString() +} /* end AllocateBGCmatrixDouble() */ -void FreeBGCmatrixString(BGCmatrixString* matrix) { - int i; - if (matrix != NULL) { - for (i = 0; i < matrix->size; ++i) { - free(matrix->data[i]); +void FreeBGCTensorDouble(BGCTensorDouble* tensor) { + if (tensor != NULL) { + free(tensor->data); + tensor->data = NULL; + tensor->rows = 0; + tensor->cols = 0; + tensor->cap_rows = 0; + tensor->cap_cols = 0; + } +} /* end FreeBGCmatrixDouble() */ + +void AllocateBGCTensorInt(const int rows, const int cols, const int procs, BGCTensorInt* tensor) { + if ((rows > 0 ) || (cols > 0) || (procs > 0)){ + tensor->rows = rows; + tensor->cols = cols; + tensor->procs = procs; + + tensor->cap_rows = nearest_power_of_2(rows); + tensor->cap_cols = nearest_power_of_2(cols); + tensor->cap_procs = nearest_power_of_2(procs); + + tensor->data = (int***) calloc((size_t)tensor->cap_rows, sizeof(int**)); + for (int i = 0; i < tensor->rows; ++i) { + tensor->data[i] = (int**) calloc((size_t)tensor->cap_cols, sizeof(int*)); + for (int j = 0; j < tensor->procs; j++) { + tensor->data[i][j] = (int*) calloc((size_t)tensor->cap_procs, sizeof(int)); + } } - free(matrix->data); - matrix->data = NULL; - matrix->size = 0; - matrix->capacity = 0; + //ALQUIMIA_ASSERT(NULL != matrix->data); + } else { + tensor->rows = 0; + tensor->cols = 0; + tensor->procs = 0; + tensor->cap_rows = 0; + tensor->cap_cols = 0; + tensor->data = NULL; + } +} /* end AllocateBGCmatrixint() */ + +void FreeBGCTensorint(BGCTensorint* tensor) { + if (tensor != NULL) { + free(tensor->data); + tensor->data = NULL; + tensor->rows = 0; + tensor->cols = 0; + tensor->cap_rows = 0; + tensor->cap_cols = 0; } -} end FreeBGCmatrixString() */ +} /* end FreeBGCmatrixint() */ /******************************************************************************* ** @@ -252,6 +302,118 @@ For reference the old function call was: void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ + void AllocateBGCState(BGCSizes* sizes, BGCState* state, + int ncells_per_col_, int num_components, int num_procs) { + sizes->ncells_per_col_ = ncells_per_col_; + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->liquid_density)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->gas_density)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->ice_density)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->porosity)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->water_content)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->suction_head)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->temperature)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->hydraulic_conductivity)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->bulk_density)); + AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_components, sizes->num_procs, &(state->total_component_concentration)); + //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); + + } /* end AllocateBGCState() */ + + void FreeBGCState(BGCState* state) { + if (state != NULL) { + FreeBGCMatrixDouble(&(state->liquid_density)); + FreeBGCMatrixDouble(&(state->gas_density)); + FreeBGCMatrixDouble(&(state->ice_density)); + FreeBGCMatrixDouble(&(state->porosity)); + FreeBGCMatrixDouble(&(state->water_content)); + FreeBGCMatrixDouble(&(state->suction_head)); + FreeBGCMatrixDouble(&(state->temperature)); + FreeBGCMatrixDouble(&(state->hydraulic_conductivity)); + FreeBGCMatrixDouble(&(state->bulk_density)); + FreeBGCTensorDouble(&(state->total_component_concentration)); + } + } /* end FreeAlquimiaState() */ + + /******************************************************************************* + ** + ** Auxiliary Data + ** + *******************************************************************************/ + + void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, + int ncells_per_col_) { + AllocateBGCMatrixInt(sizes->ncells_per_col_, + &(aux_data->aux_ints)); + + AllocateBGCMatrixDouble(sizes->ncells_per_col_, + &(aux_data->aux_doubles)); + + } /* end AllocateAlquimiaAuxiliaryData() */ + + void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { + if (aux_data != NULL) { + FreeBGCMatrixInt(&(aux_data->aux_ints)); + FreeBGCMatrixDouble(&(aux_data->aux_doubles)); + } + } /* end FreeAlquimiaAuxiliaryData() */ + + /******************************************************************************* + ** + ** Properties + ** + *******************************************************************************/ + + void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, + int ncells_per_col_, int num_procs) { + sizes->ncells_per_col_ = ncells_per_col_; + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->liquid_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->gas_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->ice_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->relative_permeability)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->thermal_conductivity)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->volume)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->depth)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->dz)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->plant_wilting_factor)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->rooting_depth_fraction)); + + AllocateBGCVectrorDouble(sizes->num_procs, &(props->shortwave_radiation)); + AllocateBGCVectrorDouble(sizes->num_procs, &(props->longwave_radiation)); + AllocateBGCVectrorDouble(sizes->num_procs, &(props->air_temperature)); + AllocateBGCVectrorDouble(sizes->num_procs, &(props->vapor_pressure_air)); + AllocateBGCVectrorDouble(sizes->num_procs, &(props->wind_speed)); + AllocateBGCVectrorDouble(sizes->num_procs, &(props->precipitation)); + AllocateBGCVectrorDouble(sizes->num_procs, &(props->elevation)); + AllocateBGCVectrorDouble(sizes->num_procs, &(props->aspect)); + AllocateBGCVectrorDouble(sizes->num_procs, &(props->slope)); + } /* end AllocateAlquimiaProperties() */ + + void FreeBGCProperties(BGCProperties* props) { + if (props != NULL) { + FreeBGCMatrixDouble(&(props->liquid_saturation)); + FreeBGCMatrixDouble(&(props->gas_saturation)); + FreeBGCMatrixDouble(&(props->ice_saturation)); + FreeBGCMatrixDouble(&(props->relative_permeability)); + FreeBGCMatrixDouble(&(props->thermal_conductivity)); + FreeBGCMatrixDouble(&(props->volume)); + FreeBGCMatrixDouble(&(props->depth)); + FreeBGCMatrixDouble(&(props->dz)); + FreeBGCMatrixDouble(&(props->plant_wilting_factor)); + FreeBGCMatrixDouble(&(props->rooting_depth_fraction)); + + FreeBGCVectrorDouble(&(props->shortwave_radiation)); + FreeBGCVectrorDouble(&(props->longwave_radiation)); + FreeBGCVectrorDouble(&(props->air_temperature)); + FreeBGCVectrorDouble(&(props->vapor_pressure_air)); + FreeBGCVectrorDouble(&(props->wind_speed)); + FreeBGCVectrorDouble(&(props->precipitation)); + FreeBGCVectrorDouble(&(props->elevation)); + FreeBGCVectrorDouble(&(props->aspect)); + FreeBGCVectrorDouble(&(props->slope)); + } + } + +/* OLD VERSION OF THE DATA MODULES void AllocateBGCState(BGCSizes* sizes, BGCState* state, int ncells_per_col_, int num_components) { sizes->ncells_per_col_ = ncells_per_col_; @@ -267,7 +429,7 @@ void AllocateBGCState(BGCSizes* sizes, BGCState* state, AllocateBGCMatrixDouble(sizes->ncells_per_col_,sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); -} /* end AllocateBGCState() */ +} void FreeBGCState(BGCState* state) { if (state != NULL) { @@ -282,13 +444,7 @@ void FreeBGCState(BGCState* state) { FreeBGCVectorDouble(&(state->bulk_density)); FreeBGCMatrixDouble(&(state->total_component_concentration)); } -} /* end FreeAlquimiaState() */ - -/******************************************************************************* - ** - ** Auxiliary Data - ** - *******************************************************************************/ +} void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, int ncells_per_col_) { @@ -298,20 +454,14 @@ void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux AllocateBGCVectorDouble(sizes->ncells_per_col_, &(aux_data->aux_doubles)); -} /* end AllocateAlquimiaAuxiliaryData() */ +} void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { if (aux_data != NULL) { FreeBGCVectorInt(&(aux_data->aux_ints)); FreeBGCVectorDouble(&(aux_data->aux_doubles)); } -} /* end FreeAlquimiaAuxiliaryData() */ - -/******************************************************************************* - ** - ** Properties - ** - *******************************************************************************/ +} void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, int ncells_per_col_) { @@ -327,7 +477,7 @@ void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->dz)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->plant_wilting_factor)); AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->rooting_depth_fraction)); -} /* end AllocateAlquimiaProperties() */ +} void FreeBGCProperties(BGCProperties* props) { if (props != NULL) { @@ -342,7 +492,7 @@ void FreeBGCProperties(BGCProperties* props) { FreeBGCVectorDouble(&(props->plant_wilting_factor)); FreeBGCVectorDouble(&(props->rooting_depth_fraction)); } -} /* end FreeAlquimiaProperties() */ +} /******************************************************************************* ** From 4985f2fe813b0945bf0453a3cfca612464639699 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Jul 2023 15:49:58 -0700 Subject: [PATCH 425/582] memory fixes related to the tensors --- src/pks/ecosim_pk/data/BGC_memory.cc | 38 ++++++++++++++-------------- src/pks/ecosim_pk/data/BGC_memory.hh | 6 +++++ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 0a4e3465e..10f9ae012 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -280,7 +280,7 @@ void AllocateBGCTensorInt(const int rows, const int cols, const int procs, BGCTe } } /* end AllocateBGCmatrixint() */ -void FreeBGCTensorint(BGCTensorint* tensor) { +void FreeBGCTensorInt(BGCTensorint* tensor) { if (tensor != NULL) { free(tensor->data); tensor->data = NULL; @@ -377,15 +377,15 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->plant_wilting_factor)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->rooting_depth_fraction)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->shortwave_radiation)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->longwave_radiation)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->air_temperature)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->vapor_pressure_air)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->wind_speed)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->precipitation)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->elevation)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->aspect)); - AllocateBGCVectrorDouble(sizes->num_procs, &(props->slope)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->shortwave_radiation)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->longwave_radiation)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->air_temperature)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->vapor_pressure_air)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->wind_speed)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->precipitation)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->elevation)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->aspect)); + AllocateBGCVectorDouble(sizes->num_procs, &(props->slope)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { @@ -401,15 +401,15 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(props->plant_wilting_factor)); FreeBGCMatrixDouble(&(props->rooting_depth_fraction)); - FreeBGCVectrorDouble(&(props->shortwave_radiation)); - FreeBGCVectrorDouble(&(props->longwave_radiation)); - FreeBGCVectrorDouble(&(props->air_temperature)); - FreeBGCVectrorDouble(&(props->vapor_pressure_air)); - FreeBGCVectrorDouble(&(props->wind_speed)); - FreeBGCVectrorDouble(&(props->precipitation)); - FreeBGCVectrorDouble(&(props->elevation)); - FreeBGCVectrorDouble(&(props->aspect)); - FreeBGCVectrorDouble(&(props->slope)); + FreeBGCVectorDouble(&(props->shortwave_radiation)); + FreeBGCVectorDouble(&(props->longwave_radiation)); + FreeBGCVectorDouble(&(props->air_temperature)); + FreeBGCVectorDouble(&(props->vapor_pressure_air)); + FreeBGCVectorDouble(&(props->wind_speed)); + FreeBGCVectorDouble(&(props->precipitation)); + FreeBGCVectorDouble(&(props->elevation)); + FreeBGCVectorDouble(&(props->aspect)); + FreeBGCVectorDouble(&(props->slope)); } } diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index a7ab1e0c3..7f29305db 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -59,6 +59,12 @@ extern "C" { void AllocateBGCMatrixString(const int rows, const int cols, BGCMatrixString* matrix); void FreeBGCMatrixString(BGCMatrixString* matrix); + void AllocateBGCTensorDouble(const int rows, const int cols, BGCTensorDouble* tensor); + void FreeBGCMatrixDouble(BGCMatrixDouble* tensor); + + void AllocateBGCTensorInt(const int rows, const int cols, BGCTensorInt* tensor); + void FreeBGCTensorInt(BGCTensorInt* tensor); + /* State */ void AllocateBGCState(BGCSizes* sizes, BGCState* state, From 6f08766f4886d4eb20e0fcd251b0b6f66962118d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Jul 2023 17:23:07 -0700 Subject: [PATCH 426/582] minor bugfixes --- src/pks/ecosim_pk/data/BGC_memory.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 10f9ae012..d8eb066f8 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -280,7 +280,7 @@ void AllocateBGCTensorInt(const int rows, const int cols, const int procs, BGCTe } } /* end AllocateBGCmatrixint() */ -void FreeBGCTensorInt(BGCTensorint* tensor) { +void FreeBGCTensorInt(BGCTensorInt* tensor) { if (tensor != NULL) { free(tensor->data); tensor->data = NULL; @@ -339,7 +339,7 @@ void AllocateBGCState(const BGCSizes* const sizes, ** Auxiliary Data ** *******************************************************************************/ - + /* void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, int ncells_per_col_) { AllocateBGCMatrixInt(sizes->ncells_per_col_, @@ -348,14 +348,15 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, &(aux_data->aux_doubles)); - } /* end AllocateAlquimiaAuxiliaryData() */ + } // end AllocateAlquimiaAuxiliaryData() void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { if (aux_data != NULL) { FreeBGCMatrixInt(&(aux_data->aux_ints)); FreeBGCMatrixDouble(&(aux_data->aux_doubles)); } - } /* end FreeAlquimiaAuxiliaryData() */ + } // end FreeAlquimiaAuxiliaryData() + */ /******************************************************************************* ** @@ -368,7 +369,7 @@ void AllocateBGCState(const BGCSizes* const sizes, sizes->ncells_per_col_ = ncells_per_col_; AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->liquid_saturation)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->gas_saturation)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->ice_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->ice_saturation)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->relative_permeability)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->thermal_conductivity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->volume)); From 0e2c275bc15844643a65f62546aa94d327c52f70 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Jul 2023 17:40:20 -0700 Subject: [PATCH 427/582] removing serial versions of the functions because they error out. --- src/pks/ecosim_pk/BGCEngine.cc | 4 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 343 +--------------------- 2 files changed, 3 insertions(+), 344 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 23db47780..d40091114 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -32,7 +32,7 @@ namespace EcoSIM { namespace { //Here are the major function that the engine will need -void CopyBGCState(BGCState* dest, BGCState* src) +/*void CopyBGCState(BGCState* dest, BGCState* src) { memcpy(dest->liquid_density.data, src->liquid_density.data, sizeof(double) * src->liquid_density.size); memcpy(dest->gas_density.data, src->gas_density.data, sizeof(double) * src->gas_density.size); @@ -65,7 +65,7 @@ void CopyBGCAuxiliaryData(BGCAuxiliaryData* dest, BGCAuxiliaryData* src) memcpy(dest->aux_doubles.data, src->aux_doubles.data, sizeof(double) * src->aux_doubles.size); } -} // namespace +} // */ BGCEngine::BGCEngine(const std::string& engineName, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 05862512a..faabd4abe 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -554,7 +554,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); std::cout << ncols_local << std::endl; - AdvanceSingleProcess(p_rank); + AdvanceSingleProcess(dt, p_rank); } } @@ -675,347 +675,6 @@ void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, } } -//Copy to EcoSIM -void EcoSIM::CopyToEcoSIM(int col, - BGCProperties& props, - BGCState& state, - BGCAuxiliaryData& aux_data, - const Tag& water_tag) -{ - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Starting copy step" << std::endl; - //Fill state with ATS variables that are going to be changed by EcoSIM - const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); - int tcc_num = tcc.NumVectors(); - - const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& relative_permeability = *(*S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydra_cond_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); - //I think I can access the surface variables with col variable and it should - //be what I want - const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& precipitation = *(*S_->Get(prain_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); - - //Define the column vectors to hold the data - auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_depth = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_wp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_rf = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - - col_vol_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - col_wc_save = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - //For the concentration I do not want a vector but a matrix - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); - - //Here is where we should do the various field-to-column calls to then pass along - //to the data structures that will pass the data to EcoSIM - //Format is: - //FieldToColumn_(column index, dataset to copy from, vector to put the data in) - FieldToColumn_(col,porosity,col_poro.ptr()); - FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); - FieldToColumn_(col,water_content,col_wc.ptr()); - //FieldToColumn_(col,suction_head,col_suc.ptr()); - FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); - FieldToColumn_(col,liquid_density,col_l_dens.ptr()); - FieldToColumn_(col,rock_density,col_r_dens.ptr()); - FieldToColumn_(col,cell_volume,col_vol.ptr()); - FieldToColumn_(col,hydraulic_conductivity,col_h_cond.ptr()); - FieldToColumn_(col,bulk_density,col_b_dens.ptr()); - FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); - FieldToColumn_(col,rooting_depth_fraction,col_rf.ptr()); - - MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); - - FieldToColumn_(col,cell_volume,col_vol_save.ptr()); - FieldToColumn_(col,water_content,col_wc_save.ptr()); - - if (has_gas) { - const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); - - FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); - FieldToColumn_(col,gas_density,col_g_dens.ptr()); - } - - if (has_ice) { - const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); - - FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); - FieldToColumn_(col,ice_density,col_i_dens.ptr()); - } - - if (has_energy) { - const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& thermal_conductivity = *(*S_->Get(therm_cond_key_, water_tag).ViewComponent("cell", false))(0); - - FieldToColumn_(col,temp, col_temp.ptr()); - FieldToColumn_(col,thermal_conductivity,col_cond.ptr()); - } - - //Initializing depth here, because it's calculated by a function and not saved in state - //it works a bit differently: - ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); - - // I think I need to loop over the column data and save it to the data - // structures. Eventually I could probably rewrite FieldToColumn_ to do this - // have to fill tcc separately (I think) - - for (int i=0; i < ncells_per_col_; ++i) { - state.liquid_density.data[i] = (*col_l_dens)[i]; - state.porosity.data[i] = (*col_poro)[i]; - state.water_content.data[i] = (*col_wc)[i]; - state.hydraulic_conductivity.data[i] = (*col_h_cond)[i]; - state.bulk_density.data[i] = (*col_b_dens)[i]; - //state.suction_head.data[i] = (*col_suc)[i]; - props.plant_wilting_factor.data[i] = (*col_wp)[i]; - props.rooting_depth_fraction.data[i] = (*col_rf)[i]; - props.liquid_saturation.data[i] = (*col_l_sat)[i]; - props.relative_permeability.data[i] = (*col_rel_perm)[i]; - props.volume.data[i] = (*col_vol)[i]; - props.depth.data[i] = (*col_depth)[i]; - props.dz.data[i] = (*col_dz)[i]; - - if (has_gas) { - props.gas_saturation.data[i] = (*col_g_sat)[i]; - state.gas_density.data[i] = (*col_g_dens)[i]; - } - - if (has_ice) { - state.ice_density.data[i] = (*col_i_dens)[i]; - props.ice_saturation.data[i] = (*col_i_sat)[i]; - } - - if (has_energy) { - state.temperature.data[i] = (*col_temp)[i]; - props.thermal_conductivity.data[i] = (*col_cond)[i]; - } - - //fill surface variables - props.shortwave_radiation = shortwave_radiation[col]; - props.longwave_radiation = longwave_radiation[col]; - props.air_temperature = air_temperature[col]; - props.vapor_pressure_air = vapor_pressure_air[col]; - props.wind_speed = wind_speed[col]; - props.precipitation = precipitation[col]; - props.elevation = elevation[col]; - props.aspect = aspect[col]; - props.slope = slope[col]; - - //Fill the atmospheric abundances - //NOTE: probably want to add an if statement here to only do this only once - props.atm_n2 = atm_n2_; - props.atm_o2 = atm_o2_; - props.atm_co2 = atm_co2_; - props.atm_ch4 = atm_ch4_; - props.atm_n2o = atm_n2o_; - props.atm_h2 = atm_h2_; - props.atm_nh3 = atm_nh3_; - } - - for (int j=0; j < tcc_num; ++j) { - for (int i=0; i < ncells_per_col_; ++i) { - state.total_component_concentration.data[j][i] = (*col_tcc)(i,j); - } - } - //mat_props.volume = mesh_->cell_volume(cell;z - //mat_props.saturation = water_saturation[0][cell]; - - // Auxiliary data -- block copy. - /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { - aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); - int num_aux_ints = bgc_engine_->Sizes().num_aux_integers; - int num_aux_doubles = bgc_engine_->Sizes().num_aux_doubles; - - for (int i = 0; i < num_aux_ints; i++) { - double* cell_aux_ints = (*aux_data_)[i]; - aux_data.aux_ints.data[i] = (int)cell_aux_ints[cell]; - } - for (int i = 0; i < num_aux_doubles; i++) { - double* cell_aux_doubles = (*aux_data_)[i + num_aux_ints]; - aux_data.aux_doubles.data[i] = cell_aux_doubles[cell]; - } - }*/ -} - -void EcoSIM::CopyEcoSIMStateToAmanzi( - const int col, - const BGCProperties& props, - const BGCState& state, - const BGCAuxiliaryData& aux_data, - const Tag& water_tag) -{ - CopyFromEcoSIM(col, props, state, aux_data, water_tag); -} - -void EcoSIM::CopyFromEcoSIM(const int col, - const BGCProperties& props, - const BGCState& state, - const BGCAuxiliaryData& aux_data, - const Tag& water_tag) -{ - - Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); - int tcc_num = tcc.NumVectors(); - - auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); - auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); - auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); - //auto& suction_head = *(*S_->GetW(suc_key_, Amanzi::Tags::NEXT, suc_key_).ViewComponent("cell",false))(0); - auto& relative_permeability = *(*S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false))(0); - auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); - auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); - auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); - auto& hydraulic_conductivity = *(*S_->GetW(hydra_cond_key_, Amanzi::Tags::NEXT, hydra_cond_key_).ViewComponent("cell",false))(0); - auto& bulk_density = *(*S_->GetW(bulk_dens_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); - - auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_g_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_i_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_temp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); - - if (has_gas) { - auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell", false))(0); - auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell", false))(0); - - for (int i=0; i < ncells_per_col_; ++i) { - (*col_g_dens)[i] = state.gas_density.data[i]; - (*col_g_sat)[i] = props.gas_saturation.data[i]; - } - - ColumnToField_(col,gas_saturation,col_g_sat.ptr()); - ColumnToField_(col,gas_density,col_g_dens.ptr()); - - } - - if (has_ice) { - auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); - auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); - - for (int i=0; i < ncells_per_col_; ++i) { - (*col_i_dens)[i] = state.ice_density.data[i]; - (*col_i_sat)[i] = props.ice_saturation.data[i]; - } - - ColumnToField_(col,ice_saturation,col_i_sat.ptr()); - ColumnToField_(col,ice_density,col_i_dens.ptr()); - } - - if (has_energy) { - auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "subsurface energy").ViewComponent("cell",false))(0); - auto& thermal_conductivity = *(*S_->GetW(therm_cond_key_, Amanzi::Tags::NEXT, therm_cond_key_).ViewComponent("cell",false))(0); - - for (int i=0; i < ncells_per_col_; ++i) { - (*col_temp)[i] = state.temperature.data[i]; - (*col_cond)[i] = props.thermal_conductivity.data[i]; - } - - ColumnToField_(col,temp, col_temp.ptr()); - ColumnToField_(col,thermal_conductivity,col_cond.ptr()); - } - - for (int i=0; i < ncells_per_col_; ++i) { - (*col_l_dens)[i] = state.liquid_density.data[i]; - (*col_poro)[i] = state.porosity.data[i]; - (*col_wc)[i] = state.water_content.data[i]; - //(*col_suc)[i] = state.suction_head.data[i]; - (*col_l_sat)[i] = props.liquid_saturation.data[i]; - //(*col_elev)[i] = props.elevation.data[i]; - (*col_rel_perm)[i] = props.relative_permeability.data[i]; - (*col_cond)[i] = props.thermal_conductivity.data[i]; - (*col_h_cond)[i] = state.hydraulic_conductivity.data[i]; - (*col_b_dens)[i] = state.bulk_density.data[i]; - (*col_vol)[i] = props.volume.data[i]; - } - - //Take new values from Ecosim state and put them into the secondary data structure - //for backing back into amanzi state - for (int j=0; j < tcc_num; ++j) { - for (int i=0; i < ncells_per_col_; ++i) { - (*col_tcc)(i,j) = state.total_component_concentration.data[j][i]; - } - } - - //Here is where the auxiliary data is filled need to try to change this to columns - //This may not be trivial - /*if (S_->HasRecord(bgc_aux_data_key_, tag_next_)) { - aux_data_ = S_->GetW(bgc_aux_data_key_, tag_next_, passwd_).ViewComponent("cell"); - - int num_aux_ints = bgc_engine_->Sizes().num_aux_integers; - int num_aux_doubles = bgc_engine_->Sizes().num_aux_doubles; - - for (int i = 0; i < num_aux_ints; i++) { - double* cell_aux_ints = (*aux_data_)[i]; - cell_aux_ints[cell] = (double)aux_data.aux_ints.data[i]; - } - for (int i = 0; i < num_aux_doubles; i++) { - double* cell_aux_doubles = (*aux_data_)[i + num_aux_ints]; - cell_aux_doubles[cell] = aux_data.aux_doubles.data[i]; - } - }*/ - - //pack this data back into the num_columns - //ColumnToField_(col,tcc,col_tcc.ptr()); - ColumnToField_(col,porosity,col_poro.ptr()); - ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); - //ColumnToField_(col,elevation,col_elev.ptr()); - ColumnToField_(col,water_content,col_wc.ptr()); - //ColumnToField_(col,suction_head,col_suc.ptr()); - ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); - ColumnToField_(col,liquid_density,col_l_dens.ptr()); - ColumnToField_(col,rock_density,col_r_dens.ptr()); - ColumnToField_(col,cell_volume,col_vol.ptr()); - ColumnToField_(col,hydraulic_conductivity,col_h_cond.ptr()); - ColumnToField_(col,bulk_density,col_b_dens.ptr()); - MatrixColumnToField_(col, tcc, col_tcc.ptr()); -} - //Copy to EcoSIM void EcoSIM::CopyToEcoSIM_process(int proc_rank, BGCProperties& props, From 2c7c6c15e8e2dd627cffe9bd59040dfd9347ca2d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Jul 2023 18:04:11 -0700 Subject: [PATCH 428/582] more minor fixes --- src/pks/ecosim_pk/BGCEngine.cc | 17 ++++++++--------- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 +++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index d40091114..2470a1b45 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -29,10 +29,8 @@ namespace Amanzi { namespace EcoSIM { -namespace { - -//Here are the major function that the engine will need -/*void CopyBGCState(BGCState* dest, BGCState* src) +/*namespace { +void CopyBGCState(BGCState* dest, BGCState* src) { memcpy(dest->liquid_density.data, src->liquid_density.data, sizeof(double) * src->liquid_density.size); memcpy(dest->gas_density.data, src->gas_density.data, sizeof(double) * src->gas_density.size); @@ -65,7 +63,7 @@ void CopyBGCAuxiliaryData(BGCAuxiliaryData* dest, BGCAuxiliaryData* src) memcpy(dest->aux_doubles.data, src->aux_doubles.data, sizeof(double) * src->aux_doubles.size); } -} // */ +}*/ BGCEngine::BGCEngine(const std::string& engineName, @@ -177,11 +175,12 @@ void BGCEngine::InitState(BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, int ncells_per_col_, - int num_components) + int num_components, + int cols_on_proc) { - AllocateBGCProperties(&sizes_, &props, ncells_per_col_); - AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components); - AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); + AllocateBGCProperties(&sizes_, &props, ncells_per_col_,cols_on_proc); + AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components,cols_on_proc); + //AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); // Make sure the auxiliary ints/doubles are zeroed out. diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index faabd4abe..7973492bd 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -215,9 +215,9 @@ void EcoSIM::Initialize() { //Need to know the number of components to initialize data structures const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); int tcc_num = tcc.NumVectors(); - + num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //Now we call the engine's init state function which allocates the data - bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num); + bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num, num_cols_); int ierr = 0; @@ -731,7 +731,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_wp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rf = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseVector(tcc_num,ncells_per_col_)); + auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); //Gather columns on this process: ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); @@ -912,7 +912,6 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, //Loop over columns on this process for (int col=0; col!=ncols_local; ++col) { - if (has_gas) { const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); From badb1111ada6b0733117d3ef2704fa30fb259fd1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 26 Jul 2023 18:14:51 -0700 Subject: [PATCH 429/582] more fixes --- src/pks/ecosim_pk/BGCEngine.hh | 3 ++- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 1bb8fe44b..7c67981ac 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -57,7 +57,8 @@ class BGCEngine { BGCState& state, BGCAuxiliaryData& aux_data, int ncells_per_col_, - int num_components); + int num_components + int cols_on_proc); // Frees the data structures that hold the chemical state information. void FreeState(BGCProperties& props, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 7973492bd..aa825b6c5 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -763,8 +763,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); FieldToColumn_(col,rooting_depth_fraction,col_rf.ptr()); - //Have to make like a tensor version here - FieldToColumn_(col, tcc, col_tcc.ptr()); + MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); if (has_gas) { const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); From 38f9d325f95b9a661b48b00760c1d1e554ec9799 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 27 Jul 2023 14:00:39 -0700 Subject: [PATCH 430/582] various bugfixes to get this to compile --- src/pks/ecosim_pk/BGCEngine.cc | 6 +- src/pks/ecosim_pk/BGCEngine.hh | 2 +- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 70 +++++++++---------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 11 --- src/pks/ecosim_pk/data/BGC_memory.hh | 10 +-- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 16 ----- 6 files changed, 44 insertions(+), 71 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 2470a1b45..02df72bd6 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -178,8 +178,8 @@ void BGCEngine::InitState(BGCProperties& props, int num_components, int cols_on_proc) { - AllocateBGCProperties(&sizes_, &props, ncells_per_col_,cols_on_proc); - AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components,cols_on_proc); + AllocateBGCProperties(&sizes_, &props, ncells_per_col_, cols_on_proc); + AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components, cols_on_proc); //AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); @@ -194,7 +194,7 @@ void BGCEngine::FreeState(BGCProperties& props, { FreeBGCProperties(&props); FreeBGCState(&state); - FreeBGCAuxiliaryData(&aux_data); + //FreeBGCAuxiliaryData(&aux_data); //FreeAlquimiaAuxiliaryOutputData(&aux_output); } diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim_pk/BGCEngine.hh index 7c67981ac..f3e4a71d1 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim_pk/BGCEngine.hh @@ -57,7 +57,7 @@ class BGCEngine { BGCState& state, BGCAuxiliaryData& aux_data, int ncells_per_col_, - int num_components + int num_components, int cols_on_proc); // Frees the data structures that hold the chemical state information. diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index aa825b6c5..7b266d859 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -824,20 +824,20 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } //fill surface variables - props.shortwave_radiation[col] = shortwave_radiation[col]; - props.longwave_radiation[col] = longwave_radiation[col]; - props.air_temperature[col] = air_temperature[col]; - props.vapor_pressure_air[col] = vapor_pressure_air[col]; - props.wind_speed[col] = wind_speed[col]; - props.precipitation[col] = precipitation[col]; - props.elevation[col] = elevation[col]; - props.aspect[col] = aspect[col]; - props.slope[col] = slope[col]; - } - - for (int component=0; component < tcc_num; ++component) { - for (int i=0; i < ncells_per_col_; ++i) { - state.total_component_concentration.data[col][component][i] = (*col_tcc)(i,component); + props.shortwave_radiation.data[col] = shortwave_radiation[col]; + props.longwave_radiation.data[col] = longwave_radiation[col]; + props.air_temperature.data[col] = air_temperature[col]; + props.vapor_pressure_air.data[col] = vapor_pressure_air[col]; + props.wind_speed.data[col] = wind_speed[col]; + props.precipitation.data[col] = precipitation[col]; + props.elevation.data[col] = elevation[col]; + props.aspect.data[col] = aspect[col]; + props.slope.data[col] = slope[col]; + + for (int component=0; component < tcc_num; ++component) { + for (int i=0; i < ncells_per_col_; ++i) { + state.total_component_concentration.data[col][component][i] = (*col_tcc)(i,component); + } } } @@ -925,8 +925,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, } if (has_ice) { - const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); + auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); + auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); + + //const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_i_dens)[i] = state.ice_density.data[col][i]; @@ -938,8 +941,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, } if (has_energy) { - const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& thermal_conductivity = *(*S_->Get(therm_cond_key_, water_tag).ViewComponent("cell", false))(0); + auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); + auto& thermal_conductivity = *(*S_->GetW(therm_cond_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); + + //const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& thermal_conductivity = *(*S_->Get(therm_cond_key_, water_tag).ViewComponent("cell", false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_temp)[i] = state.temperature.data[col][i]; @@ -979,15 +985,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, ColumnToField_(col,cell_volume,col_vol.ptr()); ColumnToField_(col,hydraulic_conductivity,col_h_cond.ptr()); ColumnToField_(col,bulk_density,col_b_dens.ptr()); - ColumnToField_(col,plant_wilting_factor,col_wp.ptr()); - ColumnToField_(col,rooting_depth_fraction,col_rf.ptr()); + //ColumnToField_(col,plant_wilting_factor,col_wp.ptr()); + //ColumnToField_(col,rooting_depth_fraction,col_rf.ptr()); } - } - -/* ******************************************************************* -* This helper performs initialization on a single column within Amanzi's state. -******************************************************************* */ +/* int EcoSIM::InitializeSingleColumn(int col) { CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); @@ -1002,9 +1004,6 @@ int EcoSIM::InitializeSingleColumn(int col) } -/* ******************************************************************* -* This helper advances the solution on a single cell within Amanzi's state. -******************************************************************* */ int EcoSIM::AdvanceSingleColumn(double dt, int col) { // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but @@ -1012,9 +1011,6 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 1; -/***************************************************************** - ADVANCE CALL GOES HERE - *******************************************************************/ bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); @@ -1024,8 +1020,8 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); return num_iterations; -} - + } +*/ int EcoSIM::InitializeSingleProcess(int proc) { CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); @@ -1034,8 +1030,9 @@ int EcoSIM::InitializeSingleProcess(int proc) bgc_engine_->DataTest(); int num_iterations = 1; + int ncols = 1; - bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); + bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, ncols); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); } @@ -1047,9 +1044,10 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 1; - + int ncols = 1; + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, - bgc_sizes_, num_iterations, col); + bgc_sizes_, num_iterations, ncols); // Move the information back into Amanzi's state, updating the given total concentration vector. CopyFromEcoSIM_process(proc, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index b4f543cc4..ff63d7c5d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -128,21 +128,10 @@ class EcoSIM : public PK_Physical { const BGCAuxiliaryData& aux_data, const Tag& water_tag = Tags::DEFAULT); - int InitializeSingleColumn(int col); - - int AdvanceSingleColumn(double dt, int col); - int InitializeSingleProcess(int proc); int AdvanceSingleProcess(double dt, int proc); - void CopyEcoSIMStateToAmanzi( - const int cell, - const BGCProperties& props, - const BGCState& state, - const BGCAuxiliaryData& aux_data, - const Tag& water_tag = Tags::DEFAULT); - void ComputeNextTimeStep(); protected: diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index 7f29305db..7180dea11 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -69,19 +69,21 @@ extern "C" { void AllocateBGCState(BGCSizes* sizes, BGCState* state, int ncells_per_col_, - int num_components); + int num_components, + int cols_on_proc); void FreeBGCState(BGCState* state); - /* Auxiliary Data */ + /* Auxiliary Data void AllocateBGCAuxiliaryData(const BGCSizes* const sizes, BGCAuxiliaryData* aux_data, int ncells_per_col_); void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data); - + */ /* Properties */ void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, - int ncells_per_col_); + int ncells_per_col_, + int cols_on_proc); void FreeBGCProperties(BGCProperties* props); // Problem Meta Data diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 4395fec6a..b03fd070d 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -75,22 +75,6 @@ subroutine FreeBGCProperties(props) bind(C, name='FreeBGCProperties') end subroutine end interface - interface - subroutine AllocateBGCAuxiliaryData(sizes, aux_data) bind(C, name='AllocateBGCAuxiliaryData') - use BGCContainers_module, only : BGCSizes, BGCAuxiliaryData - implicit none - type(BGCSizes) :: sizes - type(BGCAuxiliaryData) :: aux_data - end subroutine - end interface - interface - subroutine FreeBGCAuxiliaryData(aux_data) bind(C, name='FreeBGCAuxiliaryData') - use BGCContainers_module, only : BGCAuxiliaryData - implicit none - type(BGCAuxiliaryData) :: aux_data - end subroutine - end interface - ! The following subroutines are methods of the engine itself interface From 994700d4a1b6e67d2e723a2e698041d4774a7cfc Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 27 Jul 2023 16:13:15 -0700 Subject: [PATCH 431/582] other minor fixes --- src/pks/ecosim_pk/BGCEngine.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim_pk/BGCEngine.cc index 02df72bd6..63aab3cce 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim_pk/BGCEngine.cc @@ -184,8 +184,8 @@ void BGCEngine::InitState(BGCProperties& props, //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); // Make sure the auxiliary ints/doubles are zeroed out. - std::fill(aux_data.aux_ints.data, aux_data.aux_ints.data + aux_data.aux_ints.size, 0); - std::fill(aux_data.aux_doubles.data, aux_data.aux_doubles.data + aux_data.aux_doubles.size, 0.0); + //std::fill(aux_data.aux_ints.data, aux_data.aux_ints.data + aux_data.aux_ints.size, 0); + //std::fill(aux_data.aux_doubles.data, aux_data.aux_doubles.data + aux_data.aux_doubles.size, 0.0); } void BGCEngine::FreeState(BGCProperties& props, From bd24057fbc95defa514647cda653ca58b1b180fa Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 27 Jul 2023 16:30:52 -0700 Subject: [PATCH 432/582] testing for the surface variables --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 10 +++++++++- src/pks/ecosim_pk/data/BGC_memory.cc | 3 +++ src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 9 +++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 7b266d859..07c0b34bc 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -215,7 +215,11 @@ void EcoSIM::Initialize() { //Need to know the number of components to initialize data structures const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); int tcc_num = tcc.NumVectors(); + num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "columns on processor: " << num_cols_ << std::endl; + //Now we call the engine's init state function which allocates the data bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num, num_cols_); @@ -823,6 +827,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } } + *vo_->os() << "filling surface props" << std::endl; + *vo_->os() << "size of shortwave in struct is: " << props.shortwave_radiation.data->size << std::endl; + *vo_->os() << "size of shortwave in state is: " << shortwave_radiation.MyLength() << std::endl; + //fill surface variables props.shortwave_radiation.data[col] = shortwave_radiation[col]; props.longwave_radiation.data[col] = longwave_radiation[col]; @@ -1045,7 +1053,7 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) int num_iterations = 1; int ncols = 1; - + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, ncols); diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index d8eb066f8..92b0dd9da 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -366,6 +366,9 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, int ncells_per_col_, int num_procs) { + std::cout << "In allocate properties: " << std::endl; + std::cout << "prop size: " << num_procs << std::endl; + sizes->ncells_per_col_ = ncells_per_col_; AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->liquid_saturation)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->gas_saturation)); diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index b03fd070d..fe6db8995 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -44,11 +44,14 @@ subroutine CreateBGCInterface(engine_name, bgc_interface) bind(C, name='CreateBG ! Memory allocation subroutines interface - subroutine AllocateBGCState(sizes, state) bind(C, name='AllocateBGCState') + subroutine AllocateBGCState(sizes, state, ncells_per_col_, num_components, num_procs) bind(C, name='AllocateBGCState') use BGCContainers_module, only : BGCSizes, BGCState implicit none type(BGCSizes) :: sizes type(BGCState) :: state + integer(c_int),VALUE :: ncells_per_col_ + integer(c_int),VALUE :: num_components + integer(c_int),VALUE :: num_procs end subroutine end interface interface @@ -60,11 +63,13 @@ subroutine FreeBGCState(state) bind(C, name='FreeBGCState') end interface interface - subroutine AllocateBGCProperties(sizes, props) bind(C, name='AllocateBGCProperties') + subroutine AllocateBGCProperties(sizes, props, ncells_per_col_, num_procs) bind(C, name='AllocateBGCProperties') use BGCContainers_module, only : BGCSizes, BGCProperties implicit none type(BGCSizes) :: sizes type(BGCProperties) :: props + integer(c_int),VALUE :: ncells_per_col_ + integer(c_int),VALUE :: num_procs end subroutine end interface interface From a00dc5932b2cd44a49d011c222b35fb8c65bd822 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Fri, 28 Jul 2023 22:59:10 -0700 Subject: [PATCH 433/582] minor fixes to make it compile --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 +-- src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 07c0b34bc..d93b7a78f 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -225,7 +225,6 @@ void EcoSIM::Initialize() { int ierr = 0; - Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "printing bool:" << std::endl; *vo_->os() << (S_->HasRecord(suc_key_, Tags::DEFAULT)) << std::endl; if (S_->HasRecord(suc_key_, Tags::DEFAULT)) { @@ -828,7 +827,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } *vo_->os() << "filling surface props" << std::endl; - *vo_->os() << "size of shortwave in struct is: " << props.shortwave_radiation.data->size << std::endl; + *vo_->os() << "size of shortwave in struct is: " << props.shortwave_radiation.size << std::endl; *vo_->os() << "size of shortwave in state is: " << shortwave_radiation.MyLength() << std::endl; //fill surface variables diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index fe6db8995..9e7834fec 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -46,6 +46,7 @@ subroutine CreateBGCInterface(engine_name, bgc_interface) bind(C, name='CreateBG interface subroutine AllocateBGCState(sizes, state, ncells_per_col_, num_components, num_procs) bind(C, name='AllocateBGCState') use BGCContainers_module, only : BGCSizes, BGCState + use, intrinsic :: iso_c_binding, only: c_int implicit none type(BGCSizes) :: sizes type(BGCState) :: state @@ -65,6 +66,7 @@ subroutine FreeBGCState(state) bind(C, name='FreeBGCState') interface subroutine AllocateBGCProperties(sizes, props, ncells_per_col_, num_procs) bind(C, name='AllocateBGCProperties') use BGCContainers_module, only : BGCSizes, BGCProperties + use, intrinsic :: iso_c_binding, only: c_int implicit none type(BGCSizes) :: sizes type(BGCProperties) :: props From 2ca47e3340728f83e5109801296c75c2e3ff8571 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 31 Jul 2023 11:41:38 -0700 Subject: [PATCH 434/582] changes to make the code compile --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 19 ++++++------------- src/pks/ecosim_pk/data/BGC_memory.cc | 1 + 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d93b7a78f..e54d50789 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -919,9 +919,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, //Loop over columns on this process for (int col=0; col!=ncols_local; ++col) { if (has_gas) { - const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); - + auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false))(0); + auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_g_dens)[i] = state.gas_density.data[col][i]; (*col_g_sat)[i] = props.gas_saturation.data[col][i]; @@ -932,11 +931,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, } if (has_ice) { - auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); - auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); - - //const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); + auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); + auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_i_dens)[i] = state.ice_density.data[col][i]; @@ -948,11 +944,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, } if (has_energy) { - auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); - auto& thermal_conductivity = *(*S_->GetW(therm_cond_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); - - //const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& thermal_conductivity = *(*S_->Get(therm_cond_key_, water_tag).ViewComponent("cell", false))(0); + auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "subsurface energy").ViewComponent("cell",false))(0); + auto& thermal_conductivity = *(*S_->GetW(therm_cond_key_, Amanzi::Tags::NEXT, therm_cond_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_temp)[i] = state.temperature.data[col][i]; diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 92b0dd9da..10ba9e7ef 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -370,6 +370,7 @@ void AllocateBGCState(const BGCSizes* const sizes, std::cout << "prop size: " << num_procs << std::endl; sizes->ncells_per_col_ = ncells_per_col_; + sizes->num_procs = num_procs; AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->liquid_saturation)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->gas_saturation)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->ice_saturation)); From 8c9acf419e9cfc6ebb9a901c9848b02d1fbf1704 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 31 Jul 2023 17:09:18 -0700 Subject: [PATCH 435/582] reworking of the 3D array code --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 8 +++++--- src/pks/ecosim_pk/data/BGC_memory.cc | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e54d50789..1731eb07d 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -841,9 +841,11 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[col] = aspect[col]; props.slope.data[col] = slope[col]; - for (int component=0; component < tcc_num; ++component) { - for (int i=0; i < ncells_per_col_; ++i) { - state.total_component_concentration.data[col][component][i] = (*col_tcc)(i,component); + for (int proc_col=0; proc_col < ncols_local; ++proc_col) { + for (int component=0; component < tcc_num; ++component) { + for (int i=0; i < ncells_per_col_; ++i) { + state.total_component_concentration.data[i][component][proc_col] = (*col_tcc)(i,component); + } } } } diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 10ba9e7ef..1327eb1df 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -226,7 +226,7 @@ void AllocateBGCTensorDouble(const int rows, const int cols, const int procs, BG tensor->data = (double***) calloc((size_t)tensor->cap_rows, sizeof(double**)); for (int i = 0; i < tensor->rows; ++i) { tensor->data[i] = (double**) calloc((size_t)tensor->cap_cols, sizeof(double*)); - for (int j = 0; j < tensor->procs; j++) { + for (int j = 0; j < tensor->cols; ++j) { tensor->data[i][j] = (double*) calloc((size_t)tensor->cap_procs, sizeof(double)); } } @@ -265,7 +265,7 @@ void AllocateBGCTensorInt(const int rows, const int cols, const int procs, BGCTe tensor->data = (int***) calloc((size_t)tensor->cap_rows, sizeof(int**)); for (int i = 0; i < tensor->rows; ++i) { tensor->data[i] = (int**) calloc((size_t)tensor->cap_cols, sizeof(int*)); - for (int j = 0; j < tensor->procs; j++) { + for (int j = 0; j < tensor->cols; ++j) { tensor->data[i][j] = (int*) calloc((size_t)tensor->cap_procs, sizeof(int)); } } From c8fec28a09e266ea94c73660a66620fb138bb31f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 31 Jul 2023 17:18:23 -0700 Subject: [PATCH 436/582] testing memory for ttc --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 1731eb07d..588186238 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -826,10 +826,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } } - *vo_->os() << "filling surface props" << std::endl; - *vo_->os() << "size of shortwave in struct is: " << props.shortwave_radiation.size << std::endl; - *vo_->os() << "size of shortwave in state is: " << shortwave_radiation.MyLength() << std::endl; - //fill surface variables props.shortwave_radiation.data[col] = shortwave_radiation[col]; props.longwave_radiation.data[col] = longwave_radiation[col]; @@ -841,7 +837,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[col] = aspect[col]; props.slope.data[col] = slope[col]; - for (int proc_col=0; proc_col < ncols_local; ++proc_col) { + *vo_->os() << "Checking TCC variables: " << std::endl; + *vo_->os() << "size of processes: " << state.total_component_concentration.procs << "number of processes: " << ncols_local << std::endl; + *vo_->os() << "size of components: " << state.total_component_concentration.cols << "number of components: " << tcc_num << std::endl; + *vo_->os() << "size of processes: " << state.total_component_concentration.rows << "number of cells: " << ncells_per_col_ << std::endl; + + + for (int proc_col=0; proc_col < ncols_local; ++proc_col) { for (int component=0; component < tcc_num; ++component) { for (int i=0; i < ncells_per_col_; ++i) { state.total_component_concentration.data[i][component][proc_col] = (*col_tcc)(i,component); From 6ae9bb98ff6dcbf3b237e07e1c3e47680498b3cb Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 1 Aug 2023 10:25:23 -0700 Subject: [PATCH 437/582] minor fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 588186238..1ab90e5d3 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -215,9 +215,10 @@ void EcoSIM::Initialize() { //Need to know the number of components to initialize data structures const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); int tcc_num = tcc.NumVectors(); + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "number of components: " << tcc_num << std::endl; num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "columns on processor: " << num_cols_ << std::endl; //Now we call the engine's init state function which allocates the data From f8695e61841bd545a917edea64f7b1aa8b16f030 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 1 Aug 2023 10:38:08 -0700 Subject: [PATCH 438/582] more testing --- src/pks/ecosim_pk/data/BGC_memory.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 1327eb1df..2209fd16a 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -223,6 +223,10 @@ void AllocateBGCTensorDouble(const int rows, const int cols, const int procs, BG tensor->cap_cols = nearest_power_of_2(cols); tensor->cap_procs = nearest_power_of_2(procs); + std:::cout << "In Allocate Tensor Double: " << std::endl; + std::cout << "cols: " << cols << std::endl; + std::cout << "size cols: " << tensor->cap_cols << std::endl; + tensor->data = (double***) calloc((size_t)tensor->cap_rows, sizeof(double**)); for (int i = 0; i < tensor->rows; ++i) { tensor->data[i] = (double**) calloc((size_t)tensor->cap_cols, sizeof(double*)); @@ -305,6 +309,10 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCState(BGCSizes* sizes, BGCState* state, int ncells_per_col_, int num_components, int num_procs) { sizes->ncells_per_col_ = ncells_per_col_; + sizes->num_components = num_components; + + std::cout << "In Allocate State: " << std::endl; + std::cout << "num_components: " << num_components << std::endl; AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->liquid_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->gas_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->ice_density)); From 400aeaf12efabca43140b8c1ea022e0701464ee5 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 1 Aug 2023 12:00:57 -0700 Subject: [PATCH 439/582] more minor changes --- src/pks/ecosim_pk/data/BGC_memory.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 2209fd16a..26034c8ac 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -223,7 +223,7 @@ void AllocateBGCTensorDouble(const int rows, const int cols, const int procs, BG tensor->cap_cols = nearest_power_of_2(cols); tensor->cap_procs = nearest_power_of_2(procs); - std:::cout << "In Allocate Tensor Double: " << std::endl; + std::cout << "In Allocate Tensor Double: " << std::endl; std::cout << "cols: " << cols << std::endl; std::cout << "size cols: " << tensor->cap_cols << std::endl; From a306adec522280238193d4145d53daac42f59526 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 1 Aug 2023 12:02:52 -0700 Subject: [PATCH 440/582] more testing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 1ab90e5d3..0282aee64 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -216,7 +216,7 @@ void EcoSIM::Initialize() { const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); int tcc_num = tcc.NumVectors(); Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "number of components: " << tcc_num << std::endl; + *vo_->os() << "number of components: " << tcc_num << std::endl; num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); *vo_->os() << "columns on processor: " << num_cols_ << std::endl; @@ -839,14 +839,18 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.slope.data[col] = slope[col]; *vo_->os() << "Checking TCC variables: " << std::endl; - *vo_->os() << "size of processes: " << state.total_component_concentration.procs << "number of processes: " << ncols_local << std::endl; - *vo_->os() << "size of components: " << state.total_component_concentration.cols << "number of components: " << tcc_num << std::endl; - *vo_->os() << "size of processes: " << state.total_component_concentration.rows << "number of cells: " << ncells_per_col_ << std::endl; + *vo_->os() << "size of processes: " << state.total_component_concentration.procs << " number of processes: " << ncols_local << std::endl; + *vo_->os() << "size of components: " << state.total_component_concentration.cols << " number of components: " << tcc_num << std::endl; + *vo_->os() << "size of processes: " << state.total_component_concentration.rows << " number of cells: " << ncells_per_col_ << std::endl; + *vo_->os() << "entering loop: " << std::endl; for (int proc_col=0; proc_col < ncols_local; ++proc_col) { + *vo_->os() << "on column : " << proc_col << std::endl; for (int component=0; component < tcc_num; ++component) { + *vo_->os() << "on component: " << proc_col << std::endl; for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "on cell: " << proc_col << std::endl; state.total_component_concentration.data[i][component][proc_col] = (*col_tcc)(i,component); } } From 8d98f59035770da883594b08a1388033e0aaa25d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 1 Aug 2023 12:45:31 -0700 Subject: [PATCH 441/582] even more testing --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 0282aee64..4df89fd91 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -843,6 +843,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, *vo_->os() << "size of components: " << state.total_component_concentration.cols << " number of components: " << tcc_num << std::endl; *vo_->os() << "size of processes: " << state.total_component_concentration.rows << " number of cells: " << ncells_per_col_ << std::endl; + *vo_->os() << "Shape of data: " << state.total_component_concentration.rows << " x " + << state.total_component_concentration.cols << " x " + << state.total_component_concentration.procs << std::endl; *vo_->os() << "entering loop: " << std::endl; for (int proc_col=0; proc_col < ncols_local; ++proc_col) { @@ -850,8 +853,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, for (int component=0; component < tcc_num; ++component) { *vo_->os() << "on component: " << proc_col << std::endl; for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "on cell: " << proc_col << std::endl; - state.total_component_concentration.data[i][component][proc_col] = (*col_tcc)(i,component); + *vo_->os() << "on cell: " << i << std::endl; + *vo_->os() << "Printing state element: " << state.total_component_concentration.data[proc_col][component][i] << std::endl; + *vo_->os() << "Printing internal element: " << (*col_tcc)(component,i) << std::endl; + state.total_component_concentration.data[proc_col][component][i] = (*col_tcc)(component,i); } } } From 6a98ade56c0b1f0f6738f0e8e8dc0b8f7efe3127 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 1 Aug 2023 13:12:21 -0700 Subject: [PATCH 442/582] fixes to tests --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 4df89fd91..95a1632ca 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -851,7 +851,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, for (int proc_col=0; proc_col < ncols_local; ++proc_col) { *vo_->os() << "on column : " << proc_col << std::endl; for (int component=0; component < tcc_num; ++component) { - *vo_->os() << "on component: " << proc_col << std::endl; + *vo_->os() << "on component: " << component << std::endl; for (int i=0; i < ncells_per_col_; ++i) { *vo_->os() << "on cell: " << i << std::endl; *vo_->os() << "Printing state element: " << state.total_component_concentration.data[proc_col][component][i] << std::endl; From 0e49576a3ee90077c3c8ede206b1b1f43b886369 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 2 Aug 2023 13:48:00 -0700 Subject: [PATCH 443/582] transport tests --- src/pks/transport/transport_ats_pk.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pks/transport/transport_ats_pk.cc b/src/pks/transport/transport_ats_pk.cc index 674cadc5d..fd49e982b 100644 --- a/src/pks/transport/transport_ats_pk.cc +++ b/src/pks/transport/transport_ats_pk.cc @@ -1200,12 +1200,19 @@ Transport_ATS::CommitStep(double t_old, double t_new, const Tag& tag_next) if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Commiting state @ " << tag_next << std::endl; + *vo_->os() << "tag assertion " << std::endl; AMANZI_ASSERT(tag_next == tag_next_ || tag_next == Tags::NEXT); + *vo_->os() << "tag current setting " << std::endl; Tag tag_current = tag_next == tag_next_ ? tag_current_ : Tags::CURRENT; + *vo_->os() << "assign tcc key to tag current and tag next " << std::endl; assign(tcc_key_, tag_current, tag_next, *S_); + + *vo_->os() << "tag next if statement " << std::endl; if (tag_next == Tags::NEXT) { + *vo_->os() << "assigning saturation key " << std::endl; assign(saturation_key_, tag_current, tag_next, *S_); + *vo_->os() << "assigining density key " << std::endl; assign(molar_density_key_, tag_current, tag_next, *S_); } } From 6d4f3d77ab8212bcfc01a2c2265120b011d8ce46 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 15 Aug 2023 09:41:52 -0700 Subject: [PATCH 444/582] adding file paths --- src/pks/ecosim_pk/CMakeLists.txt | 1 + src/pks/ecosim_pk/data/CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index da2e7e4bc..df1f4ca1a 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -27,6 +27,7 @@ set(ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/SharedDataMod.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index 380a514f5..d74e25fb1 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -12,8 +12,9 @@ set(ats_ecosim_data_src_files bgc_fortran_memory_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/SharedDataMod.F90 ) set(ats_ecosim_data_inc_files BGC_constants.hh From f77fabf13bd3c3f55784670e2d40f8fa663c556a Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 15 Aug 2023 09:48:29 -0700 Subject: [PATCH 445/582] fixing path --- src/pks/ecosim_pk/CMakeLists.txt | 2 +- src/pks/ecosim_pk/data/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index df1f4ca1a..2419213c6 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -27,7 +27,7 @@ set(ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/SharedDataMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index d74e25fb1..935b8c980 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -14,7 +14,7 @@ set(ats_ecosim_data_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/SharedDataMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 ) set(ats_ecosim_data_inc_files BGC_constants.hh From c261c993ce3827ffc89db4746a7bcfff5c17e0a4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 15 Aug 2023 10:06:48 -0700 Subject: [PATCH 446/582] adding more files --- src/pks/ecosim_pk/CMakeLists.txt | 3 ++- src/pks/ecosim_pk/data/CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 2419213c6..72ecdf963 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -26,8 +26,9 @@ set(ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index 935b8c980..e31ded5ea 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -13,8 +13,9 @@ set(ats_ecosim_data_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 ) set(ats_ecosim_data_inc_files BGC_constants.hh From c58a83bf9ebb6b1060819e8f7220ff6b15dcf642 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 16 Aug 2023 16:25:33 -0700 Subject: [PATCH 447/582] pushing changes to file paths in cmake --- src/pks/ecosim_pk/CMakeLists.txt | 14 ++++++------- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 5 ++++- src/pks/ecosim_pk/data/CMakeLists.txt | 25 ++++++++++++----------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 72ecdf963..9de8c4844 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -18,17 +18,17 @@ message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") # For adding F90 files add the F90 file to the ecosim source files and # inc files. The inc file also needs a header -set(ats_ecosim_src_files +file(GLOB ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 95a1632ca..fe2534d4e 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -1041,7 +1041,10 @@ int EcoSIM::InitializeSingleProcess(int proc) CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); //ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); - bgc_engine_->DataTest(); + //bgc_engine_->DataTest(); + + /*need some sort of assertions here to double check that the data is actually + What I want it to be*/ int num_iterations = 1; int ncols = 1; diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index e31ded5ea..88e3280b5 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -5,18 +5,19 @@ # # collect all sources -set(ats_ecosim_data_src_files - BGC_constants.cc - BGC_memory.cc - BGC_containers.cc - bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 -) +file(GLOB ats_ecosim_data_src_files + EcoSIM_ATS_interface.cc + BGCEngine.cc + ecosim_wrappers.F90 + data/bgc_fortran_memory_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 + ) + set(ats_ecosim_data_inc_files BGC_constants.hh BGC_containers.hh From 3651f2062c9698ff327a2a65329ebe3b1e5418a5 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 17 Aug 2023 00:46:52 -0700 Subject: [PATCH 448/582] changes to cmake files to remove linking for now --- src/pks/ecosim_pk/CMakeLists.txt | 18 +++++++++++------- src/pks/ecosim_pk/data/CMakeLists.txt | 17 +++++++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 9de8c4844..78fc94450 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -23,13 +23,17 @@ file(GLOB ats_ecosim_src_files BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 - ) + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSUtilsMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/*.F90 +) set(ats_ecosim_inc_files ecosim_mod_test_wrapper.h diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index 88e3280b5..1505da3f0 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -10,12 +10,17 @@ file(GLOB ats_ecosim_data_src_files BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSUtilsMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_modul +e.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 +# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/*.F90 ) set(ats_ecosim_data_inc_files From 04218a26c73c847a5f0a3e7c151b40a7cd426952 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 17 Aug 2023 14:48:07 -0700 Subject: [PATCH 449/582] modifications to CMake (compiles again) --- src/pks/ecosim_pk/CMakeLists.txt | 10 ++-------- src/pks/ecosim_pk/data/CMakeLists.txt | 21 +++++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 78fc94450..68fea9830 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -18,21 +18,15 @@ message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") # For adding F90 files add the F90 file to the ecosim source files and # inc files. The inc file also needs a header -file(GLOB ats_ecosim_src_files +set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSUtilsMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/*.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index 1505da3f0..c3d88afdf 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -5,22 +5,15 @@ # # collect all sources -file(GLOB ats_ecosim_data_src_files - EcoSIM_ATS_interface.cc - BGCEngine.cc - ecosim_wrappers.F90 - data/bgc_fortran_memory_mod.F90 +set(ats_ecosim_data_src_files + BGC_constants.cc + BGC_memory.cc + BGC_containers.cc + bgc_fortran_memory_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSUtilsMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_modul -e.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 -# /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 ) set(ats_ecosim_data_inc_files From a3c1de357d1f01fb67dbfd0ee4a9f62de2b4b479 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 17 Aug 2023 16:21:11 -0700 Subject: [PATCH 450/582] testing the column varaibles, along with cleaning up var names --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 6 ++ src/pks/ecosim_pk/data/BGC_containers.hh | 2 +- src/pks/ecosim_pk/data/BGC_memory.cc | 72 ++++++++++--------- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 8 +-- 4 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index fe2534d4e..de11f9cab 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -224,6 +224,12 @@ void EcoSIM::Initialize() { //Now we call the engine's init state function which allocates the data bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num, num_cols_); + *vo_->os() << "Trying to print Sizes from engine: " << tcc_num << std::endl; + bgc_engine_->Sizes().ncells_per_col_; + bgc_engine_->Sizes().num_components; + bgc_engine_->Sizes().num_columns; + + int ierr = 0; *vo_->os() << "printing bool:" << std::endl; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index a97461185..e33c6058a 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -97,7 +97,7 @@ extern "C" { typedef struct { int ncells_per_col_; int num_components; - int num_procs; + int num_columns; } BGCSizes; typedef struct { diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 26034c8ac..41d7ecab1 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -307,22 +307,25 @@ void AllocateBGCState(const BGCSizes* const sizes, BGCState* state)*/ void AllocateBGCState(BGCSizes* sizes, BGCState* state, - int ncells_per_col_, int num_components, int num_procs) { + int ncells_per_col_, int num_components, int num_columns) { sizes->ncells_per_col_ = ncells_per_col_; sizes->num_components = num_components; + sizes->num_columns = num_columns; std::cout << "In Allocate State: " << std::endl; std::cout << "num_components: " << num_components << std::endl; - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->liquid_density)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->gas_density)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->ice_density)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->porosity)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->water_content)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->suction_head)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->temperature)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->hydraulic_conductivity)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(state->bulk_density)); - AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_components, sizes->num_procs, &(state->total_component_concentration)); + std::cout << "ncells_per_col: " << ncells_per_col_ << std::endl; + std::cout << "num_columns: " << num_columns << std::endl; + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->liquid_density)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->gas_density)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->ice_density)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->porosity)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->water_content)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->suction_head)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->temperature)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->hydraulic_conductivity)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->bulk_density)); + AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_components, sizes->num_columns, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateBGCState() */ @@ -373,32 +376,33 @@ void AllocateBGCState(const BGCSizes* const sizes, *******************************************************************************/ void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, - int ncells_per_col_, int num_procs) { + int ncells_per_col_, int num_columns) { std::cout << "In allocate properties: " << std::endl; - std::cout << "prop size: " << num_procs << std::endl; + std::cout << "prop size: " << num_columns << std::endl; sizes->ncells_per_col_ = ncells_per_col_; - sizes->num_procs = num_procs; - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->liquid_saturation)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->gas_saturation)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->ice_saturation)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->relative_permeability)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->thermal_conductivity)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->volume)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->depth)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->dz)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->plant_wilting_factor)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_procs, &(props->rooting_depth_fraction)); - - AllocateBGCVectorDouble(sizes->num_procs, &(props->shortwave_radiation)); - AllocateBGCVectorDouble(sizes->num_procs, &(props->longwave_radiation)); - AllocateBGCVectorDouble(sizes->num_procs, &(props->air_temperature)); - AllocateBGCVectorDouble(sizes->num_procs, &(props->vapor_pressure_air)); - AllocateBGCVectorDouble(sizes->num_procs, &(props->wind_speed)); - AllocateBGCVectorDouble(sizes->num_procs, &(props->precipitation)); - AllocateBGCVectorDouble(sizes->num_procs, &(props->elevation)); - AllocateBGCVectorDouble(sizes->num_procs, &(props->aspect)); - AllocateBGCVectorDouble(sizes->num_procs, &(props->slope)); + sizes->num_columns = num_columns; + //sizes->num_components = num_components; + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->liquid_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->gas_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->ice_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->relative_permeability)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->thermal_conductivity)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->volume)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->depth)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->dz)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->plant_wilting_factor)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->rooting_depth_fraction)); + + AllocateBGCVectorDouble(sizes->num_columns, &(props->shortwave_radiation)); + AllocateBGCVectorDouble(sizes->num_columns, &(props->longwave_radiation)); + AllocateBGCVectorDouble(sizes->num_columns, &(props->air_temperature)); + AllocateBGCVectorDouble(sizes->num_columns, &(props->vapor_pressure_air)); + AllocateBGCVectorDouble(sizes->num_columns, &(props->wind_speed)); + AllocateBGCVectorDouble(sizes->num_columns, &(props->precipitation)); + AllocateBGCVectorDouble(sizes->num_columns, &(props->elevation)); + AllocateBGCVectorDouble(sizes->num_columns, &(props->aspect)); + AllocateBGCVectorDouble(sizes->num_columns, &(props->slope)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* props) { diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index 9e7834fec..fdf53c5d3 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -44,7 +44,7 @@ subroutine CreateBGCInterface(engine_name, bgc_interface) bind(C, name='CreateBG ! Memory allocation subroutines interface - subroutine AllocateBGCState(sizes, state, ncells_per_col_, num_components, num_procs) bind(C, name='AllocateBGCState') + subroutine AllocateBGCState(sizes, state, ncells_per_col_, num_components, num_columns) bind(C, name='AllocateBGCState') use BGCContainers_module, only : BGCSizes, BGCState use, intrinsic :: iso_c_binding, only: c_int implicit none @@ -52,7 +52,7 @@ subroutine AllocateBGCState(sizes, state, ncells_per_col_, num_components, num_p type(BGCState) :: state integer(c_int),VALUE :: ncells_per_col_ integer(c_int),VALUE :: num_components - integer(c_int),VALUE :: num_procs + integer(c_int),VALUE :: num_columns end subroutine end interface interface @@ -64,14 +64,14 @@ subroutine FreeBGCState(state) bind(C, name='FreeBGCState') end interface interface - subroutine AllocateBGCProperties(sizes, props, ncells_per_col_, num_procs) bind(C, name='AllocateBGCProperties') + subroutine AllocateBGCProperties(sizes, props, ncells_per_col_, num_columns) bind(C, name='AllocateBGCProperties') use BGCContainers_module, only : BGCSizes, BGCProperties use, intrinsic :: iso_c_binding, only: c_int implicit none type(BGCSizes) :: sizes type(BGCProperties) :: props integer(c_int),VALUE :: ncells_per_col_ - integer(c_int),VALUE :: num_procs + integer(c_int),VALUE :: num_columns end subroutine end interface interface From 675f7ee483255d8eac0c2651546c4a80fd446f1c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 17 Aug 2023 21:51:13 -0700 Subject: [PATCH 451/582] making some modifications to tcc --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index de11f9cab..7b7907611 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -229,6 +229,9 @@ void EcoSIM::Initialize() { bgc_engine_->Sizes().num_components; bgc_engine_->Sizes().num_columns; + *vo_->os() << "number of cells: " << bgc_engine_->Sizes().ncells_per_col_; << std::endl; + *vo_->os() << "number of components: " << bgc_engine_->Sizes().num_components; << std::endl; + *vo_->os() << "number of columns: " << bgc_engine_->Sizes().num_columns; << std::endl; int ierr = 0; @@ -860,7 +863,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, *vo_->os() << "on component: " << component << std::endl; for (int i=0; i < ncells_per_col_; ++i) { *vo_->os() << "on cell: " << i << std::endl; - *vo_->os() << "Printing state element: " << state.total_component_concentration.data[proc_col][component][i] << std::endl; + //original config (doesn't work) *vo_->os() << "Printing state element: " + //<< state.total_component_concentration.data[proc_col][component][i] << std::endl; + *vo_->os() << "Printing state element: " << state.total_component_concentration.data[proc_col][i][component] << std::endl; *vo_->os() << "Printing internal element: " << (*col_tcc)(component,i) << std::endl; state.total_component_concentration.data[proc_col][component][i] = (*col_tcc)(component,i); } From 51addd37e7c6530d3c146515fe13586cfb123d32 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Fri, 18 Aug 2023 10:27:08 -0700 Subject: [PATCH 452/582] committing some minor changes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index 7b7907611..fdc0768ed 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -229,9 +229,9 @@ void EcoSIM::Initialize() { bgc_engine_->Sizes().num_components; bgc_engine_->Sizes().num_columns; - *vo_->os() << "number of cells: " << bgc_engine_->Sizes().ncells_per_col_; << std::endl; - *vo_->os() << "number of components: " << bgc_engine_->Sizes().num_components; << std::endl; - *vo_->os() << "number of columns: " << bgc_engine_->Sizes().num_columns; << std::endl; + *vo_->os() << "number of cells: " << bgc_engine_->Sizes().ncells_per_col_ << std::endl; + *vo_->os() << "number of components: " << bgc_engine_->Sizes().num_components << std::endl; + *vo_->os() << "number of columns: " << bgc_engine_->Sizes().num_columns << std::endl; int ierr = 0; @@ -856,6 +856,14 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, << state.total_component_concentration.cols << " x " << state.total_component_concentration.procs << std::endl; + for (int i = 0; i < state.total_component_concentration.rows; i++) { + for (int j = 0; j < state.total_component_concentration.cols; j++) { + for (int k = 0; k < state.total_component_concentration.procs; k++) { + printf("data[%d][%d][%d]: %d\n", i, j, k, state.total_component_concentration.data[i][j][k]); + } + } + } + /* *vo_->os() << "entering loop: " << std::endl; for (int proc_col=0; proc_col < ncols_local; ++proc_col) { *vo_->os() << "on column : " << proc_col << std::endl; @@ -865,12 +873,12 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, *vo_->os() << "on cell: " << i << std::endl; //original config (doesn't work) *vo_->os() << "Printing state element: " //<< state.total_component_concentration.data[proc_col][component][i] << std::endl; - *vo_->os() << "Printing state element: " << state.total_component_concentration.data[proc_col][i][component] << std::endl; + *vo_->os() << "Printing state element: " << state.total_component_concentration.data[i][component][proc_col] << std::endl; *vo_->os() << "Printing internal element: " << (*col_tcc)(component,i) << std::endl; state.total_component_concentration.data[proc_col][component][i] = (*col_tcc)(component,i); } } - } + }*/ } //Fill the atmospheric abundances From 8d40f7aeb69423762168e56ae6a598eda5d8c307 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 22 Aug 2023 13:43:40 -0700 Subject: [PATCH 453/582] doing some variable cleanup --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 191 +++++++++++----------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 25 ++- 2 files changed, 107 insertions(+), 109 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index fdc0768ed..e7292cdaf 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -52,54 +52,53 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saved_time_(0.0) { //grab the surface and subsurface domains - domain_ = plist_->get("domain name", "domain"); - domain_surf_ = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); + domain_subsurface_ = plist_->get("domain name", "domain"); + domain_surface_ = Keys::readDomainHint(*plist_, domain_subsurface_, "subsurface", "surface"); // transport - tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); + tcc_key_ = Keys::readKey(*plist_, domain_subsurface_, "total component concentration", "total_component_concentration"); //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell //Flow - poro_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); - saturation_liquid_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); - saturation_gas_key_ = Keys::readKey(*plist_,domain_,"saturation gas", "saturation_gas"); - saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); - water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); - rel_perm_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); - suc_key_ = Keys::readKey(*plist_,domain_,"suction","suction_head"); - liquid_den_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); - ice_den_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); - gas_den_key_ = Keys::readKey(*plist_, domain_,"mass density gas", "mass_density_gas"); - gas_den_key_test_ = Keys::readKey(*plist_, domain_, "mass density gas", "mass_density_gas"); - rock_den_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); + porosity_key_ = Keys::readKey(*plist_, domain_subsurface_, "porosity", "porosity"); + saturation_liquid_key_ = Keys::readKey(*plist_, domain_subsurface_, "saturation liquid", "saturation_liquid"); + saturation_gas_key_ = Keys::readKey(*plist_,domain_subsurface_,"saturation gas", "saturation_gas"); + saturation_ice_key_ = Keys::readKey(*plist_,domain_subsurface_,"saturation ice", "saturation_ice"); + water_content_key_ = Keys::readKey(*plist_,domain_subsurface_,"water content","water_content"); + relative_permeability_key_ = Keys::readKey(*plist_,domain_subsurface_,"relative permeability","relative_permeability"); + //suction_key_ = Keys::readKey(*plist_,domain_subsurface_,"suction","suction_head"); + liquid_density_key_ = Keys::readKey(*plist_, domain_subsurface_, "mass density liquid", "mass_density_liquid"); + ice_density_key_ = Keys::readKey(*plist_, domain_subsurface_, "mass density ice", "mass_density_ice"); + gas_density_key_ = Keys::readKey(*plist_, domain_subsurface_,"mass density gas", "mass_density_gas"); + gas_density_key_test_ = Keys::readKey(*plist_, domain_subsurface_, "mass density gas", "mass_density_gas"); + rock_density_key_ = Keys::readKey(*plist_, domain_subsurface_, "density rock", "density_rock"); //energy - T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); - therm_cond_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); + T_key_ = Keys::readKey(*plist_, domain_subsurface_, "temperature", "temperature"); + thermal_conductivity_key_ = Keys::readKey(*plist_, domain_subsurface_, "thermal conductivity", "thermal_conductivity"); //Other - cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); - min_vol_frac_key_ = Keys::readKey(*plist_, domain_, "mineral volume fractions", "mineral_volume_fractions"); - ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); - f_wp_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); - f_root_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); + cell_volume_key_ = Keys::readKey(*plist_, domain_subsurface_, "cell volume", "cell_volume"); + //ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_subsurface_, "ecosim aux data", "ecosim_aux_data"); + f_wp_key_ = Keys::readKey(*plist_, domain_subsurface_, "porosity", "porosity"); + f_root_key_ = Keys::readKey(*plist_, domain_subsurface_, "porosity", "porosity"); //Custom Evaluator keys - hydra_cond_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); - bulk_dens_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); + hydraulic_conductivity_key_ = Keys::readKey(*plist_, domain_subsurface_, "hydraulic conductivity", "hydraulic_conductivity"); + bulk_density_key_ = Keys::readKey(*plist_, domain_subsurface_, "bulk density", "bulk_density"); //Surface balance items sw_key_ = - Keys::readKey(*plist_, domain_surf_, "incoming shortwave radiation", "incoming_shortwave_radiation"); + Keys::readKey(*plist_, domain_surface_, "incoming shortwave radiation", "incoming_shortwave_radiation"); lw_key_ = - Keys::readKey(*plist_,domain_surf_, "incoming longwave radiation", "incoming_longwave_radiation"); - air_temp_key_ = Keys::readKey(*plist_, domain_surf_, "air temperature", "air_temperature"); - vp_air_key_ = Keys::readKey(*plist_, domain_surf_, "vapor pressure air", "vapor_pressure_air"); - wind_speed_key_ = Keys::readKey(*plist_, domain_surf_, "wind speed", "wind_speed"); - prain_key_ = Keys::readKey(*plist_, domain_surf_, "precipitation rain", "precipitation_rain"); - elev_key_ = Keys::readKey(*plist_, domain_surf_, "elevation", "elevation"); - aspect_key_ = Keys::readKey(*plist_, domain_surf_, "aspect", "aspect"); - slope_key_ = Keys::readKey(*plist_, domain_surf_, "slope", "slope_magnitude"); + Keys::readKey(*plist_,domain_surface_, "incoming longwave radiation", "incoming_longwave_radiation"); + air_temp_key_ = Keys::readKey(*plist_, domain_surface_, "air temperature", "air_temperature"); + vp_air_key_ = Keys::readKey(*plist_, domain_surface_, "vapor pressure air", "vapor_pressure_air"); + wind_speed_key_ = Keys::readKey(*plist_, domain_surface_, "wind speed", "wind_speed"); + prain_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation rain", "precipitation_rain"); + elev_key_ = Keys::readKey(*plist_, domain_surface_, "elevation", "elevation"); + aspect_key_ = Keys::readKey(*plist_, domain_surface_, "aspect", "aspect"); + slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); //Atmospheric abundance keys atm_n2_ = plist_->get("atmospheric N2"); @@ -141,7 +140,7 @@ EcoSIM::~EcoSIM() // -- Setup step void EcoSIM::Setup() { //Need to do some basic setup of the columns: - mesh_surf_ = S_->GetMesh(domain_surf_); + mesh_surf_ = S_->GetMesh(domain_surface_); num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); for (unsigned int col = 0; col != num_cols_; ++col) { @@ -188,18 +187,18 @@ void EcoSIM::Setup() { */ //Setup Evaluators - requireAtNext(hydra_cond_key_, tag_next_, *S_) + requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtCurrent(hydra_cond_key_, tag_current_, *S_, name_); + requireAtCurrent(hydraulic_conductivity_key_, tag_current_, *S_, name_); - requireAtNext(bulk_dens_key_, tag_next_, *S_) + requireAtNext(bulk_density_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtCurrent(bulk_dens_key_, tag_current_, *S_, name_); + requireAtCurrent(bulk_density_key_, tag_current_, *S_, name_); if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { @@ -261,12 +260,12 @@ void EcoSIM::Initialize() { // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(relative_permeability_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(liquid_density_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(rock_density_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); @@ -282,11 +281,11 @@ void EcoSIM::Initialize() { S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); - if (S_->HasRecord(gas_den_key_test_, Tags::DEFAULT)) { + if (S_->HasRecord(gas_density_key_test_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density gas key" << std::endl; S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(gas_density_key_, Tags::DEFAULT).Update(*S_, name_); has_gas = true; } else { Teuchos::OSTab tab = vo_->getOSTab(); @@ -298,8 +297,8 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found temp key" << std::endl; S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(therm_cond_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(thermal_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(cell_volume_key_, Tags::DEFAULT).Update(*S_, name_); has_energy = true; } else { Teuchos::OSTab tab = vo_->getOSTab(); @@ -307,11 +306,11 @@ void EcoSIM::Initialize() { has_energy = false; } - if (S_->HasRecord(ice_den_key_, Tags::DEFAULT)) { + if (S_->HasRecord(ice_density_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found ice key" << std::endl; S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(ice_density_key_, Tags::DEFAULT).Update(*S_, name_); has_ice = true; } else { Teuchos::OSTab tab = vo_->getOSTab(); @@ -320,11 +319,11 @@ void EcoSIM::Initialize() { } //Initialize owned evaluators - S_->GetW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); - S_->GetRecordW(hydra_cond_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); + S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); + S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); - S_->GetW(bulk_dens_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); - S_->GetRecordW(bulk_dens_key_, Tags::DEFAULT, "bulk_density").set_initialized(); + S_->GetW(bulk_density_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); + S_->GetRecordW(bulk_density_key_, Tags::DEFAULT, "bulk_density").set_initialized(); int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -394,14 +393,14 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(poro_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(rel_perm_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(liquid_den_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(rock_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(relative_permeability_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(liquid_density_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(rock_density_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(cv_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(cell_volume_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); @@ -419,25 +418,25 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(gas_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(gas_density_key_, Tags::DEFAULT).Update(*S_, name_); } if (has_ice) { S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(ice_den_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(ice_density_key_, Tags::DEFAULT).Update(*S_, name_); } if (has_energy) { S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(therm_cond_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(thermal_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); } //Update owned evaluators - Teuchos::RCP hydra_cond = S_->GetPtr(hydra_cond_key_, Tags::DEFAULT); - S_->GetEvaluator(hydra_cond_key_, Tags::DEFAULT).Update(*S_, name_); + Teuchos::RCP hydra_cond = S_->GetPtr(hydraulic_conductivity_key_, Tags::DEFAULT); + S_->GetEvaluator(hydraulic_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); - Teuchos::RCP bulk_dens = S_->GetPtr(bulk_dens_key_, Tags::DEFAULT); - S_->GetEvaluator(bulk_dens_key_, Tags::DEFAULT).Update(*S_, name_); + Teuchos::RCP bulk_dens = S_->GetPtr(bulk_density_key_, Tags::DEFAULT); + S_->GetEvaluator(bulk_density_key_, Tags::DEFAULT).Update(*S_, name_); AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -697,19 +696,19 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, { //This is the copy function for a loop over a single process instead of a single column //Fill state with ATS variables that are going to be changed by EcoSIM - const Epetra_Vector& porosity = *(*S_->Get(poro_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& porosity = *(*S_->Get(porosity_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); int tcc_num = tcc.NumVectors(); const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& relative_permeability = *(*S_->Get(rel_perm_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& liquid_density = *(*S_->Get(liquid_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& rock_density = *(*S_->Get(rock_den_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& cell_volume = *(*S_->Get(cv_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydra_cond_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& relative_permeability = *(*S_->Get(relative_permeability_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& liquid_density = *(*S_->Get(liquid_density_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& rock_density = *(*S_->Get(rock_density_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& cell_volume = *(*S_->Get(cell_volume_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydraulic_conductivity_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& bulk_density = *(*S_->Get(bulk_dens_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); @@ -723,11 +722,11 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); - auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_relative_permeability = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -764,10 +763,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, //Loop over columns on this process for (int col=0; col!=ncols_local; ++col) { - FieldToColumn_(col,porosity,col_poro.ptr()); + FieldToColumn_(col,porosity,col_porosity.ptr()); FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(col,water_content,col_wc.ptr()); - FieldToColumn_(col,relative_permeability,col_rel_perm.ptr()); + FieldToColumn_(col,relative_permeability,col_relative_permeability.ptr()); FieldToColumn_(col,liquid_density,col_l_dens.ptr()); FieldToColumn_(col,rock_density,col_r_dens.ptr()); FieldToColumn_(col,cell_volume,col_vol.ptr()); @@ -780,7 +779,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, if (has_gas) { const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& gas_density = *(*S_->Get(gas_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& gas_density = *(*S_->Get(gas_density_key_, water_tag).ViewComponent("cell", false))(0); FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); FieldToColumn_(col,gas_density,col_g_dens.ptr()); @@ -788,7 +787,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, if (has_ice) { const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& ice_density = *(*S_->Get(ice_den_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& ice_density = *(*S_->Get(ice_density_key_, water_tag).ViewComponent("cell", false))(0); FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); FieldToColumn_(col,ice_density,col_i_dens.ptr()); @@ -796,7 +795,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, if (has_energy) { const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& thermal_conductivity = *(*S_->Get(therm_cond_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); FieldToColumn_(col,temp, col_temp.ptr()); FieldToColumn_(col,thermal_conductivity,col_cond.ptr()); @@ -807,7 +806,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[col][i] = (*col_l_dens)[i]; - state.porosity.data[col][i] = (*col_poro)[i]; + state.porosity.data[col][i] = (*col_porosity)[i]; state.water_content.data[col][i] = (*col_wc)[i]; state.hydraulic_conductivity.data[col][i] = (*col_h_cond)[i]; state.bulk_density.data[col][i] = (*col_b_dens)[i]; @@ -815,7 +814,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.plant_wilting_factor.data[col][i] = (*col_wp)[i]; props.rooting_depth_fraction.data[col][i] = (*col_rf)[i]; props.liquid_saturation.data[col][i] = (*col_l_sat)[i]; - props.relative_permeability.data[col][i] = (*col_rel_perm)[i]; + props.relative_permeability.data[col][i] = (*col_relative_permeability)[i]; props.volume.data[col][i] = (*col_vol)[i]; props.depth.data[col][i] = (*col_depth)[i]; props.dz.data[col][i] = (*col_dz)[i]; @@ -903,22 +902,22 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); int tcc_num = tcc.NumVectors(); - auto& porosity = *(*S_->GetW(poro_key_, Amanzi::Tags::NEXT, poro_key_).ViewComponent("cell",false))(0); + auto& porosity = *(*S_->GetW(porosity_key_, Amanzi::Tags::NEXT, porosity_key_).ViewComponent("cell",false))(0); auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); //auto& suction_head = *(*S_->GetW(suc_key_, Amanzi::Tags::NEXT, suc_key_).ViewComponent("cell",false))(0); - auto& relative_permeability = *(*S_->GetW(rel_perm_key_, Amanzi::Tags::NEXT, rel_perm_key_).ViewComponent("cell",false))(0); - auto& liquid_density = *(*S_->GetW(liquid_den_key_, Amanzi::Tags::NEXT, liquid_den_key_).ViewComponent("cell",false))(0); - auto& rock_density = *(*S_->GetW(rock_den_key_, Amanzi::Tags::NEXT, rock_den_key_).ViewComponent("cell",false))(0); - auto& cell_volume = *(*S_->GetW(cv_key_, Amanzi::Tags::NEXT, cv_key_).ViewComponent("cell",false))(0); - auto& hydraulic_conductivity = *(*S_->GetW(hydra_cond_key_, Amanzi::Tags::NEXT, hydra_cond_key_).ViewComponent("cell",false))(0); - auto& bulk_density = *(*S_->GetW(bulk_dens_key_, Amanzi::Tags::NEXT, bulk_dens_key_).ViewComponent("cell",false))(0); - - auto col_poro = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto& relative_permeability = *(*S_->GetW(relative_permeability_key_, Amanzi::Tags::NEXT, relative_permeability_key_).ViewComponent("cell",false))(0); + auto& liquid_density = *(*S_->GetW(liquid_density_key_, Amanzi::Tags::NEXT, liquid_density_key_).ViewComponent("cell",false))(0); + auto& rock_density = *(*S_->GetW(rock_density_key_, Amanzi::Tags::NEXT, rock_density_key_).ViewComponent("cell",false))(0); + auto& cell_volume = *(*S_->GetW(cell_volume_key_, Amanzi::Tags::NEXT, cell_volume_key_).ViewComponent("cell",false))(0); + auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Amanzi::Tags::NEXT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); + auto& bulk_density = *(*S_->GetW(bulk_density_key_, Amanzi::Tags::NEXT, bulk_density_key_).ViewComponent("cell",false))(0); + + auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_rel_perm = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_relative_permeability = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -953,7 +952,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, for (int col=0; col!=ncols_local; ++col) { if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false))(0); - auto& gas_density = *(*S_->GetW(gas_den_key_, Amanzi::Tags::NEXT, gas_den_key_).ViewComponent("cell",false))(0); + auto& gas_density = *(*S_->GetW(gas_density_key_, Amanzi::Tags::NEXT, gas_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_g_dens)[i] = state.gas_density.data[col][i]; (*col_g_sat)[i] = props.gas_saturation.data[col][i]; @@ -965,7 +964,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, if (has_ice) { auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); - auto& ice_density = *(*S_->GetW(ice_den_key_, Amanzi::Tags::NEXT, ice_den_key_).ViewComponent("cell",false))(0); + auto& ice_density = *(*S_->GetW(ice_density_key_, Amanzi::Tags::NEXT, ice_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_i_dens)[i] = state.ice_density.data[col][i]; @@ -978,7 +977,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, if (has_energy) { auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "subsurface energy").ViewComponent("cell",false))(0); - auto& thermal_conductivity = *(*S_->GetW(therm_cond_key_, Amanzi::Tags::NEXT, therm_cond_key_).ViewComponent("cell",false))(0); + auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Amanzi::Tags::NEXT, thermal_conductivity_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_temp)[i] = state.temperature.data[col][i]; @@ -991,7 +990,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, for (int i=0; i < ncells_per_col_; ++i) { (*col_l_dens)[i] = state.liquid_density.data[col][i]; - (*col_poro)[i] = state.porosity.data[col][i]; + (*col_porosity)[i] = state.porosity.data[col][i]; (*col_wc)[i] = state.water_content.data[col][i]; (*col_h_cond)[i] = state.hydraulic_conductivity.data[col][i]; (*col_b_dens)[i] = state.bulk_density.data[col][i]; @@ -1009,10 +1008,10 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, } } - ColumnToField_(col,porosity,col_poro.ptr()); + ColumnToField_(col,porosity,col_porosity.ptr()); ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); ColumnToField_(col,water_content,col_wc.ptr()); - ColumnToField_(col,relative_permeability,col_rel_perm.ptr()); + ColumnToField_(col,relative_permeability,col_relative_permeability.ptr()); ColumnToField_(col,liquid_density,col_l_dens.ptr()); ColumnToField_(col,rock_density,col_r_dens.ptr()); ColumnToField_(col,cell_volume,col_vol.ptr()); diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index ff63d7c5d..831c7dd25 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -138,7 +138,7 @@ class EcoSIM : public PK_Physical { double dt_; double c_m_; Teuchos::RCP mesh_surf_; //might need this? - Key domain_surf_; + Key domain_surface_; std::string passwd_ = "state"; //The helper functions from BGC are protected not private (unclear why) @@ -181,25 +181,24 @@ class EcoSIM : public PK_Physical { // keys Key tcc_key_; - Key poro_key_; + Key porosity_key_; Key saturation_liquid_key_; Key saturation_gas_key_; Key saturation_ice_key_; Key elev_key_; Key water_content_key_; - Key rel_perm_key_; - Key liquid_den_key_; - Key ice_den_key_; - Key gas_den_key_; - Key gas_den_key_test_; - Key rock_den_key_; + Key relative_permeability_key_; + Key liquid_density_key_; + Key ice_density_key_; + Key gas_density_key_; + Key gas_density_key_test_; + Key rock_density_key_; Key T_key_; - Key therm_cond_key_; - Key cv_key_; - Key min_vol_frac_key_; + Key thermal_conductivity_key_; + Key cell_volume_key_; Key ecosim_aux_data_key_; - Key bulk_dens_key_; - Key hydra_cond_key_; + Key bulk_density_key_; + Key hydraulic_conductivity_key_; Key sw_key_; Key lw_key_; Key air_temp_key_; From 6d23bb57b28bc568e4795aa9c94066b85efa1376 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 22 Aug 2023 14:01:37 -0700 Subject: [PATCH 454/582] fixing domain --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 46 +++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index e7292cdaf..c6b6008eb 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -52,40 +52,40 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saved_time_(0.0) { //grab the surface and subsurface domains - domain_subsurface_ = plist_->get("domain name", "domain"); - domain_surface_ = Keys::readDomainHint(*plist_, domain_subsurface_, "subsurface", "surface"); + domain_ = plist_->get("domain name", "domain"); + domain_surface_ = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); // transport - tcc_key_ = Keys::readKey(*plist_, domain_subsurface_, "total component concentration", "total_component_concentration"); + tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell //Flow - porosity_key_ = Keys::readKey(*plist_, domain_subsurface_, "porosity", "porosity"); - saturation_liquid_key_ = Keys::readKey(*plist_, domain_subsurface_, "saturation liquid", "saturation_liquid"); - saturation_gas_key_ = Keys::readKey(*plist_,domain_subsurface_,"saturation gas", "saturation_gas"); - saturation_ice_key_ = Keys::readKey(*plist_,domain_subsurface_,"saturation ice", "saturation_ice"); - water_content_key_ = Keys::readKey(*plist_,domain_subsurface_,"water content","water_content"); - relative_permeability_key_ = Keys::readKey(*plist_,domain_subsurface_,"relative permeability","relative_permeability"); - //suction_key_ = Keys::readKey(*plist_,domain_subsurface_,"suction","suction_head"); - liquid_density_key_ = Keys::readKey(*plist_, domain_subsurface_, "mass density liquid", "mass_density_liquid"); - ice_density_key_ = Keys::readKey(*plist_, domain_subsurface_, "mass density ice", "mass_density_ice"); - gas_density_key_ = Keys::readKey(*plist_, domain_subsurface_,"mass density gas", "mass_density_gas"); - gas_density_key_test_ = Keys::readKey(*plist_, domain_subsurface_, "mass density gas", "mass_density_gas"); - rock_density_key_ = Keys::readKey(*plist_, domain_subsurface_, "density rock", "density_rock"); + porosity_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); + saturation_liquid_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); + saturation_gas_key_ = Keys::readKey(*plist_,domain_,"saturation gas", "saturation_gas"); + saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); + water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); + relative_permeability_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); + //suction_key_ = Keys::readKey(*plist_,domain_,"suction","suction_head"); + liquid_density_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); + ice_density_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); + gas_density_key_ = Keys::readKey(*plist_, domain_,"mass density gas", "mass_density_gas"); + gas_density_key_test_ = Keys::readKey(*plist_, domain_, "mass density gas", "mass_density_gas"); + rock_density_key_ = Keys::readKey(*plist_, domain_, "density rock", "density_rock"); //energy - T_key_ = Keys::readKey(*plist_, domain_subsurface_, "temperature", "temperature"); - thermal_conductivity_key_ = Keys::readKey(*plist_, domain_subsurface_, "thermal conductivity", "thermal_conductivity"); + T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); + thermal_conductivity_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); //Other - cell_volume_key_ = Keys::readKey(*plist_, domain_subsurface_, "cell volume", "cell_volume"); - //ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_subsurface_, "ecosim aux data", "ecosim_aux_data"); - f_wp_key_ = Keys::readKey(*plist_, domain_subsurface_, "porosity", "porosity"); - f_root_key_ = Keys::readKey(*plist_, domain_subsurface_, "porosity", "porosity"); + cell_volume_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); + //ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); + f_wp_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); + f_root_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); //Custom Evaluator keys - hydraulic_conductivity_key_ = Keys::readKey(*plist_, domain_subsurface_, "hydraulic conductivity", "hydraulic_conductivity"); - bulk_density_key_ = Keys::readKey(*plist_, domain_subsurface_, "bulk density", "bulk_density"); + hydraulic_conductivity_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); + bulk_density_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); //Surface balance items sw_key_ = From 0b5d738fa4a86a11990a7a634cf08a58584fbb19 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 22 Aug 2023 14:46:36 -0700 Subject: [PATCH 455/582] adding some more tests of memory --- src/pks/ecosim_pk/data/BGC_memory.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 41d7ecab1..0fc5b4284 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -224,8 +224,14 @@ void AllocateBGCTensorDouble(const int rows, const int cols, const int procs, BG tensor->cap_procs = nearest_power_of_2(procs); std::cout << "In Allocate Tensor Double: " << std::endl; - std::cout << "cols: " << cols << std::endl; - std::cout << "size cols: " << tensor->cap_cols << std::endl; + std::cout << "components " << cols << std::endl; + std::cout << "size components: " << tensor->cap_cols << std::endl; + + std::cout << "cells per column: " << rows << std::endl; + std::cout << "size cells per column: " << tensor->cap_rows << std::endl; + + std::cout << "columns on processor: " << procs << std::endl; + std::cout << "size columns on processor: " << tensor->cap_procs << std::endl; tensor->data = (double***) calloc((size_t)tensor->cap_rows, sizeof(double**)); for (int i = 0; i < tensor->rows; ++i) { From 454ca1aaf6a1fb50eb5ea89533a6845abea65edf Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 22 Aug 2023 15:17:42 -0700 Subject: [PATCH 456/582] renaming variables for clarity and fixing a bug --- src/pks/ecosim_pk/data/BGC_containers.hh | 16 +- src/pks/ecosim_pk/data/BGC_memory.cc | 308 +++++++++--------- src/pks/ecosim_pk/data/BGC_memory.hh | 18 +- .../ecosim_pk/data/bgc_fortran_memory_mod.F90 | 36 +- 4 files changed, 191 insertions(+), 187 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index e33c6058a..b885efa41 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -65,32 +65,32 @@ extern "C" { } BGCVectorString; typedef struct { - int rows, cols, cap_rows, cap_cols; + int cells, columns, cap_cells, cap_columns; double** data; } BGCMatrixDouble; typedef struct { - int rows, cols, cap_rows, cap_cols; + int cells, columns, cap_cells, cap_columns; int** data; } BGCMatrixInt; typedef struct { - int rows, cols, capacity; + int cells, columns, capacity; char** data; } BGCMatrixString; typedef struct { - int rows, cols, procs, cap_rows, cap_cols, cap_procs; + int cells, columns, components, cap_cells, cap_columns, cap_components; double*** data; } BGCTensorDouble; typedef struct { - int rows, cols, procs, cap_rows, cap_cols, cap_procs; + int cells, columns, components, cap_cells, cap_columns, cap_components; int*** data; } BGCTensorInt; typedef struct { - int rows, cols, procs, capacity; + int cells, columns, components, capacity; char*** data; } BGCTensorString; @@ -201,7 +201,7 @@ extern "C" { BGCState* state, BGCSizes* sizes, int num_iterations, - int ncol); + int num_columns); /* gracefully shutdown the engine, cleanup memory */ void (*Shutdown)(); @@ -223,7 +223,7 @@ extern "C" { BGCState* state, BGCSizes* sizes, int num_iterations, - int ncol); + int num_columns); /* Access to user selected geochemical data for output, i.e. pH, mineral SI, reaction rates */ diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 0fc5b4284..c050ac50b 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -145,22 +145,22 @@ void FreeBGCVectorString(BGCVectorString* vector) { ** BGC Matrix ** *******************************************************************************/ -void AllocateBGCMatrixDouble(const int rows, const int cols, BGCMatrixDouble* matrix) { - if ((rows > 0 ) || (cols > 0)){ - matrix->rows = rows; - matrix->cols = cols; - matrix->cap_rows = nearest_power_of_2(rows); - matrix->cap_cols = nearest_power_of_2(cols); - matrix->data = (double**) calloc((size_t)matrix->cap_rows, sizeof(double*)); - for (int i = 0; i < matrix->rows; ++i) { - matrix->data[i] = (double*) calloc((size_t)matrix->cap_cols, sizeof(double)); +void AllocateBGCMatrixDouble(const int cells, const int columns, BGCMatrixDouble* matrix) { + if ((cells > 0 ) || (columns > 0)){ + matrix->cells = cells; + matrix->column = columns; + matrix->capacity_cells = nearest_power_of_2(cells); + matrix->capacity_columns = nearest_power_of_2(columns); + matrix->data = (double**) calloc((size_t)matrix->capacity_columns, sizeof(double*)); + for (int i = 0; i < matrix->columns; ++i) { + matrix->data[i] = (double*) calloc((size_t)matrix->capacity_cells, sizeof(double)); } //ALQUIMIA_ASSERT(NULL != matrix->data); } else { - matrix->rows = 0; - matrix->cols = 0; - matrix->cap_rows = 0; - matrix->cap_cols = 0; + matrix->cells= 0; + matrix->columns= 0; + matrix->capacity_cells= 0; + matrix->capacity_columns= 0; matrix->data = NULL; } } /* end AllocateBGCmatrixDouble() */ @@ -169,29 +169,29 @@ void FreeBGCMatrixDouble(BGCMatrixDouble* matrix) { if (matrix != NULL) { free(matrix->data); matrix->data = NULL; - matrix->rows = 0; - matrix->cols = 0; - matrix->cap_rows = 0; - matrix->cap_cols = 0; + matrix->cells= 0; + matrix->columns= 0; + matrix->capacity_cells= 0; + matrix->capacity_columns= 0; } } /* end FreeBGCmatrixDouble() */ -void AllocateBGCMatrixInt(const int rows, const int cols, BGCMatrixInt* matrix) { - if ((rows > 0) || (cols > 0)) { - matrix->rows = rows; - matrix->cols = cols; - matrix->cap_rows = nearest_power_of_2(rows); - matrix->cap_cols = nearest_power_of_2(cols); - matrix->data = (int**) calloc((size_t)matrix->cap_rows, sizeof(int*)); - for (int i = 0; i < matrix->rows; ++i) { - matrix->data[i] = (int*) calloc((size_t)matrix->cap_cols, sizeof(int)); +void AllocateBGCMatrixInt(const int cells, const int columns, BGCMatrixInt* matrix) { + if ((cells> 0) || (columns> 0)) { + matrix->cells= cells; + matrix->columns= columns; + matrix->capacity_cells= nearest_power_of_2(cells); + matrix->capacity_columns= nearest_power_of_2(columns); + matrix->data = (int**) calloc((size_t)matrix->capacity_columns, sizeof(int*)); + for (int i = 0; i < matrix->columns; ++i) { + matrix->data[i] = (int*) calloc((size_t)matrix->capacity_cells, sizeof(int)); } //ALQUIMIA_ASSERT(NULL != matrix->data); } else { - matrix->rows = 0; - matrix->cols = 0; - matrix->cap_rows = 0; - matrix->cap_cols = 0; + matrix->cells= 0; + matrix->columns= 0; + matrix->capacity_cells= 0; + matrix->capacity_columns= 0; matrix->data = NULL; } } /* end AllocateBGCMatrixInt() */ @@ -200,10 +200,10 @@ void FreeBGCMatrixInt(BGCMatrixInt* matrix) { if (matrix != NULL) { free(matrix->data); matrix->data = NULL; - matrix->rows = 0; - matrix->cols = 0; - matrix->cap_cols = 0; - matrix->cap_rows = 0; + matrix->cells= 0; + matrix->columns= 0; + matrix->capacity_columns= 0; + matrix->capacity_cells= 0; } } /* end FreeBGCMatrixInt() */ @@ -213,40 +213,41 @@ void FreeBGCMatrixInt(BGCMatrixInt* matrix) { ** *******************************************************************************/ -void AllocateBGCTensorDouble(const int rows, const int cols, const int procs, BGCTensorDouble* tensor) { - if ((rows > 0 ) || (cols > 0) || (procs > 0)){ - tensor->rows = rows; - tensor->cols = cols; - tensor->procs = procs; +void AllocateBGCTensorDouble(const int cells, const int columns, const int components, BGCTensorDouble* tensor) { + if ((cells> 0 ) || (columns> 0) || (components > 0)){ + tensor->cells = cells; + tensor->columns = columns; + tensor->components = components; - tensor->cap_rows = nearest_power_of_2(rows); - tensor->cap_cols = nearest_power_of_2(cols); - tensor->cap_procs = nearest_power_of_2(procs); + tensor->capacity_cells= nearest_power_of_2(cells); + tensor->capacity_columns= nearest_power_of_2(columns); + tensor->capacity_components = nearest_power_of_2(components); std::cout << "In Allocate Tensor Double: " << std::endl; - std::cout << "components " << cols << std::endl; - std::cout << "size components: " << tensor->cap_cols << std::endl; + std::cout << "columns on processor " << columns << std::endl; + std::cout << "size columns on procesor: " << tensor->capacity_columns << std::endl; - std::cout << "cells per column: " << rows << std::endl; - std::cout << "size cells per column: " << tensor->cap_rows << std::endl; + std::cout << "cells per column: " << cells<< std::endl; + std::cout << "size cells per column: " << tensor->capacity_cells<< std::endl; - std::cout << "columns on processor: " << procs << std::endl; - std::cout << "size columns on processor: " << tensor->cap_procs << std::endl; + std::cout << "components: " << components << std::endl; + std::cout << "size components: " << tensor->capacity_components << std::endl; - tensor->data = (double***) calloc((size_t)tensor->cap_rows, sizeof(double**)); - for (int i = 0; i < tensor->rows; ++i) { - tensor->data[i] = (double**) calloc((size_t)tensor->cap_cols, sizeof(double*)); - for (int j = 0; j < tensor->cols; ++j) { - tensor->data[i][j] = (double*) calloc((size_t)tensor->cap_procs, sizeof(double)); + tensor->data = (double***) calloc((size_t)tensor->capacity_columns, sizeof(double**)); + for (int i = 0; i < tensor->columns; ++i) { + tensor->data[i] = (double**) calloc((size_t)tensor->capacity_cells, sizeof(double*)); + for (int j = 0; j < tensor->cells; ++j) { + tensor->data[i][j] = (double*) calloc((size_t)tensor->capacity_components, sizeof(double)); } } //ALQUIMIA_ASSERT(NULL != matrix->data); } else { - tensor->rows = 0; - tensor->cols = 0; - tensor->procs = 0; - tensor->cap_rows = 0; - tensor->cap_cols = 0; + tensor->cells= 0; + tensor->columns= 0; + tensor->components = 0; + tensor->capacity_cells = 0; + tensor->capacity_columns = 0; + tensor->capacity_components = 0; tensor->data = NULL; } } /* end AllocateBGCmatrixDouble() */ @@ -255,37 +256,39 @@ void FreeBGCTensorDouble(BGCTensorDouble* tensor) { if (tensor != NULL) { free(tensor->data); tensor->data = NULL; - tensor->rows = 0; - tensor->cols = 0; - tensor->cap_rows = 0; - tensor->cap_cols = 0; + tensor->cells= 0; + tensor->columns = 0; + tensor->capacity_cells = 0; + tensor->capacity_columns = 0; + tensor->capacity_components = 0; } } /* end FreeBGCmatrixDouble() */ -void AllocateBGCTensorInt(const int rows, const int cols, const int procs, BGCTensorInt* tensor) { - if ((rows > 0 ) || (cols > 0) || (procs > 0)){ - tensor->rows = rows; - tensor->cols = cols; - tensor->procs = procs; - - tensor->cap_rows = nearest_power_of_2(rows); - tensor->cap_cols = nearest_power_of_2(cols); - tensor->cap_procs = nearest_power_of_2(procs); - - tensor->data = (int***) calloc((size_t)tensor->cap_rows, sizeof(int**)); - for (int i = 0; i < tensor->rows; ++i) { - tensor->data[i] = (int**) calloc((size_t)tensor->cap_cols, sizeof(int*)); - for (int j = 0; j < tensor->cols; ++j) { - tensor->data[i][j] = (int*) calloc((size_t)tensor->cap_procs, sizeof(int)); +void AllocateBGCTensorInt(const int cells, const int columns, const int components, BGCTensorInt* tensor) { + if ((cells> 0 ) || (columns> 0) || (components > 0)){ + tensor->cells= cells; + tensor->columns= columns; + tensor->components = components; + + tensor->capacity_cells= nearest_power_of_2(cells); + tensor->capacity_columns= nearest_power_of_2(columns); + tensor->capacity_components = nearest_power_of_2(components); + + tensor->data = (int***) calloc((size_t)tensor->capacity_columns, sizeof(int**)); + for (int i = 0; i < tensor->columns; ++i) { + tensor->data[i] = (int**) calloc((size_t)tensor->capacity_cells, sizeof(int*)); + for (int j = 0; j < tensor->cells; ++j) { + tensor->data[i][j] = (int*) calloc((size_t)tensor->capacity_components, sizeof(int)); } } //ALQUIMIA_ASSERT(NULL != matrix->data); } else { - tensor->rows = 0; - tensor->cols = 0; - tensor->procs = 0; - tensor->cap_rows = 0; - tensor->cap_cols = 0; + tensor->cells= 0; + tensor->columns= 0; + tensor->components = 0; + tensor->capacity_cells= 0; + tensor->capacity_columns= 0; + tensor->capacity_components = 0; tensor->data = NULL; } } /* end AllocateBGCmatrixint() */ @@ -294,10 +297,11 @@ void FreeBGCTensorInt(BGCTensorInt* tensor) { if (tensor != NULL) { free(tensor->data); tensor->data = NULL; - tensor->rows = 0; - tensor->cols = 0; - tensor->cap_rows = 0; - tensor->cap_cols = 0; + tensor->cells= 0; + tensor->columns= 0; + tensor->capacity_cells= 0; + tensor->capacity_columns= 0; + tensor->capacity_components = 0; } } /* end FreeBGCmatrixint() */ @@ -381,7 +385,7 @@ void AllocateBGCState(const BGCSizes* const sizes, ** *******************************************************************************/ - void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, + void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* properties, int ncells_per_col_, int num_columns) { std::cout << "In allocate properties: " << std::endl; std::cout << "prop size: " << num_columns << std::endl; @@ -389,50 +393,50 @@ void AllocateBGCState(const BGCSizes* const sizes, sizes->ncells_per_col_ = ncells_per_col_; sizes->num_columns = num_columns; //sizes->num_components = num_components; - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->liquid_saturation)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->gas_saturation)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->ice_saturation)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->relative_permeability)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->thermal_conductivity)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->volume)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->depth)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->dz)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->plant_wilting_factor)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(props->rooting_depth_fraction)); - - AllocateBGCVectorDouble(sizes->num_columns, &(props->shortwave_radiation)); - AllocateBGCVectorDouble(sizes->num_columns, &(props->longwave_radiation)); - AllocateBGCVectorDouble(sizes->num_columns, &(props->air_temperature)); - AllocateBGCVectorDouble(sizes->num_columns, &(props->vapor_pressure_air)); - AllocateBGCVectorDouble(sizes->num_columns, &(props->wind_speed)); - AllocateBGCVectorDouble(sizes->num_columns, &(props->precipitation)); - AllocateBGCVectorDouble(sizes->num_columns, &(props->elevation)); - AllocateBGCVectorDouble(sizes->num_columns, &(props->aspect)); - AllocateBGCVectorDouble(sizes->num_columns, &(props->slope)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->liquid_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->gas_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->ice_saturation)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->relative_permeability)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->thermal_conductivity)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->volume)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->depth)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->dz)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->plant_wilting_factor)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->rooting_depth_fraction)); + + AllocateBGCVectorDouble(sizes->num_columns, &(properties->shortwave_radiation)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->longwave_radiation)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->air_temperature)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->vapor_pressure_air)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->wind_speed)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->precipitation)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->elevation)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->aspect)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->slope)); } /* end AllocateAlquimiaProperties() */ - void FreeBGCProperties(BGCProperties* props) { - if (props != NULL) { - FreeBGCMatrixDouble(&(props->liquid_saturation)); - FreeBGCMatrixDouble(&(props->gas_saturation)); - FreeBGCMatrixDouble(&(props->ice_saturation)); - FreeBGCMatrixDouble(&(props->relative_permeability)); - FreeBGCMatrixDouble(&(props->thermal_conductivity)); - FreeBGCMatrixDouble(&(props->volume)); - FreeBGCMatrixDouble(&(props->depth)); - FreeBGCMatrixDouble(&(props->dz)); - FreeBGCMatrixDouble(&(props->plant_wilting_factor)); - FreeBGCMatrixDouble(&(props->rooting_depth_fraction)); - - FreeBGCVectorDouble(&(props->shortwave_radiation)); - FreeBGCVectorDouble(&(props->longwave_radiation)); - FreeBGCVectorDouble(&(props->air_temperature)); - FreeBGCVectorDouble(&(props->vapor_pressure_air)); - FreeBGCVectorDouble(&(props->wind_speed)); - FreeBGCVectorDouble(&(props->precipitation)); - FreeBGCVectorDouble(&(props->elevation)); - FreeBGCVectorDouble(&(props->aspect)); - FreeBGCVectorDouble(&(props->slope)); + void FreeBGCProperties(BGCProperties* properties) { + if (properties != NULL) { + FreeBGCMatrixDouble(&(properties->liquid_saturation)); + FreeBGCMatrixDouble(&(properties->gas_saturation)); + FreeBGCMatrixDouble(&(properties->ice_saturation)); + FreeBGCMatrixDouble(&(properties->relative_permeability)); + FreeBGCMatrixDouble(&(properties->thermal_conductivity)); + FreeBGCMatrixDouble(&(properties->volume)); + FreeBGCMatrixDouble(&(properties->depth)); + FreeBGCMatrixDouble(&(properties->dz)); + FreeBGCMatrixDouble(&(properties->plant_wilting_factor)); + FreeBGCMatrixDouble(&(properties->rooting_depth_fraction)); + + FreeBGCVectorDouble(&(properties->shortwave_radiation)); + FreeBGCVectorDouble(&(properties->longwave_radiation)); + FreeBGCVectorDouble(&(properties->air_temperature)); + FreeBGCVectorDouble(&(properties->vapor_pressure_air)); + FreeBGCVectorDouble(&(properties->wind_speed)); + FreeBGCVectorDouble(&(properties->precipitation)); + FreeBGCVectorDouble(&(properties->elevation)); + FreeBGCVectorDouble(&(properties->aspect)); + FreeBGCVectorDouble(&(properties->slope)); } } @@ -486,34 +490,34 @@ void FreeBGCAuxiliaryData(BGCAuxiliaryData* aux_data) { } } -void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* props, +void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* properties, int ncells_per_col_) { sizes->ncells_per_col_ = ncells_per_col_; - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->liquid_saturation)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->gas_saturation)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->ice_saturation)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->relative_permeability)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->thermal_conductivity)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->volume)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->depth)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->dz)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->plant_wilting_factor)); - AllocateBGCVectorDouble(sizes->ncells_per_col_, &(props->rooting_depth_fraction)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->liquid_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->gas_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->ice_saturation)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->relative_permeability)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->thermal_conductivity)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->volume)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->depth)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->dz)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->plant_wilting_factor)); + AllocateBGCVectorDouble(sizes->ncells_per_col_, &(properties->rooting_depth_fraction)); } -void FreeBGCProperties(BGCProperties* props) { - if (props != NULL) { - FreeBGCVectorDouble(&(props->liquid_saturation)); - FreeBGCVectorDouble(&(props->gas_saturation)); - FreeBGCVectorDouble(&(props->ice_saturation)); - FreeBGCVectorDouble(&(props->relative_permeability)); - FreeBGCVectorDouble(&(props->thermal_conductivity)); - FreeBGCVectorDouble(&(props->volume)); - FreeBGCVectorDouble(&(props->depth)); - FreeBGCVectorDouble(&(props->dz)); - FreeBGCVectorDouble(&(props->plant_wilting_factor)); - FreeBGCVectorDouble(&(props->rooting_depth_fraction)); +void FreeBGCProperties(BGCProperties* properties) { + if (properties != NULL) { + FreeBGCVectorDouble(&(properties->liquid_saturation)); + FreeBGCVectorDouble(&(properties->gas_saturation)); + FreeBGCVectorDouble(&(properties->ice_saturation)); + FreeBGCVectorDouble(&(properties->relative_permeability)); + FreeBGCVectorDouble(&(properties->thermal_conductivity)); + FreeBGCVectorDouble(&(properties->volume)); + FreeBGCVectorDouble(&(properties->depth)); + FreeBGCVectorDouble(&(properties->dz)); + FreeBGCVectorDouble(&(properties->plant_wilting_factor)); + FreeBGCVectorDouble(&(properties->rooting_depth_fraction)); } } diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim_pk/data/BGC_memory.hh index 7180dea11..b620fdc22 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.hh +++ b/src/pks/ecosim_pk/data/BGC_memory.hh @@ -49,20 +49,20 @@ extern "C" { void FreeBGCVectorString(BGCVectorString* vector); /* Matrix */ - void AllocateBGCMatrixDouble(const int rows, const int cols, BGCMatrixDouble* matrix); + void AllocateBGCMatrixDouble(const int cells, const int columns, BGCMatrixDouble* matrix); void FreeBGCMatrixDouble(BGCMatrixDouble* matrix); - void AllocateBGCMatrixInt(const int rows, const int cols, BGCMatrixInt* matrix); + void AllocateBGCMatrixInt(const int cells, const int columns, BGCMatrixInt* matrix); void FreeBGCMatrixInt(BGCMatrixInt* matrix); - void AllocateBGCMatrixString(const int rows, const int cols, BGCMatrixString* matrix); + void AllocateBGCMatrixString(const int cells, const int columns, BGCMatrixString* matrix); void FreeBGCMatrixString(BGCMatrixString* matrix); - void AllocateBGCTensorDouble(const int rows, const int cols, BGCTensorDouble* tensor); + void AllocateBGCTensorDouble(const int cells, const int columns, BGCTensorDouble* tensor); void FreeBGCMatrixDouble(BGCMatrixDouble* tensor); - void AllocateBGCTensorInt(const int rows, const int cols, BGCTensorInt* tensor); + void AllocateBGCTensorInt(const int cells, const int columns, BGCTensorInt* tensor); void FreeBGCTensorInt(BGCTensorInt* tensor); /* State */ @@ -70,7 +70,7 @@ extern "C" { BGCState* state, int ncells_per_col_, int num_components, - int cols_on_proc); + int num_columns); void FreeBGCState(BGCState* state); /* Auxiliary Data @@ -81,10 +81,10 @@ extern "C" { */ /* Properties */ void AllocateBGCProperties(BGCSizes* sizes, - BGCProperties* props, + BGCProperties* properties, int ncells_per_col_, - int cols_on_proc); - void FreeBGCProperties(BGCProperties* props); + int num_columns); + void FreeBGCProperties(BGCProperties* properties); // Problem Meta Data /*void AllocateAlquimiaProblemMetaData(const AlquimiaSizes* const sizes, diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 index fdf53c5d3..39da905c0 100644 --- a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 @@ -64,21 +64,21 @@ subroutine FreeBGCState(state) bind(C, name='FreeBGCState') end interface interface - subroutine AllocateBGCProperties(sizes, props, ncells_per_col_, num_columns) bind(C, name='AllocateBGCProperties') + subroutine AllocateBGCProperties(sizes, properties, ncells_per_col_, num_columns) bind(C, name='AllocateBGCProperties') use BGCContainers_module, only : BGCSizes, BGCProperties use, intrinsic :: iso_c_binding, only: c_int implicit none type(BGCSizes) :: sizes - type(BGCProperties) :: props + type(BGCProperties) :: properties integer(c_int),VALUE :: ncells_per_col_ integer(c_int),VALUE :: num_columns end subroutine end interface interface - subroutine FreeBGCProperties(props) bind(C, name='FreeBGCProperties') + subroutine FreeBGCProperties(properties) bind(C, name='FreeBGCProperties') use BGCContainers_module, only : BGCProperties implicit none - type(BGCProperties) :: props + type(BGCProperties) :: properties end subroutine end interface @@ -94,7 +94,7 @@ subroutine DataTest() bind(C) interface - subroutine Setup(props, state, sizes, num_iterations, ncol) bind(C) + subroutine Setup(properties, state, sizes, num_iterations, num_columns) bind(C) use, intrinsic :: iso_c_binding, only: c_char, c_bool, c_ptr, c_int use BGCContainers_module, only : BGCSizes,BGCProperties,& @@ -103,9 +103,9 @@ subroutine Setup(props, state, sizes, num_iterations, ncol) bind(C) implicit none integer(c_int),VALUE :: num_iterations - integer(c_int),VALUE :: ncol + integer(c_int),VALUE :: num_columns - type(BGCProperties) :: props + type(BGCProperties) :: properties type(BGCState) :: state type(BGCSizes) :: sizes @@ -124,7 +124,7 @@ subroutine Shutdown() bind(C) ! take one (or more?) reaction steps in operator split mode interface - subroutine Advance(delta_t, props, state, sizes, num_iterations, ncol) bind(C) + subroutine Advance(delta_t, properties, state, sizes, num_iterations, num_columns) bind(C) use, intrinsic :: iso_c_binding, only : c_ptr, c_double, c_int use BGCContainers_module, only : BGCSizes,BGCProperties,& BGCState @@ -132,9 +132,9 @@ subroutine Advance(delta_t, props, state, sizes, num_iterations, ncol) bind(C) real(c_double),VALUE :: delta_t integer(c_int),VALUE :: num_iterations - integer(c_int),VALUE :: ncol + integer(c_int),VALUE :: num_columns - type(BGCProperties) :: props + type(BGCProperties) :: properties type(BGCState) :: state type(BGCSizes) :: sizes end subroutine @@ -154,7 +154,7 @@ subroutine BGC_Fortran_DataTest(this) end subroutine BGC_Fortran_DataTest - subroutine BGC_Fortran_Setup(this, props, state, sizes, num_iterations, ncol) + subroutine BGC_Fortran_Setup(this, properties, state, sizes, num_iterations, num_columns) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer use BGCContainers_module, only : BGCSizes, BGCProperties,& BGCState @@ -163,16 +163,16 @@ subroutine BGC_Fortran_Setup(this, props, state, sizes, num_iterations, ncol) class(BGCFortranInterface) :: this real(c_double) :: delta_t - integer(c_int) :: ncol + integer(c_int) :: num_columns integer(c_int) :: num_iterations - type(BGCProperties) :: props + type(BGCProperties) :: properties type(BGCState) :: state type(BGCSizes) :: sizes procedure(Setup), pointer :: engine_Setup call c_f_procpointer(this%c_interface%Setup,engine_Setup) - call engine_Setup(props, state, sizes, num_iterations, ncol) + call engine_Setup(properties, state, sizes, num_iterations, num_columns) end subroutine BGC_Fortran_Setup @@ -188,7 +188,7 @@ subroutine BGC_Fortran_Shutdown(this) end subroutine BGC_Fortran_Shutdown - subroutine BGC_Fortran_Advance(this, delta_t, props, state, sizes, num_iterations, ncol) + subroutine BGC_Fortran_Advance(this, delta_t, properties, state, sizes, num_iterations, num_columns) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer use BGCContainers_module, only : BGCSizes, BGCProperties,& BGCState @@ -197,16 +197,16 @@ subroutine BGC_Fortran_Advance(this, delta_t, props, state, sizes, num_iteration class(BGCFortranInterface) :: this real(c_double) :: delta_t - integer(c_int) :: ncol + integer(c_int) :: num_columns integer(c_int) :: num_iterations - type(BGCProperties) :: props + type(BGCProperties) :: properties type(BGCState) :: state type(BGCSizes) :: sizes procedure(Advance), pointer :: engine_Advance call c_f_procpointer(this%c_interface%Advance,engine_Advance) - call engine_Advance(delta_t, props, state, sizes, num_iterations, ncol) + call engine_Advance(delta_t, properties, state, sizes, num_iterations, num_columns) end subroutine BGC_Fortran_Advance subroutine Create_Fortran_BGC_Interface(this,engine_name) From c9fac14dbcf0302fecdf560d18612512fffd8ff1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 22 Aug 2023 15:34:41 -0700 Subject: [PATCH 457/582] minor fixes --- src/pks/ecosim_pk/data/BGC_containers.hh | 8 ++++---- src/pks/ecosim_pk/data/BGC_memory.cc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index b885efa41..8bc941c21 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -65,12 +65,12 @@ extern "C" { } BGCVectorString; typedef struct { - int cells, columns, cap_cells, cap_columns; + int cells, columns, capacity_cells, capacity_columns; double** data; } BGCMatrixDouble; typedef struct { - int cells, columns, cap_cells, cap_columns; + int cells, columns, capacity_cells, capacity_columns; int** data; } BGCMatrixInt; @@ -80,12 +80,12 @@ extern "C" { } BGCMatrixString; typedef struct { - int cells, columns, components, cap_cells, cap_columns, cap_components; + int cells, columns, components, capacity_cells, capacity_columns, cap_components; double*** data; } BGCTensorDouble; typedef struct { - int cells, columns, components, cap_cells, cap_columns, cap_components; + int cells, columns, components, capacity_cells, capacity_columns, cap_components; int*** data; } BGCTensorInt; diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index c050ac50b..2fa631259 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -148,7 +148,7 @@ void FreeBGCVectorString(BGCVectorString* vector) { void AllocateBGCMatrixDouble(const int cells, const int columns, BGCMatrixDouble* matrix) { if ((cells > 0 ) || (columns > 0)){ matrix->cells = cells; - matrix->column = columns; + matrix->columns = columns; matrix->capacity_cells = nearest_power_of_2(cells); matrix->capacity_columns = nearest_power_of_2(columns); matrix->data = (double**) calloc((size_t)matrix->capacity_columns, sizeof(double*)); From 6d70113b3cce268ed756dbf4699f77765e418927 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 22 Aug 2023 16:08:10 -0700 Subject: [PATCH 458/582] more variable renaming and fixes --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 312 +++++++++++----------- src/pks/ecosim_pk/EcoSIM_ATS_interface.hh | 32 +-- src/pks/ecosim_pk/data/BGC_containers.hh | 4 +- 3 files changed, 172 insertions(+), 176 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index c6b6008eb..d5f1e0ff5 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -141,18 +141,14 @@ EcoSIM::~EcoSIM() void EcoSIM::Setup() { //Need to do some basic setup of the columns: mesh_surf_ = S_->GetMesh(domain_surface_); - num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - for (unsigned int col = 0; col != num_cols_; ++col) { - int f = mesh_surf_->entity_get_parent(AmanziMesh::CELL, col); - auto& col_iter = mesh_->cells_of_column(col); + for (unsigned int column = 0; column != num_columns_; ++column) { + int f = mesh_surf_->entity_get_parent(AmanziMesh::CELL, column); + auto& col_iter = mesh_->cells_of_column(column); std::size_t ncol_cells = col_iter.size(); - // unclear which this should be: - // -- col area is the true face area - double col_area = mesh_->face_area(f); - // -- col area is the projected face area - // double col_area = mesh_surf_->cell_volume(col); + double column_area = mesh_->face_area(f); if (ncells_per_col_ < 0) { ncells_per_col_ = ncol_cells; @@ -217,11 +213,11 @@ void EcoSIM::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "number of components: " << tcc_num << std::endl; - num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - *vo_->os() << "columns on processor: " << num_cols_ << std::endl; + num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + *vo_->os() << "columns on processor: " << num_columns_ << std::endl; //Now we call the engine's init state function which allocates the data - bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num, num_cols_); + bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num, num_columns_); *vo_->os() << "Trying to print Sizes from engine: " << tcc_num << std::endl; bgc_engine_->Sizes().ncells_per_col_; @@ -325,20 +321,20 @@ void EcoSIM::Initialize() { S_->GetW(bulk_density_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); S_->GetRecordW(bulk_density_key_, Tags::DEFAULT, "bulk_density").set_initialized(); - int num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + int num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //Looping over the columns and initializing - /*for (int col=0; col!=num_cols_; ++col) { + /*for (int col=0; col!=num_columns_; ++col) { ierr = InitializeSingleColumn(col); }*/ //loop over processes instead: - ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; - *vo_->os() << "total columns from num_entities: " << ncols_global << std::endl; + *vo_->os() << "total columns cell_map: " << num_columns_global << std::endl; + *vo_->os() << "total columns from num_entities: " << num_columns_global << std::endl; //Trying to loop over processors now: int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); @@ -347,8 +343,8 @@ void EcoSIM::Initialize() { MPI_Barrier(MPI_COMM_WORLD); if (p_rank==k) { std::cout << "on processor " << p_rank << std::endl; - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << ncols_local << std::endl; + num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << num_columns_local << std::endl; InitializeSingleProcess(p_rank); } @@ -438,7 +434,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { Teuchos::RCP bulk_dens = S_->GetPtr(bulk_density_key_, Tags::DEFAULT); S_->GetEvaluator(bulk_density_key_, Tags::DEFAULT).Update(*S_, name_); - AmanziMesh::Entity_ID num_cols_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + AmanziMesh::Entity_ID num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); // grab the required fields S_->GetEvaluator("porosity", tag_next_).Update(*S_, name_); @@ -549,12 +545,12 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { } //loop over processes instead: - ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; - *vo_->os() << "total columns from num_entities: " << ncols_global << std::endl; + *vo_->os() << "total columns cell_map: " << num_columns_global << std::endl; + *vo_->os() << "total columns from num_entities: " << num_columns_global << std::endl; //Trying to loop over processors now: int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); @@ -563,8 +559,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { MPI_Barrier(MPI_COMM_WORLD); if (p_rank==k) { std::cout << "on processor " << p_rank << std::endl; - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << ncols_local << std::endl; + num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << num_columns_local << std::endl; AdvanceSingleProcess(dt, p_rank); } @@ -573,7 +569,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { } // helper function for pushing field to column -void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, +void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_Vector& vec, Teuchos::Ptr col_vec) { auto& col_iter = mesh_->cells_of_column(col); @@ -585,10 +581,10 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, } } -void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Teuchos::Ptr vec, +void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID column, const Teuchos::Ptr vec, Teuchos::Ptr col_vec) { - auto& col_iter = mesh_->cells_of_column(col); + auto& col_iter = mesh_->cells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { std::size_t vec_index = col_iter[i]; @@ -597,11 +593,11 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID col, const Teuchos::Ptr col_arr) { int n_comp = m_arr.NumVectors(); - auto& col_iter = mesh_->cells_of_column(col); + auto& col_iter = mesh_->cells_of_column(column); for (int j=0; j!=n_comp; ++j){ for (std::size_t i=0; i!=col_iter.size(); ++i) { @@ -611,29 +607,29 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiV } // helper function for pushing column back to field -void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, +void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Epetra_Vector& vec, Teuchos::Ptr col_vec) { - auto& col_iter = mesh_->cells_of_column(col); + auto& col_iter = mesh_->cells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { vec[col_iter[i]] = (*col_vec)[i]; } } -void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::Ptr vec, +void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Teuchos::Ptr vec, Teuchos::Ptr col_vec) { - auto& col_iter = mesh_->cells_of_column(col); + auto& col_iter = mesh_->cells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { (*vec)[col_iter[i]] = (*col_vec)[i]; } } -void EcoSIM::MatrixColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector& m_arr, +void EcoSIM::MatrixColumnToField_(AmanziMesh::Entity_ID column, Epetra_MultiVector& m_arr, Teuchos::Ptr col_arr) { int n_comp = m_arr.NumVectors(); - auto& col_iter = mesh_->cells_of_column(col); + auto& col_iter = mesh_->cells_of_column(column); for (int j=0; j!=n_comp; ++j){ for (std::size_t i=0; i!=col_iter.size(); ++i) { @@ -644,11 +640,11 @@ void EcoSIM::MatrixColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector& } // helper function for collecting column dz and depth -void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID col, +void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID column, Teuchos::Ptr depth, Teuchos::Ptr dz) { - AmanziMesh::Entity_ID f_above = mesh_surf_->entity_get_parent(AmanziMesh::CELL, col); - auto& col_iter = mesh_->cells_of_column(col); + AmanziMesh::Entity_ID f_above = mesh_surf_->entity_get_parent(AmanziMesh::CELL, column); + auto& col_iter = mesh_->cells_of_column(column); ncells_per_col_ = col_iter.size(); AmanziGeometry::Point surf_centroid = mesh_->face_centroid(f_above); @@ -746,125 +742,125 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); //Gather columns on this process: - ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; - *vo_->os() << "total columns from num_entities: " << ncols_global_ptype << std::endl; + *vo_->os() << "total columns cell_map: " << num_columns_global << std::endl; + *vo_->os() << "total columns from num_entities: " << num_columns_global_ptype << std::endl; //Trying to loop over processors now: int p_rank; MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); MPI_Barrier(MPI_COMM_WORLD); std::cout << "on processor " << p_rank << std::endl; - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << ncols_local << std::endl; + num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << num_columns_local << std::endl; //Loop over columns on this process - for (int col=0; col!=ncols_local; ++col) { - FieldToColumn_(col,porosity,col_porosity.ptr()); - FieldToColumn_(col,liquid_saturation,col_l_sat.ptr()); - FieldToColumn_(col,water_content,col_wc.ptr()); - FieldToColumn_(col,relative_permeability,col_relative_permeability.ptr()); - FieldToColumn_(col,liquid_density,col_l_dens.ptr()); - FieldToColumn_(col,rock_density,col_r_dens.ptr()); - FieldToColumn_(col,cell_volume,col_vol.ptr()); - FieldToColumn_(col,hydraulic_conductivity,col_h_cond.ptr()); - FieldToColumn_(col,bulk_density,col_b_dens.ptr()); - FieldToColumn_(col,plant_wilting_factor,col_wp.ptr()); - FieldToColumn_(col,rooting_depth_fraction,col_rf.ptr()); - - MatrixFieldToColumn_(col, tcc, col_tcc.ptr()); + for (int column=0; column!=num_columns_local; ++column) { + FieldToColumn_(column,porosity,col_porosity.ptr()); + FieldToColumn_(column,liquid_saturation,col_l_sat.ptr()); + FieldToColumn_(column,water_content,col_wc.ptr()); + FieldToColumn_(column,relative_permeability,col_relative_permeability.ptr()); + FieldToColumn_(column,liquid_density,col_l_dens.ptr()); + FieldToColumn_(column,rock_density,col_r_dens.ptr()); + FieldToColumn_(column,cell_volume,col_vol.ptr()); + FieldToColumn_(column,hydraulic_conductivity,col_h_cond.ptr()); + FieldToColumn_(column,bulk_density,col_b_dens.ptr()); + FieldToColumn_(column,plant_wilting_factor,col_wp.ptr()); + FieldToColumn_(column,rooting_depth_fraction,col_rf.ptr()); + + MatrixFieldToColumn_(column, tcc, col_tcc.ptr()); if (has_gas) { const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& gas_density = *(*S_->Get(gas_density_key_, water_tag).ViewComponent("cell", false))(0); - FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); - FieldToColumn_(col,gas_density,col_g_dens.ptr()); + FieldToColumn_(column,gas_saturation,col_g_sat.ptr()); + FieldToColumn_(column,gas_density,col_g_dens.ptr()); } if (has_ice) { const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& ice_density = *(*S_->Get(ice_density_key_, water_tag).ViewComponent("cell", false))(0); - FieldToColumn_(col,ice_saturation,col_i_sat.ptr()); - FieldToColumn_(col,ice_density,col_i_dens.ptr()); + FieldToColumn_(column,ice_saturation,col_i_sat.ptr()); + FieldToColumn_(column,ice_density,col_i_dens.ptr()); } if (has_energy) { const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - FieldToColumn_(col,temp, col_temp.ptr()); - FieldToColumn_(col,thermal_conductivity,col_cond.ptr()); + FieldToColumn_(column,temp, col_temp.ptr()); + FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); } // This is for computing depth - ColDepthDz_(col, col_depth.ptr(), col_dz.ptr()); + ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); for (int i=0; i < ncells_per_col_; ++i) { - state.liquid_density.data[col][i] = (*col_l_dens)[i]; - state.porosity.data[col][i] = (*col_porosity)[i]; - state.water_content.data[col][i] = (*col_wc)[i]; - state.hydraulic_conductivity.data[col][i] = (*col_h_cond)[i]; - state.bulk_density.data[col][i] = (*col_b_dens)[i]; + state.liquid_density.data[column][i] = (*col_l_dens)[i]; + state.porosity.data[column][i] = (*col_porosity)[i]; + state.water_content.data[column][i] = (*col_wc)[i]; + state.hydraulic_conductivity.data[column][i] = (*col_h_cond)[i]; + state.bulk_density.data[column][i] = (*col_b_dens)[i]; //state.suction_head.data[i] = (*col_suc)[i]; - props.plant_wilting_factor.data[col][i] = (*col_wp)[i]; - props.rooting_depth_fraction.data[col][i] = (*col_rf)[i]; - props.liquid_saturation.data[col][i] = (*col_l_sat)[i]; - props.relative_permeability.data[col][i] = (*col_relative_permeability)[i]; - props.volume.data[col][i] = (*col_vol)[i]; - props.depth.data[col][i] = (*col_depth)[i]; - props.dz.data[col][i] = (*col_dz)[i]; + props.plant_wilting_factor.data[column][i] = (*col_wp)[i]; + props.rooting_depth_fraction.data[column][i] = (*col_rf)[i]; + props.liquid_saturation.data[column][i] = (*col_l_sat)[i]; + props.relative_permeability.data[column][i] = (*col_relative_permeability)[i]; + props.volume.data[column][i] = (*col_vol)[i]; + props.depth.data[column][i] = (*col_depth)[i]; + props.dz.data[column][i] = (*col_dz)[i]; if (has_gas) { - props.gas_saturation.data[col][i] = (*col_g_sat)[i]; - state.gas_density.data[col][i] = (*col_g_dens)[i]; + props.gas_saturation.data[column][i] = (*col_g_sat)[i]; + state.gas_density.data[column][i] = (*col_g_dens)[i]; } if (has_ice) { - state.ice_density.data[col][i] = (*col_i_dens)[i]; - props.ice_saturation.data[col][i] = (*col_i_sat)[i]; + state.ice_density.data[column][i] = (*col_i_dens)[i]; + props.ice_saturation.data[column][i] = (*col_i_sat)[i]; } if (has_energy) { - state.temperature.data[col][i] = (*col_temp)[i]; - props.thermal_conductivity.data[col][i] = (*col_cond)[i]; + state.temperature.data[column][i] = (*col_temp)[i]; + props.thermal_conductivity.data[column][i] = (*col_cond)[i]; } } //fill surface variables - props.shortwave_radiation.data[col] = shortwave_radiation[col]; - props.longwave_radiation.data[col] = longwave_radiation[col]; - props.air_temperature.data[col] = air_temperature[col]; - props.vapor_pressure_air.data[col] = vapor_pressure_air[col]; - props.wind_speed.data[col] = wind_speed[col]; - props.precipitation.data[col] = precipitation[col]; - props.elevation.data[col] = elevation[col]; - props.aspect.data[col] = aspect[col]; - props.slope.data[col] = slope[col]; + props.shortwave_radiation.data[column] = shortwave_radiation[column]; + props.longwave_radiation.data[column] = longwave_radiation[column]; + props.air_temperature.data[column] = air_temperature[column]; + props.vapor_pressure_air.data[column] = vapor_pressure_air[column]; + props.wind_speed.data[column] = wind_speed[column]; + props.precipitation.data[column] = precipitation[column]; + props.elevation.data[column] = elevation[column]; + props.aspect.data[column] = aspect[column]; + props.slope.data[column] = slope[column]; *vo_->os() << "Checking TCC variables: " << std::endl; - *vo_->os() << "size of processes: " << state.total_component_concentration.procs << " number of processes: " << ncols_local << std::endl; - *vo_->os() << "size of components: " << state.total_component_concentration.cols << " number of components: " << tcc_num << std::endl; - *vo_->os() << "size of processes: " << state.total_component_concentration.rows << " number of cells: " << ncells_per_col_ << std::endl; + *vo_->os() << "size of processes: " << state.total_component_concentration.components << " number of processes: " << num_columns_local << std::endl; + *vo_->os() << "size of components: " << state.total_component_concentration.columns << " number of components: " << tcc_num << std::endl; + *vo_->os() << "size of processes: " << state.total_component_concentration.cells << " number of cells: " << ncells_per_col_ << std::endl; - *vo_->os() << "Shape of data: " << state.total_component_concentration.rows << " x " - << state.total_component_concentration.cols << " x " - << state.total_component_concentration.procs << std::endl; + *vo_->os() << "Shape of data: " << state.total_component_concentration.cells << " x " + << state.total_component_concentration.columns << " x " + << state.total_component_concentration.components << std::endl; - for (int i = 0; i < state.total_component_concentration.rows; i++) { - for (int j = 0; j < state.total_component_concentration.cols; j++) { - for (int k = 0; k < state.total_component_concentration.procs; k++) { + for (int i = 0; i < state.total_component_concentration.cells; i++) { + for (int j = 0; j < state.total_component_concentration.columns; j++) { + for (int k = 0; k < state.total_component_concentration.components; k++) { printf("data[%d][%d][%d]: %d\n", i, j, k, state.total_component_concentration.data[i][j][k]); } } } /* *vo_->os() << "entering loop: " << std::endl; - for (int proc_col=0; proc_col < ncols_local; ++proc_col) { + for (int proc_col=0; proc_col < num_columns_local; ++proc_col) { *vo_->os() << "on column : " << proc_col << std::endl; for (int component=0; component < tcc_num; ++component) { *vo_->os() << "on component: " << component << std::endl; @@ -892,7 +888,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } -void EcoSIM::CopyFromEcoSIM_process(const int col, +void EcoSIM::CopyFromEcoSIM_process(const int column, const BGCProperties& props, const BGCState& state, const BGCAuxiliaryData& aux_data, @@ -933,33 +929,33 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); //Gather columns on this process: - ncols_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - ncols_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); + num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total columns cell_map: " << ncols_global << std::endl; - *vo_->os() << "total columns from num_entities: " << ncols_global_ptype << std::endl; + *vo_->os() << "total columns cell_map: " << num_columns_global << std::endl; + *vo_->os() << "total columns from num_entities: " << num_columns_global_ptype << std::endl; //Trying to loop over processors now: int p_rank; MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); MPI_Barrier(MPI_COMM_WORLD); std::cout << "on processor " << p_rank << std::endl; - ncols_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << ncols_local << std::endl; + num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + std::cout << num_columns_local << std::endl; //Loop over columns on this process - for (int col=0; col!=ncols_local; ++col) { + for (int col=0; col!=num_columns_local; ++col) { if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false))(0); auto& gas_density = *(*S_->GetW(gas_density_key_, Amanzi::Tags::NEXT, gas_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { - (*col_g_dens)[i] = state.gas_density.data[col][i]; - (*col_g_sat)[i] = props.gas_saturation.data[col][i]; + (*col_g_dens)[i] = state.gas_density.data[column][i]; + (*col_g_sat)[i] = props.gas_saturation.data[column][i]; } - FieldToColumn_(col,gas_saturation,col_g_sat.ptr()); - FieldToColumn_(col,gas_density,col_g_dens.ptr()); + FieldToColumn_(column,gas_saturation,col_g_sat.ptr()); + FieldToColumn_(column,gas_density,col_g_dens.ptr()); } if (has_ice) { @@ -967,12 +963,12 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, auto& ice_density = *(*S_->GetW(ice_density_key_, Amanzi::Tags::NEXT, ice_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { - (*col_i_dens)[i] = state.ice_density.data[col][i]; - (*col_i_sat)[i] = props.ice_saturation.data[col][i]; + (*col_i_dens)[i] = state.ice_density.data[column][i]; + (*col_i_sat)[i] = props.ice_saturation.data[column][i]; } - ColumnToField_(col,ice_saturation,col_i_sat.ptr()); - ColumnToField_(col,ice_density,col_i_dens.ptr()); + ColumnToField_(column,ice_saturation,col_i_sat.ptr()); + ColumnToField_(column,ice_density,col_i_dens.ptr()); } if (has_energy) { @@ -980,59 +976,59 @@ void EcoSIM::CopyFromEcoSIM_process(const int col, auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Amanzi::Tags::NEXT, thermal_conductivity_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { - (*col_temp)[i] = state.temperature.data[col][i]; - (*col_cond)[i] = props.thermal_conductivity.data[col][i]; + (*col_temp)[i] = state.temperature.data[column][i]; + (*col_cond)[i] = props.thermal_conductivity.data[column][i]; } - ColumnToField_(col,temp, col_temp.ptr()); - ColumnToField_(col,thermal_conductivity,col_cond.ptr()); + ColumnToField_(column,temp, col_temp.ptr()); + ColumnToField_(column,thermal_conductivity,col_cond.ptr()); } for (int i=0; i < ncells_per_col_; ++i) { - (*col_l_dens)[i] = state.liquid_density.data[col][i]; - (*col_porosity)[i] = state.porosity.data[col][i]; - (*col_wc)[i] = state.water_content.data[col][i]; - (*col_h_cond)[i] = state.hydraulic_conductivity.data[col][i]; - (*col_b_dens)[i] = state.bulk_density.data[col][i]; + (*col_l_dens)[i] = state.liquid_density.data[column][i]; + (*col_porosity)[i] = state.porosity.data[column][i]; + (*col_wc)[i] = state.water_content.data[column][i]; + (*col_h_cond)[i] = state.hydraulic_conductivity.data[column][i]; + (*col_b_dens)[i] = state.bulk_density.data[column][i]; if (has_gas) { - (*col_g_dens)[i] = state.gas_density.data[col][i]; + (*col_g_dens)[i] = state.gas_density.data[column][i]; } if (has_ice) { - (*col_i_dens)[i] = state.ice_density.data[col][i]; + (*col_i_dens)[i] = state.ice_density.data[column][i]; } if (has_energy) { - (*col_temp)[i] = state.temperature.data[col][i]; + (*col_temp)[i] = state.temperature.data[column][i]; } } - ColumnToField_(col,porosity,col_porosity.ptr()); - ColumnToField_(col,liquid_saturation,col_l_sat.ptr()); - ColumnToField_(col,water_content,col_wc.ptr()); - ColumnToField_(col,relative_permeability,col_relative_permeability.ptr()); - ColumnToField_(col,liquid_density,col_l_dens.ptr()); - ColumnToField_(col,rock_density,col_r_dens.ptr()); - ColumnToField_(col,cell_volume,col_vol.ptr()); - ColumnToField_(col,hydraulic_conductivity,col_h_cond.ptr()); - ColumnToField_(col,bulk_density,col_b_dens.ptr()); - //ColumnToField_(col,plant_wilting_factor,col_wp.ptr()); - //ColumnToField_(col,rooting_depth_fraction,col_rf.ptr()); + ColumnToField_(column,porosity,col_porosity.ptr()); + ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); + ColumnToField_(column,water_content,col_wc.ptr()); + ColumnToField_(column,relative_permeability,col_relative_permeability.ptr()); + ColumnToField_(column,liquid_density,col_l_dens.ptr()); + ColumnToField_(column,rock_density,col_r_dens.ptr()); + ColumnToField_(column,cell_volume,col_vol.ptr()); + ColumnToField_(column,hydraulic_conductivity,col_h_cond.ptr()); + ColumnToField_(column,bulk_density,col_b_dens.ptr()); + //ColumnToField_(column,plant_wilting_factor,col_wp.ptr()); + //ColumnToField_(column,rooting_depth_fraction,col_rf.ptr()); } } /* int EcoSIM::InitializeSingleColumn(int col) { - CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + CopyToEcoSIM(column, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - //ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); + //ecosim_datatest_wrapper(column, &bgc_props_, &bgc_sizes_); bgc_engine_->DataTest(); int num_iterations = 1; bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); - CopyEcoSIMStateToAmanzi(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + CopyEcoSIMStateToAmanzi(column, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); } @@ -1040,7 +1036,7 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) { // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but // should use the same tag as transport. See #673 - CopyToEcoSIM(col, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + CopyToEcoSIM(column, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 1; @@ -1048,7 +1044,7 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) bgc_sizes_, num_iterations, col); // Move the information back into Amanzi's state, updating the given total concentration vector. - CopyEcoSIMStateToAmanzi(col, + CopyEcoSIMStateToAmanzi(column, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); return num_iterations; @@ -1058,16 +1054,16 @@ int EcoSIM::InitializeSingleProcess(int proc) { CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - //ecosim_datatest_wrapper(col, &bgc_props_, &bgc_sizes_); + //ecosim_datatest_wrapper(column, &bgc_props_, &bgc_sizes_); //bgc_engine_->DataTest(); /*need some sort of assertions here to double check that the data is actually What I want it to be*/ int num_iterations = 1; - int ncols = 1; + int num_columns = 1; - bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, ncols); + bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); } @@ -1079,10 +1075,10 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 1; - int ncols = 1; + int num_columns = 1; bgc_engine_->Advance(dt, bgc_props_, bgc_state_, - bgc_sizes_, num_iterations, ncols); + bgc_sizes_, num_iterations, num_columns); // Move the information back into Amanzi's state, updating the given total concentration vector. CopyFromEcoSIM_process(proc, diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh index 831c7dd25..e9dfc238c 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh @@ -95,7 +95,7 @@ class EcoSIM : public PK_Physical { //The Chemistry_PK even though it isn't used there, and then included Teuchos::RCP bgc_engine() { return bgc_engine_; } - /*void CopyToEcoSIM(int col, + /*void CopyToEcoSIM(int column, BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data);*/ @@ -103,7 +103,7 @@ class EcoSIM : public PK_Physical { private: //Helper functions from Alquimia - void CopyToEcoSIM(int col, + void CopyToEcoSIM(int column, BGCProperties& props, BGCState& state, BGCAuxiliaryData& aux_data, @@ -143,28 +143,28 @@ class EcoSIM : public PK_Physical { //The helper functions from BGC are protected not private (unclear why) //I don't think I need this here, probably in the engine - void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + void FieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_Vector& vec, Teuchos::Ptr col_vec); - void FieldToColumn_(AmanziMesh::Entity_ID col, Teuchos::Ptr vec, + void FieldToColumn_(AmanziMesh::Entity_ID column, Teuchos::Ptr vec, Teuchos::Ptr col_vec); - void MatrixFieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_MultiVector& m_arr, + void MatrixFieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_MultiVector& m_arr, Teuchos::Ptr col_arr); - //void FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, + //void FieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_Vector& vec, // double* col_vec); - void ColDepthDz_(AmanziMesh::Entity_ID col, + void ColDepthDz_(AmanziMesh::Entity_ID column, Teuchos::Ptr depth, Teuchos::Ptr dz); - void ColumnToField_(AmanziMesh::Entity_ID col, Epetra_Vector& vec, + void ColumnToField_(AmanziMesh::Entity_ID column, Epetra_Vector& vec, Teuchos::Ptr col_vec); - void ColumnToField_(AmanziMesh::Entity_ID col, Teuchos::Ptr vec, + void ColumnToField_(AmanziMesh::Entity_ID column, Teuchos::Ptr vec, Teuchos::Ptr col_vec); - void MatrixColumnToField_(AmanziMesh::Entity_ID col, Epetra_MultiVector& m_arr, + void MatrixColumnToField_(AmanziMesh::Entity_ID column, Epetra_MultiVector& m_arr, Teuchos::Ptr col_arr); //evaluator for transpiration; //I don't think I need this anymore @@ -172,10 +172,10 @@ class EcoSIM : public PK_Physical { int number_aqueous_components_; int ncells_per_col_; - int num_cols_; - int ncols_local; - int ncols_global; - int ncols_global_ptype; + int num_columns_; + int num_columns_local; + int num_columns_global; + int num_columns_global_ptype; double saved_time_; double current_time_; @@ -221,8 +221,8 @@ class EcoSIM : public PK_Physical { BGCAuxiliaryData bgc_aux_data_; BGCSizes bgc_sizes_; - Teuchos::RCP col_vol_save; - Teuchos::RCP col_wc_save; + Teuchos::RCP column_vol_save; + Teuchos::RCP column_wc_save; bool bgc_initialized_; bool has_energy, has_gas, has_ice; diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim_pk/data/BGC_containers.hh index 8bc941c21..278f26fbd 100644 --- a/src/pks/ecosim_pk/data/BGC_containers.hh +++ b/src/pks/ecosim_pk/data/BGC_containers.hh @@ -80,12 +80,12 @@ extern "C" { } BGCMatrixString; typedef struct { - int cells, columns, components, capacity_cells, capacity_columns, cap_components; + int cells, columns, components, capacity_cells, capacity_columns, capacity_components; double*** data; } BGCTensorDouble; typedef struct { - int cells, columns, components, capacity_cells, capacity_columns, cap_components; + int cells, columns, components, capacity_cells, capacity_columns, capacity_components; int*** data; } BGCTensorInt; From 35204be2e08c41cdc7ffa2669f274dd6d90a9459 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 23 Aug 2023 10:29:22 -0700 Subject: [PATCH 459/582] rewrittting loops --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index d5f1e0ff5..dc95af941 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -851,8 +851,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, << state.total_component_concentration.columns << " x " << state.total_component_concentration.components << std::endl; - for (int i = 0; i < state.total_component_concentration.cells; i++) { - for (int j = 0; j < state.total_component_concentration.columns; j++) { + // data[columns][cells][components] + for (int i = 0; i < state.total_component_concentration.columns; i++) { + for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { printf("data[%d][%d][%d]: %d\n", i, j, k, state.total_component_concentration.data[i][j][k]); } @@ -860,17 +861,17 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } /* *vo_->os() << "entering loop: " << std::endl; - for (int proc_col=0; proc_col < num_columns_local; ++proc_col) { - *vo_->os() << "on column : " << proc_col << std::endl; - for (int component=0; component < tcc_num; ++component) { - *vo_->os() << "on component: " << component << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "on cell: " << i << std::endl; + for (int i=0; i < num_columns_local; ++i) { + *vo_->os() << "on column : " << i << std::endl; + for (int j=0; j < ncells_per_col_; ++j) { + *vo_->os() << "on cell: " << j << std::endl; + for (int k=0; k < tcc_num; ++k) { + *vo_->os() << "on component: " << k << std::endl; //original config (doesn't work) *vo_->os() << "Printing state element: " //<< state.total_component_concentration.data[proc_col][component][i] << std::endl; - *vo_->os() << "Printing state element: " << state.total_component_concentration.data[i][component][proc_col] << std::endl; - *vo_->os() << "Printing internal element: " << (*col_tcc)(component,i) << std::endl; - state.total_component_concentration.data[proc_col][component][i] = (*col_tcc)(component,i); + *vo_->os() << "Printing state element: " << state.total_component_concentration.data[i][j][k] << std::endl; + *vo_->os() << "Printing internal element: " << (*col_tcc)(j,k) << std::endl; + state.total_component_concentration.data[i][j][k] = (*col_tcc)(j,k); } } }*/ From 7c39f5710430a2e943d320e87917310e6623fec4 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 23 Aug 2023 10:36:02 -0700 Subject: [PATCH 460/582] minor typo --- src/pks/ecosim_pk/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc index dc95af941..21a17d2d5 100644 --- a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc @@ -572,7 +572,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_Vector& vec, Teuchos::Ptr col_vec) { - auto& col_iter = mesh_->cells_of_column(col); + auto& col_iter = mesh_->cells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { std::size_t vec_index = col_iter[i]; From 5be5b3c1b4b6a27f15ce642abf9ab98d3cd977d2 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 23 Aug 2023 15:01:17 -0700 Subject: [PATCH 461/582] changes to loops --- src/pks/ecosim_pk/data/BGC_memory.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 2fa631259..516704a6a 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -233,11 +233,11 @@ void AllocateBGCTensorDouble(const int cells, const int columns, const int compo std::cout << "components: " << components << std::endl; std::cout << "size components: " << tensor->capacity_components << std::endl; - tensor->data = (double***) calloc((size_t)tensor->capacity_columns, sizeof(double**)); - for (int i = 0; i < tensor->columns; ++i) { + tensor->data = (double***) calloc((size_t)tensor->capacity_components, sizeof(double**)); + for (int i = 0; i < tensor->components; ++i) { tensor->data[i] = (double**) calloc((size_t)tensor->capacity_cells, sizeof(double*)); for (int j = 0; j < tensor->cells; ++j) { - tensor->data[i][j] = (double*) calloc((size_t)tensor->capacity_components, sizeof(double)); + tensor->data[i][j] = (double*) calloc((size_t)tensor->capacity_columns, sizeof(double)); } } //ALQUIMIA_ASSERT(NULL != matrix->data); @@ -274,11 +274,11 @@ void AllocateBGCTensorInt(const int cells, const int columns, const int componen tensor->capacity_columns= nearest_power_of_2(columns); tensor->capacity_components = nearest_power_of_2(components); - tensor->data = (int***) calloc((size_t)tensor->capacity_columns, sizeof(int**)); - for (int i = 0; i < tensor->columns; ++i) { + tensor->data = (int***) calloc((size_t)tensor->capacity_components, sizeof(int**)); + for (int i = 0; i < tensor->components; ++i) { tensor->data[i] = (int**) calloc((size_t)tensor->capacity_cells, sizeof(int*)); for (int j = 0; j < tensor->cells; ++j) { - tensor->data[i][j] = (int*) calloc((size_t)tensor->capacity_components, sizeof(int)); + tensor->data[i][j] = (int*) calloc((size_t)tensor->capacity_columns, sizeof(int)); } } //ALQUIMIA_ASSERT(NULL != matrix->data); From 3c9169116b4996f9559967661168327af9887210 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 23 Aug 2023 20:13:52 -0700 Subject: [PATCH 462/582] working version of the processor refactoring --- src/pks/ecosim_pk/data/BGC_memory.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim_pk/data/BGC_memory.cc index 516704a6a..42d4dc288 100644 --- a/src/pks/ecosim_pk/data/BGC_memory.cc +++ b/src/pks/ecosim_pk/data/BGC_memory.cc @@ -233,11 +233,11 @@ void AllocateBGCTensorDouble(const int cells, const int columns, const int compo std::cout << "components: " << components << std::endl; std::cout << "size components: " << tensor->capacity_components << std::endl; - tensor->data = (double***) calloc((size_t)tensor->capacity_components, sizeof(double**)); - for (int i = 0; i < tensor->components; ++i) { + tensor->data = (double***) calloc((size_t)tensor->capacity_columns, sizeof(double**)); + for (int i = 0; i < tensor->columns; ++i) { tensor->data[i] = (double**) calloc((size_t)tensor->capacity_cells, sizeof(double*)); for (int j = 0; j < tensor->cells; ++j) { - tensor->data[i][j] = (double*) calloc((size_t)tensor->capacity_columns, sizeof(double)); + tensor->data[i][j] = (double*) calloc((size_t)tensor->capacity_components, sizeof(double)); } } //ALQUIMIA_ASSERT(NULL != matrix->data); @@ -274,11 +274,11 @@ void AllocateBGCTensorInt(const int cells, const int columns, const int componen tensor->capacity_columns= nearest_power_of_2(columns); tensor->capacity_components = nearest_power_of_2(components); - tensor->data = (int***) calloc((size_t)tensor->capacity_components, sizeof(int**)); - for (int i = 0; i < tensor->components; ++i) { + tensor->data = (int***) calloc((size_t)tensor->capacity_columns, sizeof(int**)); + for (int i = 0; i < tensor->columns; ++i) { tensor->data[i] = (int**) calloc((size_t)tensor->capacity_cells, sizeof(int*)); for (int j = 0; j < tensor->cells; ++j) { - tensor->data[i][j] = (int*) calloc((size_t)tensor->capacity_columns, sizeof(int)); + tensor->data[i][j] = (int*) calloc((size_t)tensor->capacity_components, sizeof(int)); } } //ALQUIMIA_ASSERT(NULL != matrix->data); @@ -335,7 +335,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->temperature)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->hydraulic_conductivity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->bulk_density)); - AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_components, sizes->num_columns, &(state->total_component_concentration)); + AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateBGCState() */ From 38feaf324746b5b8cc8e4473cc44f04166cfd572 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 24 Aug 2023 12:52:09 -0700 Subject: [PATCH 463/582] modifying cmake files --- src/pks/ecosim_pk/CMakeLists.txt | 7 ++----- src/pks/ecosim_pk/data/CMakeLists.txt | 9 +++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 68fea9830..9dc7e8f79 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -18,15 +18,12 @@ message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") # For adding F90 files add the F90 file to the ecosim source files and # inc files. The inc file also needs a header -set(ats_ecosim_src_files +file(GLOB_RECURSE ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/*.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index c3d88afdf..1ff651723 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -5,16 +5,13 @@ # # collect all sources -set(ats_ecosim_data_src_files +file(Glob_RECURSE ats_ecosim_data_src_files BGC_constants.cc BGC_memory.cc BGC_containers.cc bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/c_f_interface_module.F90 - ) + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/*.F90 +) set(ats_ecosim_data_inc_files BGC_constants.hh From 1454af177565378161027ca8e99fbfa37f8c03f1 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 24 Aug 2023 13:32:10 -0700 Subject: [PATCH 464/582] more variable name changes for consistency and changing directory name --- src/executables/CMakeLists.txt | 2 +- src/pks/CMakeLists.txt | 2 +- src/pks/{ecosim_pk => ecosim}/BGCEngine.cc | 28 ++++++++--------- src/pks/{ecosim_pk => ecosim}/BGCEngine.hh | 16 +++++----- src/pks/{ecosim_pk => ecosim}/CMakeLists.txt | 8 ++--- .../EcoSIM_ATS_interface.cc | 0 .../EcoSIM_ATS_interface.hh | 0 .../EcoSIM_ATS_interface_reg.hh | 0 .../constitutive_relations/CMakeLists.txt | 0 .../bulk_density/bulk_density.py | 2 +- .../bulk_density/bulk_density_evaluator.cc | 0 .../bulk_density/bulk_density_evaluator.hh | 0 .../bulk_density_evaluator_reg.hh | 0 .../bulk_density/bulk_density_model.cc | 0 .../bulk_density/bulk_density_model.hh | 0 .../hydraulic_conductivity.py | 2 +- .../hydraulic_conductivity_evaluator.cc | 0 .../hydraulic_conductivity_evaluator.hh | 0 .../hydraulic_conductivity_evaluator_reg.hh | 0 .../hydraulic_conductivity_model.cc | 0 .../hydraulic_conductivity_model.hh | 0 .../data/BGC_constants.cc | 0 .../data/BGC_constants.hh | 0 .../data/BGC_containers.cc | 0 .../data/BGC_containers.hh | 0 .../{ecosim_pk => ecosim}/data/BGC_memory.cc | 0 .../{ecosim_pk => ecosim}/data/BGC_memory.hh | 0 .../{ecosim_pk => ecosim}/data/CMakeLists.txt | 0 .../data/bgc_fortran_memory_mod.F90 | 0 .../{ecosim_pk => ecosim}/ecosim_interface.h | 4 +-- .../{ecosim_pk => ecosim}/ecosim_mod_test.F90 | 0 .../ecosim_mod_test_wrapper.c | 0 .../ecosim_mod_test_wrapper.h | 0 .../{ecosim_pk => ecosim}/ecosim_wrappers.F90 | 30 +++++++++---------- 34 files changed, 47 insertions(+), 47 deletions(-) rename src/pks/{ecosim_pk => ecosim}/BGCEngine.cc (97%) rename src/pks/{ecosim_pk => ecosim}/BGCEngine.hh (92%) rename src/pks/{ecosim_pk => ecosim}/CMakeLists.txt (83%) rename src/pks/{ecosim_pk => ecosim}/EcoSIM_ATS_interface.cc (100%) rename src/pks/{ecosim_pk => ecosim}/EcoSIM_ATS_interface.hh (100%) rename src/pks/{ecosim_pk => ecosim}/EcoSIM_ATS_interface_reg.hh (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/CMakeLists.txt (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/bulk_density/bulk_density.py (95%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/bulk_density/bulk_density_evaluator.cc (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/bulk_density/bulk_density_evaluator.hh (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/bulk_density/bulk_density_model.cc (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/bulk_density/bulk_density_model.hh (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py (91%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc (100%) rename src/pks/{ecosim_pk => ecosim}/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh (100%) rename src/pks/{ecosim_pk => ecosim}/data/BGC_constants.cc (100%) rename src/pks/{ecosim_pk => ecosim}/data/BGC_constants.hh (100%) rename src/pks/{ecosim_pk => ecosim}/data/BGC_containers.cc (100%) rename src/pks/{ecosim_pk => ecosim}/data/BGC_containers.hh (100%) rename src/pks/{ecosim_pk => ecosim}/data/BGC_memory.cc (100%) rename src/pks/{ecosim_pk => ecosim}/data/BGC_memory.hh (100%) rename src/pks/{ecosim_pk => ecosim}/data/CMakeLists.txt (100%) rename src/pks/{ecosim_pk => ecosim}/data/bgc_fortran_memory_mod.F90 (100%) rename src/pks/{ecosim_pk => ecosim}/ecosim_interface.h (98%) rename src/pks/{ecosim_pk => ecosim}/ecosim_mod_test.F90 (100%) rename src/pks/{ecosim_pk => ecosim}/ecosim_mod_test_wrapper.c (100%) rename src/pks/{ecosim_pk => ecosim}/ecosim_mod_test_wrapper.h (100%) rename src/pks/{ecosim_pk => ecosim}/ecosim_wrappers.F90 (82%) diff --git a/src/executables/CMakeLists.txt b/src/executables/CMakeLists.txt index 2b6073454..e4b8a3463 100644 --- a/src/executables/CMakeLists.txt +++ b/src/executables/CMakeLists.txt @@ -42,7 +42,7 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/energy) include_directories(${ATS_SOURCE_DIR}/src/pks/flow) include_directories(${ATS_SOURCE_DIR}/src/pks/deformation) include_directories(${ATS_SOURCE_DIR}/src/pks/transport) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) include_directories(${ATS_SOURCE_DIR}/src/operators/upwinding) include_directories(${ATS_SOURCE_DIR}/src/operators/advection) include_directories(${ATS_SOURCE_DIR}/src/operators/deformation) diff --git a/src/pks/CMakeLists.txt b/src/pks/CMakeLists.txt index c8963f40c..b6c78b6fa 100644 --- a/src/pks/CMakeLists.txt +++ b/src/pks/CMakeLists.txt @@ -57,4 +57,4 @@ add_subdirectory(deform) add_subdirectory(surface_balance) add_subdirectory(biogeochemistry) add_subdirectory(mpc) -add_subdirectory(ecosim_pk) +add_subdirectory(ecosim) diff --git a/src/pks/ecosim_pk/BGCEngine.cc b/src/pks/ecosim/BGCEngine.cc similarity index 97% rename from src/pks/ecosim_pk/BGCEngine.cc rename to src/pks/ecosim/BGCEngine.cc index 63aab3cce..5f5d1e159 100644 --- a/src/pks/ecosim_pk/BGCEngine.cc +++ b/src/pks/ecosim/BGCEngine.cc @@ -171,15 +171,15 @@ BGCEngine::Sizes() const return sizes_; } -void BGCEngine::InitState(BGCProperties& props, +void BGCEngine::InitState(BGCProperties& properties, BGCState& state, BGCAuxiliaryData& aux_data, int ncells_per_col_, int num_components, - int cols_on_proc) + int num_columns) { - AllocateBGCProperties(&sizes_, &props, ncells_per_col_, cols_on_proc); - AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components, cols_on_proc); + AllocateBGCProperties(&sizes_, &properties, ncells_per_col_, num_columns); + AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components, num_columns); //AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); @@ -188,11 +188,11 @@ void BGCEngine::InitState(BGCProperties& props, //std::fill(aux_data.aux_doubles.data, aux_data.aux_doubles.data + aux_data.aux_doubles.size, 0.0); } -void BGCEngine::FreeState(BGCProperties& props, +void BGCEngine::FreeState(BGCProperties& properties, BGCState& state, BGCAuxiliaryData& aux_data) { - FreeBGCProperties(&props); + FreeBGCProperties(&properties); FreeBGCState(&state); //FreeBGCAuxiliaryData(&aux_data); //FreeAlquimiaAuxiliaryOutputData(&aux_output); @@ -203,18 +203,18 @@ void BGCEngine::DataTest() { bgc_.DataTest(); } -bool BGCEngine::Setup(BGCProperties& props, +bool BGCEngine::Setup(BGCProperties& properties, BGCState& state, BGCSizes& sizes_, int num_iterations, - int ncol) + int num_columns) { // Advance the chemical reaction all operator-split-like. - bgc_.Setup(&props, + bgc_.Setup(&properties, &state, &sizes_, num_iterations, - ncol); + num_columns); //This is alquimia's advance function which we won't need //calling EcoSIM advance driver @@ -225,19 +225,19 @@ bool BGCEngine::Setup(BGCProperties& props, } bool BGCEngine::Advance(const double delta_time, - BGCProperties& props, + BGCProperties& properties, BGCState& state, BGCSizes& sizes_, int num_iterations, - int ncol) + int num_columns) { // Advance the chemical reaction all operator-split-like. bgc_.Advance(delta_time, - &props, + &properties, &state, &sizes_, num_iterations, - ncol); + num_columns); //This is alquimia's advance function which we won't need //calling EcoSIM advance driver diff --git a/src/pks/ecosim_pk/BGCEngine.hh b/src/pks/ecosim/BGCEngine.hh similarity index 92% rename from src/pks/ecosim_pk/BGCEngine.hh rename to src/pks/ecosim/BGCEngine.hh index f3e4a71d1..afc29e663 100644 --- a/src/pks/ecosim_pk/BGCEngine.hh +++ b/src/pks/ecosim/BGCEngine.hh @@ -53,42 +53,42 @@ class BGCEngine { const BGCSizes& Sizes() const; // Initializes the data structures that hold the chemical state information. - void InitState(BGCProperties& props, + void InitState(BGCProperties& properties, BGCState& state, BGCAuxiliaryData& aux_data, int ncells_per_col_, int num_components, - int cols_on_proc); + int num_columns); // Frees the data structures that hold the chemical state information. - void FreeState(BGCProperties& props, + void FreeState(BGCProperties& properties, BGCState& state, BGCAuxiliaryData& aux_data); /* Don't need for now void EnforceCondition(const std::string& condition_name, const double time, - const AlquimiaProperties& props, + const AlquimiaProperties& properties, AlquimiaState& state, AlquimiaAuxiliaryData& aux_data);*/ void DataTest(); - bool Setup(BGCProperties& props, + bool Setup(BGCProperties& properties, BGCState& state, BGCSizes& sizes, int num_iterations, - int ncol); + int num_columns); // Advances the species represented by the given array of concentrations, replacing old values // with new values. The order of the concentrations in the array matches that of the species names // returned by GetSpeciesNames. Returns true if the advance is successful, // false if it fails. bool Advance(const double delta_time, - BGCProperties& props, + BGCProperties& properties, BGCState& state, BGCSizes& sizes, int num_iterations, - int ncol); + int num_columns); //Functions from the alquimia util section, I don't think I need the full code so I think //I can just copy these functions over diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt similarity index 83% rename from src/pks/ecosim_pk/CMakeLists.txt rename to src/pks/ecosim/CMakeLists.txt index 9dc7e8f79..04145719c 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -4,10 +4,10 @@ add_subdirectory(constitutive_relations) add_subdirectory(data) include_directories(${ATS_SOURCE_DIR}/src/pks) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/data) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/bulk_density) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/data) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) #include_directories(${TPL_INSTALL_PREFIX}/ecosim/f90src/ATSUtils/) include_directories(${ECOSIM_INCLUDE_DIRS}) diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc similarity index 100% rename from src/pks/ecosim_pk/EcoSIM_ATS_interface.cc rename to src/pks/ecosim/EcoSIM_ATS_interface.cc diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh similarity index 100% rename from src/pks/ecosim_pk/EcoSIM_ATS_interface.hh rename to src/pks/ecosim/EcoSIM_ATS_interface.hh diff --git a/src/pks/ecosim_pk/EcoSIM_ATS_interface_reg.hh b/src/pks/ecosim/EcoSIM_ATS_interface_reg.hh similarity index 100% rename from src/pks/ecosim_pk/EcoSIM_ATS_interface_reg.hh rename to src/pks/ecosim/EcoSIM_ATS_interface_reg.hh diff --git a/src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt b/src/pks/ecosim/constitutive_relations/CMakeLists.txt similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/CMakeLists.txt rename to src/pks/ecosim/constitutive_relations/CMakeLists.txt diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density.py b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density.py similarity index 95% rename from src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density.py rename to src/pks/ecosim/constitutive_relations/bulk_density/bulk_density.py index 72d42d87d..6a57923c7 100644 --- a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density.py +++ b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density.py @@ -22,6 +22,6 @@ phi, nr, sl, nl, si, ni, sg, ng = sympy.var("phi,nr,sl,nl,si,ni,sg,ng") expression = nr*(1 - phi) + phi*(sl*nl + si*ni + sg*ng); -generate_evaluator("bulk_density", "ecosim_pk", +generate_evaluator("bulk_density", "ecosim", "bulk density", "bulk_density", deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.cc rename to src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator.hh rename to src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh rename to src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.cc rename to src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc diff --git a/src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/bulk_density/bulk_density_model.hh rename to src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py similarity index 91% rename from src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py rename to src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py index 4c053ef29..64a913725 100644 --- a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py +++ b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity.py @@ -15,6 +15,6 @@ g_ = sympy.var("g_") expression = (k * rho * mu) / mu; -generate_evaluator("hydraulic_conductivity", "ecosim_pk", +generate_evaluator("hydraulic_conductivity", "ecosim", "hydraulic conductivity", "hydraulic_conductivity", deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc rename to src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh rename to src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.hh diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh rename to src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc rename to src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc diff --git a/src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh similarity index 100% rename from src/pks/ecosim_pk/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh rename to src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh diff --git a/src/pks/ecosim_pk/data/BGC_constants.cc b/src/pks/ecosim/data/BGC_constants.cc similarity index 100% rename from src/pks/ecosim_pk/data/BGC_constants.cc rename to src/pks/ecosim/data/BGC_constants.cc diff --git a/src/pks/ecosim_pk/data/BGC_constants.hh b/src/pks/ecosim/data/BGC_constants.hh similarity index 100% rename from src/pks/ecosim_pk/data/BGC_constants.hh rename to src/pks/ecosim/data/BGC_constants.hh diff --git a/src/pks/ecosim_pk/data/BGC_containers.cc b/src/pks/ecosim/data/BGC_containers.cc similarity index 100% rename from src/pks/ecosim_pk/data/BGC_containers.cc rename to src/pks/ecosim/data/BGC_containers.cc diff --git a/src/pks/ecosim_pk/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh similarity index 100% rename from src/pks/ecosim_pk/data/BGC_containers.hh rename to src/pks/ecosim/data/BGC_containers.hh diff --git a/src/pks/ecosim_pk/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc similarity index 100% rename from src/pks/ecosim_pk/data/BGC_memory.cc rename to src/pks/ecosim/data/BGC_memory.cc diff --git a/src/pks/ecosim_pk/data/BGC_memory.hh b/src/pks/ecosim/data/BGC_memory.hh similarity index 100% rename from src/pks/ecosim_pk/data/BGC_memory.hh rename to src/pks/ecosim/data/BGC_memory.hh diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt similarity index 100% rename from src/pks/ecosim_pk/data/CMakeLists.txt rename to src/pks/ecosim/data/CMakeLists.txt diff --git a/src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 similarity index 100% rename from src/pks/ecosim_pk/data/bgc_fortran_memory_mod.F90 rename to src/pks/ecosim/data/bgc_fortran_memory_mod.F90 diff --git a/src/pks/ecosim_pk/ecosim_interface.h b/src/pks/ecosim/ecosim_interface.h similarity index 98% rename from src/pks/ecosim_pk/ecosim_interface.h rename to src/pks/ecosim/ecosim_interface.h index 823e12acf..5f1e4a5c0 100644 --- a/src/pks/ecosim_pk/ecosim_interface.h +++ b/src/pks/ecosim/ecosim_interface.h @@ -46,7 +46,7 @@ void ecosim_setup( BGCState* state, BGCSizes* sizes, int num_iterations, - int ncol + int num_columns ); void ecosim_shutdown(); @@ -57,7 +57,7 @@ void ecosim_advance( BGCState* state, BGCSizes* sizes, int num_iterations, - int ncol + int num_columns ); #ifdef __cplusplus diff --git a/src/pks/ecosim_pk/ecosim_mod_test.F90 b/src/pks/ecosim/ecosim_mod_test.F90 similarity index 100% rename from src/pks/ecosim_pk/ecosim_mod_test.F90 rename to src/pks/ecosim/ecosim_mod_test.F90 diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.c b/src/pks/ecosim/ecosim_mod_test_wrapper.c similarity index 100% rename from src/pks/ecosim_pk/ecosim_mod_test_wrapper.c rename to src/pks/ecosim/ecosim_mod_test_wrapper.c diff --git a/src/pks/ecosim_pk/ecosim_mod_test_wrapper.h b/src/pks/ecosim/ecosim_mod_test_wrapper.h similarity index 100% rename from src/pks/ecosim_pk/ecosim_mod_test_wrapper.h rename to src/pks/ecosim/ecosim_mod_test_wrapper.h diff --git a/src/pks/ecosim_pk/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 similarity index 82% rename from src/pks/ecosim_pk/ecosim_wrappers.F90 rename to src/pks/ecosim/ecosim_wrappers.F90 index 9c838ba11..640daa4ee 100644 --- a/src/pks/ecosim_pk/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -41,8 +41,8 @@ end subroutine EcoSIM_DataTest ! **************************************************************************** ! -subroutine EcoSIM_Setup(props, state, sizes, & - num_iterations, ncol) bind(C) +subroutine EcoSIM_Setup(properties, state, sizes, & + num_iterations, num_columns) bind(C) use, intrinsic :: iso_c_binding @@ -56,23 +56,23 @@ subroutine EcoSIM_Setup(props, state, sizes, & type (BGCSizes), intent(out) :: sizes type (BGCState), intent(inout) :: state !type (BGCAuxiliaryData), intent(inout) :: aux_data - type (BGCProperties), intent(in) :: props - integer, intent(in) :: ncol + type (BGCProperties), intent(in) :: properties + integer, intent(in) :: num_columns integer, intent(in) :: num_iterations integer :: jz integer :: js write(*,*) "starting driver transfer ATS2EcoSIMData" - call ATS2EcoSIMData(ncol, state, props, sizes) + call ATS2EcoSIMData(num_columns, state, properties, sizes) write(*,*) "starting driver Init_EcoSIM" - !call Init_EcoSIM(jz,js,ncol) + !call Init_EcoSIM(jz,js,num_columns) write(*,*) "starting driver transfer EcoSIM2ATSData" - call EcoSIM2ATSData(ncol, state, sizes) + call EcoSIM2ATSData(num_columns, state, sizes) end subroutine EcoSIM_Setup @@ -93,8 +93,8 @@ subroutine EcoSIM_Shutdown() bind(C) !type (BGCSizes), intent(out) :: sizes !type (BGCState), intent(in) :: state !type (BGCAuxiliaryData), intent(in) :: aux_data - !type (BGCProperties), intent(in) :: props - !integer :: ncol, jz, js + !type (BGCProperties), intent(in) :: properties + !integer :: num_columns, jz, js !integer, intent(in) :: num_iterations end subroutine EcoSIM_Shutdown @@ -103,11 +103,11 @@ end subroutine EcoSIM_Shutdown subroutine EcoSIM_Advance( & delta_t, & - props, & + properties, & state, & sizes, & num_iterations, & - ncol) bind(C) + num_columns) bind(C) use, intrinsic :: iso_c_binding use BGCContainers_module @@ -117,17 +117,17 @@ subroutine EcoSIM_Advance( & ! function parameters real (c_double), value, intent(in) :: delta_t - type (BGCProperties), intent(in) :: props + type (BGCProperties), intent(in) :: properties type (BGCState), intent(inout) :: state type (BGCSizes), intent(out) :: sizes !type (BGCEngineStatus), intent(out) :: status - integer, intent(in) :: ncol + integer, intent(in) :: num_columns integer, intent(in) :: num_iterations - call ATS2EcoSIMData(ncol, state, props, sizes) + call ATS2EcoSIMData(num_columns, state, properties, sizes) !call Run_EcoSIM_one_step() - call EcoSIM2ATSData(ncol, state, sizes) + call EcoSIM2ATSData(num_columns, state, sizes) end subroutine EcoSIM_Advance From 1060278c4d85a2a9e8be9971e1f960c3e0c08840 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 24 Aug 2023 14:53:53 -0700 Subject: [PATCH 465/582] changing cmake --- src/pks/ecosim_pk/CMakeLists.txt | 3 +-- src/pks/ecosim_pk/data/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim_pk/CMakeLists.txt b/src/pks/ecosim_pk/CMakeLists.txt index 9dc7e8f79..8d207708b 100644 --- a/src/pks/ecosim_pk/CMakeLists.txt +++ b/src/pks/ecosim_pk/CMakeLists.txt @@ -18,12 +18,11 @@ message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") # For adding F90 files add the F90 file to the ecosim source files and # inc files. The inc file also needs a header -file(GLOB_RECURSE ats_ecosim_src_files +set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/*.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim_pk/data/CMakeLists.txt b/src/pks/ecosim_pk/data/CMakeLists.txt index 1ff651723..3ebf1fad4 100644 --- a/src/pks/ecosim_pk/data/CMakeLists.txt +++ b/src/pks/ecosim_pk/data/CMakeLists.txt @@ -5,12 +5,11 @@ # # collect all sources -file(Glob_RECURSE ats_ecosim_data_src_files +set(ats_ecosim_data_src_files BGC_constants.cc BGC_memory.cc BGC_containers.cc bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/*.F90 ) set(ats_ecosim_data_inc_files From 75bdf6801fdd5b5208cf53018e88f98775a3b86b Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 24 Aug 2023 16:30:47 -0700 Subject: [PATCH 466/582] adding CMake --- src/pks/ecosim/CMakeLists.txt | 10 +++++++++- src/pks/ecosim/data/CMakeLists.txt | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 6dff1841c..338cb0599 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -18,11 +18,19 @@ message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") # For adding F90 files add the F90 file to the ecosim source files and # inc files. The inc file also needs a header -set(ats_ecosim_src_files +#set(ats_ecosim_src_files +# EcoSIM_ATS_interface.cc +# BGCEngine.cc +# ecosim_wrappers.F90 +# data/bgc_fortran_memory_mod.F90 +#) + +file(GLOB ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/* ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 3ebf1fad4..e50e2ba77 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -5,11 +5,19 @@ # # collect all sources -set(ats_ecosim_data_src_files +#set(ats_ecosim_data_src_files +# BGC_constants.cc +# BGC_memory.cc +# BGC_containers.cc +# bgc_fortran_memory_mod.F90 +#) + +file(GLOB ats_ecosim_data_src_files BGC_constants.cc BGC_memory.cc BGC_containers.cc bgc_fortran_memory_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/* ) set(ats_ecosim_data_inc_files From 3ff93ffd1c3bde8686dbe47deb6050b3a792a67b Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 24 Aug 2023 16:53:06 -0700 Subject: [PATCH 467/582] more CMake commits --- src/pks/ecosim/CMakeLists.txt | 14 +++++++++++++- src/pks/ecosim/data/CMakeLists.txt | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 338cb0599..925db49a1 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -3,12 +3,24 @@ add_subdirectory(constitutive_relations) add_subdirectory(data) +set(TPL_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") + include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/data) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) -#include_directories(${TPL_INSTALL_PREFIX}/ecosim/f90src/ATSUtils/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) + +include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurPhys/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) include_directories(${ECOSIM_INCLUDE_DIRS}) diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index e50e2ba77..d5c29a265 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -12,6 +12,19 @@ # bgc_fortran_memory_mod.F90 #) +set(TPL_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") + +include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurPhys/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) + file(GLOB ats_ecosim_data_src_files BGC_constants.cc BGC_memory.cc From 18bbf4c3a7eeef0aa75858fb8a71e95fd1359dea Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 24 Aug 2023 17:00:50 -0700 Subject: [PATCH 468/582] more CMake --- src/pks/ecosim/CMakeLists.txt | 11 ++++++++++- src/pks/ecosim/data/CMakeLists.txt | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 925db49a1..e5dd23b91 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -42,7 +42,16 @@ file(GLOB ats_ecosim_src_files BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/* + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SoilPhys/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurPhys/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index d5c29a265..88b466679 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -31,6 +31,16 @@ file(GLOB ats_ecosim_data_src_files BGC_containers.cc bgc_fortran_memory_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/* + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SoilPhys/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurPhys/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 ) set(ats_ecosim_data_inc_files From f3edb79325b7603a40d28a18eeed1c623b87ca98 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Fri, 25 Aug 2023 09:49:10 -0700 Subject: [PATCH 469/582] more cmake --- src/pks/ecosim/CMakeLists.txt | 2 ++ src/pks/ecosim/data/CMakeLists.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index e5dd23b91..f2f3367b0 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -20,6 +20,7 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurPhys/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) include_directories(${ECOSIM_INCLUDE_DIRS}) @@ -51,6 +52,7 @@ file(GLOB ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SoilPhys/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurPhys/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/PhysData/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 ) diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 88b466679..5ae5ec179 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -24,6 +24,7 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) file(GLOB ats_ecosim_data_src_files BGC_constants.cc @@ -40,6 +41,7 @@ file(GLOB ats_ecosim_data_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SoilPhys/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurPhys/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/PhysData/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 ) From bcdf5ba9e296a7b5fab38ff4d525dd892b6b13de Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Fri, 25 Aug 2023 11:14:46 -0700 Subject: [PATCH 470/582] more cmake --- src/pks/ecosim/CMakeLists.txt | 4 ++-- src/pks/ecosim/data/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index f2f3367b0..f60853936 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -19,7 +19,7 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurPhys/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) @@ -51,7 +51,7 @@ file(GLOB ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SoilPhys/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurPhys/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurfPhys/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/PhysData/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 ) diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 5ae5ec179..2920f6465 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -22,7 +22,7 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurPhys/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) @@ -40,7 +40,7 @@ file(GLOB ats_ecosim_data_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SoilPhys/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurPhys/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurfPhys/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/PhysData/*.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 ) From 403318d998c50b6419e13fc7f1ef77b727990942 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 28 Aug 2023 16:36:18 -0700 Subject: [PATCH 471/582] more direct attempt at CMake fix --- src/pks/ecosim/CMakeLists.txt | 32 ++++++++++++++++++----------- src/pks/ecosim/data/CMakeLists.txt | 33 ++++++++++++++++++------------ 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index f60853936..8d63ed85b 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -38,22 +38,30 @@ message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") # data/bgc_fortran_memory_mod.F90 #) -file(GLOB ats_ecosim_src_files +set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SoilPhys/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurfPhys/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/PhysData/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSEcoSIMInitMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/fileUtil.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilWaterDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/GridDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SOMDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPhysDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/LandSurfDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/ClimForcDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPropertyDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/GridConsts.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMConfig.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/TracerIDMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/ElmIDMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/minimathmod.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 2920f6465..82bb70de8 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -26,23 +26,30 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) -file(GLOB ats_ecosim_data_src_files +set(ats_ecosim_data_src_files BGC_constants.cc BGC_memory.cc BGC_containers.cc bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/* - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SoilPhys/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/SurfPhys/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/HydroTherm/PhysData/*.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/*.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSEcoSIMInitMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/fileUtil.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilWaterDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/GridDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SOMDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPhysDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/LandSurfDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/ClimForcDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPropertyDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/GridConsts.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMConfig.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/TracerIDMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/ElmIDMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/minimathmod.F90 ) set(ats_ecosim_data_inc_files From e700e04237e80d67fc1d46df396e5f2ae34d36ce Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 28 Aug 2023 16:56:56 -0700 Subject: [PATCH 472/582] more cmake nonsense --- src/pks/ecosim/CMakeLists.txt | 8 +++++++- src/pks/ecosim/data/CMakeLists.txt | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 8d63ed85b..22d9514d7 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -50,6 +50,10 @@ set(ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/fileUtil.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_time_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/EcosimConst.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ncdio_pio.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_log_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilWaterDataType.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/GridDataType.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SOMDataType.F90 @@ -57,11 +61,13 @@ set(ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/LandSurfDataType.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/ClimForcDataType.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPropertyDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/InitAllocMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/GridConsts.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMConfig.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/TracerIDMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/ElmIDMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/minimathmod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMCtrlMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/MiniMathMod.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 82bb70de8..ffe71f718 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -38,6 +38,10 @@ set(ats_ecosim_data_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/fileUtil.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_time_mod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/EcosimConst.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ncdio_pio.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_log_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilWaterDataType.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/GridDataType.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SOMDataType.F90 @@ -45,11 +49,13 @@ set(ats_ecosim_data_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/LandSurfDataType.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/ClimForcDataType.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPropertyDataType.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/InitAllocMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/GridConsts.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMConfig.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/TracerIDMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/ElmIDMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/minimathmod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMCtrlMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/MiniMathMod.F90 ) set(ats_ecosim_data_inc_files From 7efa9f6e5ec002a81bfdf57c423a95ae29eea33d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 28 Aug 2023 17:15:21 -0700 Subject: [PATCH 473/582] cmake --- src/pks/ecosim/CMakeLists.txt | 11 ++++++++++- src/pks/ecosim/data/CMakeLists.txt | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 22d9514d7..e527976ce 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -51,7 +51,7 @@ set(ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/fileUtil.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_time_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/EcosimConst.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/EcoSimConst.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ncdio_pio.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_log_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilWaterDataType.F90 @@ -68,6 +68,15 @@ set(ats_ecosim_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/ElmIDMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMCtrlMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/MiniMathMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/GrosubsMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/PhotoSynsMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/RootMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/LitterFallMod.f90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/PlantBranchMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/EcoSiMParDataMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/GrosubPars.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/NoduleBGCMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/APIs/PlantAPIData.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index ffe71f718..4e474ec10 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -39,7 +39,7 @@ set(ats_ecosim_data_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/fileUtil.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_time_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/EcosimConst.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/EcoSimConst.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ncdio_pio.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_log_mod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilWaterDataType.F90 @@ -56,6 +56,15 @@ set(ats_ecosim_data_src_files /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/ElmIDMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMCtrlMod.F90 /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/MiniMathMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/GrosubsMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/PhotoSynsMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/RootMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/LitterFallMod.f90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/PlantBranchMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/EcoSiMParDataMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/GrosubPars.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/NoduleBGCMod.F90 + /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/APIs/PlantAPIData.F90 ) set(ats_ecosim_data_inc_files From e29299ddc982b0c99bdcb9beec7a455276c54558 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 29 Aug 2023 11:01:44 -0700 Subject: [PATCH 474/582] trying method of linking libs --- src/pks/ecosim/CMakeLists.txt | 63 ++++++++++++++---------------- src/pks/ecosim/data/CMakeLists.txt | 62 +++++++++++++---------------- 2 files changed, 57 insertions(+), 68 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index e527976ce..ac524ae92 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory(constitutive_relations) add_subdirectory(data) set(TPL_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") +set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) @@ -43,40 +44,6 @@ set(ats_ecosim_src_files BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSEcoSIMInitMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/fileUtil.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_time_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/EcoSimConst.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ncdio_pio.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_log_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilWaterDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/GridDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SOMDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPhysDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/LandSurfDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/ClimForcDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPropertyDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/InitAllocMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/GridConsts.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMConfig.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/TracerIDMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/ElmIDMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMCtrlMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/MiniMathMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/GrosubsMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/PhotoSynsMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/RootMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/LitterFallMod.f90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/PlantBranchMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/EcoSiMParDataMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/GrosubPars.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/NoduleBGCMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/APIs/PlantAPIData.F90 ) set(ats_ecosim_inc_files @@ -106,6 +73,34 @@ set(ats_ecosim_link_libs ats_operators ats_ecosim_data ats_ecosim_relations + libAPIData.a + libAPIs.a + libATSUtils_mods.a + libPhysData.a + libSnowPhys.a + libSoilPhys.a + libSurfPhys.a + libbalances.a + libbox_chem.a + libbox_model.a + libboxshared.a + libdisturb_mods.a + libecosim_datatype.a + libecosim_main.a + libecosim_mods.a + libioutils.a + liblayers_chem.a + liblayers_model.a + libmesh.a + libminimath.a + libmodelconfig.a + libmodelforc.a + libmodelpars.a + libnonsalt.a + libplant_bgc.a + libplant_driver.a + libsalt.a + libutil.a ) message(inc_files="${ats_ecosim_inc_files}") diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 4e474ec10..19763160f 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -31,40 +31,6 @@ set(ats_ecosim_data_src_files BGC_memory.cc BGC_containers.cc bgc_fortran_memory_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSCPLMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/ATSEcoSIMInitMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/BGC_containers.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ATSUtils/SharedDataMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/data_kind_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/abortutils.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/fileUtil.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_time_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/EcoSimConst.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ncdio_pio.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/utils/ecosim_log_mod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilWaterDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/GridDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SOMDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPhysDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/LandSurfDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/ClimForcDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_datatype/SoilPropertyDataType.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/ecosim_mods/InitAllocMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/mesh/GridConsts.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMConfig.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/TracerIDMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/ElmIDMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelconfig/EcoSIMCtrlMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/minimath/MiniMathMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/GrosubsMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/PhotoSynsMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/RootMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/LitterFallMod.f90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/PlantBranchMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/EcoSiMParDataMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/modelpars/GrosubPars.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/plant_bgc/NoduleBGCMod.F90 - /global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/f90src/APIs/PlantAPIData.F90 ) set(ats_ecosim_data_inc_files @@ -90,6 +56,34 @@ set(ats_ecosim_data_link_libs ats_pks ats_eos ats_operators + libAPIData.a + libAPIs.a + libATSUtils_mods.a + libPhysData.a + libSnowPhys.a + libSoilPhys.a + libSurfPhys.a + libbalances.a + libbox_chem.a + libbox_model.a + libboxshared.a + libdisturb_mods.a + libecosim_datatype.a + libecosim_main.a + libecosim_mods.a + libioutils.a + liblayers_chem.a + liblayers_model.a + libmesh.a + libminimath.a + libmodelconfig.a + libmodelforc.a + libmodelpars.a + libnonsalt.a + libplant_bgc.a + libplant_driver.a + libsalt.a + libutil.a ) # make the library From 617a8e7ee0d297e9b83d8e5215560d29a1b5cb7c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 29 Aug 2023 11:05:34 -0700 Subject: [PATCH 475/582] modifying library method --- src/pks/ecosim/CMakeLists.txt | 56 ++++++++++++++--------------- src/pks/ecosim/data/CMakeLists.txt | 57 +++++++++++++++--------------- 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index ac524ae92..a33827917 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -73,34 +73,34 @@ set(ats_ecosim_link_libs ats_operators ats_ecosim_data ats_ecosim_relations - libAPIData.a - libAPIs.a - libATSUtils_mods.a - libPhysData.a - libSnowPhys.a - libSoilPhys.a - libSurfPhys.a - libbalances.a - libbox_chem.a - libbox_model.a - libboxshared.a - libdisturb_mods.a - libecosim_datatype.a - libecosim_main.a - libecosim_mods.a - libioutils.a - liblayers_chem.a - liblayers_model.a - libmesh.a - libminimath.a - libmodelconfig.a - libmodelforc.a - libmodelpars.a - libnonsalt.a - libplant_bgc.a - libplant_driver.a - libsalt.a - libutil.a + ${ECOSIM_LIB_LOCATION}/libAPIData.a + ${ECOSIM_LIB_LOCATION}/libAPIs.a + ${ECOSIM_LIB_LOCATION}/libATSUtils_mods.a + ${ECOSIM_LIB_LOCATION}/libPhysData.a + ${ECOSIM_LIB_LOCATION}/libSnowPhys.a + ${ECOSIM_LIB_LOCATION}/libSoilPhys.a + ${ECOSIM_LIB_LOCATION}/libSurfPhys.a + ${ECOSIM_LIB_LOCATION}/libbalances.a + ${ECOSIM_LIB_LOCATION}/libbox_chem.a + ${ECOSIM_LIB_LOCATION}/libbox_model.a + ${ECOSIM_LIB_LOCATION}/libboxshared.a + ${ECOSIM_LIB_LOCATION}/libdisturb_mods.a + ${ECOSIM_LIB_LOCATION}/libecosim_datatype.a + ${ECOSIM_LIB_LOCATION}/libecosim_main.a + ${ECOSIM_LIB_LOCATION}/libecosim_mods.a + ${ECOSIM_LIB_LOCATION}/libioutils.a + ${ECOSIM_LIB_LOCATION}/liblayers_chem.a + ${ECOSIM_LIB_LOCATION}/liblayers_model.a + ${ECOSIM_LIB_LOCATION}/libmesh.a + ${ECOSIM_LIB_LOCATION}/libminimath.a + ${ECOSIM_LIB_LOCATION}/libmodelconfig.a + ${ECOSIM_LIB_LOCATION}/libmodelforc.a + ${ECOSIM_LIB_LOCATION}/libmodelpars.a + ${ECOSIM_LIB_LOCATION}/libnonsalt.a + ${ECOSIM_LIB_LOCATION}/libplant_bgc.a + ${ECOSIM_LIB_LOCATION}/libplant_driver.a + ${ECOSIM_LIB_LOCATION}/libsalt.a + ${ECOSIM_LIB_LOCATION}/libutil.a ) message(inc_files="${ats_ecosim_inc_files}") diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 19763160f..7b3b54dfa 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -13,6 +13,7 @@ #) set(TPL_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") +set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) @@ -56,34 +57,34 @@ set(ats_ecosim_data_link_libs ats_pks ats_eos ats_operators - libAPIData.a - libAPIs.a - libATSUtils_mods.a - libPhysData.a - libSnowPhys.a - libSoilPhys.a - libSurfPhys.a - libbalances.a - libbox_chem.a - libbox_model.a - libboxshared.a - libdisturb_mods.a - libecosim_datatype.a - libecosim_main.a - libecosim_mods.a - libioutils.a - liblayers_chem.a - liblayers_model.a - libmesh.a - libminimath.a - libmodelconfig.a - libmodelforc.a - libmodelpars.a - libnonsalt.a - libplant_bgc.a - libplant_driver.a - libsalt.a - libutil.a + ${ECOSIM_LIB_LOCATION}/libAPIData.a + ${ECOSIM_LIB_LOCATION}/libAPIs.a + ${ECOSIM_LIB_LOCATION}/libATSUtils_mods.a + ${ECOSIM_LIB_LOCATION}/libPhysData.a + ${ECOSIM_LIB_LOCATION}/libSnowPhys.a + ${ECOSIM_LIB_LOCATION}/libSoilPhys.a + ${ECOSIM_LIB_LOCATION}/libSurfPhys.a + ${ECOSIM_LIB_LOCATION}/libbalances.a + ${ECOSIM_LIB_LOCATION}/libbox_chem.a + ${ECOSIM_LIB_LOCATION}/libbox_model.a + ${ECOSIM_LIB_LOCATION}/libboxshared.a + ${ECOSIM_LIB_LOCATION}/libdisturb_mods.a + ${ECOSIM_LIB_LOCATION}/libecosim_datatype.a + ${ECOSIM_LIB_LOCATION}/libecosim_main.a + ${ECOSIM_LIB_LOCATION}/libecosim_mods.a + ${ECOSIM_LIB_LOCATION}/libioutils.a + ${ECOSIM_LIB_LOCATION}/liblayers_chem.a + ${ECOSIM_LIB_LOCATION}/liblayers_model.a + ${ECOSIM_LIB_LOCATION}/libmesh.a + ${ECOSIM_LIB_LOCATION}/libminimath.a + ${ECOSIM_LIB_LOCATION}/libmodelconfig.a + ${ECOSIM_LIB_LOCATION}/libmodelforc.a + ${ECOSIM_LIB_LOCATION}/libmodelpars.a + ${ECOSIM_LIB_LOCATION}/libnonsalt.a + ${ECOSIM_LIB_LOCATION}/libplant_bgc.a + ${ECOSIM_LIB_LOCATION}/libplant_driver.a + ${ECOSIM_LIB_LOCATION}/libsalt.a + ${ECOSIM_LIB_LOCATION}/libutil.a ) # make the library From bf480fd98f7a4dd72cbba928222597f209bb865f Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 29 Aug 2023 12:14:26 -0700 Subject: [PATCH 476/582] more cmake changes --- src/pks/ecosim/CMakeLists.txt | 7 ++++++- src/pks/ecosim/data/CMakeLists.txt | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index a33827917..6c25c0eb2 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -3,7 +3,7 @@ add_subdirectory(constitutive_relations) add_subdirectory(data) -set(TPL_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") +set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") include_directories(${ATS_SOURCE_DIR}/src/pks) @@ -44,6 +44,11 @@ set(ats_ecosim_src_files BGCEngine.cc ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/BGC_containers.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSCPLMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMInitMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 ) set(ats_ecosim_inc_files diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 7b3b54dfa..0102fff3a 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -12,7 +12,7 @@ # bgc_fortran_memory_mod.F90 #) -set(TPL_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") +set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) @@ -32,6 +32,12 @@ set(ats_ecosim_data_src_files BGC_memory.cc BGC_containers.cc bgc_fortran_memory_mod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/BGC_containers.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/BGC_containers.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSCPLMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMInitMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 ) set(ats_ecosim_data_inc_files From 40de843c387aa724f2a54666b5d526e6919a677c Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 29 Aug 2023 12:21:49 -0700 Subject: [PATCH 477/582] more cmake tests --- src/pks/ecosim/CMakeLists.txt | 11 +++++++++++ src/pks/ecosim/data/CMakeLists.txt | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 6c25c0eb2..e1dee88d3 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -5,6 +5,7 @@ add_subdirectory(data) set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") +set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release/f90src") include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) @@ -24,6 +25,16 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurPhys/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) + include_directories(${ECOSIM_INCLUDE_DIRS}) message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 0102fff3a..b322a7b00 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -14,6 +14,7 @@ set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") +set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release/f90src") include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) @@ -27,6 +28,16 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurPhys/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) + set(ats_ecosim_data_src_files BGC_constants.cc BGC_memory.cc From 70af13134a9d59c12c1e703bbd04b06740823710 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 29 Aug 2023 16:11:59 -0700 Subject: [PATCH 478/582] working version --- src/pks/ecosim/CMakeLists.txt | 8 +++++++- src/pks/ecosim/data/CMakeLists.txt | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index e1dee88d3..e9ef46ef5 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -5,7 +5,8 @@ add_subdirectory(data) set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") -set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release/f90src") +set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") +set(NETCDF_LIB "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) @@ -117,6 +118,11 @@ set(ats_ecosim_link_libs ${ECOSIM_LIB_LOCATION}/libplant_driver.a ${ECOSIM_LIB_LOCATION}/libsalt.a ${ECOSIM_LIB_LOCATION}/libutil.a + ${NETCDF_LIB}/libnetcdf.so + ${NETCDF_LIB}/libnetcdf.so.19 + ${NETCDF_LIB}/libnetcdff.so + ${NETCDF_LIB}/libnetcdff.so.7 + ${NETCDF_LIB}/libnetcdff.so.7.1.0 ) message(inc_files="${ats_ecosim_inc_files}") diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index b322a7b00..5d82e9357 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -14,7 +14,8 @@ set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") -set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release/f90src") +set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") +set(NETCDF_LIB "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) @@ -37,6 +38,7 @@ include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurPhys/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) +include_directories(${}) set(ats_ecosim_data_src_files BGC_constants.cc @@ -60,6 +62,7 @@ set(ats_ecosim_data_inc_files set(ats_ecosim_data_link_libs ${Teuchos_LIBRARIES} ${Epetra_LIBRARIES} + ${NETCDF_LIBRARIES} error_handling atk mesh @@ -102,6 +105,11 @@ set(ats_ecosim_data_link_libs ${ECOSIM_LIB_LOCATION}/libplant_driver.a ${ECOSIM_LIB_LOCATION}/libsalt.a ${ECOSIM_LIB_LOCATION}/libutil.a + ${NETCDF_LIB}/libnetcdf.so + ${NETCDF_LIB}/libnetcdf.so.19 + ${NETCDF_LIB}/libnetcdff.so + ${NETCDF_LIB}/libnetcdff.so.7 + ${NETCDF_LIB}/libnetcdff.so.7.1.0 ) # make the library From bde88310a70611801d417495f6144ae7482c10e1 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Fri, 1 Sep 2023 13:46:56 -0700 Subject: [PATCH 479/582] pushing reworked versions of the CMake files --- src/pks/ecosim/CMakeLists.txt | 43 ++++++------------------------ src/pks/ecosim/data/CMakeLists.txt | 34 ++++------------------- 2 files changed, 13 insertions(+), 64 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index e9ef46ef5..22a633b71 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -68,7 +68,13 @@ set(ats_ecosim_inc_files EcoSIM_ATS_interface.hh BGCEngine.hh ecosim_interface.h - ) +) + +file(GLOB ECOSIM_LIBRARIES + ${ECOSIM_LIB_LOCATION}/*.a +) + +find_package(NetCDF REQUIRED) set(ats_ecosim_link_libs ${Teuchos_LIBRARIES} @@ -90,40 +96,7 @@ set(ats_ecosim_link_libs ats_operators ats_ecosim_data ats_ecosim_relations - ${ECOSIM_LIB_LOCATION}/libAPIData.a - ${ECOSIM_LIB_LOCATION}/libAPIs.a - ${ECOSIM_LIB_LOCATION}/libATSUtils_mods.a - ${ECOSIM_LIB_LOCATION}/libPhysData.a - ${ECOSIM_LIB_LOCATION}/libSnowPhys.a - ${ECOSIM_LIB_LOCATION}/libSoilPhys.a - ${ECOSIM_LIB_LOCATION}/libSurfPhys.a - ${ECOSIM_LIB_LOCATION}/libbalances.a - ${ECOSIM_LIB_LOCATION}/libbox_chem.a - ${ECOSIM_LIB_LOCATION}/libbox_model.a - ${ECOSIM_LIB_LOCATION}/libboxshared.a - ${ECOSIM_LIB_LOCATION}/libdisturb_mods.a - ${ECOSIM_LIB_LOCATION}/libecosim_datatype.a - ${ECOSIM_LIB_LOCATION}/libecosim_main.a - ${ECOSIM_LIB_LOCATION}/libecosim_mods.a - ${ECOSIM_LIB_LOCATION}/libioutils.a - ${ECOSIM_LIB_LOCATION}/liblayers_chem.a - ${ECOSIM_LIB_LOCATION}/liblayers_model.a - ${ECOSIM_LIB_LOCATION}/libmesh.a - ${ECOSIM_LIB_LOCATION}/libminimath.a - ${ECOSIM_LIB_LOCATION}/libmodelconfig.a - ${ECOSIM_LIB_LOCATION}/libmodelforc.a - ${ECOSIM_LIB_LOCATION}/libmodelpars.a - ${ECOSIM_LIB_LOCATION}/libnonsalt.a - ${ECOSIM_LIB_LOCATION}/libplant_bgc.a - ${ECOSIM_LIB_LOCATION}/libplant_driver.a - ${ECOSIM_LIB_LOCATION}/libsalt.a - ${ECOSIM_LIB_LOCATION}/libutil.a - ${NETCDF_LIB}/libnetcdf.so - ${NETCDF_LIB}/libnetcdf.so.19 - ${NETCDF_LIB}/libnetcdff.so - ${NETCDF_LIB}/libnetcdff.so.7 - ${NETCDF_LIB}/libnetcdff.so.7.1.0 - ) +) message(inc_files="${ats_ecosim_inc_files}") diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 5d82e9357..e7cfa9296 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -59,10 +59,14 @@ set(ats_ecosim_data_inc_files BGC_memory.hh ) +file(GLOB ECOSIM_LIBRARIES + ${ECOSIM_LIB_LOCATION}/*.a +) + set(ats_ecosim_data_link_libs ${Teuchos_LIBRARIES} ${Epetra_LIBRARIES} - ${NETCDF_LIBRARIES} + ${ECOSIM_LIBRARIES} error_handling atk mesh @@ -77,34 +81,6 @@ set(ats_ecosim_data_link_libs ats_pks ats_eos ats_operators - ${ECOSIM_LIB_LOCATION}/libAPIData.a - ${ECOSIM_LIB_LOCATION}/libAPIs.a - ${ECOSIM_LIB_LOCATION}/libATSUtils_mods.a - ${ECOSIM_LIB_LOCATION}/libPhysData.a - ${ECOSIM_LIB_LOCATION}/libSnowPhys.a - ${ECOSIM_LIB_LOCATION}/libSoilPhys.a - ${ECOSIM_LIB_LOCATION}/libSurfPhys.a - ${ECOSIM_LIB_LOCATION}/libbalances.a - ${ECOSIM_LIB_LOCATION}/libbox_chem.a - ${ECOSIM_LIB_LOCATION}/libbox_model.a - ${ECOSIM_LIB_LOCATION}/libboxshared.a - ${ECOSIM_LIB_LOCATION}/libdisturb_mods.a - ${ECOSIM_LIB_LOCATION}/libecosim_datatype.a - ${ECOSIM_LIB_LOCATION}/libecosim_main.a - ${ECOSIM_LIB_LOCATION}/libecosim_mods.a - ${ECOSIM_LIB_LOCATION}/libioutils.a - ${ECOSIM_LIB_LOCATION}/liblayers_chem.a - ${ECOSIM_LIB_LOCATION}/liblayers_model.a - ${ECOSIM_LIB_LOCATION}/libmesh.a - ${ECOSIM_LIB_LOCATION}/libminimath.a - ${ECOSIM_LIB_LOCATION}/libmodelconfig.a - ${ECOSIM_LIB_LOCATION}/libmodelforc.a - ${ECOSIM_LIB_LOCATION}/libmodelpars.a - ${ECOSIM_LIB_LOCATION}/libnonsalt.a - ${ECOSIM_LIB_LOCATION}/libplant_bgc.a - ${ECOSIM_LIB_LOCATION}/libplant_driver.a - ${ECOSIM_LIB_LOCATION}/libsalt.a - ${ECOSIM_LIB_LOCATION}/libutil.a ${NETCDF_LIB}/libnetcdf.so ${NETCDF_LIB}/libnetcdf.so.19 ${NETCDF_LIB}/libnetcdff.so From 365777219b0e176b988aaebf5bfb1b68eba7c6cb Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 5 Sep 2023 13:41:29 -0700 Subject: [PATCH 480/582] modifications to beging initalization of ecosim --- src/pks/ecosim/BGCEngine.cc | 6 ++++-- src/pks/ecosim/BGCEngine.hh | 3 ++- src/pks/ecosim/EcoSIM_ATS_interface.cc | 2 +- src/pks/ecosim/data/BGC_containers.hh | 3 ++- src/pks/ecosim/data/bgc_fortran_memory_mod.F90 | 3 ++- src/pks/ecosim/ecosim_interface.h | 3 ++- src/pks/ecosim/ecosim_wrappers.F90 | 8 +++++--- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/pks/ecosim/BGCEngine.cc b/src/pks/ecosim/BGCEngine.cc index 5f5d1e159..c93213151 100644 --- a/src/pks/ecosim/BGCEngine.cc +++ b/src/pks/ecosim/BGCEngine.cc @@ -207,14 +207,16 @@ bool BGCEngine::Setup(BGCProperties& properties, BGCState& state, BGCSizes& sizes_, int num_iterations, - int num_columns) + int num_columns + int ncells_per_col_) { // Advance the chemical reaction all operator-split-like. bgc_.Setup(&properties, &state, &sizes_, num_iterations, - num_columns); + num_columns, + ncells_per_col_); //This is alquimia's advance function which we won't need //calling EcoSIM advance driver diff --git a/src/pks/ecosim/BGCEngine.hh b/src/pks/ecosim/BGCEngine.hh index afc29e663..2ba44b2f9 100644 --- a/src/pks/ecosim/BGCEngine.hh +++ b/src/pks/ecosim/BGCEngine.hh @@ -77,7 +77,8 @@ class BGCEngine { BGCState& state, BGCSizes& sizes, int num_iterations, - int num_columns); + int num_columns, + int ncells_per_col_); // Advances the species represented by the given array of concentrations, replacing old values // with new values. The order of the concentrations in the array matches that of the species names diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 21a17d2d5..50e72ef62 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1064,7 +1064,7 @@ int EcoSIM::InitializeSingleProcess(int proc) int num_iterations = 1; int num_columns = 1; - bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns); + bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns,ncells_per_col_); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); } diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 278f26fbd..074ee1f26 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -201,7 +201,8 @@ extern "C" { BGCState* state, BGCSizes* sizes, int num_iterations, - int num_columns); + int num_columns, + int ncells_per_col_); /* gracefully shutdown the engine, cleanup memory */ void (*Shutdown)(); diff --git a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 index 39da905c0..a1a629c1a 100644 --- a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 @@ -94,7 +94,7 @@ subroutine DataTest() bind(C) interface - subroutine Setup(properties, state, sizes, num_iterations, num_columns) bind(C) + subroutine Setup(properties, state, sizes, num_iterations, num_columns,ncells_per_col_) bind(C) use, intrinsic :: iso_c_binding, only: c_char, c_bool, c_ptr, c_int use BGCContainers_module, only : BGCSizes,BGCProperties,& @@ -104,6 +104,7 @@ subroutine Setup(properties, state, sizes, num_iterations, num_columns) bind(C) integer(c_int),VALUE :: num_iterations integer(c_int),VALUE :: num_columns + integer(c_int),VALUE :: ncells_per_col_ type(BGCProperties) :: properties type(BGCState) :: state diff --git a/src/pks/ecosim/ecosim_interface.h b/src/pks/ecosim/ecosim_interface.h index 5f1e4a5c0..835c72188 100644 --- a/src/pks/ecosim/ecosim_interface.h +++ b/src/pks/ecosim/ecosim_interface.h @@ -46,7 +46,8 @@ void ecosim_setup( BGCState* state, BGCSizes* sizes, int num_iterations, - int num_columns + int num_columns, + int ncells_per_col_ ); void ecosim_shutdown(); diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index 640daa4ee..3656ba88d 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -42,7 +42,7 @@ end subroutine EcoSIM_DataTest ! **************************************************************************** ! subroutine EcoSIM_Setup(properties, state, sizes, & - num_iterations, num_columns) bind(C) + num_iterations, num_columns, ncells_per_col_) bind(C) use, intrinsic :: iso_c_binding @@ -59,16 +59,18 @@ subroutine EcoSIM_Setup(properties, state, sizes, & type (BGCProperties), intent(in) :: properties integer, intent(in) :: num_columns integer, intent(in) :: num_iterations - integer :: jz + integer, intent(in) :: ncells_per_col_ integer :: js write(*,*) "starting driver transfer ATS2EcoSIMData" + js=1 + call ATS2EcoSIMData(num_columns, state, properties, sizes) write(*,*) "starting driver Init_EcoSIM" - !call Init_EcoSIM(jz,js,num_columns) + call Init_EcoSIM(ncells_per_col,js,num_columns) write(*,*) "starting driver transfer EcoSIM2ATSData" From 613f5e118b0be5833846036280cb9cf25c0616cf Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 5 Sep 2023 15:07:06 -0700 Subject: [PATCH 481/582] compiled code with init ecosim --- src/pks/ecosim/BGCEngine.cc | 2 +- src/pks/ecosim/data/bgc_fortran_memory_mod.F90 | 5 +++-- src/pks/ecosim/ecosim_wrappers.F90 | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim/BGCEngine.cc b/src/pks/ecosim/BGCEngine.cc index c93213151..f11dd2469 100644 --- a/src/pks/ecosim/BGCEngine.cc +++ b/src/pks/ecosim/BGCEngine.cc @@ -207,7 +207,7 @@ bool BGCEngine::Setup(BGCProperties& properties, BGCState& state, BGCSizes& sizes_, int num_iterations, - int num_columns + int num_columns, int ncells_per_col_) { // Advance the chemical reaction all operator-split-like. diff --git a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 index a1a629c1a..88dd13604 100644 --- a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 @@ -155,7 +155,7 @@ subroutine BGC_Fortran_DataTest(this) end subroutine BGC_Fortran_DataTest - subroutine BGC_Fortran_Setup(this, properties, state, sizes, num_iterations, num_columns) + subroutine BGC_Fortran_Setup(this, properties, state, sizes, num_iterations, num_columns, ncells_per_col_) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer use BGCContainers_module, only : BGCSizes, BGCProperties,& BGCState @@ -166,6 +166,7 @@ subroutine BGC_Fortran_Setup(this, properties, state, sizes, num_iterations, num real(c_double) :: delta_t integer(c_int) :: num_columns integer(c_int) :: num_iterations + integer(c_int) :: ncells_per_col_ type(BGCProperties) :: properties type(BGCState) :: state type(BGCSizes) :: sizes @@ -173,7 +174,7 @@ subroutine BGC_Fortran_Setup(this, properties, state, sizes, num_iterations, num procedure(Setup), pointer :: engine_Setup call c_f_procpointer(this%c_interface%Setup,engine_Setup) - call engine_Setup(properties, state, sizes, num_iterations, num_columns) + call engine_Setup(properties, state, sizes, num_iterations, num_columns,ncells_per_col_) end subroutine BGC_Fortran_Setup diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index 3656ba88d..d8fbf08c5 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -70,7 +70,7 @@ subroutine EcoSIM_Setup(properties, state, sizes, & write(*,*) "starting driver Init_EcoSIM" - call Init_EcoSIM(ncells_per_col,js,num_columns) + call Init_EcoSIM(ncells_per_col_,js,num_columns) write(*,*) "starting driver transfer EcoSIM2ATSData" From f49560a01f912d2a6fec0e76da319d972399a555 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 6 Sep 2023 16:06:01 -0700 Subject: [PATCH 482/582] minor changes --- src/pks/ecosim/data/bgc_fortran_memory_mod.F90 | 6 ++++-- src/pks/ecosim/ecosim_wrappers.F90 | 17 ++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 index 88dd13604..43650f79a 100644 --- a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 @@ -155,7 +155,8 @@ subroutine BGC_Fortran_DataTest(this) end subroutine BGC_Fortran_DataTest - subroutine BGC_Fortran_Setup(this, properties, state, sizes, num_iterations, num_columns, ncells_per_col_) + subroutine BGC_Fortran_Setup(this, properties, state, sizes, num_iterations,& + num_columns, ncells_per_col_) use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_double, c_f_procpointer use BGCContainers_module, only : BGCSizes, BGCProperties,& BGCState @@ -174,7 +175,8 @@ subroutine BGC_Fortran_Setup(this, properties, state, sizes, num_iterations, num procedure(Setup), pointer :: engine_Setup call c_f_procpointer(this%c_interface%Setup,engine_Setup) - call engine_Setup(properties, state, sizes, num_iterations, num_columns,ncells_per_col_) + call engine_Setup(properties, state, sizes, num_iterations, & + num_columns, ncells_per_col_) end subroutine BGC_Fortran_Setup diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index d8fbf08c5..dce989409 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -41,8 +41,8 @@ end subroutine EcoSIM_DataTest ! **************************************************************************** ! -subroutine EcoSIM_Setup(properties, state, sizes, & - num_iterations, num_columns, ncells_per_col_) bind(C) +subroutine EcoSIM_Setup(properties, state, sizes, num_iterations,& + num_columns, ncells_per_col_) bind(C) use, intrinsic :: iso_c_binding @@ -57,20 +57,15 @@ subroutine EcoSIM_Setup(properties, state, sizes, & type (BGCState), intent(inout) :: state !type (BGCAuxiliaryData), intent(inout) :: aux_data type (BGCProperties), intent(in) :: properties - integer, intent(in) :: num_columns - integer, intent(in) :: num_iterations - integer, intent(in) :: ncells_per_col_ - integer :: js + integer, intent(inout) :: num_columns + integer, intent(inout) :: num_iterations + integer, intent(inout) :: ncells_per_col_ write(*,*) "starting driver transfer ATS2EcoSIMData" - js=1 - call ATS2EcoSIMData(num_columns, state, properties, sizes) - write(*,*) "starting driver Init_EcoSIM" - - call Init_EcoSIM(ncells_per_col_,js,num_columns) + call Init_EcoSIM(ncells_per_col_,num_columns) write(*,*) "starting driver transfer EcoSIM2ATSData" From e6e4ee4bb4a496b5505ca0556cc9ff1afeb4b2f0 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 6 Sep 2023 16:16:42 -0700 Subject: [PATCH 483/582] modifications to use sizes to init --- src/pks/ecosim/data/bgc_fortran_memory_mod.F90 | 2 +- src/pks/ecosim/ecosim_wrappers.F90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 index 43650f79a..1c144d860 100644 --- a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 @@ -94,7 +94,7 @@ subroutine DataTest() bind(C) interface - subroutine Setup(properties, state, sizes, num_iterations, num_columns,ncells_per_col_) bind(C) + subroutine Setup(properties, state, sizes, num_iterations, num_columns, ncells_per_col_) bind(C) use, intrinsic :: iso_c_binding, only: c_char, c_bool, c_ptr, c_int use BGCContainers_module, only : BGCSizes,BGCProperties,& diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index dce989409..88d7abae0 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -65,7 +65,7 @@ subroutine EcoSIM_Setup(properties, state, sizes, num_iterations,& call ATS2EcoSIMData(num_columns, state, properties, sizes) - call Init_EcoSIM(ncells_per_col_,num_columns) + call Init_EcoSIM(sizes) write(*,*) "starting driver transfer EcoSIM2ATSData" From 8f6a393e0a05a71cdebc1a2c136e05137b629b5e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 2 Oct 2023 12:26:28 -0700 Subject: [PATCH 484/582] Initial push to test surface and subsurface sources --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 56 +++++++++++++++++++++++++- src/pks/ecosim/EcoSIM_ATS_interface.hh | 4 ++ src/pks/ecosim/data/BGC_containers.hh | 4 ++ src/pks/ecosim/data/BGC_memory.cc | 4 ++ src/pks/ecosim/ecosim_wrappers.F90 | 2 +- 5 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 50e72ef62..9c86acc1c 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -77,6 +77,17 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, T_key_ = Keys::readKey(*plist_, domain_, "temperature", "temperature"); thermal_conductivity_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); + //Sources + surface_water_source_key_ = Keys::readKey(plist, domain_, "surface water source", "water_source"); + surface_energy_source_key_ = + Keys::readKey(plist, domain_, "surface energy source", "total_energy_source"); + subsurface_water_source_key_ = + Keys::readKey(plist, domain_ss_, "subsurface water source", "water_source"); + subsurface_energy_source_key_ = + Keys::readKey(plist, domain_ss_, "subsurface energy source", "total_energy_source"); + //snow_source_key_ = Keys::readKey(plist, domain_snow_, "snow mass source - sink", "source_sink"); + //new_snow_key_ = Keys::readKey(plist, domain_snow_, "new snow source", "source"); + //Other cell_volume_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); //ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); @@ -264,6 +275,9 @@ void EcoSIM::Initialize() { S_->GetEvaluator(rock_density_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); //Surface properties from met data @@ -276,6 +290,8 @@ void EcoSIM::Initialize() { S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); if (S_->HasRecord(gas_density_key_test_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); @@ -399,6 +415,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(cell_volume_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); //Surface data from met data @@ -411,6 +429,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); @@ -718,6 +738,12 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& subsurface_energy_source = *(*S_->Get(subsurface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); + + const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -738,6 +764,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rf = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_ss_energy_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); @@ -770,6 +798,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,bulk_density,col_b_dens.ptr()); FieldToColumn_(column,plant_wilting_factor,col_wp.ptr()); FieldToColumn_(column,rooting_depth_fraction,col_rf.ptr()); + FieldToColumn_(column,subsurface_water_source,col_ss_water_source.ptr()); + FieldToColumn_(column,subsurface_energy_source,col_ss_energy_source.ptr()); MatrixFieldToColumn_(column, tcc, col_tcc.ptr()); @@ -806,6 +836,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.water_content.data[column][i] = (*col_wc)[i]; state.hydraulic_conductivity.data[column][i] = (*col_h_cond)[i]; state.bulk_density.data[column][i] = (*col_b_dens)[i]; + state.subsurface_water_source[column][i] = (*col_ss_water_source)[i]; + state.subsurface_energy_source[column][i] = (*col_ss_energy_source)[i]; //state.suction_head.data[i] = (*col_suc)[i]; props.plant_wilting_factor.data[column][i] = (*col_wp)[i]; props.rooting_depth_fraction.data[column][i] = (*col_rf)[i]; @@ -832,6 +864,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } //fill surface variables + state.surface_energy_source.data[column] = surface_energy_source[column]; + state.surface_water_source.data[column] = surface_water_source[column]; + props.shortwave_radiation.data[column] = shortwave_radiation[column]; props.longwave_radiation.data[column] = longwave_radiation[column]; props.air_temperature.data[column] = air_temperature[column]; @@ -910,6 +945,13 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Amanzi::Tags::NEXT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); auto& bulk_density = *(*S_->GetW(bulk_density_key_, Amanzi::Tags::NEXT, bulk_density_key_).ViewComponent("cell",false))(0); + auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); + auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); + + auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + + auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -926,6 +968,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto col_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_h_cond = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_ss_energy_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); @@ -955,8 +999,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_g_sat)[i] = props.gas_saturation.data[column][i]; } - FieldToColumn_(column,gas_saturation,col_g_sat.ptr()); - FieldToColumn_(column,gas_density,col_g_dens.ptr()); + ColumnToField_(column,gas_saturation,col_g_sat.ptr()); + ColumnToField_(column,gas_density,col_g_dens.ptr()); } if (has_ice) { @@ -992,6 +1036,12 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_h_cond)[i] = state.hydraulic_conductivity.data[column][i]; (*col_b_dens)[i] = state.bulk_density.data[column][i]; + (*col_ss_water_source)[i] = state.subsurface_water_source[column][i]; + (*col_ss_energy_source)[i] = state.subsurface_energy_source[column][i]; + + surface_energy_source[column] = state.surface_energy_source.data[column]; + surface_water_source[column] = state.surface_water_source.data[column]; + if (has_gas) { (*col_g_dens)[i] = state.gas_density.data[column][i]; } @@ -1014,6 +1064,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, ColumnToField_(column,cell_volume,col_vol.ptr()); ColumnToField_(column,hydraulic_conductivity,col_h_cond.ptr()); ColumnToField_(column,bulk_density,col_b_dens.ptr()); + ColumnToField_(column,subsurface_water_source,col_ss_water_source.ptr()); + ColumnToField_(column,subsurface_energy_source,col_ss_energy_source.ptr()); //ColumnToField_(column,plant_wilting_factor,col_wp.ptr()); //ColumnToField_(column,rooting_depth_fraction,col_rf.ptr()); } diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index e9dfc238c..a3cbd2cab 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -210,6 +210,10 @@ class EcoSIM : public PK_Physical { Key suc_key_; Key aspect_key_; Key slope_key_; + Key surface_energy_source_key_; + Key subsurface_energy_source_key_; + Key surface_water_source_key_; + Key subsurface_water_source_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 074ee1f26..c662bc4ba 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -110,6 +110,10 @@ extern "C" { BGCMatrixDouble temperature; BGCMatrixDouble hydraulic_conductivity; BGCMatrixDouble bulk_density; + BGCMatrixDouble subsurface_water_source; + BGCMatrixDouble subsurface_energy_source; + BGCVectorDouble surface_energy_source; + BGCVectorDouble surface_water_source; BGCTensorDouble total_component_concentration; } BGCState; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 42d4dc288..f1001f523 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -335,6 +335,8 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->temperature)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->hydraulic_conductivity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->bulk_density)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->subsurface_energy_source)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->subsurface_water_source)); AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); @@ -351,6 +353,8 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(state->temperature)); FreeBGCMatrixDouble(&(state->hydraulic_conductivity)); FreeBGCMatrixDouble(&(state->bulk_density)); + FreeBGCMatrixDouble(&(state->surface_energy_source)); + FreeBGCMatrixDouble(&(state->surface_water_source)); FreeBGCTensorDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index 88d7abae0..585aae984 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -123,7 +123,7 @@ subroutine EcoSIM_Advance( & call ATS2EcoSIMData(num_columns, state, properties, sizes) - !call Run_EcoSIM_one_step() + call Run_EcoSIM_one_step() call EcoSIM2ATSData(num_columns, state, sizes) From 7ef4d7c6020cc92dcfbec711d4aabc5a9a180736 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 2 Oct 2023 22:47:50 -0700 Subject: [PATCH 485/582] minor fixes to make the first test run --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 24 ++++++++++++------------ src/pks/ecosim/data/BGC_memory.cc | 8 ++++++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 9c86acc1c..ac80a5b24 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -78,13 +78,13 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, thermal_conductivity_key_ = Keys::readKey(*plist_, domain_, "thermal conductivity", "thermal_conductivity"); //Sources - surface_water_source_key_ = Keys::readKey(plist, domain_, "surface water source", "water_source"); + surface_water_source_key_ = Keys::readKey(*plist_, domain_surface_, "surface water source", "water_source"); surface_energy_source_key_ = - Keys::readKey(plist, domain_, "surface energy source", "total_energy_source"); + Keys::readKey(*plist_, domain_surface_, "surface energy source", "total_energy_source"); subsurface_water_source_key_ = - Keys::readKey(plist, domain_ss_, "subsurface water source", "water_source"); + Keys::readKey(*plist_, domain_, "subsurface water source", "water_source"); subsurface_energy_source_key_ = - Keys::readKey(plist, domain_ss_, "subsurface energy source", "total_energy_source"); + Keys::readKey(*plist_, domain_, "subsurface energy source", "total_energy_source"); //snow_source_key_ = Keys::readKey(plist, domain_snow_, "snow mass source - sink", "source_sink"); //new_snow_key_ = Keys::readKey(plist, domain_snow_, "new snow source", "source"); @@ -836,8 +836,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.water_content.data[column][i] = (*col_wc)[i]; state.hydraulic_conductivity.data[column][i] = (*col_h_cond)[i]; state.bulk_density.data[column][i] = (*col_b_dens)[i]; - state.subsurface_water_source[column][i] = (*col_ss_water_source)[i]; - state.subsurface_energy_source[column][i] = (*col_ss_energy_source)[i]; + state.subsurface_water_source.data[column][i] = (*col_ss_water_source)[i]; + state.subsurface_energy_source.data[column][i] = (*col_ss_energy_source)[i]; //state.suction_head.data[i] = (*col_suc)[i]; props.plant_wilting_factor.data[column][i] = (*col_wp)[i]; props.rooting_depth_fraction.data[column][i] = (*col_rf)[i]; @@ -945,11 +945,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Amanzi::Tags::NEXT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); auto& bulk_density = *(*S_->GetW(bulk_density_key_, Amanzi::Tags::NEXT, bulk_density_key_).ViewComponent("cell",false))(0); - auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); - auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); + auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Amanzi::Tags::NEXT, surface_energy_source_key_).ViewComponent("cell", false))(0); + auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Amanzi::Tags::NEXT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); - auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, water_tag).ViewComponent("cell", false))(0); - auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Amanzi::Tags::NEXT, surface_water_source_key_).ViewComponent("cell", false))(0); + auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Amanzi::Tags::NEXT, subsurface_water_source_key_).ViewComponent("cell", false))(0); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1036,8 +1036,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_h_cond)[i] = state.hydraulic_conductivity.data[column][i]; (*col_b_dens)[i] = state.bulk_density.data[column][i]; - (*col_ss_water_source)[i] = state.subsurface_water_source[column][i]; - (*col_ss_energy_source)[i] = state.subsurface_energy_source[column][i]; + (*col_ss_water_source)[i] = state.subsurface_water_source.data[column][i]; + (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; surface_energy_source[column] = state.surface_energy_source.data[column]; surface_water_source[column] = state.surface_water_source.data[column]; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index f1001f523..f23cdf867 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -338,6 +338,8 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->subsurface_energy_source)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->subsurface_water_source)); AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_water_source)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_energy_source)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateBGCState() */ @@ -353,8 +355,10 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(state->temperature)); FreeBGCMatrixDouble(&(state->hydraulic_conductivity)); FreeBGCMatrixDouble(&(state->bulk_density)); - FreeBGCMatrixDouble(&(state->surface_energy_source)); - FreeBGCMatrixDouble(&(state->surface_water_source)); + FreeBGCMatrixDouble(&(state->subsurface_energy_source)); + FreeBGCMatrixDouble(&(state->subsurface_water_source)); + FreeBGCVectorDouble(&(state->surface_energy_source)); + FreeBGCVectorDouble(&(state->surface_water_source)); FreeBGCTensorDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ From 63cf99313cbf417e77965a40caa8bf6cc0e3ca89 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 3 Oct 2023 13:03:26 -0700 Subject: [PATCH 486/582] rewriting print statements to get rid of some old ones and add new ones --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 64 ++++---------------------- src/pks/ecosim/data/BGC_memory.cc | 18 +------- 2 files changed, 11 insertions(+), 71 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index ac80a5b24..6ecd4c780 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -222,27 +222,14 @@ void EcoSIM::Initialize() { const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); int tcc_num = tcc.NumVectors(); Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "number of components: " << tcc_num << std::endl; num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - *vo_->os() << "columns on processor: " << num_columns_ << std::endl; //Now we call the engine's init state function which allocates the data bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num, num_columns_); - *vo_->os() << "Trying to print Sizes from engine: " << tcc_num << std::endl; - bgc_engine_->Sizes().ncells_per_col_; - bgc_engine_->Sizes().num_components; - bgc_engine_->Sizes().num_columns; - - *vo_->os() << "number of cells: " << bgc_engine_->Sizes().ncells_per_col_ << std::endl; - *vo_->os() << "number of components: " << bgc_engine_->Sizes().num_components << std::endl; - *vo_->os() << "number of columns: " << bgc_engine_->Sizes().num_columns << std::endl; - int ierr = 0; - *vo_->os() << "printing bool:" << std::endl; - *vo_->os() << (S_->HasRecord(suc_key_, Tags::DEFAULT)) << std::endl; if (S_->HasRecord(suc_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "has suction key." << std::endl; @@ -349,8 +336,6 @@ void EcoSIM::Initialize() { num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total columns cell_map: " << num_columns_global << std::endl; - *vo_->os() << "total columns from num_entities: " << num_columns_global << std::endl; //Trying to loop over processors now: int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); @@ -358,9 +343,7 @@ void EcoSIM::Initialize() { for (int k = 0; k < numProcesses; ++k) { MPI_Barrier(MPI_COMM_WORLD); if (p_rank==k) { - std::cout << "on processor " << p_rank << std::endl; num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << num_columns_local << std::endl; InitializeSingleProcess(p_rank); } @@ -569,8 +552,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total columns cell_map: " << num_columns_global << std::endl; - *vo_->os() << "total columns from num_entities: " << num_columns_global << std::endl; //Trying to loop over processors now: int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); @@ -578,9 +559,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { for (int k = 0; k < numProcesses; ++k) { MPI_Barrier(MPI_COMM_WORLD); if (p_rank==k) { - std::cout << "on processor " << p_rank << std::endl; num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << num_columns_local << std::endl; AdvanceSingleProcess(dt, p_rank); } @@ -774,16 +753,12 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total columns cell_map: " << num_columns_global << std::endl; - *vo_->os() << "total columns from num_entities: " << num_columns_global_ptype << std::endl; //Trying to loop over processors now: int p_rank; MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); MPI_Barrier(MPI_COMM_WORLD); - std::cout << "on processor " << p_rank << std::endl; num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << num_columns_local << std::endl; //Loop over columns on this process for (int column=0; column!=num_columns_local; ++column) { @@ -877,39 +852,18 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; - *vo_->os() << "Checking TCC variables: " << std::endl; - *vo_->os() << "size of processes: " << state.total_component_concentration.components << " number of processes: " << num_columns_local << std::endl; - *vo_->os() << "size of components: " << state.total_component_concentration.columns << " number of components: " << tcc_num << std::endl; - *vo_->os() << "size of processes: " << state.total_component_concentration.cells << " number of cells: " << ncells_per_col_ << std::endl; - - *vo_->os() << "Shape of data: " << state.total_component_concentration.cells << " x " - << state.total_component_concentration.columns << " x " - << state.total_component_concentration.components << std::endl; + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "surface source vars before: " << std::endl; + *vo_->os() << "surface water source: " << props.surface_water_source.data[column] << std::endl; + *vo_->os() << "surface energy source: " << props.surface_energy_source.data[column] << std::endl; // data[columns][cells][components] for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { - printf("data[%d][%d][%d]: %d\n", i, j, k, state.total_component_concentration.data[i][j][k]); } } } - /* - *vo_->os() << "entering loop: " << std::endl; - for (int i=0; i < num_columns_local; ++i) { - *vo_->os() << "on column : " << i << std::endl; - for (int j=0; j < ncells_per_col_; ++j) { - *vo_->os() << "on cell: " << j << std::endl; - for (int k=0; k < tcc_num; ++k) { - *vo_->os() << "on component: " << k << std::endl; - //original config (doesn't work) *vo_->os() << "Printing state element: " - //<< state.total_component_concentration.data[proc_col][component][i] << std::endl; - *vo_->os() << "Printing state element: " << state.total_component_concentration.data[i][j][k] << std::endl; - *vo_->os() << "Printing internal element: " << (*col_tcc)(j,k) << std::endl; - state.total_component_concentration.data[i][j][k] = (*col_tcc)(j,k); - } - } - }*/ } //Fill the atmospheric abundances @@ -978,16 +932,12 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); - *vo_->os() << "total columns cell_map: " << num_columns_global << std::endl; - *vo_->os() << "total columns from num_entities: " << num_columns_global_ptype << std::endl; //Trying to loop over processors now: int p_rank; MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); MPI_Barrier(MPI_COMM_WORLD); - std::cout << "on processor " << p_rank << std::endl; num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - std::cout << num_columns_local << std::endl; //Loop over columns on this process for (int col=0; col!=num_columns_local; ++col) { @@ -1055,6 +1005,12 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, } } + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "surface source vars after: " << std::endl; + *vo_->os() << "surface water source: " << props.surface_water_source.data[column] << std::endl; + *vo_->os() << "surface energy source: " << props.surface_energy_source.data[column] << std::endl; + + ColumnToField_(column,porosity,col_porosity.ptr()); ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); ColumnToField_(column,water_content,col_wc.ptr()); diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index f23cdf867..439f06383 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -223,16 +223,6 @@ void AllocateBGCTensorDouble(const int cells, const int columns, const int compo tensor->capacity_columns= nearest_power_of_2(columns); tensor->capacity_components = nearest_power_of_2(components); - std::cout << "In Allocate Tensor Double: " << std::endl; - std::cout << "columns on processor " << columns << std::endl; - std::cout << "size columns on procesor: " << tensor->capacity_columns << std::endl; - - std::cout << "cells per column: " << cells<< std::endl; - std::cout << "size cells per column: " << tensor->capacity_cells<< std::endl; - - std::cout << "components: " << components << std::endl; - std::cout << "size components: " << tensor->capacity_components << std::endl; - tensor->data = (double***) calloc((size_t)tensor->capacity_columns, sizeof(double**)); for (int i = 0; i < tensor->columns; ++i) { tensor->data[i] = (double**) calloc((size_t)tensor->capacity_cells, sizeof(double*)); @@ -322,10 +312,6 @@ void AllocateBGCState(const BGCSizes* const sizes, sizes->num_components = num_components; sizes->num_columns = num_columns; - std::cout << "In Allocate State: " << std::endl; - std::cout << "num_components: " << num_components << std::endl; - std::cout << "ncells_per_col: " << ncells_per_col_ << std::endl; - std::cout << "num_columns: " << num_columns << std::endl; AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->liquid_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->gas_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->ice_density)); @@ -358,7 +344,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(state->subsurface_energy_source)); FreeBGCMatrixDouble(&(state->subsurface_water_source)); FreeBGCVectorDouble(&(state->surface_energy_source)); - FreeBGCVectorDouble(&(state->surface_water_source)); + FreeBGCVectorDouble(&(state->surface_water_source)); FreeBGCTensorDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ @@ -395,8 +381,6 @@ void AllocateBGCState(const BGCSizes* const sizes, void AllocateBGCProperties(BGCSizes* sizes, BGCProperties* properties, int ncells_per_col_, int num_columns) { - std::cout << "In allocate properties: " << std::endl; - std::cout << "prop size: " << num_columns << std::endl; sizes->ncells_per_col_ = ncells_per_col_; sizes->num_columns = num_columns; From e0ce5ebb3c30b20375c79e4977c642df5e7c4309 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 3 Oct 2023 19:27:15 -0700 Subject: [PATCH 487/582] minor fixes to interface --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 6ecd4c780..59b56df7d 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -854,8 +854,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "surface source vars before: " << std::endl; - *vo_->os() << "surface water source: " << props.surface_water_source.data[column] << std::endl; - *vo_->os() << "surface energy source: " << props.surface_energy_source.data[column] << std::endl; + *vo_->os() << "surface water source: " << state.surface_water_source.data[column] << std::endl; + *vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; // data[columns][cells][components] for (int i = 0; i < state.total_component_concentration.columns; i++) { @@ -1007,8 +1007,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "surface source vars after: " << std::endl; - *vo_->os() << "surface water source: " << props.surface_water_source.data[column] << std::endl; - *vo_->os() << "surface energy source: " << props.surface_energy_source.data[column] << std::endl; + *vo_->os() << "surface water source: " << state.surface_water_source.data[column] << std::endl; + *vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; ColumnToField_(column,porosity,col_porosity.ptr()); From a8a874f1649e63dc695b11795b051f754d45f18d Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 5 Oct 2023 21:09:34 -0700 Subject: [PATCH 488/582] Added diagnostics for testing energy source sink --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 58 ++++++++++++------- src/pks/energy/energy_base_physics.cc | 12 +++- src/pks/energy/energy_base_ti.cc | 3 + .../seb_threecomponent_evaluator.cc | 15 +++++ 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 59b56df7d..4abdb4bfc 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -253,7 +253,9 @@ void EcoSIM::Initialize() { } // Ensure dependencies are filled - S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); + // May not need to update (also causes an assertion error if called before + // The PK that owns the variable + /*S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); @@ -264,11 +266,11 @@ void EcoSIM::Initialize() { S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); - + */ //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); //Surface properties from met data - S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); + /*S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); @@ -279,7 +281,7 @@ void EcoSIM::Initialize() { S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); - + if (S_->HasRecord(gas_density_key_test_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density gas key" << std::endl; @@ -316,7 +318,7 @@ void EcoSIM::Initialize() { *vo_->os() << "Did not find ice key" << std::endl; has_ice = false; } - + */ //Initialize owned evaluators S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); @@ -838,6 +840,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } } + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "surface energy from state: " << std::endl; + *vo_->os() << "surface energy source: " << surface_energy_source[column] << std::endl; + //fill surface variables state.surface_energy_source.data[column] = surface_energy_source[column]; state.surface_water_source.data[column] = surface_water_source[column]; @@ -852,12 +858,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "surface source vars before: " << std::endl; - *vo_->os() << "surface water source: " << state.surface_water_source.data[column] << std::endl; + *vo_->os() << "surface source after copying for EcoSIM: " << std::endl; *vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << "surface energy source (from state): " << surface_energy_source[column] << std::endl; - // data[columns][cells][components] for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { @@ -899,11 +903,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Amanzi::Tags::NEXT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); auto& bulk_density = *(*S_->GetW(bulk_density_key_, Amanzi::Tags::NEXT, bulk_density_key_).ViewComponent("cell",false))(0); - auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Amanzi::Tags::NEXT, surface_energy_source_key_).ViewComponent("cell", false))(0); - auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Amanzi::Tags::NEXT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); + auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); + auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Tags::DEFAULT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); - auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Amanzi::Tags::NEXT, surface_water_source_key_).ViewComponent("cell", false))(0); - auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Amanzi::Tags::NEXT, subsurface_water_source_key_).ViewComponent("cell", false))(0); + auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); + auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -941,7 +945,13 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, //Loop over columns on this process for (int col=0; col!=num_columns_local; ++col) { - if (has_gas) { + + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "surface source after EcoSIM run: " << std::endl; + *vo_->os() << "surface energy source (from state): " << surface_energy_source[column] << std::endl; + + + if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false))(0); auto& gas_density = *(*S_->GetW(gas_density_key_, Amanzi::Tags::NEXT, gas_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { @@ -989,9 +999,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_ss_water_source)[i] = state.subsurface_water_source.data[column][i]; (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; - surface_energy_source[column] = state.surface_energy_source.data[column]; - surface_water_source[column] = state.surface_water_source.data[column]; - + //??vec[col_iter[i]] = (*col_vec)[i]; if (has_gas) { (*col_g_dens)[i] = state.gas_density.data[column][i]; } @@ -1005,10 +1013,20 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, } } - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "surface source vars after: " << std::endl; - *vo_->os() << "surface water source: " << state.surface_water_source.data[column] << std::endl; + *vo_->os() << "Attempting to set state value " << std::endl; + + surface_energy_source[column] = state.surface_energy_source.data[column]; + + *vo_->os() << "Energy after equating to EcoSIM value: " << std::endl; *vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << "surface energy source (from State): " << surface_energy_source[column] << std::endl; + //*vo_->os() << "surface source vars after: " << std::endl; + //*vo_->os() << "surface water source: " << state.surface_water_source.data[column] << std::endl; + //*vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << "Just printing directly from state:" << std::endl; + auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Amanzi::Tags::NEXT, surface_energy_source_key_).ViewComponent("cell", false))(0); + *vo_->os() << new_e_source << std::endl; + ColumnToField_(column,porosity,col_porosity.ptr()); diff --git a/src/pks/energy/energy_base_physics.cc b/src/pks/energy/energy_base_physics.cc index bfd19f35f..f54832735 100644 --- a/src/pks/energy/energy_base_physics.cc +++ b/src/pks/energy/energy_base_physics.cc @@ -145,10 +145,20 @@ EnergyBase::AddSources_(const Tag& tag, const Teuchos::Ptr& g) S_->GetEvaluator(source_key_, tag).Update(*S_, name_); const Epetra_MultiVector& source1 = *S_->Get(source_key_, tag).ViewComponent("cell", false); + + *vo_->os() << "We are in AddSources" << std::endl; // Add into residual unsigned int ncells = g_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { g_c[0][c] -= source1[0][c] * cv[0][c]; } + + for (unsigned int c = 0; c != ncells; ++c) { + *vo_->os() << "On cell " << c << ":" << std::endl; + *vo_->os() << "g: " << g_c[0][c] << std::endl; + *vo_->os() << "source: " << source1[0][c] << std::endl; + *vo_->os() << "cv: " << cv[0][c] << std::endl; + g_c[0][c] -= source1[0][c] * cv[0][c]; + + } if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Adding external source term" << std::endl; db_->WriteVector(" Q_ext", S_->GetPtr(source_key_, tag).ptr(), false); diff --git a/src/pks/energy/energy_base_ti.cc b/src/pks/energy/energy_base_ti.cc index 83938268e..d0c41e90d 100644 --- a/src/pks/energy/energy_base_ti.cc +++ b/src/pks/energy/energy_base_ti.cc @@ -73,8 +73,11 @@ EnergyBase::FunctionalResidual(double t_old, db_->WriteBoundaryConditions(bc_markers(), bc_values()); // zero out residual + *vo_->os() << "In Functional Residual" << std::endl; Teuchos::RCP res = g->Data(); + *vo_->os() << "g = " << g << std::endl; res->PutScalar(0.0); + *vo_->os() << "(should be zero): g = " << g << std::endl; // diffusion term, implicit ApplyDiffusion_(tag_next_, res.ptr()); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc index 10c35e22d..a42c5480a 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc @@ -211,6 +211,8 @@ SEBThreeComponentEvaluator::Evaluate_(const State& S, const std::vector(poro_key_, tag).ViewComponent("cell", false); const auto& ss_pres = *S.Get(ss_pres_key_, tag).ViewComponent("cell", false); + + // collect output vecs auto& water_source = *results[0]->ViewComponent("cell", false); auto& energy_source = *results[1]->ViewComponent("cell", false); @@ -218,6 +220,13 @@ SEBThreeComponentEvaluator::Evaluate_(const State& S, const std::vectorViewComponent("cell", false); auto& snow_source = *results[4]->ViewComponent("cell", false); auto& new_snow = *results[5]->ViewComponent("cell", false); + + if (vo_.os_OK(Teuchos::VERB_EXTREME)) + *vo_.os() << "Water and Energy Sources Before:" + << ": energy source = " << energy_source + << ", water source = " << water_source << std::endl; + + water_source.PutScalar(0.); energy_source.PutScalar(0.); ss_water_source.PutScalar(0.); @@ -225,6 +234,12 @@ SEBThreeComponentEvaluator::Evaluate_(const State& S, const std::vectorGetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); - + if (S_->HasRecord(gas_density_key_test_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found mass density gas key" << std::endl; @@ -719,7 +721,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_energy_source = *(*S_->Get(subsurface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_key_, water_tag).ViewComponent("cell", false))(0); @@ -841,7 +844,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "surface energy from state: " << std::endl; + *vo_->os() << "surface energy from state: " << std::endl; *vo_->os() << "surface energy source: " << surface_energy_source[column] << std::endl; //fill surface variables @@ -903,7 +906,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Amanzi::Tags::NEXT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); auto& bulk_density = *(*S_->GetW(bulk_density_key_, Amanzi::Tags::NEXT, bulk_density_key_).ViewComponent("cell",false))(0); - auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); + //auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); + auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Tags::DEFAULT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); @@ -949,7 +953,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "surface source after EcoSIM run: " << std::endl; *vo_->os() << "surface energy source (from state): " << surface_energy_source[column] << std::endl; - + if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false))(0); @@ -1027,8 +1031,6 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Amanzi::Tags::NEXT, surface_energy_source_key_).ViewComponent("cell", false))(0); *vo_->os() << new_e_source << std::endl; - - ColumnToField_(column,porosity,col_porosity.ptr()); ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); ColumnToField_(column,water_content,col_wc.ptr()); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index a3cbd2cab..ea5d832a5 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -214,6 +214,7 @@ class EcoSIM : public PK_Physical { Key subsurface_energy_source_key_; Key surface_water_source_key_; Key subsurface_water_source_key_; + Key surface_energy_source_ecosim_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/energy/energy_base_physics.cc b/src/pks/energy/energy_base_physics.cc index f54832735..3e0529d53 100644 --- a/src/pks/energy/energy_base_physics.cc +++ b/src/pks/energy/energy_base_physics.cc @@ -134,7 +134,7 @@ EnergyBase::AddSources_(const Tag& tag, const Teuchos::Ptr& g) Teuchos::OSTab tab = vo_->getOSTab(); Epetra_MultiVector& g_c = *g->ViewComponent("cell", false); - + *vo_->os() << "In AddSources" S_->GetEvaluator(cell_vol_key_, tag_next_).Update(*S_, name_); const Epetra_MultiVector& cv = *S_->Get(cell_vol_key_, tag_next_).ViewComponent("cell", false); @@ -145,20 +145,14 @@ EnergyBase::AddSources_(const Tag& tag, const Teuchos::Ptr& g) S_->GetEvaluator(source_key_, tag).Update(*S_, name_); const Epetra_MultiVector& source1 = *S_->Get(source_key_, tag).ViewComponent("cell", false); - - *vo_->os() << "We are in AddSources" << std::endl; // Add into residual unsigned int ncells = g_c.MyLength(); - - for (unsigned int c = 0; c != ncells; ++c) { - *vo_->os() << "On cell " << c << ":" << std::endl; - *vo_->os() << "g: " << g_c[0][c] << std::endl; - *vo_->os() << "source: " << source1[0][c] << std::endl; - *vo_->os() << "cv: " << cv[0][c] << std::endl; - g_c[0][c] -= source1[0][c] * cv[0][c]; - - } + for (unsigned int c = 0; c != ncells; ++c) { + *vo_->os() << "source: " << source1[0][c]; + g_c[0][c] -= source1[0][c] * cv[0][c]; + + } if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Adding external source term" << std::endl; db_->WriteVector(" Q_ext", S_->GetPtr(source_key_, tag).ptr(), false); diff --git a/testing/ats-regression-tests b/testing/ats-regression-tests index 66c52a13f..6ecdcf611 160000 --- a/testing/ats-regression-tests +++ b/testing/ats-regression-tests @@ -1 +1 @@ -Subproject commit 66c52a13f41ecd1060f3d2608c9bae686014adfb +Subproject commit 6ecdcf611238a2e3e420214d76e8ac80db796c40 From 96a33c773ac8f643b21aabbd2b57b5d645806ed5 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Fri, 6 Oct 2023 20:50:54 -0700 Subject: [PATCH 490/582] Working with EcoSIM source test --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 2 +- src/pks/energy/energy_base_physics.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index d9cbaf479..5a89d71c0 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -907,7 +907,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& bulk_density = *(*S_->GetW(bulk_density_key_, Amanzi::Tags::NEXT, bulk_density_key_).ViewComponent("cell",false))(0); //auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); - auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); + auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, surface_energy_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Tags::DEFAULT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); diff --git a/src/pks/energy/energy_base_physics.cc b/src/pks/energy/energy_base_physics.cc index 3e0529d53..c64541633 100644 --- a/src/pks/energy/energy_base_physics.cc +++ b/src/pks/energy/energy_base_physics.cc @@ -134,7 +134,7 @@ EnergyBase::AddSources_(const Tag& tag, const Teuchos::Ptr& g) Teuchos::OSTab tab = vo_->getOSTab(); Epetra_MultiVector& g_c = *g->ViewComponent("cell", false); - *vo_->os() << "In AddSources" + *vo_->os() << "In AddSources"; S_->GetEvaluator(cell_vol_key_, tag_next_).Update(*S_, name_); const Epetra_MultiVector& cv = *S_->Get(cell_vol_key_, tag_next_).ViewComponent("cell", false); From c4a3b38718d60af23e228665ab03fcb439c1b6cb Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 11 Oct 2023 14:19:27 -0700 Subject: [PATCH 491/582] initial commit of seb (debugging) --- src/pks/ecosim/CMakeLists.txt | 3 ++- src/pks/ecosim/data/CMakeLists.txt | 3 ++- src/pks/ecosim/ecosim_wrappers.F90 | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 22a633b71..dce9588cb 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -33,7 +33,7 @@ include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurPhys/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) include_directories(${ECOSIM_INCLUDE_DIRS}) @@ -59,6 +59,7 @@ set(ats_ecosim_src_files ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/BGC_containers.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSCPLMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMInitMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMAdvanceMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 ) diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index e7cfa9296..e01512739 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -36,7 +36,7 @@ include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurPhys/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) include_directories(${}) @@ -51,6 +51,7 @@ set(ats_ecosim_data_src_files ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMInitMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMAdvanceMod.F90 ) set(ats_ecosim_data_inc_files diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index 585aae984..26bcb28e9 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -123,7 +123,7 @@ subroutine EcoSIM_Advance( & call ATS2EcoSIMData(num_columns, state, properties, sizes) - call Run_EcoSIM_one_step() + call Run_EcoSIM_one_step(sizes) call EcoSIM2ATSData(num_columns, state, sizes) From 6f4e3de1fbf91db2147b46f864adadda2c164c1e Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 23 Oct 2023 10:59:25 -0700 Subject: [PATCH 492/582] various debugging tests for suction --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 9 ++++++--- .../constitutive_relations/wrm/suction_head_evaluator.cc | 2 +- src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc | 7 +++++++ .../flow/constitutive_relations/wrm/wrm_van_genuchten.cc | 4 ++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 5a89d71c0..c0a6f5a92 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -66,7 +66,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); relative_permeability_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); - //suction_key_ = Keys::readKey(*plist_,domain_,"suction","suction_head"); + //suc_key_ = Keys::readKey(*plist_,domain_,"suction head","suction_head"); liquid_density_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_density_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); gas_density_key_ = Keys::readKey(*plist_, domain_,"mass density gas", "mass_density_gas"); @@ -125,6 +125,9 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, dt_ = plist_->get("initial time step", 1.); c_m_ = plist_->get("heat capacity [J mol^-1 K^-1]"); + //Teuchos::OSTab tab = vo_->getOSTab(); + //*vo_->os() << vo_->color("green") << "heat capacity: " << c_m_; + //This initialized the engine (found in BGCEngine.cc) This is the code that //actually points to the driver if (!plist_->isParameter("engine")) { @@ -308,7 +311,7 @@ void EcoSIM::Initialize() { *vo_->os() << "Did not find temp key" << std::endl; has_energy = false; } - + */ if (S_->HasRecord(ice_density_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found ice key" << std::endl; @@ -320,7 +323,7 @@ void EcoSIM::Initialize() { *vo_->os() << "Did not find ice key" << std::endl; has_ice = false; } - */ + //Initialize owned evaluators S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); diff --git a/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator.cc index 960570abc..45268a7d1 100644 --- a/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator.cc @@ -72,7 +72,7 @@ SuctionHeadEvaluator::Evaluate_(const State& S, const std::vector(sat_key_, tag)->ViewComponent("cell", false); Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); - + std::cout << "Hey we're running the suction evaluator"; int ncells = res_c.MyLength(); for (unsigned int c = 0; c != ncells; ++c) { int index = (*wrms_->first)[c]; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc index d402dc106..99c6ba051 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc @@ -51,6 +51,8 @@ WRMEvaluator::InitializeFromPlist_() Tag tag = my_keys_.front().second; my_keys_.clear(); + std::cout << "In WRMEvaluator: InitializeFromPlist_"; + std::size_t liq_pos = akey.find("liquid"); std::size_t gas_pos = akey.find("gas"); if (liq_pos != std::string::npos) { @@ -89,6 +91,8 @@ WRMEvaluator::Evaluate_(const State& S, const std::vector& res wrms_->first->Verify(); } + std::cout << "In WRMEvaluator:Evaluate_"; + Tag tag = my_keys_.front().second; Epetra_MultiVector& sat_c = *results[0]->ViewComponent("cell", false); const Epetra_MultiVector& pres_c = @@ -159,6 +163,9 @@ WRMEvaluator::EvaluatePartialDerivative_(const State& S, wrms_->first->Verify(); } + std::cout << "In WRMEvaluator: Derivative"; + + Tag tag = my_keys_.front().second; Epetra_MultiVector& sat_c = *results[0]->ViewComponent("cell", false); const Epetra_MultiVector& pres_c = diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc index 81058013c..8eaf4f3d7 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc @@ -88,6 +88,7 @@ WRMVanGenuchten::d_k_relative(double s) double WRMVanGenuchten::saturation(double pc) { + //std::cout << "What about Saturation?"; if (pc > pc0_) { return std::pow(1.0 + std::pow(alpha_ * pc, n_), -m_) * (1.0 - sr_) + sr_; } else if (pc <= 0.) { @@ -123,6 +124,8 @@ WRMVanGenuchten::capillaryPressure(double s) double se = (s - sr_) / (1.0 - sr_); se = std::min(se, 1.0); se = std::max(se, 1.e-40); + + std::cout << "Is Capillary pressure running?"; if (se < 1.e-8) { return std::pow(se, -1.0 / (m_ * n_)) / alpha_; } else { @@ -232,6 +235,7 @@ WRMVanGenuchten::InitializeFromPlist_() double WRMVanGenuchten::suction_head(double s) { + std::cout << "We are in suction head in van Genuchten"; double se = (s - sr_) / (1 - sr_); if (se > FLOW_WRM_TOLERANCE) { return -(1. / alpha_) * pow(pow(se, -1. / m_) - 1, 1. - m_); From 8613b7f45dcced4335a24db10d33a29cd65bcc15 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 23 Oct 2023 19:03:04 -0700 Subject: [PATCH 493/582] trying to gain access to WRM --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 13 +++++++++++-- src/pks/ecosim/EcoSIM_ATS_interface.hh | 5 ++++- .../wrm/wrm_fpd_permafrost_model.cc | 4 ++++ .../wrm/wrm_fpd_permafrost_model.hh | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index c0a6f5a92..41c571814 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -126,7 +126,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, c_m_ = plist_->get("heat capacity [J mol^-1 K^-1]"); //Teuchos::OSTab tab = vo_->getOSTab(); - //*vo_->os() << vo_->color("green") << "heat capacity: " << c_m_; + //*vo_->os() << vo_->color("green") << "heat capacity: " << c_m_; //This initialized the engine (found in BGCEngine.cc) This is the code that //actually points to the driver @@ -143,6 +143,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string engine_name = plist_->get("engine"); std::string engine_inputfile = plist_->get("engine input file"); bgc_engine_ = Teuchos::rcp(new BGCEngine(engine_name, engine_inputfile)); + + AMANZI_ASSERT(plist_.isSublist("WRM parameters")); + Teuchos::ParameterList sublist = plist_.sublist("WRM parameters"); + wrms_ = createWRMPartition(sublist); + InitializeFromPlist_(); } @@ -323,7 +328,7 @@ void EcoSIM::Initialize() { *vo_->os() << "Did not find ice key" << std::endl; has_ice = false; } - + //Initialize owned evaluators S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); @@ -393,6 +398,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { << " t1 = " << S_->get_time(tag_next_) << " h = " << dt << std::endl << "----------------------------------------------------------------" << std::endl; + *vo_->os() << "Testing WRMs" << std::endl; + double s_test = 0.5; + double suction_head = wrm_->suction_head(s_test); + // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index ea5d832a5..2372c5a44 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -42,6 +42,8 @@ #include "pk_physical_default.hh" #include "PK_Physical.hh" #include "ecosim_mod_test_wrapper.h" +#include "wrm.hh" +#include "wrm_partition.hh" namespace Amanzi { @@ -56,10 +58,10 @@ class EcoSIM : public PK_Physical { const Teuchos::RCP& plist, const Teuchos::RCP& S, const Teuchos::RCP& solution); - // Virtual destructor ~EcoSIM(); + Teuchos::RCP get_WRMs() { return wrms_; } // is a PK // -- Setup data //virtual void Setup(const Teuchos::Ptr&S); @@ -135,6 +137,7 @@ class EcoSIM : public PK_Physical { void ComputeNextTimeStep(); protected: + Teuchos::RCP wrms_; double dt_; double c_m_; Teuchos::RCP mesh_surf_; //might need this? diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc index b10a89d19..9d808bf49 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc @@ -83,6 +83,10 @@ WRMFPDPermafrostModel::dsaturations_dpc_ice(double pc_liq, double pc_ice, double } } +WRMFPDPermafrostModel::suction_head(double s) +{ + suction_head = wrm_->suction_head(s); +} } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh index 0cdfb5f7f..dd4f12e06 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh @@ -39,6 +39,7 @@ class WRMFPDPermafrostModel : public WRMPermafrostModel { virtual void dsaturations_dpc_liq(double pc_liq, double pc_ice, double (&dsats)[3]); virtual void dsaturations_dpc_ice(double pc_liq, double pc_ice, double (&dsats)[3]); + virtual void suction_head(double s); protected: double deriv_regularization_; From 87580b9810216ed4438e4b259c85c956299d5cb6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 24 Oct 2023 12:34:16 -0700 Subject: [PATCH 494/582] more suction testing --- .../constitutive_relations/wrm/wrm_fpd_permafrost_model.cc | 1 + .../constitutive_relations/wrm/wrm_fpd_permafrost_model.hh | 2 +- .../constitutive_relations/wrm/wrm_permafrost_evaluator.cc | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc index 9d808bf49..71752e022 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc @@ -83,6 +83,7 @@ WRMFPDPermafrostModel::dsaturations_dpc_ice(double pc_liq, double pc_ice, double } } +void WRMFPDPermafrostModel::suction_head(double s) { suction_head = wrm_->suction_head(s); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh index dd4f12e06..9812e582e 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh @@ -39,7 +39,7 @@ class WRMFPDPermafrostModel : public WRMPermafrostModel { virtual void dsaturations_dpc_liq(double pc_liq, double pc_ice, double (&dsats)[3]); virtual void dsaturations_dpc_ice(double pc_liq, double pc_ice, double (&dsats)[3]); - virtual void suction_head(double s); + virtual void suction_head(double s, double suction_head); protected: double deriv_regularization_; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc index 19ea2ceab..dea32e9d4 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc @@ -158,6 +158,7 @@ WRMPermafrostEvaluator::Evaluate_(const State& S, const std::vector(pc_ice_key_, tag)->ViewComponent("cell", false); double sats[3]; + double shs; int ncells = satg_c.MyLength(); for (AmanziMesh::Entity_ID c = 0; c != ncells; ++c) { int i = (*permafrost_models_->first)[c]; @@ -165,6 +166,11 @@ WRMPermafrostEvaluator::Evaluate_(const State& S, const std::vectorsecond[i]->suction_head(s_test, shs); + std::cout << "suction head: " << shs << std::endl; } // Potentially do face values as well, though only for saturation_liquid? From 370a38e3fa4c47d1503a7c8d8ce35d13c3fc319a Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 2 Nov 2023 11:41:20 -0700 Subject: [PATCH 495/582] working version of surface balance --- src/pks/ecosim/CMakeLists.txt | 3 +++ src/pks/ecosim/EcoSIM_ATS_interface.cc | 7 ++++--- src/pks/ecosim/EcoSIM_ATS_interface.hh | 6 ++---- src/pks/ecosim/data/CMakeLists.txt | 4 +++- .../constitutive_relations/wrm/wrm_fpd_permafrost_model.cc | 6 +++--- .../constitutive_relations/wrm/wrm_fpd_permafrost_model.hh | 2 +- .../constitutive_relations/wrm/wrm_permafrost_evaluator.cc | 3 ++- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index dce9588cb..90d2e7e45 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -24,6 +24,7 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) @@ -31,9 +32,11 @@ include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) include_directories(${ECOSIM_INCLUDE_DIRS}) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 41c571814..8e9c28cb4 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -144,10 +144,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string engine_inputfile = plist_->get("engine input file"); bgc_engine_ = Teuchos::rcp(new BGCEngine(engine_name, engine_inputfile)); - AMANZI_ASSERT(plist_.isSublist("WRM parameters")); + /*(AMANZI_ASSERT(plist_.isSublist("WRM parameters")); Teuchos::ParameterList sublist = plist_.sublist("WRM parameters"); wrms_ = createWRMPartition(sublist); InitializeFromPlist_(); + */ } @@ -398,9 +399,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { << " t1 = " << S_->get_time(tag_next_) << " h = " << dt << std::endl << "----------------------------------------------------------------" << std::endl; - *vo_->os() << "Testing WRMs" << std::endl; + /**vo_->os() << "Testing WRMs" << std::endl; double s_test = 0.5; - double suction_head = wrm_->suction_head(s_test); + double suction_head = wrm_->suction_head(s_test);*/ // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 2372c5a44..cb6d75c16 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -42,8 +42,6 @@ #include "pk_physical_default.hh" #include "PK_Physical.hh" #include "ecosim_mod_test_wrapper.h" -#include "wrm.hh" -#include "wrm_partition.hh" namespace Amanzi { @@ -61,7 +59,7 @@ class EcoSIM : public PK_Physical { // Virtual destructor ~EcoSIM(); - Teuchos::RCP get_WRMs() { return wrms_; } + //Teuchos::RCP get_WRMs() { return wrms_; } // is a PK // -- Setup data //virtual void Setup(const Teuchos::Ptr&S); @@ -137,7 +135,7 @@ class EcoSIM : public PK_Physical { void ComputeNextTimeStep(); protected: - Teuchos::RCP wrms_; + //Teuchos::RCP wrms_; double dt_; double c_m_; Teuchos::RCP mesh_surf_; //might need this? diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index e01512739..f55f488b6 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -26,6 +26,7 @@ include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) +include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) @@ -37,8 +38,9 @@ include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) -include_directories(${}) +include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) set(ats_ecosim_data_src_files BGC_constants.cc diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc index 71752e022..f8a2e86e1 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc @@ -83,11 +83,11 @@ WRMFPDPermafrostModel::dsaturations_dpc_ice(double pc_liq, double pc_ice, double } } -void -WRMFPDPermafrostModel::suction_head(double s) +/*void +WRMFPDPermafrostModel::suction_head(double s, double suction_head) { suction_head = wrm_->suction_head(s); -} +}*/ } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh index 9812e582e..f44c51541 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh @@ -39,7 +39,7 @@ class WRMFPDPermafrostModel : public WRMPermafrostModel { virtual void dsaturations_dpc_liq(double pc_liq, double pc_ice, double (&dsats)[3]); virtual void dsaturations_dpc_ice(double pc_liq, double pc_ice, double (&dsats)[3]); - virtual void suction_head(double s, double suction_head); + //virtual void suction_head(double s, double suction_head); protected: double deriv_regularization_; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc index dea32e9d4..8eeb7088b 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc @@ -167,10 +167,11 @@ WRMPermafrostEvaluator::Evaluate_(const State& S, const std::vectorsecond[i]->suction_head(s_test, shs); std::cout << "suction head: " << shs << std::endl; + */ } // Potentially do face values as well, though only for saturation_liquid? From 6a4075b2a68ab1070d8306727184fc9abfc3839b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 2 Nov 2023 12:37:50 -0700 Subject: [PATCH 496/582] adding some print statements to the overlandflow PK --- src/pks/flow/overland_pressure_pk.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pks/flow/overland_pressure_pk.cc b/src/pks/flow/overland_pressure_pk.cc index 34aa8c257..3a5503768 100644 --- a/src/pks/flow/overland_pressure_pk.cc +++ b/src/pks/flow/overland_pressure_pk.cc @@ -1260,13 +1260,19 @@ OverlandPressureFlow::ModifyCorrection(double h, // (where pressure derivatives are discontinuous) int my_limited = 0; int n_limited_spurt = 0; + *vo_->os() << "the patm limit is: " << patm_limit_ << std::endl; if (patm_limit_ > 0.) { double patm = S_->Get("atmospheric_pressure", Tags::DEFAULT); Epetra_MultiVector& du_c = *du->Data()->ViewComponent("cell", false); const Epetra_MultiVector& u_c = *u->Data()->ViewComponent("cell", false); + *vo_->os() << "checking u limits for du_c of size: " << du_c.MyLength << std::endl; for (int c = 0; c != du_c.MyLength(); ++c) { + *vo_->os() << "printing values for cell " << c << std::endl; + *vo_->os() << "patm = " << patm << std::endl; + *vo_->os() << "u_c[0][c] = " << u_c[0][c] << std::endl; + *vo_->os() << "du_c[0][c] = " << du_c[0][c] << std::endl; if ((u_c[0][c] < patm) && (u_c[0][c] - du_c[0][c] > patm + patm_limit_)) { du_c[0][c] = u_c[0][c] - (patm + patm_limit_); my_limited++; @@ -1279,6 +1285,7 @@ OverlandPressureFlow::ModifyCorrection(double h, } if (patm_hard_limit_) { + *vo_->os() << "In patm hard limit: " << std::endl; double patm = S_->Get("atmospheric_pressure", Tags::DEFAULT); Epetra_MultiVector& du_c = *du->Data()->ViewComponent("cell", false); @@ -1314,6 +1321,7 @@ OverlandPressureFlow::ModifyCorrection(double h, my_limited = 0; int n_limited_change = 0; + *vo_->os() << "p_limit_ = " << p_limit_ << std::endl; if (p_limit_ > 0.) { for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); ++comp) { From a6805209a9d2f7ee44461f641fa554a38d4dfdaa Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 6 Nov 2023 11:21:08 -0800 Subject: [PATCH 497/582] Testing removing the copyback step --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 8e9c28cb4..7a9ec12c3 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1106,7 +1106,7 @@ int EcoSIM::InitializeSingleProcess(int proc) int num_columns = 1; bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns,ncells_per_col_); - CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + //CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); } @@ -1123,8 +1123,8 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) bgc_sizes_, num_iterations, num_columns); // Move the information back into Amanzi's state, updating the given total concentration vector. - CopyFromEcoSIM_process(proc, - bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + //CopyFromEcoSIM_process(proc, + // bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); return num_iterations; } From 3c133b8ba227a98ffdac47b4bb79d368cdb4083e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 6 Nov 2023 15:32:03 -0800 Subject: [PATCH 498/582] changing the tags to default --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 7a9ec12c3..8133f6d07 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -905,19 +905,19 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, const Tag& water_tag) { - Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Amanzi::Tags::NEXT, "state")->ViewComponent("cell",false)); + Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Tags::DEFAULT, "state")->ViewComponent("cell",false)); int tcc_num = tcc.NumVectors(); - auto& porosity = *(*S_->GetW(porosity_key_, Amanzi::Tags::NEXT, porosity_key_).ViewComponent("cell",false))(0); - auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Amanzi::Tags::NEXT, saturation_liquid_key_).ViewComponent("cell",false))(0); - auto& water_content = *(*S_->GetW(water_content_key_, Amanzi::Tags::NEXT, water_content_key_).ViewComponent("cell",false))(0); - //auto& suction_head = *(*S_->GetW(suc_key_, Amanzi::Tags::NEXT, suc_key_).ViewComponent("cell",false))(0); - auto& relative_permeability = *(*S_->GetW(relative_permeability_key_, Amanzi::Tags::NEXT, relative_permeability_key_).ViewComponent("cell",false))(0); - auto& liquid_density = *(*S_->GetW(liquid_density_key_, Amanzi::Tags::NEXT, liquid_density_key_).ViewComponent("cell",false))(0); - auto& rock_density = *(*S_->GetW(rock_density_key_, Amanzi::Tags::NEXT, rock_density_key_).ViewComponent("cell",false))(0); - auto& cell_volume = *(*S_->GetW(cell_volume_key_, Amanzi::Tags::NEXT, cell_volume_key_).ViewComponent("cell",false))(0); - auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Amanzi::Tags::NEXT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); - auto& bulk_density = *(*S_->GetW(bulk_density_key_, Amanzi::Tags::NEXT, bulk_density_key_).ViewComponent("cell",false))(0); + auto& porosity = *(*S_->GetW(porosity_key_, Tags::DEFAULT, porosity_key_).ViewComponent("cell",false))(0); + auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Tags::DEFAULT, saturation_liquid_key_).ViewComponent("cell",false))(0); + auto& water_content = *(*S_->GetW(water_content_key_, Tags::DEFAULT, water_content_key_).ViewComponent("cell",false))(0); + //auto& suction_head = *(*S_->GetW(suc_key_, Tags::DEFAULT, suc_key_).ViewComponent("cell",false))(0); + auto& relative_permeability = *(*S_->GetW(relative_permeability_key_, Tags::DEFAULT, relative_permeability_key_).ViewComponent("cell",false))(0); + auto& liquid_density = *(*S_->GetW(liquid_density_key_, Tags::DEFAULT, liquid_density_key_).ViewComponent("cell",false))(0); + auto& rock_density = *(*S_->GetW(rock_density_key_, Tags::DEFAULT, rock_density_key_).ViewComponent("cell",false))(0); + auto& cell_volume = *(*S_->GetW(cell_volume_key_, Tags::DEFAULT, cell_volume_key_).ViewComponent("cell",false))(0); + auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); + auto& bulk_density = *(*S_->GetW(bulk_density_key_, Tags::DEFAULT, bulk_density_key_).ViewComponent("cell",false))(0); //auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, surface_energy_source_ecosim_key_).ViewComponent("cell", false))(0); @@ -969,8 +969,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, if (has_gas) { - auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Amanzi::Tags::NEXT, saturation_gas_key_).ViewComponent("cell",false))(0); - auto& gas_density = *(*S_->GetW(gas_density_key_, Amanzi::Tags::NEXT, gas_density_key_).ViewComponent("cell",false))(0); + auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Tags::DEFAULT, saturation_gas_key_).ViewComponent("cell",false))(0); + auto& gas_density = *(*S_->GetW(gas_density_key_, Tags::DEFAULT, gas_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_g_dens)[i] = state.gas_density.data[column][i]; (*col_g_sat)[i] = props.gas_saturation.data[column][i]; @@ -981,8 +981,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, } if (has_ice) { - auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Amanzi::Tags::NEXT, saturation_ice_key_).ViewComponent("cell",false))(0); - auto& ice_density = *(*S_->GetW(ice_density_key_, Amanzi::Tags::NEXT, ice_density_key_).ViewComponent("cell",false))(0); + auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Tags::DEFAULT, saturation_ice_key_).ViewComponent("cell",false))(0); + auto& ice_density = *(*S_->GetW(ice_density_key_, Tags::DEFAULT, ice_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_i_dens)[i] = state.ice_density.data[column][i]; @@ -994,8 +994,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, } if (has_energy) { - auto& temp = *(*S_->GetW(T_key_, Amanzi::Tags::NEXT, "subsurface energy").ViewComponent("cell",false))(0); - auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Amanzi::Tags::NEXT, thermal_conductivity_key_).ViewComponent("cell",false))(0); + auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); + auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { (*col_temp)[i] = state.temperature.data[column][i]; @@ -1041,7 +1041,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, //*vo_->os() << "surface water source: " << state.surface_water_source.data[column] << std::endl; //*vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; *vo_->os() << "Just printing directly from state:" << std::endl; - auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Amanzi::Tags::NEXT, surface_energy_source_key_).ViewComponent("cell", false))(0); + auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); *vo_->os() << new_e_source << std::endl; ColumnToField_(column,porosity,col_porosity.ptr()); @@ -1106,7 +1106,7 @@ int EcoSIM::InitializeSingleProcess(int proc) int num_columns = 1; bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns,ncells_per_col_); - //CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); } @@ -1123,8 +1123,8 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) bgc_sizes_, num_iterations, num_columns); // Move the information back into Amanzi's state, updating the given total concentration vector. - //CopyFromEcoSIM_process(proc, - // bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + CopyFromEcoSIM_process(proc, + bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); return num_iterations; } From 56a25903ece75904f7401a7dfef34f1b6326a560 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 6 Nov 2023 17:41:39 -0800 Subject: [PATCH 499/582] printing data looking for a bug --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 44 +++++++++++++++++++------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 8133f6d07..1eb0edb36 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -967,11 +967,14 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, *vo_->os() << "surface source after EcoSIM run: " << std::endl; *vo_->os() << "surface energy source (from state): " << surface_energy_source[column] << std::endl; - - if (has_gas) { + if (has_gas) { + *vo_->os() << "Looping over gas data: " << std::endl; auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Tags::DEFAULT, saturation_gas_key_).ViewComponent("cell",false))(0); auto& gas_density = *(*S_->GetW(gas_density_key_, Tags::DEFAULT, gas_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "For cell " << i << ": " << std::endl; + *vo_->os() << " gas density: " << state.gas_density.data[column][i] << std::endl; + *vo_->os() << " gas saturation: " << props.gas_saturation.data[column][i] << std::endl; (*col_g_dens)[i] = state.gas_density.data[column][i]; (*col_g_sat)[i] = props.gas_saturation.data[column][i]; } @@ -985,6 +988,10 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& ice_density = *(*S_->GetW(ice_density_key_, Tags::DEFAULT, ice_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "Looping over ice data: " << std::endl; + *vo_->os() << "For cell " << i << ": " << std::endl; + *vo_->os() << " ice density: " << state.ice_density.data[column][i] << std::endl; + *vo_->os() << " ice saturation: " << props.ice_saturation.data[column][i] << std::endl; (*col_i_dens)[i] = state.ice_density.data[column][i]; (*col_i_sat)[i] = props.ice_saturation.data[column][i]; } @@ -997,7 +1004,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); + *vo_->os() << "Looping over energy data: " << std::endl; for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "For cell " << i << ": " << std::endl; + *vo_->os() << " temperature: " << state.temperature.data[column][i] << std::endl; + *vo_->os() << " thermal cond: " << props.thermal_conductivity.data[column][i] << std::endl; (*col_temp)[i] = state.temperature.data[column][i]; (*col_cond)[i] = props.thermal_conductivity.data[column][i]; } @@ -1006,7 +1017,16 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, ColumnToField_(column,thermal_conductivity,col_cond.ptr()); } + *vo_->os() << "Looping over data: " << std::endl; for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "For cell " << i << ": " << std::endl; + *vo_->os() << " liquid density: " << state.liquid_density.data[column][i] << std::endl; + *vo_->os() << " porosity: " << state.porosity.data[column][i] << std::endl; + *vo_->os() << " water content: " << state.water_content.data[column][i] << std::endl; + *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; + *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; + *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; + *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; (*col_l_dens)[i] = state.liquid_density.data[column][i]; (*col_porosity)[i] = state.porosity.data[column][i]; (*col_wc)[i] = state.water_content.data[column][i]; @@ -1016,8 +1036,9 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_ss_water_source)[i] = state.subsurface_water_source.data[column][i]; (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; + //??vec[col_iter[i]] = (*col_vec)[i]; - if (has_gas) { + /*if (has_gas) { (*col_g_dens)[i] = state.gas_density.data[column][i]; } @@ -1028,21 +1049,20 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, if (has_energy) { (*col_temp)[i] = state.temperature.data[column][i]; } - } - - *vo_->os() << "Attempting to set state value " << std::endl; + }*/ - surface_energy_source[column] = state.surface_energy_source.data[column]; + //*vo_->os() << "Attempting to set state value " << std::endl; + //surface_energy_source[column] = state.surface_energy_source.data[column]; - *vo_->os() << "Energy after equating to EcoSIM value: " << std::endl; - *vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << "surface energy source (from State): " << surface_energy_source[column] << std::endl; + //*vo_->os() << "Energy after equating to EcoSIM value: " << std::endl; + //*vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; + //*vo_->os() << "surface energy source (from State): " << surface_energy_source[column] << std::endl; //*vo_->os() << "surface source vars after: " << std::endl; //*vo_->os() << "surface water source: " << state.surface_water_source.data[column] << std::endl; //*vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << "Just printing directly from state:" << std::endl; + //*vo_->os() << "Just printing directly from state:" << std::endl; auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); - *vo_->os() << new_e_source << std::endl; + //*vo_->os() << new_e_source << std::endl; ColumnToField_(column,porosity,col_porosity.ptr()); ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); From 317004dd2665d664a91a4c6fbb42b4c3424fc028 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 6 Nov 2023 17:51:56 -0800 Subject: [PATCH 500/582] fixing bracket --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 1eb0edb36..d7ef45b11 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1026,7 +1026,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; - *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; + *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; (*col_l_dens)[i] = state.liquid_density.data[column][i]; (*col_porosity)[i] = state.porosity.data[column][i]; (*col_wc)[i] = state.water_content.data[column][i]; @@ -1048,8 +1048,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, if (has_energy) { (*col_temp)[i] = state.temperature.data[column][i]; - } - }*/ + }*/ + } //*vo_->os() << "Attempting to set state value " << std::endl; //surface_energy_source[column] = state.surface_energy_source.data[column]; From 43da4a97f0cf9b49850d168acfc2add1864d2ad5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Nov 2023 10:50:42 -0800 Subject: [PATCH 501/582] trying to print everything I can --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 143 +++++++++++++++++++------ 1 file changed, 113 insertions(+), 30 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index d7ef45b11..9e8123c89 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -629,6 +629,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Epetra_Vector& vec, auto& col_iter = mesh_->cells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { vec[col_iter[i]] = (*col_vec)[i]; + *vo_->os() << "vel[col_iter] = " << vec[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; } } @@ -638,6 +639,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Teuchos::Ptrcells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { (*vec)[col_iter[i]] = (*col_vec)[i]; + *vo_->os() << "vel[col_iter] = " << vec[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; } } @@ -857,9 +859,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "surface energy from state: " << std::endl; - *vo_->os() << "surface energy source: " << surface_energy_source[column] << std::endl; - //fill surface variables state.surface_energy_source.data[column] = surface_energy_source[column]; state.surface_water_source.data[column] = surface_water_source[column]; @@ -874,10 +873,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; - *vo_->os() << "surface source after copying for EcoSIM: " << std::endl; - *vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << "surface energy source (from state): " << surface_energy_source[column] << std::endl; - for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { @@ -886,6 +881,59 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } } + Teuchos::OSTab tab = vo_->getOSTab(); + + *vo_->os() << "Printing all before data:" << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + if (i==0) { + *vo_->os() << "For cell " << i << ":" << std::endl; + *vo_->os() << " liquid density: " << state.liquid_density.data[column][i] << std::endl; + *vo_->os() << " porosity: " << state.porosity.data[column][i] << std::endl; + *vo_->os() << " water content: " << state.water_content.data[column][i] << std::endl; + *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; + *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; + *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; + *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; + //state.suction_head.data[i] = (*col_suc)[i]; + *vo_->os() << " plant wilting factor: " << props.plant_wilting_factor.data[column][i] << std::endl; + *vo_->os() << " rooting depth fraction: " << props.rooting_depth_fraction.data[column][i] << std::endl; + *vo_->os() << " liquid saturation: " << props.liquid_saturation.data[column][i] << std::endl; + *vo_->os() << " relative permeability: " << props.relative_permeability.data[column][i] << std::endl; + *vo_->os() << " volume: " << props.volume.data[column][i] << std::endl; + *vo_->os() << " depth: " << props.depth.data[column][i] << std::endl; + + if (has_gas) { + *vo_->os() << " gas saturation: " << props.gas_saturation.data[column][i] << std::endl; + *vo_->os() << " gas density: " << state.gas_density.data[column][i] << std::endl; + } + + if (has_ice) { + *vo_->os() << " ice density: " << state.ice_density.data[column][i] << std::endl; + *vo_->os() << " ice saturation: " << props.ice_saturation.data[column][i] << std::endl; + } + + if (has_energy) { + *vo_->os() << " temperature: " << state.temperature.data[column][i] << std::endl; + *vo_->os() << " thermal conductivity: " << props.thermal_conductivity.data[column][i] << std::endl; + } + } + } + + //fill surface variables + *vo_->os() << " surface energy source: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << " surface water source: " << state.surface_water_source.data[column] << std::endl; + + *vo_->os() << " shortwave radiation: " << props.shortwave_radiation.data[column] << std::endl; + *vo_->os() << " longwave radiation: " << props.longwave_radiation.data[column] << std::endl; + *vo_->os() << " air temperature: " << props.air_temperature.data[column] << std::endl; + *vo_->os() << " vapor pressure air: " << props.vapor_pressure_air.data[column] << std::endl; + *vo_->os() << " wind speed: " << props.wind_speed.data[column] << std::endl; + *vo_->os() << " precipitation: " << props.precipitation.data[column] << std::endl; + *vo_->os() << " elevation: " << props.elevation.data[column] << std::endl; + *vo_->os() << " aspect: " << props.aspect.data[column] << std::endl; + *vo_->os() << " slope: " << props.slope.data[column] << std::endl; + + //Fill the atmospheric abundances //NOTE: probably want to add an if statement here to only do this only once props.atm_n2 = atm_n2_; @@ -1004,11 +1052,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); - *vo_->os() << "Looping over energy data: " << std::endl; for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "For cell " << i << ": " << std::endl; - *vo_->os() << " temperature: " << state.temperature.data[column][i] << std::endl; - *vo_->os() << " thermal cond: " << props.thermal_conductivity.data[column][i] << std::endl; (*col_temp)[i] = state.temperature.data[column][i]; (*col_cond)[i] = props.thermal_conductivity.data[column][i]; } @@ -1017,16 +1061,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, ColumnToField_(column,thermal_conductivity,col_cond.ptr()); } - *vo_->os() << "Looping over data: " << std::endl; for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "For cell " << i << ": " << std::endl; - *vo_->os() << " liquid density: " << state.liquid_density.data[column][i] << std::endl; - *vo_->os() << " porosity: " << state.porosity.data[column][i] << std::endl; - *vo_->os() << " water content: " << state.water_content.data[column][i] << std::endl; - *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; - *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; - *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; - *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; (*col_l_dens)[i] = state.liquid_density.data[column][i]; (*col_porosity)[i] = state.porosity.data[column][i]; (*col_wc)[i] = state.water_content.data[column][i]; @@ -1035,22 +1070,58 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_ss_water_source)[i] = state.subsurface_water_source.data[column][i]; (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; + } + *vo_->os() << "Printing all after data:" << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + if (i==0) { + *vo_->os() << "For cell " << i << ":" << std::endl; + *vo_->os() << " liquid density: " << state.liquid_density.data[column][i] << std::endl; + *vo_->os() << " porosity: " << state.porosity.data[column][i] << std::endl; + *vo_->os() << " water content: " << state.water_content.data[column][i] << std::endl; + *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; + *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; + *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; + *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; + //state.suction_head.data[i] = (*col_suc)[i]; + *vo_->os() << " plant wilting factor: " << props.plant_wilting_factor.data[column][i] << std::endl; + *vo_->os() << " rooting depth fraction: " << props.rooting_depth_fraction.data[column][i] << std::endl; + *vo_->os() << " liquid saturation: " << props.liquid_saturation.data[column][i] << std::endl; + *vo_->os() << " relative permeability: " << props.relative_permeability.data[column][i] << std::endl; + *vo_->os() << " volume: " << props.volume.data[column][i] << std::endl; + *vo_->os() << " depth: " << props.depth.data[column][i] << std::endl; + + if (has_gas) { + *vo_->os() << " gas saturation: " << props.gas_saturation.data[column][i] << std::endl; + *vo_->os() << " gas density: " << state.gas_density.data[column][i] << std::endl; + } - //??vec[col_iter[i]] = (*col_vec)[i]; - /*if (has_gas) { - (*col_g_dens)[i] = state.gas_density.data[column][i]; - } + if (has_ice) { + *vo_->os() << " ice density: " << state.ice_density.data[column][i] << std::endl; + *vo_->os() << " ice saturation: " << props.ice_saturation.data[column][i] << std::endl; + } - if (has_ice) { - (*col_i_dens)[i] = state.ice_density.data[column][i]; + if (has_energy) { + *vo_->os() << " temperature: " << state.temperature.data[column][i] << std::endl; + *vo_->os() << " thermal conductivity: " << props.thermal_conductivity.data[column][i] << std::endl; + } } - - if (has_energy) { - (*col_temp)[i] = state.temperature.data[column][i]; - }*/ } + //fill surface variables + *vo_->os() << " surface energy source: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << " surface water source: " << state.surface_water_source.data[column] << std::endl; + + *vo_->os() << " shortwave radiation: " << props.shortwave_radiation.data[column] << std::endl; + *vo_->os() << " longwave radiation: " << props.longwave_radiation.data[column] << std::endl; + *vo_->os() << " air temperature: " << props.air_temperature.data[column] << std::endl; + *vo_->os() << " vapor pressure air: " << props.vapor_pressure_air.data[column] << std::endl; + *vo_->os() << " wind speed: " << props.wind_speed.data[column] << std::endl; + *vo_->os() << " precipitation: " << props.precipitation.data[column] << std::endl; + *vo_->os() << " elevation: " << props.elevation.data[column] << std::endl; + *vo_->os() << " aspect: " << props.aspect.data[column] << std::endl; + *vo_->os() << " slope: " << props.slope.data[column] << std::endl; + //*vo_->os() << "Attempting to set state value " << std::endl; //surface_energy_source[column] = state.surface_energy_source.data[column]; @@ -1064,16 +1135,28 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); //*vo_->os() << new_e_source << std::endl; + *vo_->os() << "Printing column to field:" << std::endl; + *vo_->os() << "Porosity" << std::endl; ColumnToField_(column,porosity,col_porosity.ptr()); + *vo_->os() << "liquid sat" << std::endl; ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); + *vo_->os() << "water content" << std::endl; ColumnToField_(column,water_content,col_wc.ptr()); + *vo_->os() << "rel perm" << std::endl; ColumnToField_(column,relative_permeability,col_relative_permeability.ptr()); + *vo_->os() << "liquid density" << std::endl; ColumnToField_(column,liquid_density,col_l_dens.ptr()); + *vo_->os() << "rock density" << std::endl; ColumnToField_(column,rock_density,col_r_dens.ptr()); + *vo_->os() << "cell volume" << std::endl; ColumnToField_(column,cell_volume,col_vol.ptr()); + *vo_->os() << "hydraulic cond" << std::endl; ColumnToField_(column,hydraulic_conductivity,col_h_cond.ptr()); + *vo_->os() << "bulk dens" << std::endl; ColumnToField_(column,bulk_density,col_b_dens.ptr()); + *vo_->os() << "water source" << std::endl; ColumnToField_(column,subsurface_water_source,col_ss_water_source.ptr()); + *vo_->os() << "energy source" << std::endl; ColumnToField_(column,subsurface_energy_source,col_ss_energy_source.ptr()); //ColumnToField_(column,plant_wilting_factor,col_wp.ptr()); //ColumnToField_(column,rooting_depth_fraction,col_rf.ptr()); From 0bb362026b4b8301290b6b09aa023b4635ef19b6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 7 Nov 2023 11:58:29 -0800 Subject: [PATCH 502/582] minor bugfix --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 103 ++++++++++++------------- 1 file changed, 49 insertions(+), 54 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 9e8123c89..6a31a5b51 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -639,7 +639,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Teuchos::Ptrcells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { (*vec)[col_iter[i]] = (*col_vec)[i]; - *vo_->os() << "vel[col_iter] = " << vec[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; + *vo_->os() << "vel[col_iter] = " << (*vec)[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; } } @@ -857,8 +857,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.thermal_conductivity.data[column][i] = (*col_cond)[i]; } } - - Teuchos::OSTab tab = vo_->getOSTab(); //fill surface variables state.surface_energy_source.data[column] = surface_energy_source[column]; state.surface_water_source.data[column] = surface_water_source[column]; @@ -873,67 +871,64 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; - for (int i = 0; i < state.total_component_concentration.columns; i++) { - for (int j = 0; j < state.total_component_concentration.cells; j++) { - for (int k = 0; k < state.total_component_concentration.components; k++) { - } - } - } - } + *vo_->os() << "Printing all before data:" << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + if (i==0) { + *vo_->os() << "For cell " << i << ":" << std::endl; + *vo_->os() << " liquid density: " << state.liquid_density.data[column][i] << std::endl; + *vo_->os() << " porosity: " << state.porosity.data[column][i] << std::endl; + *vo_->os() << " water content: " << state.water_content.data[column][i] << std::endl; + *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; + *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; + *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; + *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; + //state.suction_head.data[i] = (*col_suc)[i]; + *vo_->os() << " plant wilting factor: " << props.plant_wilting_factor.data[column][i] << std::endl; + *vo_->os() << " rooting depth fraction: " << props.rooting_depth_fraction.data[column][i] << std::endl; + *vo_->os() << " liquid saturation: " << props.liquid_saturation.data[column][i] << std::endl; + *vo_->os() << " relative permeability: " << props.relative_permeability.data[column][i] << std::endl; + *vo_->os() << " volume: " << props.volume.data[column][i] << std::endl; + *vo_->os() << " depth: " << props.depth.data[column][i] << std::endl; - Teuchos::OSTab tab = vo_->getOSTab(); + if (has_gas) { + *vo_->os() << " gas saturation: " << props.gas_saturation.data[column][i] << std::endl; + *vo_->os() << " gas density: " << state.gas_density.data[column][i] << std::endl; + } - *vo_->os() << "Printing all before data:" << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - if (i==0) { - *vo_->os() << "For cell " << i << ":" << std::endl; - *vo_->os() << " liquid density: " << state.liquid_density.data[column][i] << std::endl; - *vo_->os() << " porosity: " << state.porosity.data[column][i] << std::endl; - *vo_->os() << " water content: " << state.water_content.data[column][i] << std::endl; - *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; - *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; - *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; - *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; - //state.suction_head.data[i] = (*col_suc)[i]; - *vo_->os() << " plant wilting factor: " << props.plant_wilting_factor.data[column][i] << std::endl; - *vo_->os() << " rooting depth fraction: " << props.rooting_depth_fraction.data[column][i] << std::endl; - *vo_->os() << " liquid saturation: " << props.liquid_saturation.data[column][i] << std::endl; - *vo_->os() << " relative permeability: " << props.relative_permeability.data[column][i] << std::endl; - *vo_->os() << " volume: " << props.volume.data[column][i] << std::endl; - *vo_->os() << " depth: " << props.depth.data[column][i] << std::endl; + if (has_ice) { + *vo_->os() << " ice density: " << state.ice_density.data[column][i] << std::endl; + *vo_->os() << " ice saturation: " << props.ice_saturation.data[column][i] << std::endl; + } - if (has_gas) { - *vo_->os() << " gas saturation: " << props.gas_saturation.data[column][i] << std::endl; - *vo_->os() << " gas density: " << state.gas_density.data[column][i] << std::endl; + if (has_energy) { + *vo_->os() << " temperature: " << state.temperature.data[column][i] << std::endl; + *vo_->os() << " thermal conductivity: " << props.thermal_conductivity.data[column][i] << std::endl; + } } + } - if (has_ice) { - *vo_->os() << " ice density: " << state.ice_density.data[column][i] << std::endl; - *vo_->os() << " ice saturation: " << props.ice_saturation.data[column][i] << std::endl; - } + //fill surface variables + *vo_->os() << " surface energy source: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << " surface water source: " << state.surface_water_source.data[column] << std::endl; - if (has_energy) { - *vo_->os() << " temperature: " << state.temperature.data[column][i] << std::endl; - *vo_->os() << " thermal conductivity: " << props.thermal_conductivity.data[column][i] << std::endl; + *vo_->os() << " shortwave radiation: " << props.shortwave_radiation.data[column] << std::endl; + *vo_->os() << " longwave radiation: " << props.longwave_radiation.data[column] << std::endl; + *vo_->os() << " air temperature: " << props.air_temperature.data[column] << std::endl; + *vo_->os() << " vapor pressure air: " << props.vapor_pressure_air.data[column] << std::endl; + *vo_->os() << " wind speed: " << props.wind_speed.data[column] << std::endl; + *vo_->os() << " precipitation: " << props.precipitation.data[column] << std::endl; + *vo_->os() << " elevation: " << props.elevation.data[column] << std::endl; + *vo_->os() << " aspect: " << props.aspect.data[column] << std::endl; + *vo_->os() << " slope: " << props.slope.data[column] << std::endl; + + for (int i = 0; i < state.total_component_concentration.columns; i++) { + for (int j = 0; j < state.total_component_concentration.cells; j++) { + for (int k = 0; k < state.total_component_concentration.components; k++) { + } } } } - //fill surface variables - *vo_->os() << " surface energy source: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << " surface water source: " << state.surface_water_source.data[column] << std::endl; - - *vo_->os() << " shortwave radiation: " << props.shortwave_radiation.data[column] << std::endl; - *vo_->os() << " longwave radiation: " << props.longwave_radiation.data[column] << std::endl; - *vo_->os() << " air temperature: " << props.air_temperature.data[column] << std::endl; - *vo_->os() << " vapor pressure air: " << props.vapor_pressure_air.data[column] << std::endl; - *vo_->os() << " wind speed: " << props.wind_speed.data[column] << std::endl; - *vo_->os() << " precipitation: " << props.precipitation.data[column] << std::endl; - *vo_->os() << " elevation: " << props.elevation.data[column] << std::endl; - *vo_->os() << " aspect: " << props.aspect.data[column] << std::endl; - *vo_->os() << " slope: " << props.slope.data[column] << std::endl; - - //Fill the atmospheric abundances //NOTE: probably want to add an if statement here to only do this only once props.atm_n2 = atm_n2_; From 82676928282ab4e82a665f5b030c9c6317203d99 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 8 Nov 2023 09:35:15 -0800 Subject: [PATCH 503/582] fixed version of the ecosim PK --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 6a31a5b51..ba7e992fd 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1130,29 +1130,18 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); //*vo_->os() << new_e_source << std::endl; + *vo_->os() << "Printing column to field:" << std::endl; - *vo_->os() << "Porosity" << std::endl; - ColumnToField_(column,porosity,col_porosity.ptr()); *vo_->os() << "liquid sat" << std::endl; ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); *vo_->os() << "water content" << std::endl; ColumnToField_(column,water_content,col_wc.ptr()); *vo_->os() << "rel perm" << std::endl; ColumnToField_(column,relative_permeability,col_relative_permeability.ptr()); - *vo_->os() << "liquid density" << std::endl; - ColumnToField_(column,liquid_density,col_l_dens.ptr()); - *vo_->os() << "rock density" << std::endl; - ColumnToField_(column,rock_density,col_r_dens.ptr()); - *vo_->os() << "cell volume" << std::endl; - ColumnToField_(column,cell_volume,col_vol.ptr()); *vo_->os() << "hydraulic cond" << std::endl; ColumnToField_(column,hydraulic_conductivity,col_h_cond.ptr()); *vo_->os() << "bulk dens" << std::endl; ColumnToField_(column,bulk_density,col_b_dens.ptr()); - *vo_->os() << "water source" << std::endl; - ColumnToField_(column,subsurface_water_source,col_ss_water_source.ptr()); - *vo_->os() << "energy source" << std::endl; - ColumnToField_(column,subsurface_energy_source,col_ss_energy_source.ptr()); //ColumnToField_(column,plant_wilting_factor,col_wp.ptr()); //ColumnToField_(column,rooting_depth_fraction,col_rf.ptr()); } From e617def55b906680e01202904d5fda78406743f7 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Nov 2023 14:57:41 -0800 Subject: [PATCH 504/582] testing new parameters --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 133 ++----------------------- src/pks/ecosim/data/BGC_containers.hh | 1 + 2 files changed, 7 insertions(+), 127 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index ba7e992fd..8afc9c6c8 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -93,8 +93,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //Other cell_volume_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); //ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); - f_wp_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); - f_root_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); + f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); + f_root_key_ = Keys::readKey(*plist_, domain_, "rooting depth fraction", "rooting_depth_fraction"); //Custom Evaluator keys hydraulic_conductivity_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); @@ -629,7 +629,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Epetra_Vector& vec, auto& col_iter = mesh_->cells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { vec[col_iter[i]] = (*col_vec)[i]; - *vo_->os() << "vel[col_iter] = " << vec[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; + //*vo_->os() << "vel[col_iter] = " << vec[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; } } @@ -639,7 +639,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Teuchos::Ptrcells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { (*vec)[col_iter[i]] = (*col_vec)[i]; - *vo_->os() << "vel[col_iter] = " << (*vec)[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; + //*vo_->os() << "vel[col_iter] = " << (*vec)[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; } } @@ -871,56 +871,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; - *vo_->os() << "Printing all before data:" << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - if (i==0) { - *vo_->os() << "For cell " << i << ":" << std::endl; - *vo_->os() << " liquid density: " << state.liquid_density.data[column][i] << std::endl; - *vo_->os() << " porosity: " << state.porosity.data[column][i] << std::endl; - *vo_->os() << " water content: " << state.water_content.data[column][i] << std::endl; - *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; - *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; - *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; - *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; - //state.suction_head.data[i] = (*col_suc)[i]; - *vo_->os() << " plant wilting factor: " << props.plant_wilting_factor.data[column][i] << std::endl; - *vo_->os() << " rooting depth fraction: " << props.rooting_depth_fraction.data[column][i] << std::endl; - *vo_->os() << " liquid saturation: " << props.liquid_saturation.data[column][i] << std::endl; - *vo_->os() << " relative permeability: " << props.relative_permeability.data[column][i] << std::endl; - *vo_->os() << " volume: " << props.volume.data[column][i] << std::endl; - *vo_->os() << " depth: " << props.depth.data[column][i] << std::endl; - - if (has_gas) { - *vo_->os() << " gas saturation: " << props.gas_saturation.data[column][i] << std::endl; - *vo_->os() << " gas density: " << state.gas_density.data[column][i] << std::endl; - } - - if (has_ice) { - *vo_->os() << " ice density: " << state.ice_density.data[column][i] << std::endl; - *vo_->os() << " ice saturation: " << props.ice_saturation.data[column][i] << std::endl; - } - - if (has_energy) { - *vo_->os() << " temperature: " << state.temperature.data[column][i] << std::endl; - *vo_->os() << " thermal conductivity: " << props.thermal_conductivity.data[column][i] << std::endl; - } - } - } - - //fill surface variables - *vo_->os() << " surface energy source: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << " surface water source: " << state.surface_water_source.data[column] << std::endl; - - *vo_->os() << " shortwave radiation: " << props.shortwave_radiation.data[column] << std::endl; - *vo_->os() << " longwave radiation: " << props.longwave_radiation.data[column] << std::endl; - *vo_->os() << " air temperature: " << props.air_temperature.data[column] << std::endl; - *vo_->os() << " vapor pressure air: " << props.vapor_pressure_air.data[column] << std::endl; - *vo_->os() << " wind speed: " << props.wind_speed.data[column] << std::endl; - *vo_->os() << " precipitation: " << props.precipitation.data[column] << std::endl; - *vo_->os() << " elevation: " << props.elevation.data[column] << std::endl; - *vo_->os() << " aspect: " << props.aspect.data[column] << std::endl; - *vo_->os() << " slope: " << props.slope.data[column] << std::endl; - for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { @@ -938,7 +888,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.atm_n2o = atm_n2o_; props.atm_h2 = atm_h2_; props.atm_nh3 = atm_nh3_; - + props.heat_capacity = c_m_; } void EcoSIM::CopyFromEcoSIM_process(const int column, @@ -1007,17 +957,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, for (int col=0; col!=num_columns_local; ++col) { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "surface source after EcoSIM run: " << std::endl; - *vo_->os() << "surface energy source (from state): " << surface_energy_source[column] << std::endl; if (has_gas) { - *vo_->os() << "Looping over gas data: " << std::endl; auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Tags::DEFAULT, saturation_gas_key_).ViewComponent("cell",false))(0); auto& gas_density = *(*S_->GetW(gas_density_key_, Tags::DEFAULT, gas_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "For cell " << i << ": " << std::endl; - *vo_->os() << " gas density: " << state.gas_density.data[column][i] << std::endl; - *vo_->os() << " gas saturation: " << props.gas_saturation.data[column][i] << std::endl; (*col_g_dens)[i] = state.gas_density.data[column][i]; (*col_g_sat)[i] = props.gas_saturation.data[column][i]; } @@ -1031,10 +975,6 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& ice_density = *(*S_->GetW(ice_density_key_, Tags::DEFAULT, ice_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "Looping over ice data: " << std::endl; - *vo_->os() << "For cell " << i << ": " << std::endl; - *vo_->os() << " ice density: " << state.ice_density.data[column][i] << std::endl; - *vo_->os() << " ice saturation: " << props.ice_saturation.data[column][i] << std::endl; (*col_i_dens)[i] = state.ice_density.data[column][i]; (*col_i_sat)[i] = props.ice_saturation.data[column][i]; } @@ -1067,70 +1007,9 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; } - *vo_->os() << "Printing all after data:" << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - if (i==0) { - *vo_->os() << "For cell " << i << ":" << std::endl; - *vo_->os() << " liquid density: " << state.liquid_density.data[column][i] << std::endl; - *vo_->os() << " porosity: " << state.porosity.data[column][i] << std::endl; - *vo_->os() << " water content: " << state.water_content.data[column][i] << std::endl; - *vo_->os() << " hydraulic_cond: " << state.hydraulic_conductivity.data[column][i] << std::endl; - *vo_->os() << " bulk density: " << state.bulk_density.data[column][i] << std::endl; - *vo_->os() << " water source: " << state.subsurface_water_source.data[column][i] << std::endl; - *vo_->os() << " energy source: " << state.subsurface_energy_source.data[column][i] << std::endl; - //state.suction_head.data[i] = (*col_suc)[i]; - *vo_->os() << " plant wilting factor: " << props.plant_wilting_factor.data[column][i] << std::endl; - *vo_->os() << " rooting depth fraction: " << props.rooting_depth_fraction.data[column][i] << std::endl; - *vo_->os() << " liquid saturation: " << props.liquid_saturation.data[column][i] << std::endl; - *vo_->os() << " relative permeability: " << props.relative_permeability.data[column][i] << std::endl; - *vo_->os() << " volume: " << props.volume.data[column][i] << std::endl; - *vo_->os() << " depth: " << props.depth.data[column][i] << std::endl; - - if (has_gas) { - *vo_->os() << " gas saturation: " << props.gas_saturation.data[column][i] << std::endl; - *vo_->os() << " gas density: " << state.gas_density.data[column][i] << std::endl; - } - - if (has_ice) { - *vo_->os() << " ice density: " << state.ice_density.data[column][i] << std::endl; - *vo_->os() << " ice saturation: " << props.ice_saturation.data[column][i] << std::endl; - } - - if (has_energy) { - *vo_->os() << " temperature: " << state.temperature.data[column][i] << std::endl; - *vo_->os() << " thermal conductivity: " << props.thermal_conductivity.data[column][i] << std::endl; - } - } - } - - //fill surface variables - *vo_->os() << " surface energy source: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << " surface water source: " << state.surface_water_source.data[column] << std::endl; - - *vo_->os() << " shortwave radiation: " << props.shortwave_radiation.data[column] << std::endl; - *vo_->os() << " longwave radiation: " << props.longwave_radiation.data[column] << std::endl; - *vo_->os() << " air temperature: " << props.air_temperature.data[column] << std::endl; - *vo_->os() << " vapor pressure air: " << props.vapor_pressure_air.data[column] << std::endl; - *vo_->os() << " wind speed: " << props.wind_speed.data[column] << std::endl; - *vo_->os() << " precipitation: " << props.precipitation.data[column] << std::endl; - *vo_->os() << " elevation: " << props.elevation.data[column] << std::endl; - *vo_->os() << " aspect: " << props.aspect.data[column] << std::endl; - *vo_->os() << " slope: " << props.slope.data[column] << std::endl; - - //*vo_->os() << "Attempting to set state value " << std::endl; - //surface_energy_source[column] = state.surface_energy_source.data[column]; - - //*vo_->os() << "Energy after equating to EcoSIM value: " << std::endl; - //*vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; - //*vo_->os() << "surface energy source (from State): " << surface_energy_source[column] << std::endl; - //*vo_->os() << "surface source vars after: " << std::endl; - //*vo_->os() << "surface water source: " << state.surface_water_source.data[column] << std::endl; - //*vo_->os() << "surface energy source: " << state.surface_energy_source.data[column] << std::endl; - //*vo_->os() << "Just printing directly from state:" << std::endl; auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); - //*vo_->os() << new_e_source << std::endl; - + *vo_->os() << "Printing column to field:" << std::endl; *vo_->os() << "liquid sat" << std::endl; ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index c662bc4ba..f6c059dda 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -144,6 +144,7 @@ extern "C" { double atm_n2o; double atm_h2; double atm_nh3; + double heat_capacity; } BGCProperties; /* From 7dc224057a37dd86d39fc363d7deb29f846874d9 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 8 Nov 2023 16:19:32 -0800 Subject: [PATCH 505/582] adding WP and FC params --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 8 ++++++-- src/pks/ecosim/data/BGC_containers.hh | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 8afc9c6c8..6e3483916 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -93,8 +93,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //Other cell_volume_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); //ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); - f_wp_key_ = Keys::readKey(*plist_, domain_, "plant wilting factor", "plant_wilting_factor"); - f_root_key_ = Keys::readKey(*plist_, domain_, "rooting depth fraction", "rooting_depth_fraction"); + f_wp_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); + f_root_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); //Custom Evaluator keys hydraulic_conductivity_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); @@ -121,6 +121,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, atm_n2o_ = plist_->get("atmospheric N2O"); atm_h2_ = plist_->get("atmospheric H2"); atm_nh3_ = plist_->get("atmospheric NH3"); + pressure_at_field_capacity = plist_->get("Field Capacity [Mpa < 0]"); + pressure_at_wilting_point = plist_->get("Wilting Point [Mpa < 0]"); dt_ = plist_->get("initial time step", 1.); c_m_ = plist_->get("heat capacity [J mol^-1 K^-1]"); @@ -889,6 +891,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.atm_h2 = atm_h2_; props.atm_nh3 = atm_nh3_; props.heat_capacity = c_m_; + props.field_capacity = pressure_at_field_capacity; + props.wilting_point = pressure_at_wilting_point; } void EcoSIM::CopyFromEcoSIM_process(const int column, diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index f6c059dda..fd88cef11 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -145,6 +145,8 @@ extern "C" { double atm_h2; double atm_nh3; double heat_capacity; + double field_capacity; + double wilting_point; } BGCProperties; /* From 428d01e2d99448499d50bc9d86cdb76ea7fad210 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Nov 2023 13:39:40 -0800 Subject: [PATCH 506/582] trying to add suction head --- .../wrm/wrm_permafrost_evaluator.cc | 8 ++++++++ .../wrm/wrm_permafrost_evaluator.hh | 1 + .../flow/constitutive_relations/wrm/wrm_van_genuchten.cc | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc index 8eeb7088b..9026f0a99 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc @@ -134,6 +134,11 @@ WRMPermafrostEvaluator::InitializeFromPlist_() pc_ice_key_ = Keys::readKey( plist_, domain_name, "liquid-ice capillary pressure", "capillary_pressure_liq_ice"); dependencies_.insert(KeyTag{ pc_ice_key_, tag }); + + suction_head_key_ = Keys::readKey( + plist_, domain_name, "suction head", "suction_head"); + dependencies_.insert(KeyTag{ suction_head_key_, tag}); + ) } @@ -184,6 +189,9 @@ WRMPermafrostEvaluator::Evaluate_(const State& S, const std::vector(pc_ice_key_, tag)->ViewComponent("boundary_face", false); + const Epetra_MultiVector& suction_head = + *S.GetPtr(suction_head_key_, tag)->ViewComponent("boundary_face", false); + // Need to get boundary face's inner cell to specify the WRM. Teuchos::RCP mesh = results[0]->Mesh(); const Epetra_Map& vandelay_map = mesh->exterior_face_map(false); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh index 489c04149..1b567f2da 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh @@ -55,6 +55,7 @@ class WRMPermafrostEvaluator : public EvaluatorSecondaryMonotypeCV { protected: Key pc_liq_key_; Key pc_ice_key_; + Key suction_head_key_; Teuchos::RCP permafrost_models_; Teuchos::RCP wrms_; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc index 8eaf4f3d7..08711c3b7 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc @@ -124,8 +124,8 @@ WRMVanGenuchten::capillaryPressure(double s) double se = (s - sr_) / (1.0 - sr_); se = std::min(se, 1.0); se = std::max(se, 1.e-40); - - std::cout << "Is Capillary pressure running?"; + + //std::cout << "Is Capillary pressure running?"; if (se < 1.e-8) { return std::pow(se, -1.0 / (m_ * n_)) / alpha_; } else { From b4e2e148c89f67f920155e7d6cb80b1283316fc6 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Nov 2023 17:33:41 -0800 Subject: [PATCH 507/582] attempting to add suction head more broadly to flow --- src/pks/flow/constitutive_relations/wrm/wrm.hh | 4 ++-- .../wrm/wrm_permafrost_evaluator.cc | 9 ++++----- .../wrm/wrm_van_genuchten.cc | 1 + src/pks/flow/permafrost_pk.cc | 15 +++++++++++++++ src/pks/flow/richards_pk.cc | 14 ++++++++++++++ 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/pks/flow/constitutive_relations/wrm/wrm.hh b/src/pks/flow/constitutive_relations/wrm/wrm.hh index c1f82f799..483eb90cd 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm.hh @@ -54,8 +54,8 @@ class WRM { virtual double capillaryPressure(double saturation) = 0; virtual double d_capillaryPressure(double saturation) = 0; virtual double residualSaturation() = 0; - virtual double suction_head(double saturation) { return 0.; }; - virtual double d_suction_head(double saturation) { return 0.; }; + virtual double suction_head(double saturation) = 0; + virtual double d_suction_head(double saturation) = 0.; }; typedef double (WRM::*KRelFn)(double pc); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc index 9026f0a99..9a4e9a754 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc @@ -135,10 +135,9 @@ WRMPermafrostEvaluator::InitializeFromPlist_() plist_, domain_name, "liquid-ice capillary pressure", "capillary_pressure_liq_ice"); dependencies_.insert(KeyTag{ pc_ice_key_, tag }); - suction_head_key_ = Keys::readKey( + /*suction_head_key_ = Keys::readKey( plist_, domain_name, "suction head", "suction_head"); - dependencies_.insert(KeyTag{ suction_head_key_, tag}); - ) + dependencies_.insert(KeyTag{ suction_head_key_, tag});*/ } @@ -189,8 +188,8 @@ WRMPermafrostEvaluator::Evaluate_(const State& S, const std::vector(pc_ice_key_, tag)->ViewComponent("boundary_face", false); - const Epetra_MultiVector& suction_head = - *S.GetPtr(suction_head_key_, tag)->ViewComponent("boundary_face", false); + //const Epetra_MultiVector& suction_head = + // *S.GetPtr(suction_head_key_, tag)->ViewComponent("boundary_face", false); // Need to get boundary face's inner cell to specify the WRM. Teuchos::RCP mesh = results[0]->Mesh(); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc index 08711c3b7..7935718bf 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc @@ -232,6 +232,7 @@ WRMVanGenuchten::InitializeFromPlist_() /* ****************************************************************** * Suction formula: input is liquid saturation. ****************************************************************** */ + double WRMVanGenuchten::suction_head(double s) { diff --git a/src/pks/flow/permafrost_pk.cc b/src/pks/flow/permafrost_pk.cc index 125be7a33..fbfe5205c 100644 --- a/src/pks/flow/permafrost_pk.cc +++ b/src/pks/flow/permafrost_pk.cc @@ -21,6 +21,7 @@ #include "wrm_permafrost_evaluator.hh" #include "rel_perm_evaluator.hh" #include "rel_perm_sutraice_evaluator.hh" +#include "suction_head_evaluator.hh" #include "pk_helpers.hh" #include "permafrost.hh" @@ -68,6 +69,13 @@ Permafrost::SetupPhysicalEvaluators_() kr_plist.setParameters(S_->GetEvaluatorList(sat_key_)); kr_plist.set("evaluator type", "WRM rel perm"); } + std::cout << "coef_key_ = " << coef_key_ <HasEvaluator(suction_head_key_, tag_next_) && + (S_->GetEvaluatorList(suction_head_key_).numParams() == 0)) { + Teuchos::ParameterList& kr_plist = S_->GetEvaluatorList(suction_head_key_); + kr_plist.setParameters(S_->GetEvaluatorList(sat_key_)); + kr_plist.set("evaluator type", "WRM suction head"); + } // -- saturation requireAtNext(sat_key_, tag_next_, *S_) @@ -101,6 +109,13 @@ Permafrost::SetupPhysicalEvaluators_() ->AddComponent("cell", AmanziMesh::CELL, 1) ->AddComponent("boundary_face", AmanziMesh::BOUNDARY_FACE, 1); + // -- the rel perm evaluator, also with the same underlying WRM. + requireAtNext(suction_head_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1) + ->AddComponent("boundary_face", AmanziMesh::BOUNDARY_FACE, 1); + // -- get the WRM models auto wrm_eval = dynamic_cast(&wrm); AMANZI_ASSERT(wrm_eval != nullptr); diff --git a/src/pks/flow/richards_pk.cc b/src/pks/flow/richards_pk.cc index 8eb0fa080..8f919f2db 100644 --- a/src/pks/flow/richards_pk.cc +++ b/src/pks/flow/richards_pk.cc @@ -24,6 +24,7 @@ #include "predictor_delegate_bc_flux.hh" #include "wrm_evaluator.hh" #include "rel_perm_evaluator.hh" +#include "suction_head_evaluator.hh" #include "richards_water_content_evaluator.hh" #include "OperatorDefs.hh" #include "BoundaryFlux.hh" @@ -83,6 +84,7 @@ Richards::Richards(Teuchos::ParameterList& pk_tree, Keys::readKey(*plist_, domain_, "capillary_pressure_gas_liq", "capillary_pressure_gas_liq"); capillary_pressure_liq_ice_key_ = Keys::readKey(*plist_, domain_, "capillary_pressure_liq_ice", "capillary_pressure_liq_ice"); + suction_head_key_ = Keys::readKey(*plist_, domain_, "suction_head", "suction head"); if (S_->IsDeformableMesh(domain_)) deform_key_ = Keys::readKey(*plist_, domain_, "deformation indicator", "base_porosity"); @@ -99,6 +101,11 @@ Richards::Richards(Teuchos::ParameterList& pk_tree, kr_plist.setParameters(S_->GetEvaluatorList(sat_key_)); kr_plist.set("evaluator type", "WRM rel perm"); } + if (S_->GetEvaluatorList(suction_head_key_).numParams() == 0) { + Teuchos::ParameterList& sh_plist = S_->GetEvaluatorList(suction_head_key_); + sh_plist.setParameters(S_->GetEvaluatorList(sat_key_)); + sh_plist.set("evaluator type", "WRM suction head"); + } // scaling for permeability for better "nondimensionalization" perm_scale_ = plist_->get("permeability rescaling", 1.e7); @@ -468,6 +475,13 @@ Richards::SetupPhysicalEvaluators_() ->AddComponent("cell", AmanziMesh::CELL, 1) ->AddComponent("boundary_face", AmanziMesh::BOUNDARY_FACE, 1); + // -- rel perm + requireAtNext(suction_head_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1) + ->AddComponent("boundary_face", AmanziMesh::BOUNDARY_FACE, 1); + // -- get the WRM models auto wrm_eval = dynamic_cast(&wrm); AMANZI_ASSERT(wrm_eval != nullptr); From c1eaa54d6af7c66cc1211ebe5afa6ae34bbfb537 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Nov 2023 16:20:15 -0800 Subject: [PATCH 508/582] trying to add suction head --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 4 +- .../matric_pressure/matric_pressure.py | 26 +++ .../matric_pressure_evaluator.cc | 150 ++++++++++++++++++ .../matric_pressure_evaluator.hh | 54 +++++++ .../matric_pressure_evaluator_reg.hh | 11 ++ .../matric_pressure/matric_pressure_model.cc | 60 +++++++ .../matric_pressure/matric_pressure_model.hh | 42 +++++ .../evaluator_generator.py | 28 ++-- 8 files changed, 360 insertions(+), 15 deletions(-) create mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure.py create mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc create mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh create mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh create mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc create mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 6e3483916..6e3af4faa 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -121,8 +121,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, atm_n2o_ = plist_->get("atmospheric N2O"); atm_h2_ = plist_->get("atmospheric H2"); atm_nh3_ = plist_->get("atmospheric NH3"); - pressure_at_field_capacity = plist_->get("Field Capacity [Mpa < 0]"); - pressure_at_wilting_point = plist_->get("Wilting Point [Mpa < 0]"); + pressure_at_field_capacity = plist_->get("Field Capacity [Mpa]"); + pressure_at_wilting_point = plist_->get("Wilting Point [Mpa]"); dt_ = plist_->get("initial time step", 1.); c_m_ = plist_->get("heat capacity [J mol^-1 K^-1]"); diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure.py b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure.py new file mode 100644 index 000000000..d0adeacce --- /dev/null +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure.py @@ -0,0 +1,26 @@ +"""Richards water content evaluator: the standard form as a function of liquid saturation.""" + +import sys, os +sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) +from evaluator_generator import generate_evaluator + +deps = [("porosity", "phi"), + ("saturation_liquid", "sl"), + ("molar_density_liquid", "nl"), + ("cell_volume", "cv") + ] + +params = [("alpha", "double", "van genuchten alpha"), +("m", "double", "van genuchten m"), +("n", "double", "van genuchten n"), +("sr", "double", "residual saturation") +] + +import sympy +phi, sl, nl, cv = sympy.var("phi,sl,nl,cv") +alpha_, m_, n_, sr_ = sympy.var("alpha_,m_,n_,sr_") +expression = -1/(alpha_**n_) * (1 - ((sl - sr_)/(cv*nl*phi - sr_))**(1/m_))**(-n_) + +generate_evaluator("matric_pressure", "flow", + "matric pressure", "matric_pressure", + deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc new file mode 100644 index 000000000..0e589aef8 --- /dev/null +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc @@ -0,0 +1,150 @@ +/* + The hydraulic conductivity evaluator is an algebraic evaluator of a given model. +Richards water content evaluator: the standard form as a function of liquid saturation. + Generated via evaluator_generator. +*/ + +#include "hydraulic_conductivity_evaluator.hh" +#include "hydraulic_conductivity_model.hh" + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +// Constructor from ParameterList +HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(Teuchos::ParameterList& plist) : + EvaluatorSecondaryMonotypeCV(plist) +{ + Teuchos::ParameterList& sublist = plist_.sublist("hydraulic_conductivity parameters"); + model_ = Teuchos::rcp(new HydraulicConductivityModel(sublist)); + InitializeFromPlist_(); +} + + +// Copy constructor +//Don't seem to need this +/*HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other) : + EvaluatorSecondaryMonotypeCV(other), + k_key_(other.k_key_), + rho_key_(other.rho_key_), + mu_key_(other.mu_key_), + model_(other.model_) {}*/ + + +// Virtual copy constructor +Teuchos::RCP +HydraulicConductivityEvaluator::Clone() const +{ + return Teuchos::rcp(new HydraulicConductivityEvaluator(*this)); +} + + +// Initialize by setting up dependencies +void +HydraulicConductivityEvaluator::InitializeFromPlist_() +{ + // Set up my dependencies + // - defaults to prefixed via domain + //Key domain_name = Keys::getDomain(my_key_); + Key domain_name = Keys::getDomain(my_keys_.front().first); + Tag tag = my_keys_.front().second; + + // - pull Keys from plist + // dependency: permeability + k_key_ = Keys::readKey(plist_, domain_name, "permeability", "permeability"); + dependencies_.insert(KeyTag{ k_key_, tag }); + + // dependency: mass_density_liquid + rho_key_ = Keys::readKey(plist_, domain_name, "mass density liquid", "mass_density_liquid"); + dependencies_.insert(KeyTag{ rho_key_, tag}); + + // dependency: viscosity_liquid + mu_key_ = Keys::readKey(plist_, domain_name, "viscosity liquid", "viscosity_liquid"); + dependencies_.insert(KeyTag{ mu_key_, tag}); +} + + +void +HydraulicConductivityEvaluator::Evaluate_(const State& S, + const std::vector& result) +{ + Tag tag = my_keys_.front().second; + Teuchos::RCP k = S.GetPtr(k_key_, tag); + Teuchos::RCP rho = S.GetPtr(rho_key_, tag); + Teuchos::RCP mu = S.GetPtr(mu_key_, tag); + + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { + const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); + + int ncomp = result[0]->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->HydraulicConductivity(k_v[0][i], rho_v[0][i], mu_v[0][i]); + } + } +} + + +void +HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) +{ + Tag tag = my_keys_.front().second; + Teuchos::RCP k = S.GetPtr(k_key_, tag); + Teuchos::RCP rho = S.GetPtr(rho_key_, tag); + Teuchos::RCP mu = S.GetPtr(mu_key_, tag); + + if (wrt_key == k_key_) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { + const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); + + int ncomp = result[0]->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DHydraulicConductivityDPermeability(k_v[0][i], rho_v[0][i], mu_v[0][i]); + } + } + + } else if (wrt_key == rho_key_) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { + const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); + + int ncomp = result[0]->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DHydraulicConductivityDMassDensityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); + } + } + + } else if (wrt_key == mu_key_) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { + const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); + + int ncomp = result[0]->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DHydraulicConductivityDViscosityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); + } + } + + } else { + AMANZI_ASSERT(0); + } +} + + +} //namespace +} //namespace +} //namespace diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh new file mode 100644 index 000000000..c9255d435 --- /dev/null +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh @@ -0,0 +1,54 @@ +/* + The hydraulic conductivity evaluator is an algebraic evaluator of a given model. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#ifndef AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ +#define AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +class HydraulicConductivityModel; + +class HydraulicConductivityEvaluator : public EvaluatorSecondaryMonotypeCV { + public: + explicit HydraulicConductivityEvaluator(Teuchos::ParameterList& plist); + HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other) = default; + virtual Teuchos::RCP Clone() const override; + + Teuchos::RCP get_model() { return model_; } + + protected: + // Required methods from EvaluatorSecondaryMonotypeCV + virtual void Evaluate_(const State& S, + const std::vector& result) override; + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) override; + + void InitializeFromPlist_(); + + Key k_key_; + Key rho_key_; + Key mu_key_; + + Teuchos::RCP model_; + + private: + static Utils::RegisteredFactory reg_; + +}; + +} //namespace +} //namespace +} //namespace + +#endif diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh new file mode 100644 index 000000000..63570e4a7 --- /dev/null +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh @@ -0,0 +1,11 @@ +#include "hydraulic_conductivity_evaluator.hh" + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +Utils::RegisteredFactory HydraulicConductivityEvaluator::reg_("hydraulic conductivity"); + +} //namespace +} //namespace +} //namespace diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc new file mode 100644 index 000000000..976c73c4b --- /dev/null +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc @@ -0,0 +1,60 @@ +/* + The hydraulic conductivity model is an algebraic model with dependencies. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#include "Teuchos_ParameterList.hpp" +#include "dbc.hh" +#include "hydraulic_conductivity_model.hh" + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +// Constructor from ParameterList +HydraulicConductivityModel::HydraulicConductivityModel(Teuchos::ParameterList& plist) +{ + InitializeFromPlist_(plist); +} + + +// Initialize parameters +void +HydraulicConductivityModel::InitializeFromPlist_(Teuchos::ParameterList& plist) +{ + //g_ = plist.get("gravitational constant"); +} + + +// main method +double +HydraulicConductivityModel::HydraulicConductivity(double k, double rho, double mu) const +{ + return k*rho; +} + +double +HydraulicConductivityModel::DHydraulicConductivityDPermeability(double k, double rho, double mu) const +{ + return rho; +} + +double +HydraulicConductivityModel::DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const +{ + return k; +} + +double +HydraulicConductivityModel::DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const +{ + return 0; +} + +} //namespace +} //namespace +} //namespace diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh new file mode 100644 index 000000000..f7a07f425 --- /dev/null +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh @@ -0,0 +1,42 @@ +/* + The hydraulic conductivity model is an algebraic model with dependencies. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#ifndef AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ +#define AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +class HydraulicConductivityModel { + + public: + explicit + HydraulicConductivityModel(Teuchos::ParameterList& plist); + + double HydraulicConductivity(double k, double rho, double mu) const; + + double DHydraulicConductivityDPermeability(double k, double rho, double mu) const; + double DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const; + double DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const; + + protected: + void InitializeFromPlist_(Teuchos::ParameterList& plist); + + protected: + + double g_; + +}; + +} //namespace +} //namespace +} //namespace + +#endif diff --git a/tools/evaluator_generator/evaluator_generator.py b/tools/evaluator_generator/evaluator_generator.py index 19057fcca..be85332aa 100644 --- a/tools/evaluator_generator/evaluator_generator.py +++ b/tools/evaluator_generator/evaluator_generator.py @@ -9,15 +9,17 @@ def loadTemplate(tname): _templates[tname] = tfid.read()[:-1] # python seems to force end of file with newline character even though it is not there? def render(tname, d): + print(tname) try: template = _templates[tname] except KeyError: loadTemplate(tname) - template = _templates[tname] + template = _templates[tname] - assert type(d) is dict + assert type(d) is dict + print("Contents of dictionary (d):", d) return template.format(**d) - + class EvalGen(object): def __init__(self, name, namespace, descriptor, my_key=None, expression=None, doc=None, **kwargs): @@ -76,7 +78,7 @@ def renderCopyConstructor(self): return '\n'.join([render('evaluator_keyCopyConstructor.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) def renderKeyDeclaration(self): - return '\n'.join([render('evaluator_keyDeclaration.hh', dict(arg=arg,var=var)) for arg,var in zip(self.args, self.vars)]) + return '\n'.join([render('evaluator_keyDeclaration.hh', dict(arg=arg, var=var)) for arg, var in zip(self.args, self.vars)]) def renderKeyInitialize(self): dicts = [] @@ -85,12 +87,12 @@ def renderKeyInitialize(self): return '\n\n'.join([render('evaluator_keyInitialize.cc', argdict) for argdict in dicts]) def renderKeyCompositeVector(self): - return '\n'.join([render('evaluator_keyCompositeVector.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) + return '\n'.join([render('evaluator_keyCompositeVector.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) def renderKeyEpetraVector(self): - return '\n'.join([render('evaluator_keyEpetraVector.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) + return '\n'.join([render('evaluator_keyEpetraVector.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) def renderKeyEpetraVectorIndented(self): - return '\n'.join([render('evaluator_keyEpetraVectorIndented.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) + return '\n'.join([render('evaluator_keyEpetraVectorIndented.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) def renderMyMethodArgs(self): return ", ".join(["%s_v[0][i]"%var for var in self.vars]) @@ -115,7 +117,7 @@ def getDict(arg,var): d['wrtMethod'] = ''.join([word[0].upper()+word[1:] for word in arg.split("_")]) d['myMethodArgs'] = self.renderMyMethodArgs() return d - + if len(self.args) > 0: d = getDict(self.args[0], self.vars[0]) d['if_elseif'] = render('evaluator_ifWRT.cc', d) @@ -132,7 +134,7 @@ def getDict(arg,var): " }"])) return "\n\n".join(wrt_list) - + def renderModelMethodDeclaration(self): return render('model_declaration.hh', dict(myMethod=self.d['myKeyMethod'], myMethodDeclarationArgs=self.d['myMethodDeclarationArgs'])) @@ -167,7 +169,7 @@ def renderModelDerivImplementations(self): myMethodDeclarationArgs=self.d['myMethodDeclarationArgs'], myMethodImplementation=implementation))) return '\n\n'.join(impls) - + def renderModelParamDeclarations(self): return '\n'.join([' %s %s;'%p for p in self.pars]) @@ -261,8 +263,8 @@ def generate_evaluator(name, namespace, descriptor, my_key, dependencies, parame fid.write(render(outfile, eg.d)) - - + + if __name__ == "__main__": eg = EvalGen("iem", "energy", "internal energy", "internal_energy", evalClassName='IEM') eg.addArg("temperature", "temp"); @@ -273,4 +275,4 @@ def generate_evaluator(name, namespace, descriptor, my_key, dependencies, parame print (render("evaluator.cc", eg.d)) print (render("evaluator_reg.hh", eg.d)) print (render("model.hh", eg.d)) - print (render("model.cc", eg.d)) + print (render("model.cc", eg.d)) From a32768c75aee9c4ad33ef7070d5d9a77f5276136 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Nov 2023 14:40:45 -0800 Subject: [PATCH 509/582] original addition of the matric pressure evaluator --- .../matric_pressure_evaluator.cc | 109 ++++++++---------- .../matric_pressure_evaluator.hh | 27 ++--- .../matric_pressure_evaluator_reg.hh | 6 +- .../matric_pressure/matric_pressure_model.cc | 31 ++--- .../matric_pressure/matric_pressure_model.hh | 18 ++- .../evaluator_generator.py | 4 +- 6 files changed, 85 insertions(+), 110 deletions(-) diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc index 0e589aef8..aa0cb56b7 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc @@ -1,31 +1,31 @@ /* - The hydraulic conductivity evaluator is an algebraic evaluator of a given model. + The matric pressure evaluator is an algebraic evaluator of a given model. Richards water content evaluator: the standard form as a function of liquid saturation. Generated via evaluator_generator. */ -#include "hydraulic_conductivity_evaluator.hh" -#include "hydraulic_conductivity_model.hh" +#include "matric_pressure_evaluator.hh" +#include "matric_pressure_model.hh" namespace Amanzi { -namespace Ecosim { +namespace Flow { namespace Relations { // Constructor from ParameterList -HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(Teuchos::ParameterList& plist) : +MatricPressureEvaluator::MatricPressureEvaluator(Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(plist) { - Teuchos::ParameterList& sublist = plist_.sublist("hydraulic_conductivity parameters"); - model_ = Teuchos::rcp(new HydraulicConductivityModel(sublist)); + Teuchos::ParameterList& sublist = plist_.sublist("matric_pressure parameters"); + model_ = Teuchos::rcp(new MatricPressureModel(sublist)); InitializeFromPlist_(); } // Copy constructor //Don't seem to need this -/*HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other) : +/*MatricPressureEvaluator::MatricPressureEvaluator(const MatricPressureEvaluator& other) : EvaluatorSecondaryMonotypeCV(other), - k_key_(other.k_key_), + k_key_(other.k_key_) rho_key_(other.rho_key_), mu_key_(other.mu_key_), model_(other.model_) {}*/ @@ -33,15 +33,15 @@ HydraulicConductivityEvaluator::HydraulicConductivityEvaluator(Teuchos::Paramete // Virtual copy constructor Teuchos::RCP -HydraulicConductivityEvaluator::Clone() const +MatricPressureEvaluator::Clone() const { - return Teuchos::rcp(new HydraulicConductivityEvaluator(*this)); + return Teuchos::rcp(new MatricPressureEvaluator(*this)); } // Initialize by setting up dependencies void -HydraulicConductivityEvaluator::InitializeFromPlist_() +MatricPressureEvaluator::InitializeFromPlist_() { // Set up my dependencies // - defaults to prefixed via domain @@ -51,95 +51,76 @@ HydraulicConductivityEvaluator::InitializeFromPlist_() // - pull Keys from plist // dependency: permeability - k_key_ = Keys::readKey(plist_, domain_name, "permeability", "permeability"); - dependencies_.insert(KeyTag{ k_key_, tag }); + porosity_key_ = Keys::readKey(plist_, domain_name, "porosity", "porosity"); + dependencies_.insert(KeyTag{ porosity_key_, tag }); - // dependency: mass_density_liquid - rho_key_ = Keys::readKey(plist_, domain_name, "mass density liquid", "mass_density_liquid"); - dependencies_.insert(KeyTag{ rho_key_, tag}); + // dependency: saturation_liquid + water_content_key_ = Keys::readKey(plist_, domain_name, "water content", "water_content"); + dependencies_.insert(KeyTag{ water_content_key_, tag}); - // dependency: viscosity_liquid - mu_key_ = Keys::readKey(plist_, domain_name, "viscosity liquid", "viscosity_liquid"); - dependencies_.insert(KeyTag{ mu_key_, tag}); + // dependency: molar density liquid + mdens_liquid_key_ = Keys::readKey(plist_, domain_name, "molar density liquid", "molar_density_liquid"); + dependencies_.insert(KeyTag{ mdens_liquid_key_, tag}); + + // dependency: cell volume + cv_key_ = Keys::readKey(plist_, domain_name, "cell volume", "cell_volume"); + dependencies_.insert(KeyTag{ cv_key_, tag}); } void -HydraulicConductivityEvaluator::Evaluate_(const State& S, +MatricPressureEvaluator::Evaluate_(const State& S, const std::vector& result) { Tag tag = my_keys_.front().second; - Teuchos::RCP k = S.GetPtr(k_key_, tag); - Teuchos::RCP rho = S.GetPtr(rho_key_, tag); - Teuchos::RCP mu = S.GetPtr(mu_key_, tag); + Teuchos::RCP phi = S.GetPtr(porosity_key_, tag); + Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); + Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); + Teuchos::RCP cv = S.GetPtr(cv_key_, tag); for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->HydraulicConductivity(k_v[0][i], rho_v[0][i], mu_v[0][i]); + result_v[0][i] = model_->MatricPressure(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i]); } } } void -HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, +MatricPressureEvaluator::EvaluatePartialDerivative_(const State& S, const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) { Tag tag = my_keys_.front().second; - Teuchos::RCP k = S.GetPtr(k_key_, tag); - Teuchos::RCP rho = S.GetPtr(rho_key_, tag); - Teuchos::RCP mu = S.GetPtr(mu_key_, tag); + Teuchos::RCP phi = S.GetPtr(porosity_key_, tag); + Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); + Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); + Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == k_key_) { for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); - const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DHydraulicConductivityDPermeability(k_v[0][i], rho_v[0][i], mu_v[0][i]); - } - } - - } else if (wrt_key == rho_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); - const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DHydraulicConductivityDMassDensityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); - } - } - - } else if (wrt_key == mu_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); - const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& mu_v = *mu->ViewComponent(*comp, false); + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DHydraulicConductivityDViscosityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); + result_v[0][i] = model_->DMatricPressureDPorosity(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i]); } } - } else { + } + else { AMANZI_ASSERT(0); } } diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh index c9255d435..ee185369c 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh @@ -7,25 +7,25 @@ Richards water content evaluator: the standard form as a function of liquid satu Authors: Ethan Coon (ecoon@lanl.gov) */ -#ifndef AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ -#define AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_EVALUATOR_HH_ +#ifndef AMANZI_FLOW_MATRIC_PRESSURE_EVALUATOR_HH_ +#define AMANZI_FLOW_MATRIC_PRESSURE_EVALUATOR_HH_ #include "Factory.hh" #include "EvaluatorSecondaryMonotype.hh" namespace Amanzi { -namespace Ecosim { +namespace Flow { namespace Relations { -class HydraulicConductivityModel; +class MatricPressureModel; -class HydraulicConductivityEvaluator : public EvaluatorSecondaryMonotypeCV { +class MatricPressureEvaluator : public EvaluatorSecondaryMonotypeCV { public: - explicit HydraulicConductivityEvaluator(Teuchos::ParameterList& plist); - HydraulicConductivityEvaluator(const HydraulicConductivityEvaluator& other) = default; + explicit MatricPressureEvaluator(Teuchos::ParameterList& plist); + MatricPressureEvaluator(const MatricPressureEvaluator& other) = default; virtual Teuchos::RCP Clone() const override; - Teuchos::RCP get_model() { return model_; } + Teuchos::RCP get_model() { return model_; } protected: // Required methods from EvaluatorSecondaryMonotypeCV @@ -36,14 +36,15 @@ class HydraulicConductivityEvaluator : public EvaluatorSecondaryMonotypeCV { void InitializeFromPlist_(); - Key k_key_; - Key rho_key_; - Key mu_key_; + Key porosity_key_; + Key water_content_key_; + Key mdens_liquid_key_; + Key cv_key_ - Teuchos::RCP model_; + Teuchos::RCP model_; private: - static Utils::RegisteredFactory reg_; + static Utils::RegisteredFactory reg_; }; diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh index 63570e4a7..3d994ab2f 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh @@ -1,10 +1,10 @@ -#include "hydraulic_conductivity_evaluator.hh" +#include "matric_pressure_evaluator.hh" namespace Amanzi { -namespace Ecosim { +namespace Flow { namespace Relations { -Utils::RegisteredFactory HydraulicConductivityEvaluator::reg_("hydraulic conductivity"); +Utils::RegisteredFactory MatricPressureEvaluator::reg_("matric pressure"); } //namespace } //namespace diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc index 976c73c4b..91855eab7 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc @@ -16,7 +16,7 @@ namespace Ecosim { namespace Relations { // Constructor from ParameterList -HydraulicConductivityModel::HydraulicConductivityModel(Teuchos::ParameterList& plist) +MatricPressureModel::MatricPressureModel(Teuchos::ParameterList& plist) { InitializeFromPlist_(plist); } @@ -24,35 +24,28 @@ HydraulicConductivityModel::HydraulicConductivityModel(Teuchos::ParameterList& p // Initialize parameters void -HydraulicConductivityModel::InitializeFromPlist_(Teuchos::ParameterList& plist) +MatricPressureModel::InitializeFromPlist_(Teuchos::ParameterList& plist) { - //g_ = plist.get("gravitational constant"); + m_ = plist.get("van genuchten m"); + n_ = plist.get("van genuchten n"); + alpha_ = plist.get("van genuchten alpha"); + sr_ = plist.get("residual saturation [-]"); } // main method double -HydraulicConductivityModel::HydraulicConductivity(double k, double rho, double mu) const +MatricPressureModel::MatricPressure(double phi, double theta, double rho, double cv) const { - return k*rho; + theta_r = cv*rho*phi*sr_; //This is water content at residual saturation + theta_s = cv*rho*phi; //This is the water content at saturation + return -1.0 / std::pow(alpha_, n_) * std::pow(1.0 - std::pow((theta - theta_r) / (theta_s - theta_r), 1.0 / m_), -n_); } double -HydraulicConductivityModel::DHydraulicConductivityDPermeability(double k, double rho, double mu) const +MatricPressureModel::DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const { - return rho; -} - -double -HydraulicConductivityModel::DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const -{ - return k; -} - -double -HydraulicConductivityModel::DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const -{ - return 0; + return 1.0; } } //namespace diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh index f7a07f425..d56b7c1aa 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh @@ -7,31 +7,29 @@ Richards water content evaluator: the standard form as a function of liquid satu Authors: Ethan Coon (ecoon@lanl.gov) */ -#ifndef AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ -#define AMANZI_ECOSIM_HYDRAULIC_CONDUCTIVITY_MODEL_HH_ +#ifndef AMANZI_FLOW_MATRIC_PRESSURE_MODEL_HH_ +#define AMANZI_FLOW_MATRIC_PRESSURE_MODEL_HH_ namespace Amanzi { -namespace Ecosim { +namespace Flow { namespace Relations { -class HydraulicConductivityModel { +class MatricPressureModel { public: explicit - HydraulicConductivityModel(Teuchos::ParameterList& plist); + MatricPressureModel(Teuchos::ParameterList& plist); - double HydraulicConductivity(double k, double rho, double mu) const; + double MatricPressure(double phi, double theta, double rho, double cv) const; - double DHydraulicConductivityDPermeability(double k, double rho, double mu) const; - double DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const; - double DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const; + double DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const; protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); protected: - double g_; + double m_, n_, alpha_, theta_r_; }; diff --git a/tools/evaluator_generator/evaluator_generator.py b/tools/evaluator_generator/evaluator_generator.py index be85332aa..a651867cf 100644 --- a/tools/evaluator_generator/evaluator_generator.py +++ b/tools/evaluator_generator/evaluator_generator.py @@ -18,11 +18,12 @@ def render(tname, d): assert type(d) is dict print("Contents of dictionary (d):", d) - return template.format(**d) + #return template.format(**d) class EvalGen(object): def __init__(self, name, namespace, descriptor, my_key=None, expression=None, doc=None, **kwargs): + print("what is this") self.d = {} self.setName(name, **kwargs) self.setNamespace(namespace, **kwargs) @@ -248,6 +249,7 @@ def generate_evaluator(name, namespace, descriptor, my_key, dependencies, parame eg.addArg(*dep) for par in parameters: + print(par) eg.addParam(*par) eg.genArgs() From 28c62a465fc97ec65825f891628cdae15bd8805b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Nov 2023 13:42:41 -0800 Subject: [PATCH 510/582] various minor changes and add matric pressure --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 18 ++++++++++-------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 3 ++- src/pks/flow/constitutive_relations/wrm/wrm.hh | 4 ++-- src/pks/flow/overland_pressure_pk.cc | 8 -------- src/pks/flow/permafrost_pk.cc | 15 --------------- src/pks/flow/richards_pk.cc | 14 -------------- 6 files changed, 14 insertions(+), 48 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 6e3af4faa..a17436980 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -66,7 +66,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); relative_permeability_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); - //suc_key_ = Keys::readKey(*plist_,domain_,"suction head","suction_head"); + matric_pressure_key_ = Keys::readKey(*plist_,domain_,"matric pressure","matric_pressure"); liquid_density_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_density_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); gas_density_key_ = Keys::readKey(*plist_, domain_,"mass density gas", "mass_density_gas"); @@ -419,7 +419,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); - //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); //Surface data from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -475,9 +475,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) .ViewComponent("cell",false))(0); - /*S_->GetEvaluator("suction_head", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& suction_head = *(*S_->Get("suction_head", tag_next_) - .ViewComponent("cell",false))(0);*/ + S_->GetEvaluator("matric_pressure", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& suction_head = *(*S_->Get("matric_pressure", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) @@ -723,7 +723,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& rock_density = *(*S_->Get(rock_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cell_volume_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydraulic_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& suction_head = *(*S_->Get(suc_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& matric_pressure = *(*S_->Get(matric_pressure_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); @@ -750,7 +750,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_relative_permeability = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_suc = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_mat_p = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_r_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_vol = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_g_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -797,6 +797,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,rooting_depth_fraction,col_rf.ptr()); FieldToColumn_(column,subsurface_water_source,col_ss_water_source.ptr()); FieldToColumn_(column,subsurface_energy_source,col_ss_energy_source.ptr()); + FieldToColumn_(column,matric_pressure,col_mat_p.ptr()); MatrixFieldToColumn_(column, tcc, col_tcc.ptr()); @@ -835,7 +836,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.bulk_density.data[column][i] = (*col_b_dens)[i]; state.subsurface_water_source.data[column][i] = (*col_ss_water_source)[i]; state.subsurface_energy_source.data[column][i] = (*col_ss_energy_source)[i]; - //state.suction_head.data[i] = (*col_suc)[i]; + state.matric_pressure.data[i] = (*col_mat_p)[i]; + props.plant_wilting_factor.data[column][i] = (*col_wp)[i]; props.rooting_depth_fraction.data[column][i] = (*col_rf)[i]; props.liquid_saturation.data[column][i] = (*col_l_sat)[i]; diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index cb6d75c16..abea89bf3 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -208,7 +208,7 @@ class EcoSIM : public PK_Physical { Key prain_key_; Key f_wp_key_; Key f_root_key_; - Key suc_key_; + Key matric_pressure_key_; Key aspect_key_; Key slope_key_; Key surface_energy_source_key_; @@ -220,6 +220,7 @@ class EcoSIM : public PK_Physical { Teuchos::RCP bgc_engine_; double atm_n2_, atm_o2_, atm_co2_, atm_ch4_, atm_n2o_, atm_h2_, atm_nh3_; + double pressure_at_field_capacity, pressure_at_wilting_point;:walking private: BGCState bgc_state_; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm.hh b/src/pks/flow/constitutive_relations/wrm/wrm.hh index 483eb90cd..4a449d7ae 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm.hh @@ -54,8 +54,8 @@ class WRM { virtual double capillaryPressure(double saturation) = 0; virtual double d_capillaryPressure(double saturation) = 0; virtual double residualSaturation() = 0; - virtual double suction_head(double saturation) = 0; - virtual double d_suction_head(double saturation) = 0.; + virtual double suction_head(double saturation) { return 0.; }; + virtual double d_suction_head(double saturation) = { return 0.; }; }; typedef double (WRM::*KRelFn)(double pc); diff --git a/src/pks/flow/overland_pressure_pk.cc b/src/pks/flow/overland_pressure_pk.cc index 3a5503768..1a2e701b7 100644 --- a/src/pks/flow/overland_pressure_pk.cc +++ b/src/pks/flow/overland_pressure_pk.cc @@ -1260,19 +1260,12 @@ OverlandPressureFlow::ModifyCorrection(double h, // (where pressure derivatives are discontinuous) int my_limited = 0; int n_limited_spurt = 0; - *vo_->os() << "the patm limit is: " << patm_limit_ << std::endl; if (patm_limit_ > 0.) { double patm = S_->Get("atmospheric_pressure", Tags::DEFAULT); Epetra_MultiVector& du_c = *du->Data()->ViewComponent("cell", false); const Epetra_MultiVector& u_c = *u->Data()->ViewComponent("cell", false); - - *vo_->os() << "checking u limits for du_c of size: " << du_c.MyLength << std::endl; for (int c = 0; c != du_c.MyLength(); ++c) { - *vo_->os() << "printing values for cell " << c << std::endl; - *vo_->os() << "patm = " << patm << std::endl; - *vo_->os() << "u_c[0][c] = " << u_c[0][c] << std::endl; - *vo_->os() << "du_c[0][c] = " << du_c[0][c] << std::endl; if ((u_c[0][c] < patm) && (u_c[0][c] - du_c[0][c] > patm + patm_limit_)) { du_c[0][c] = u_c[0][c] - (patm + patm_limit_); my_limited++; @@ -1285,7 +1278,6 @@ OverlandPressureFlow::ModifyCorrection(double h, } if (patm_hard_limit_) { - *vo_->os() << "In patm hard limit: " << std::endl; double patm = S_->Get("atmospheric_pressure", Tags::DEFAULT); Epetra_MultiVector& du_c = *du->Data()->ViewComponent("cell", false); diff --git a/src/pks/flow/permafrost_pk.cc b/src/pks/flow/permafrost_pk.cc index fbfe5205c..125be7a33 100644 --- a/src/pks/flow/permafrost_pk.cc +++ b/src/pks/flow/permafrost_pk.cc @@ -21,7 +21,6 @@ #include "wrm_permafrost_evaluator.hh" #include "rel_perm_evaluator.hh" #include "rel_perm_sutraice_evaluator.hh" -#include "suction_head_evaluator.hh" #include "pk_helpers.hh" #include "permafrost.hh" @@ -69,13 +68,6 @@ Permafrost::SetupPhysicalEvaluators_() kr_plist.setParameters(S_->GetEvaluatorList(sat_key_)); kr_plist.set("evaluator type", "WRM rel perm"); } - std::cout << "coef_key_ = " << coef_key_ <HasEvaluator(suction_head_key_, tag_next_) && - (S_->GetEvaluatorList(suction_head_key_).numParams() == 0)) { - Teuchos::ParameterList& kr_plist = S_->GetEvaluatorList(suction_head_key_); - kr_plist.setParameters(S_->GetEvaluatorList(sat_key_)); - kr_plist.set("evaluator type", "WRM suction head"); - } // -- saturation requireAtNext(sat_key_, tag_next_, *S_) @@ -109,13 +101,6 @@ Permafrost::SetupPhysicalEvaluators_() ->AddComponent("cell", AmanziMesh::CELL, 1) ->AddComponent("boundary_face", AmanziMesh::BOUNDARY_FACE, 1); - // -- the rel perm evaluator, also with the same underlying WRM. - requireAtNext(suction_head_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::CELL, 1) - ->AddComponent("boundary_face", AmanziMesh::BOUNDARY_FACE, 1); - // -- get the WRM models auto wrm_eval = dynamic_cast(&wrm); AMANZI_ASSERT(wrm_eval != nullptr); diff --git a/src/pks/flow/richards_pk.cc b/src/pks/flow/richards_pk.cc index 8f919f2db..8eb0fa080 100644 --- a/src/pks/flow/richards_pk.cc +++ b/src/pks/flow/richards_pk.cc @@ -24,7 +24,6 @@ #include "predictor_delegate_bc_flux.hh" #include "wrm_evaluator.hh" #include "rel_perm_evaluator.hh" -#include "suction_head_evaluator.hh" #include "richards_water_content_evaluator.hh" #include "OperatorDefs.hh" #include "BoundaryFlux.hh" @@ -84,7 +83,6 @@ Richards::Richards(Teuchos::ParameterList& pk_tree, Keys::readKey(*plist_, domain_, "capillary_pressure_gas_liq", "capillary_pressure_gas_liq"); capillary_pressure_liq_ice_key_ = Keys::readKey(*plist_, domain_, "capillary_pressure_liq_ice", "capillary_pressure_liq_ice"); - suction_head_key_ = Keys::readKey(*plist_, domain_, "suction_head", "suction head"); if (S_->IsDeformableMesh(domain_)) deform_key_ = Keys::readKey(*plist_, domain_, "deformation indicator", "base_porosity"); @@ -101,11 +99,6 @@ Richards::Richards(Teuchos::ParameterList& pk_tree, kr_plist.setParameters(S_->GetEvaluatorList(sat_key_)); kr_plist.set("evaluator type", "WRM rel perm"); } - if (S_->GetEvaluatorList(suction_head_key_).numParams() == 0) { - Teuchos::ParameterList& sh_plist = S_->GetEvaluatorList(suction_head_key_); - sh_plist.setParameters(S_->GetEvaluatorList(sat_key_)); - sh_plist.set("evaluator type", "WRM suction head"); - } // scaling for permeability for better "nondimensionalization" perm_scale_ = plist_->get("permeability rescaling", 1.e7); @@ -475,13 +468,6 @@ Richards::SetupPhysicalEvaluators_() ->AddComponent("cell", AmanziMesh::CELL, 1) ->AddComponent("boundary_face", AmanziMesh::BOUNDARY_FACE, 1); - // -- rel perm - requireAtNext(suction_head_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::CELL, 1) - ->AddComponent("boundary_face", AmanziMesh::BOUNDARY_FACE, 1); - // -- get the WRM models auto wrm_eval = dynamic_cast(&wrm); AMANZI_ASSERT(wrm_eval != nullptr); From 909c9a96643ff4d0e38b1391a4e387a5caf86f3d Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 16 Nov 2023 14:22:40 -0800 Subject: [PATCH 511/582] minor fixes, adding matric to state --- src/pks/ecosim/EcoSIM_ATS_interface.hh | 2 +- src/pks/ecosim/data/BGC_containers.hh | 2 +- src/pks/ecosim/data/BGC_memory.cc | 4 ++-- src/pks/flow/constitutive_relations/wrm/wrm.hh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index abea89bf3..5fcac6466 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -220,7 +220,7 @@ class EcoSIM : public PK_Physical { Teuchos::RCP bgc_engine_; double atm_n2_, atm_o2_, atm_co2_, atm_ch4_, atm_n2o_, atm_h2_, atm_nh3_; - double pressure_at_field_capacity, pressure_at_wilting_point;:walking + double pressure_at_field_capacity, pressure_at_wilting_point; private: BGCState bgc_state_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index fd88cef11..30fff204c 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -106,7 +106,7 @@ extern "C" { BGCMatrixDouble ice_density; BGCMatrixDouble porosity; BGCMatrixDouble water_content; - BGCMatrixDouble suction_head; + BGCMatrixDouble matric_pressure; BGCMatrixDouble temperature; BGCMatrixDouble hydraulic_conductivity; BGCMatrixDouble bulk_density; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 439f06383..b954b398d 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -317,7 +317,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->ice_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->porosity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->water_content)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->suction_head)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->matric_pressure)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->temperature)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->hydraulic_conductivity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->bulk_density)); @@ -337,7 +337,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(state->ice_density)); FreeBGCMatrixDouble(&(state->porosity)); FreeBGCMatrixDouble(&(state->water_content)); - FreeBGCMatrixDouble(&(state->suction_head)); + FreeBGCMatrixDouble(&(state->matric_pressure)); FreeBGCMatrixDouble(&(state->temperature)); FreeBGCMatrixDouble(&(state->hydraulic_conductivity)); FreeBGCMatrixDouble(&(state->bulk_density)); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm.hh b/src/pks/flow/constitutive_relations/wrm/wrm.hh index 4a449d7ae..c1f82f799 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm.hh @@ -55,7 +55,7 @@ class WRM { virtual double d_capillaryPressure(double saturation) = 0; virtual double residualSaturation() = 0; virtual double suction_head(double saturation) { return 0.; }; - virtual double d_suction_head(double saturation) = { return 0.; }; + virtual double d_suction_head(double saturation) { return 0.; }; }; typedef double (WRM::*KRelFn)(double pc); From 228880d0e143a6d816d302323cd2260c4c4c4c5b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 20 Nov 2023 11:40:55 -0800 Subject: [PATCH 512/582] modifying flow to acrtivate mp --- src/pks/flow/richards.hh | 1 + src/pks/flow/richards_pk.cc | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/pks/flow/richards.hh b/src/pks/flow/richards.hh index 0aa3f6376..2bced3035 100644 --- a/src/pks/flow/richards.hh +++ b/src/pks/flow/richards.hh @@ -447,6 +447,7 @@ class Richards : public PK_PhysicalBDF_Default { Key sat_ice_key_; Key capillary_pressure_gas_liq_key_; Key capillary_pressure_liq_ice_key_; + Key matric_pressure_key_; Key deform_key_; // debugging control diff --git a/src/pks/flow/richards_pk.cc b/src/pks/flow/richards_pk.cc index 8eb0fa080..eb95a7988 100644 --- a/src/pks/flow/richards_pk.cc +++ b/src/pks/flow/richards_pk.cc @@ -83,6 +83,7 @@ Richards::Richards(Teuchos::ParameterList& pk_tree, Keys::readKey(*plist_, domain_, "capillary_pressure_gas_liq", "capillary_pressure_gas_liq"); capillary_pressure_liq_ice_key_ = Keys::readKey(*plist_, domain_, "capillary_pressure_liq_ice", "capillary_pressure_liq_ice"); + matric_pressure_key_ = Keys::readKey(*plist_, domain_, "matric pressure", "matric_pressure"); if (S_->IsDeformableMesh(domain_)) deform_key_ = Keys::readKey(*plist_, domain_, "deformation indicator", "base_porosity"); @@ -461,6 +462,15 @@ Richards::SetupPhysicalEvaluators_() // and at the current time, where it is a copy evaluator requireAtCurrent(sat_key_, tag_current_, *S_, name_); + requireAtNext(matric_pressure_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + S_->RequireEvaluator(matric_pressure_key_, tag_next_); + + // and at the current time, where it is a copy evaluator + requireAtCurrent(sat_key_, tag_current_, *S_, name_); + // -- rel perm requireAtNext(coef_key_, tag_next_, *S_) .SetMesh(mesh_) From cf2fddb2a3c75b5962901a1920fa673d35802b22 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 20 Nov 2023 11:42:52 -0800 Subject: [PATCH 513/582] minor fix --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index a17436980..3df07c7ac 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -243,7 +243,7 @@ void EcoSIM::Initialize() { int ierr = 0; - if (S_->HasRecord(suc_key_, Tags::DEFAULT)) { + /*if (S_->HasRecord(suc_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "has suction key." << std::endl; } else { @@ -263,7 +263,7 @@ void EcoSIM::Initialize() { } else { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "Does not have suction key at next" << std::endl; - } + }*/ // Ensure dependencies are filled // May not need to update (also causes an assertion error if called before @@ -836,7 +836,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.bulk_density.data[column][i] = (*col_b_dens)[i]; state.subsurface_water_source.data[column][i] = (*col_ss_water_source)[i]; state.subsurface_energy_source.data[column][i] = (*col_ss_energy_source)[i]; - state.matric_pressure.data[i] = (*col_mat_p)[i]; + state.matric_pressure.data[column][i] = (*col_mat_p)[i]; props.plant_wilting_factor.data[column][i] = (*col_wp)[i]; props.rooting_depth_fraction.data[column][i] = (*col_rf)[i]; From 50edee3b71998fe31a55abf9a11f0875d0133927 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 20 Nov 2023 11:55:17 -0800 Subject: [PATCH 514/582] edit cmake files --- src/pks/flow/CMakeLists.txt | 1 + src/pks/flow/constitutive_relations/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/flow/CMakeLists.txt b/src/pks/flow/CMakeLists.txt index c082da5a1..0b78d825c 100644 --- a/src/pks/flow/CMakeLists.txt +++ b/src/pks/flow/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/operators/advection) include_directories(${ATS_SOURCE_DIR}/src/operators/upwinding) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/water_content) +include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/matric_pressure) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/wrm) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/overland_conductivity) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/elevation) diff --git a/src/pks/flow/constitutive_relations/CMakeLists.txt b/src/pks/flow/constitutive_relations/CMakeLists.txt index 0ee2a1947..7c636cb8d 100644 --- a/src/pks/flow/constitutive_relations/CMakeLists.txt +++ b/src/pks/flow/constitutive_relations/CMakeLists.txt @@ -7,7 +7,7 @@ # collect all sources -list(APPEND subdirs elevation overland_conductivity porosity sources water_content wrm) +list(APPEND subdirs elevation overland_conductivity porosity sources water_content wrm matric_pressure) set(ats_flow_relations_src_files "") set(ats_flow_relations_inc_files "") From fdb049469c8c13e3470cda88950943adfa0589c8 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 27 Nov 2023 14:55:20 -0800 Subject: [PATCH 515/582] Moved matric pressure and made it work --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 13 ++ .../constitutive_relations/CMakeLists.txt | 9 ++ .../matric_pressure/matric_pressure.py | 26 ++++ .../matric_pressure_evaluator.cc | 131 ++++++++++++++++++ .../matric_pressure_evaluator.hh | 56 ++++++++ .../matric_pressure_evaluator_reg.hh | 11 ++ .../matric_pressure/matric_pressure_model.cc | 50 +++++++ .../matric_pressure/matric_pressure_model.hh | 44 ++++++ .../matric_pressure_evaluator.cc | 2 +- .../matric_pressure_evaluator.hh | 6 +- .../matric_pressure/matric_pressure_model.cc | 19 ++- .../matric_pressure/matric_pressure_model.hh | 10 +- src/pks/flow/richards_pk.cc | 6 +- 13 files changed, 364 insertions(+), 19 deletions(-) create mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure.py create mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc create mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh create mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh create mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc create mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 3df07c7ac..bb5289e3c 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -220,6 +220,12 @@ void EcoSIM::Setup() { ->AddComponent("cell", AmanziMesh::CELL, 1); requireAtCurrent(bulk_density_key_, tag_current_, *S_, name_); + requireAtNext(matric_pressure_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); @@ -339,6 +345,10 @@ void EcoSIM::Initialize() { S_->GetW(bulk_density_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); S_->GetRecordW(bulk_density_key_, Tags::DEFAULT, "bulk_density").set_initialized(); + S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); + S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); + + int num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //Looping over the columns and initializing @@ -456,6 +466,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { Teuchos::RCP bulk_dens = S_->GetPtr(bulk_density_key_, Tags::DEFAULT); S_->GetEvaluator(bulk_density_key_, Tags::DEFAULT).Update(*S_, name_); + Teuchos::RCP matric_pressure = S_->GetPtr(matric_pressure_key_, Tags::DEFAULT); + S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); + AmanziMesh::Entity_ID num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); // grab the required fields diff --git a/src/pks/ecosim/constitutive_relations/CMakeLists.txt b/src/pks/ecosim/constitutive_relations/CMakeLists.txt index fcfdaea19..4e2eae25f 100644 --- a/src/pks/ecosim/constitutive_relations/CMakeLists.txt +++ b/src/pks/ecosim/constitutive_relations/CMakeLists.txt @@ -13,6 +13,8 @@ set(ats_ecosim_relations_src_files bulk_density/bulk_density_model.cc hydraulic_conductivity/hydraulic_conductivity_evaluator.cc hydraulic_conductivity/hydraulic_conductivity_model.cc + matric_pressure/matric_pressure_evaluator.cc + matric_pressure/matric_pressure_model.cc ) set(ats_ecosim_relations_inc_files @@ -20,6 +22,8 @@ set(ats_ecosim_relations_inc_files bulk_density/bulk_density_model.hh hydraulic_conductivity/hydraulic_conductivity_evaluator.hh hydraulic_conductivity/hydraulic_conductivity_model.hh + matric_pressure/matric_pressure_evaluator.hh + matric_pressure/matric_pressure_model.hh ) set(ats_ecosim_relations_link_libs @@ -57,6 +61,11 @@ register_evaluator_with_factory( LISTNAME ATS_ECOSIM_RELATIONS_REG ) +register_evaluator_with_factory( + HEADERFILE matric_pressure/matric_pressure_evaluator_reg.hh + LISTNAME ATS_ECOSIM_RELATIONS_REG +) + generate_evaluators_registration_header( HEADERFILE ats_ecosim_relations_registration.hh LISTNAME ATS_ECOSIM_RELATIONS_REG diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure.py b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure.py new file mode 100644 index 000000000..d0adeacce --- /dev/null +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure.py @@ -0,0 +1,26 @@ +"""Richards water content evaluator: the standard form as a function of liquid saturation.""" + +import sys, os +sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) +from evaluator_generator import generate_evaluator + +deps = [("porosity", "phi"), + ("saturation_liquid", "sl"), + ("molar_density_liquid", "nl"), + ("cell_volume", "cv") + ] + +params = [("alpha", "double", "van genuchten alpha"), +("m", "double", "van genuchten m"), +("n", "double", "van genuchten n"), +("sr", "double", "residual saturation") +] + +import sympy +phi, sl, nl, cv = sympy.var("phi,sl,nl,cv") +alpha_, m_, n_, sr_ = sympy.var("alpha_,m_,n_,sr_") +expression = -1/(alpha_**n_) * (1 - ((sl - sr_)/(cv*nl*phi - sr_))**(1/m_))**(-n_) + +generate_evaluator("matric_pressure", "flow", + "matric pressure", "matric_pressure", + deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc new file mode 100644 index 000000000..bf7614cce --- /dev/null +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc @@ -0,0 +1,131 @@ +/* + The matric pressure evaluator is an algebraic evaluator of a given model. +Richards water content evaluator: the standard form as a function of liquid saturation. + Generated via evaluator_generator. +*/ + +#include "matric_pressure_evaluator.hh" +#include "matric_pressure_model.hh" + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +// Constructor from ParameterList +MatricPressureEvaluator::MatricPressureEvaluator(Teuchos::ParameterList& plist) : + EvaluatorSecondaryMonotypeCV(plist) +{ + Teuchos::ParameterList& sublist = plist_.sublist("matric_pressure parameters"); + model_ = Teuchos::rcp(new MatricPressureModel(sublist)); + InitializeFromPlist_(); +} + + +// Copy constructor +//Don't seem to need this +/*MatricPressureEvaluator::MatricPressureEvaluator(const MatricPressureEvaluator& other) : + EvaluatorSecondaryMonotypeCV(other), + k_key_(other.k_key_) + rho_key_(other.rho_key_), + mu_key_(other.mu_key_), + model_(other.model_) {}*/ + + +// Virtual copy constructor +Teuchos::RCP +MatricPressureEvaluator::Clone() const +{ + return Teuchos::rcp(new MatricPressureEvaluator(*this)); +} + + +// Initialize by setting up dependencies +void +MatricPressureEvaluator::InitializeFromPlist_() +{ + // Set up my dependencies + // - defaults to prefixed via domain + //Key domain_name = Keys::getDomain(my_key_); + Key domain_name = Keys::getDomain(my_keys_.front().first); + Tag tag = my_keys_.front().second; + + // - pull Keys from plist + // dependency: permeability + porosity_key_ = Keys::readKey(plist_, domain_name, "porosity", "porosity"); + dependencies_.insert(KeyTag{ porosity_key_, tag }); + + // dependency: saturation_liquid + water_content_key_ = Keys::readKey(plist_, domain_name, "water content", "water_content"); + dependencies_.insert(KeyTag{ water_content_key_, tag}); + + // dependency: molar density liquid + mdens_liquid_key_ = Keys::readKey(plist_, domain_name, "molar density liquid", "molar_density_liquid"); + dependencies_.insert(KeyTag{ mdens_liquid_key_, tag}); + + // dependency: cell volume + cv_key_ = Keys::readKey(plist_, domain_name, "cell volume", "cell_volume"); + dependencies_.insert(KeyTag{ cv_key_, tag}); +} + + +void +MatricPressureEvaluator::Evaluate_(const State& S, + const std::vector& result) +{ + Tag tag = my_keys_.front().second; + Teuchos::RCP phi = S.GetPtr(porosity_key_, tag); + Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); + Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); + Teuchos::RCP cv = S.GetPtr(cv_key_, tag); + + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); + + int ncomp = result[0]->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->MatricPressure(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i]); + } + } +} + + +void +MatricPressureEvaluator::EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) +{ + Tag tag = my_keys_.front().second; + Teuchos::RCP phi = S.GetPtr(porosity_key_, tag); + Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); + Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); + Teuchos::RCP cv = S.GetPtr(cv_key_, tag); + + if (wrt_key == porosity_key_) { + for (CompositeVector::name_iterator comp=result[0]->begin(); + comp!=result[0]->end(); ++comp) { + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); + + int ncomp = result[0]->size(*comp, false); + for (int i=0; i!=ncomp; ++i) { + result_v[0][i] = model_->DMatricPressureDPorosity(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i]); + } + } + + } + else { + AMANZI_ASSERT(0); + } +} + + +} //namespace +} //namespace +} //namespace diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh new file mode 100644 index 000000000..854d33e40 --- /dev/null +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh @@ -0,0 +1,56 @@ +/* + The hydraulic conductivity evaluator is an algebraic evaluator of a given model. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#ifndef AMANZI_FLOW_MATRIC_PRESSURE_EVALUATOR_HH_ +#define AMANZI_FLOW_MATRIC_PRESSURE_EVALUATOR_HH_ + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +class MatricPressureModel; + +class MatricPressureEvaluator : public EvaluatorSecondaryMonotypeCV { + public: + explicit MatricPressureEvaluator(Teuchos::ParameterList& plist); + MatricPressureEvaluator(const MatricPressureEvaluator& other) = default; + virtual Teuchos::RCP Clone() const override; + + Teuchos::RCP get_model() { return model_; } + + protected: + // Required methods from EvaluatorSecondaryMonotypeCV + virtual void Evaluate_(const State& S, + const std::vector& result) override; + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) override; + + void InitializeFromPlist_(); + + protected: + Key porosity_key_; + Key water_content_key_; + Key mdens_liquid_key_; + Key cv_key_; + + Teuchos::RCP model_; + + private: + static Utils::RegisteredFactory reg_; + +}; + +} //namespace +} //namespace +} //namespace + +#endif diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh new file mode 100644 index 000000000..7609e097e --- /dev/null +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh @@ -0,0 +1,11 @@ +#include "matric_pressure_evaluator.hh" + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +Utils::RegisteredFactory MatricPressureEvaluator::reg_("matric pressure"); + +} //namespace +} //namespace +} //namespace diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc new file mode 100644 index 000000000..87f74aa8b --- /dev/null +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc @@ -0,0 +1,50 @@ +/* + The hydraulic conductivity model is an algebraic model with dependencies. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#include "Teuchos_ParameterList.hpp" +#include "dbc.hh" +#include "matric_pressure_model.hh" + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +// Constructor from ParameterList +MatricPressureModel::MatricPressureModel(Teuchos::ParameterList& plist) +{ + InitializeFromPlist_(plist); +} + + +// Initialize parameters +void MatricPressureModel::InitializeFromPlist_(Teuchos::ParameterList& plist) +{ + m_ = plist.get("van genuchten m [-]", 0.3671); + n_ = plist.get("van genuchten n [-]", 1.58); + alpha_ = plist.get("van genuchten alpha [Pa^-1]", 2e-05); + sr_ = plist.get("residual saturation [-]", 0.2); +} + + +// main method +double MatricPressureModel::MatricPressure(double phi, double theta, double rho, double cv) const +{ + //theta_r_ = cv*rho*phi*sr_; This is water content at residual saturation + //theta_s = cv*rho*phi; This is the water content at saturation + return -1.0 / std::pow(alpha_, n_) * std::pow(1.0 - std::pow((theta - cv*rho*phi*sr_) / ((cv*rho*phi) - cv*rho*phi*sr_), 1.0 / m_), -n_); +} + +double MatricPressureModel::DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const +{ + return 1.0; +} + +} //namespace +} //namespace +} //namespace diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh new file mode 100644 index 000000000..2b565c932 --- /dev/null +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh @@ -0,0 +1,44 @@ +/* + The hydraulic conductivity model is an algebraic model with dependencies. + + Generated via evaluator_generator with: +Richards water content evaluator: the standard form as a function of liquid saturation. + + Authors: Ethan Coon (ecoon@lanl.gov) +*/ + +#ifndef AMANZI_FLOW_MATRIC_PRESSURE_MODEL_HH_ +#define AMANZI_FLOW_MATRIC_PRESSURE_MODEL_HH_ + +namespace Amanzi { +namespace Ecosim { +namespace Relations { + +class MatricPressureModel { + + public: + explicit MatricPressureModel(Teuchos::ParameterList& plist); + + double MatricPressure(double phi, double theta, double rho, double cv) const; + + double DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const; + + protected: + void InitializeFromPlist_(Teuchos::ParameterList& plist); + + private: + + double m_; + double n_; + double alpha_; + double theta_r_; + double sr_; + double theta_s; + +}; + +} //namespace +} //namespace +} //namespace + +#endif diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc index aa0cb56b7..4b99b8923 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc @@ -104,7 +104,7 @@ MatricPressureEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); Teuchos::RCP cv = S.GetPtr(cv_key_, tag); - if (wrt_key == k_key_) { + if (wrt_key == porosity_key_) { for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh index ee185369c..76a674b81 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh @@ -21,7 +21,8 @@ class MatricPressureModel; class MatricPressureEvaluator : public EvaluatorSecondaryMonotypeCV { public: - explicit MatricPressureEvaluator(Teuchos::ParameterList& plist); + explicit + MatricPressureEvaluator(Teuchos::ParameterList& plist); MatricPressureEvaluator(const MatricPressureEvaluator& other) = default; virtual Teuchos::RCP Clone() const override; @@ -36,10 +37,11 @@ class MatricPressureEvaluator : public EvaluatorSecondaryMonotypeCV { void InitializeFromPlist_(); + protected: Key porosity_key_; Key water_content_key_; Key mdens_liquid_key_; - Key cv_key_ + Key cv_key_; Teuchos::RCP model_; diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc index 91855eab7..8b35907b2 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc @@ -9,10 +9,10 @@ Richards water content evaluator: the standard form as a function of liquid satu #include "Teuchos_ParameterList.hpp" #include "dbc.hh" -#include "hydraulic_conductivity_model.hh" +#include "matric_pressure_model.hh" namespace Amanzi { -namespace Ecosim { +namespace Flow { namespace Relations { // Constructor from ParameterList @@ -23,8 +23,7 @@ MatricPressureModel::MatricPressureModel(Teuchos::ParameterList& plist) // Initialize parameters -void -MatricPressureModel::InitializeFromPlist_(Teuchos::ParameterList& plist) +void MatricPressureModel::InitializeFromPlist_(Teuchos::ParameterList& plist) { m_ = plist.get("van genuchten m"); n_ = plist.get("van genuchten n"); @@ -34,16 +33,14 @@ MatricPressureModel::InitializeFromPlist_(Teuchos::ParameterList& plist) // main method -double -MatricPressureModel::MatricPressure(double phi, double theta, double rho, double cv) const +double MatricPressureModel::MatricPressure(double phi, double theta, double rho, double cv) const { - theta_r = cv*rho*phi*sr_; //This is water content at residual saturation - theta_s = cv*rho*phi; //This is the water content at saturation - return -1.0 / std::pow(alpha_, n_) * std::pow(1.0 - std::pow((theta - theta_r) / (theta_s - theta_r), 1.0 / m_), -n_); + //theta_r_ = cv*rho*phi*sr_; This is water content at residual saturation + //theta_s = cv*rho*phi; This is the water content at saturation + return -1.0 / std::pow(alpha_, n_) * std::pow(1.0 - std::pow((theta - cv*rho*phi*sr_) / ((cv*rho*phi) - cv*rho*phi*sr_), 1.0 / m_), -n_); } -double -MatricPressureModel::DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const +double MatricPressureModel::DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const { return 1.0; } diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh index d56b7c1aa..a0afa5b99 100644 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh +++ b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh @@ -18,6 +18,7 @@ class MatricPressureModel { public: explicit + MatricPressureModel(Teuchos::ParameterList& plist); double MatricPressure(double phi, double theta, double rho, double cv) const; @@ -27,9 +28,14 @@ class MatricPressureModel { protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); - protected: + private: - double m_, n_, alpha_, theta_r_; + double m_; + double n_; + double alpha_; + double theta_r_; + double sr_; + double theta_s; }; diff --git a/src/pks/flow/richards_pk.cc b/src/pks/flow/richards_pk.cc index eb95a7988..c1b009f45 100644 --- a/src/pks/flow/richards_pk.cc +++ b/src/pks/flow/richards_pk.cc @@ -83,7 +83,7 @@ Richards::Richards(Teuchos::ParameterList& pk_tree, Keys::readKey(*plist_, domain_, "capillary_pressure_gas_liq", "capillary_pressure_gas_liq"); capillary_pressure_liq_ice_key_ = Keys::readKey(*plist_, domain_, "capillary_pressure_liq_ice", "capillary_pressure_liq_ice"); - matric_pressure_key_ = Keys::readKey(*plist_, domain_, "matric pressure", "matric_pressure"); + //matric_pressure_key_ = Keys::readKey(*plist_, domain_, "matric pressure", "matric_pressure"); if (S_->IsDeformableMesh(domain_)) deform_key_ = Keys::readKey(*plist_, domain_, "deformation indicator", "base_porosity"); @@ -462,12 +462,12 @@ Richards::SetupPhysicalEvaluators_() // and at the current time, where it is a copy evaluator requireAtCurrent(sat_key_, tag_current_, *S_, name_); - requireAtNext(matric_pressure_key_, tag_next_, *S_) + /*requireAtNext(matric_pressure_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); S_->RequireEvaluator(matric_pressure_key_, tag_next_); - + */ // and at the current time, where it is a copy evaluator requireAtCurrent(sat_key_, tag_current_, *S_, name_); From 4228fe7fbaa8c84a5aa8a7074bea5bd01cdb11be Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 28 Nov 2023 16:19:08 -0800 Subject: [PATCH 516/582] adding some prints --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index bb5289e3c..4ae822e06 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -875,7 +875,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } } //fill surface variables + state.surface_energy_source.data[column] = surface_energy_source[column]; + + *vo_->os() << "Column " << column << std::endl; + *vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; + state.surface_water_source.data[column] = surface_water_source[column]; props.shortwave_radiation.data[column] = shortwave_radiation[column]; @@ -1026,19 +1032,25 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; } - auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); + *vo_->os() << "Before setting" << column << std::endl; + *vo_->os() << "Column " << column << std::endl; + *vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; + + surface_energy_source[column] = state.surface_energy_source.data[column]; + *vo_->os() << "After setting" << column << std::endl; + *vo_->os() << "Column " << column << std::endl; + *vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; + *vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; - *vo_->os() << "Printing column to field:" << std::endl; - *vo_->os() << "liquid sat" << std::endl; + auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); + + *vo_->os() << "bulk dens" << std::endl; ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); - *vo_->os() << "water content" << std::endl; ColumnToField_(column,water_content,col_wc.ptr()); - *vo_->os() << "rel perm" << std::endl; ColumnToField_(column,relative_permeability,col_relative_permeability.ptr()); - *vo_->os() << "hydraulic cond" << std::endl; ColumnToField_(column,hydraulic_conductivity,col_h_cond.ptr()); - *vo_->os() << "bulk dens" << std::endl; ColumnToField_(column,bulk_density,col_b_dens.ptr()); //ColumnToField_(column,plant_wilting_factor,col_wp.ptr()); //ColumnToField_(column,rooting_depth_fraction,col_rf.ptr()); From 31165cf372bcf9cb4ce2a9ac70fa8750aee326da Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Nov 2023 11:26:26 -0800 Subject: [PATCH 517/582] checking depth variables --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 4ae822e06..be3381dbd 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -841,6 +841,11 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, // This is for computing depth ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); + *vo_->os() << "Column " << column << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "Depth["<< i << "] = " << (*col_depth)[i] << "Dz["<< i << "] = " << (*col_dz)[i] << std::endl; + } + for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[column][i] = (*col_l_dens)[i]; state.porosity.data[column][i] = (*col_porosity)[i]; From 7a2aae86733ed7b34f015ba78ad884b3ad741e9f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 30 Nov 2023 12:00:14 -0800 Subject: [PATCH 518/582] adding cumulative depth --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 9 +++++++++ src/pks/ecosim/data/BGC_containers.hh | 1 + src/pks/ecosim/data/BGC_memory.cc | 1 + 3 files changed, 11 insertions(+) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index be3381dbd..adde3edbc 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -780,6 +780,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_rf = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_energy_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_depth_c = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); @@ -845,6 +846,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, for (int i=0; i < ncells_per_col_; ++i) { *vo_->os() << "Depth["<< i << "] = " << (*col_depth)[i] << "Dz["<< i << "] = " << (*col_dz)[i] << std::endl; } + double sum = 0.0; + for (int i = 0; i < ncells_per_col_; ++i) { + sum += (*col_dz)[i]; + (*col_depth_c)[i] = sum; + } + + std::reverse(col_depth_c->begin(), col_depth_c->end()); for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[column][i] = (*col_l_dens)[i]; @@ -862,6 +870,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.relative_permeability.data[column][i] = (*col_relative_permeability)[i]; props.volume.data[column][i] = (*col_vol)[i]; props.depth.data[column][i] = (*col_depth)[i]; + props.depth_c.data[column][i] = (*col_depth_c)[i]; props.dz.data[column][i] = (*col_dz)[i]; if (has_gas) { diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 30fff204c..44d95319e 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -125,6 +125,7 @@ extern "C" { BGCMatrixDouble thermal_conductivity; BGCMatrixDouble volume; BGCMatrixDouble depth; + BGCMatrixDouble depth_c BGCMatrixDouble dz; BGCMatrixDouble plant_wilting_factor; BGCMatrixDouble rooting_depth_fraction; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index b954b398d..460a5a660 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -392,6 +392,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->thermal_conductivity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->volume)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->depth)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->depth_c)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->dz)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->plant_wilting_factor)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->rooting_depth_fraction)); From 0fd4195113bcacc681fd60e4cc1976d0fbb89d2c Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 30 Nov 2023 13:56:22 -0800 Subject: [PATCH 519/582] fixes to make reverse cumulative --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 13 ++++++------- src/pks/ecosim/data/BGC_containers.hh | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index adde3edbc..269577adb 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -842,18 +842,17 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, // This is for computing depth ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); - *vo_->os() << "Column " << column << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "Depth["<< i << "] = " << (*col_depth)[i] << "Dz["<< i << "] = " << (*col_dz)[i] << std::endl; - } double sum = 0.0; - for (int i = 0; i < ncells_per_col_; ++i) { + for (int i = ncells_per_col_ - 1; i >= 0; --i) { sum += (*col_dz)[i]; (*col_depth_c)[i] = sum; } - - std::reverse(col_depth_c->begin(), col_depth_c->end()); + *vo_->os() << "Column " << column << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "Depth["<< i << "] = " << (*col_depth)[i] << " Depth_Reversed["<< i << "] = " << (*col_depth_c)[i] << std::endl; + } + for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[column][i] = (*col_l_dens)[i]; state.porosity.data[column][i] = (*col_porosity)[i]; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 44d95319e..764e470a3 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -125,7 +125,7 @@ extern "C" { BGCMatrixDouble thermal_conductivity; BGCMatrixDouble volume; BGCMatrixDouble depth; - BGCMatrixDouble depth_c + BGCMatrixDouble depth_c; BGCMatrixDouble dz; BGCMatrixDouble plant_wilting_factor; BGCMatrixDouble rooting_depth_fraction; From d077d119fdc451fe64bee44bdf65aab28e581ef8 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Sat, 9 Dec 2023 12:58:54 -0800 Subject: [PATCH 520/582] minor fixes --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 79 +++++++++++-------- .../constitutive_relations/CMakeLists.txt | 4 + 2 files changed, 51 insertions(+), 32 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 269577adb..c570a202c 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -454,10 +454,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(ice_density_key_, Tags::DEFAULT).Update(*S_, name_); } - if (has_energy) { - S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(thermal_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); - } + S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(thermal_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); //Update owned evaluators Teuchos::RCP hydra_cond = S_->GetPtr(hydraulic_conductivity_key_, Tags::DEFAULT); @@ -569,15 +567,13 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false))(0); } - if (has_energy) { - S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& temp = *(*S_->Get("temperature", tag_next_) - .ViewComponent("cell",false))(0); + S_->GetEvaluator("temperature", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& temp = *(*S_->Get("temperature", tag_next_) + .ViewComponent("cell",false))(0); - S_->GetEvaluator("thermal_conductivity", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& thermal_conductivity = *(*S_->Get("thermal_conductivity", tag_next_) - .ViewComponent("cell",false))(0); - } + S_->GetEvaluator("thermal_conductivity", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& thermal_conductivity = *(*S_->Get("thermal_conductivity", tag_next_) + .ViewComponent("cell",false))(0); //loop over processes instead: num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); @@ -831,13 +827,11 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,ice_density,col_i_dens.ptr()); } - if (has_energy) { - const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - FieldToColumn_(column,temp, col_temp.ptr()); - FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); - } + FieldToColumn_(column,temp, col_temp.ptr()); + FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); // This is for computing depth ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); @@ -882,15 +876,18 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.ice_saturation.data[column][i] = (*col_i_sat)[i]; } - if (has_energy) { - state.temperature.data[column][i] = (*col_temp)[i]; - props.thermal_conductivity.data[column][i] = (*col_cond)[i]; - } + state.temperature.data[column][i] = (*col_temp)[i]; + props.thermal_conductivity.data[column][i] = (*col_cond)[i]; } //fill surface variables state.surface_energy_source.data[column] = surface_energy_source[column]; + *vo_->os() << "printing temperature:"; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "temp["<< i << "] = " << (*col_temp)[i] << std::endl; + } + *vo_->os() << "Column " << column << std::endl; *vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; *vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; @@ -907,6 +904,26 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; + *vo_->os() << "Variable: surface_water_source, Value: " << state.surface_water_source.data[column] << std::endl; + *vo_->os() << "Variable: shortwave_radiation, Value: " << shortwave_radiation[column] << std::endl; + *vo_->os() << "Variable without [column]: shortwave_radiation, Value: " << shortwave_radiation << std::endl; + *vo_->os() << "Variable: longwave_radiation, Value: " << longwave_radiation[column] << std::endl; + *vo_->os() << "Variable without [column]: longwave_radiation, Value: " << longwave_radiation << std::endl; + *vo_->os() << "Variable: air_temperature, Value: " << air_temperature[column] << std::endl; + *vo_->os() << "Variable without [column]: air_temperature, Value: " << air_temperature << std::endl; + *vo_->os() << "Variable: vapor_pressure_air, Value: " << vapor_pressure_air[column] << std::endl; + *vo_->os() << "Variable without [column]: vapor_pressure_air, Value: " << vapor_pressure_air << std::endl; + *vo_->os() << "Variable: wind_speed, Value: " << wind_speed[column] << std::endl; + *vo_->os() << "Variable without [column]: wind_speed, Value: " << wind_speed << std::endl; + *vo_->os() << "Variable: precipitation, Value: " << precipitation[column] << std::endl; + *vo_->os() << "Variable without [column]: precipitation, Value: " << precipitation << std::endl; + *vo_->os() << "Variable: elevation, Value: " << elevation[column] << std::endl; + *vo_->os() << "Variable without [column]: elevation, Value: " << elevation << std::endl; + *vo_->os() << "Variable: aspect, Value: " << aspect[column] << std::endl; + *vo_->os() << "Variable without [column]: aspect, Value: " << aspect << std::endl; + *vo_->os() << "Variable: slope, Value: " << slope[column] << std::endl; + *vo_->os() << "Variable without [column]: slope, Value: " << slope << std::endl; + for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { @@ -1021,19 +1038,17 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, ColumnToField_(column,ice_density,col_i_dens.ptr()); } - if (has_energy) { - auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); - auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); + auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); + auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); - for (int i=0; i < ncells_per_col_; ++i) { - (*col_temp)[i] = state.temperature.data[column][i]; - (*col_cond)[i] = props.thermal_conductivity.data[column][i]; - } - - ColumnToField_(column,temp, col_temp.ptr()); - ColumnToField_(column,thermal_conductivity,col_cond.ptr()); + for (int i=0; i < ncells_per_col_; ++i) { + (*col_temp)[i] = state.temperature.data[column][i]; + (*col_cond)[i] = props.thermal_conductivity.data[column][i]; } + ColumnToField_(column,temp, col_temp.ptr()); + ColumnToField_(column,thermal_conductivity,col_cond.ptr()); + for (int i=0; i < ncells_per_col_; ++i) { (*col_l_dens)[i] = state.liquid_density.data[column][i]; (*col_porosity)[i] = state.porosity.data[column][i]; diff --git a/src/pks/flow/constitutive_relations/CMakeLists.txt b/src/pks/flow/constitutive_relations/CMakeLists.txt index 7c636cb8d..909975d4e 100644 --- a/src/pks/flow/constitutive_relations/CMakeLists.txt +++ b/src/pks/flow/constitutive_relations/CMakeLists.txt @@ -12,7 +12,9 @@ list(APPEND subdirs elevation overland_conductivity porosity sources water_conte set(ats_flow_relations_src_files "") set(ats_flow_relations_inc_files "") +message("printing subdirs:") foreach(lcv IN LISTS subdirs) + message("${lcv}") include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/${lcv}) file(GLOB subdir_sources "./${lcv}/*.cc") @@ -22,7 +24,9 @@ foreach(lcv IN LISTS subdirs) set(ats_flow_relations_inc_files ${ats_flow_relations_inc_files} ${subdir_incs}) file(GLOB registrations "./${lcv}/*_reg.hh" ) + message("printing reg files:") foreach(reg_lcv IN LISTS registrations) + message("${reg_lcv}") register_abs_evaluator_with_factory(HEADERFILE ${reg_lcv} LISTNAME ATS_FLOW_RELATIONS_REG) endforeach(reg_lcv) From 18845164f9bbfa22ae43a5e0637c46751f11497b Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 13 Dec 2023 15:03:22 -0800 Subject: [PATCH 521/582] more changes --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 36 +------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index c570a202c..c7c734c60 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -411,10 +411,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { << " t1 = " << S_->get_time(tag_next_) << " h = " << dt << std::endl << "----------------------------------------------------------------" << std::endl; - /**vo_->os() << "Testing WRMs" << std::endl; - double s_test = 0.5; - double suction_head = wrm_->suction_head(s_test);*/ - + // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); @@ -904,26 +901,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; - *vo_->os() << "Variable: surface_water_source, Value: " << state.surface_water_source.data[column] << std::endl; - *vo_->os() << "Variable: shortwave_radiation, Value: " << shortwave_radiation[column] << std::endl; - *vo_->os() << "Variable without [column]: shortwave_radiation, Value: " << shortwave_radiation << std::endl; - *vo_->os() << "Variable: longwave_radiation, Value: " << longwave_radiation[column] << std::endl; - *vo_->os() << "Variable without [column]: longwave_radiation, Value: " << longwave_radiation << std::endl; - *vo_->os() << "Variable: air_temperature, Value: " << air_temperature[column] << std::endl; - *vo_->os() << "Variable without [column]: air_temperature, Value: " << air_temperature << std::endl; - *vo_->os() << "Variable: vapor_pressure_air, Value: " << vapor_pressure_air[column] << std::endl; - *vo_->os() << "Variable without [column]: vapor_pressure_air, Value: " << vapor_pressure_air << std::endl; - *vo_->os() << "Variable: wind_speed, Value: " << wind_speed[column] << std::endl; - *vo_->os() << "Variable without [column]: wind_speed, Value: " << wind_speed << std::endl; - *vo_->os() << "Variable: precipitation, Value: " << precipitation[column] << std::endl; - *vo_->os() << "Variable without [column]: precipitation, Value: " << precipitation << std::endl; - *vo_->os() << "Variable: elevation, Value: " << elevation[column] << std::endl; - *vo_->os() << "Variable without [column]: elevation, Value: " << elevation << std::endl; - *vo_->os() << "Variable: aspect, Value: " << aspect[column] << std::endl; - *vo_->os() << "Variable without [column]: aspect, Value: " << aspect << std::endl; - *vo_->os() << "Variable: slope, Value: " << slope[column] << std::endl; - *vo_->os() << "Variable without [column]: slope, Value: " << slope << std::endl; - for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { @@ -1060,21 +1037,10 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; } - *vo_->os() << "Before setting" << column << std::endl; - *vo_->os() << "Column " << column << std::endl; - *vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; - surface_energy_source[column] = state.surface_energy_source.data[column]; - *vo_->os() << "After setting" << column << std::endl; - *vo_->os() << "Column " << column << std::endl; - *vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; - auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); - *vo_->os() << "bulk dens" << std::endl; ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); ColumnToField_(column,water_content,col_wc.ptr()); ColumnToField_(column,relative_permeability,col_relative_permeability.ptr()); From fb6f760edb42972002f3e1499ced34edc193251e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 13 Dec 2023 15:14:38 -0800 Subject: [PATCH 522/582] Testing different energy methods --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index c7c734c60..4081334a8 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1037,7 +1037,15 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; } - surface_energy_source[column] = state.surface_energy_source.data[column]; + double energy_source_tot = state.surface_energy_source.data[column]; + + *vo_->os() << "ATS timestep: " << dt << " s" << std::endl; + *vo_->os() << "Total energy from EcoSIM: " << energy_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << energy_source_tot/(3600.0) << " MJ/s" <os() << "Rate to conserve total energy from EcoSIM: " << energy_source_tot/dt << " MJ/s" <os() << "testing using flux conservation: " << std::endl; + + surface_energy_source[column] = state.surface_energy_source.data[column]/(3600.0); auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); From e4f093f7963119753e933c69e74e3411506ed6c2 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 14 Dec 2023 12:03:09 -0800 Subject: [PATCH 523/582] Removing some prints and fixing timestep error --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 4081334a8..c4e291876 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -124,7 +124,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, pressure_at_field_capacity = plist_->get("Field Capacity [Mpa]"); pressure_at_wilting_point = plist_->get("Wilting Point [Mpa]"); - dt_ = plist_->get("initial time step", 1.); + dt_ = plist_->get("initial time step"); c_m_ = plist_->get("heat capacity [J mol^-1 K^-1]"); //Teuchos::OSTab tab = vo_->getOSTab(); @@ -839,10 +839,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, (*col_depth_c)[i] = sum; } - *vo_->os() << "Column " << column << std::endl; + /**vo_->os() << "Column " << column << std::endl; for (int i=0; i < ncells_per_col_; ++i) { *vo_->os() << "Depth["<< i << "] = " << (*col_depth)[i] << " Depth_Reversed["<< i << "] = " << (*col_depth_c)[i] << std::endl; - } + }*/ for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[column][i] = (*col_l_dens)[i]; @@ -880,10 +880,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.surface_energy_source.data[column] = surface_energy_source[column]; - *vo_->os() << "printing temperature:"; + /**vo_->os() << "printing temperature:"; for (int i=0; i < ncells_per_col_; ++i) { *vo_->os() << "temp["<< i << "] = " << (*col_temp)[i] << std::endl; - } + }*/ *vo_->os() << "Column " << column << std::endl; *vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; From 8324a3fb3b540fd12913ccba51902b843ed33f4f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 14 Dec 2023 12:06:18 -0800 Subject: [PATCH 524/582] minor fix --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index c4e291876..eca7ee6d1 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1039,10 +1039,10 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, double energy_source_tot = state.surface_energy_source.data[column]; - *vo_->os() << "ATS timestep: " << dt << " s" << std::endl; + *vo_->os() << "ATS timestep: " << dt_ << " s" << std::endl; *vo_->os() << "Total energy from EcoSIM: " << energy_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << energy_source_tot/(3600.0) << " MJ/s" <os() << "Rate to conserve total energy from EcoSIM: " << energy_source_tot/dt << " MJ/s" <os() << "Rate to conserve total energy from EcoSIM: " << energy_source_tot/dt_ << " MJ/s" <os() << "testing using flux conservation: " << std::endl; surface_energy_source[column] = state.surface_energy_source.data[column]/(3600.0); From a5139b93ca3239caaba06cc01e27bb2ddad870bf Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 21 Dec 2023 11:26:44 -0800 Subject: [PATCH 525/582] deleting matric pressure eval from flow --- src/pks/ecosim/CMakeLists.txt | 1 + src/pks/flow/CMakeLists.txt | 2 +- .../constitutive_relations/CMakeLists.txt | 4 - .../matric_pressure/matric_pressure.py | 26 ---- .../matric_pressure_evaluator.cc | 131 ------------------ .../matric_pressure_evaluator.hh | 57 -------- .../matric_pressure_evaluator_reg.hh | 11 -- .../matric_pressure/matric_pressure_model.cc | 50 ------- .../matric_pressure/matric_pressure_model.hh | 46 ------ 9 files changed, 2 insertions(+), 326 deletions(-) delete mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure.py delete mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc delete mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh delete mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh delete mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc delete mode 100644 src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 90d2e7e45..90244e18a 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/data) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) +include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) diff --git a/src/pks/flow/CMakeLists.txt b/src/pks/flow/CMakeLists.txt index 0b78d825c..9957a62be 100644 --- a/src/pks/flow/CMakeLists.txt +++ b/src/pks/flow/CMakeLists.txt @@ -12,7 +12,7 @@ include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/operators/advection) include_directories(${ATS_SOURCE_DIR}/src/operators/upwinding) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/water_content) -include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/matric_pressure) +#include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/matric_pressure) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/wrm) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/overland_conductivity) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/elevation) diff --git a/src/pks/flow/constitutive_relations/CMakeLists.txt b/src/pks/flow/constitutive_relations/CMakeLists.txt index 909975d4e..7c636cb8d 100644 --- a/src/pks/flow/constitutive_relations/CMakeLists.txt +++ b/src/pks/flow/constitutive_relations/CMakeLists.txt @@ -12,9 +12,7 @@ list(APPEND subdirs elevation overland_conductivity porosity sources water_conte set(ats_flow_relations_src_files "") set(ats_flow_relations_inc_files "") -message("printing subdirs:") foreach(lcv IN LISTS subdirs) - message("${lcv}") include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/${lcv}) file(GLOB subdir_sources "./${lcv}/*.cc") @@ -24,9 +22,7 @@ foreach(lcv IN LISTS subdirs) set(ats_flow_relations_inc_files ${ats_flow_relations_inc_files} ${subdir_incs}) file(GLOB registrations "./${lcv}/*_reg.hh" ) - message("printing reg files:") foreach(reg_lcv IN LISTS registrations) - message("${reg_lcv}") register_abs_evaluator_with_factory(HEADERFILE ${reg_lcv} LISTNAME ATS_FLOW_RELATIONS_REG) endforeach(reg_lcv) diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure.py b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure.py deleted file mode 100644 index d0adeacce..000000000 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Richards water content evaluator: the standard form as a function of liquid saturation.""" - -import sys, os -sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) -from evaluator_generator import generate_evaluator - -deps = [("porosity", "phi"), - ("saturation_liquid", "sl"), - ("molar_density_liquid", "nl"), - ("cell_volume", "cv") - ] - -params = [("alpha", "double", "van genuchten alpha"), -("m", "double", "van genuchten m"), -("n", "double", "van genuchten n"), -("sr", "double", "residual saturation") -] - -import sympy -phi, sl, nl, cv = sympy.var("phi,sl,nl,cv") -alpha_, m_, n_, sr_ = sympy.var("alpha_,m_,n_,sr_") -expression = -1/(alpha_**n_) * (1 - ((sl - sr_)/(cv*nl*phi - sr_))**(1/m_))**(-n_) - -generate_evaluator("matric_pressure", "flow", - "matric pressure", "matric_pressure", - deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc deleted file mode 100644 index 4b99b8923..000000000 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* - The matric pressure evaluator is an algebraic evaluator of a given model. -Richards water content evaluator: the standard form as a function of liquid saturation. - Generated via evaluator_generator. -*/ - -#include "matric_pressure_evaluator.hh" -#include "matric_pressure_model.hh" - -namespace Amanzi { -namespace Flow { -namespace Relations { - -// Constructor from ParameterList -MatricPressureEvaluator::MatricPressureEvaluator(Teuchos::ParameterList& plist) : - EvaluatorSecondaryMonotypeCV(plist) -{ - Teuchos::ParameterList& sublist = plist_.sublist("matric_pressure parameters"); - model_ = Teuchos::rcp(new MatricPressureModel(sublist)); - InitializeFromPlist_(); -} - - -// Copy constructor -//Don't seem to need this -/*MatricPressureEvaluator::MatricPressureEvaluator(const MatricPressureEvaluator& other) : - EvaluatorSecondaryMonotypeCV(other), - k_key_(other.k_key_) - rho_key_(other.rho_key_), - mu_key_(other.mu_key_), - model_(other.model_) {}*/ - - -// Virtual copy constructor -Teuchos::RCP -MatricPressureEvaluator::Clone() const -{ - return Teuchos::rcp(new MatricPressureEvaluator(*this)); -} - - -// Initialize by setting up dependencies -void -MatricPressureEvaluator::InitializeFromPlist_() -{ - // Set up my dependencies - // - defaults to prefixed via domain - //Key domain_name = Keys::getDomain(my_key_); - Key domain_name = Keys::getDomain(my_keys_.front().first); - Tag tag = my_keys_.front().second; - - // - pull Keys from plist - // dependency: permeability - porosity_key_ = Keys::readKey(plist_, domain_name, "porosity", "porosity"); - dependencies_.insert(KeyTag{ porosity_key_, tag }); - - // dependency: saturation_liquid - water_content_key_ = Keys::readKey(plist_, domain_name, "water content", "water_content"); - dependencies_.insert(KeyTag{ water_content_key_, tag}); - - // dependency: molar density liquid - mdens_liquid_key_ = Keys::readKey(plist_, domain_name, "molar density liquid", "molar_density_liquid"); - dependencies_.insert(KeyTag{ mdens_liquid_key_, tag}); - - // dependency: cell volume - cv_key_ = Keys::readKey(plist_, domain_name, "cell volume", "cell_volume"); - dependencies_.insert(KeyTag{ cv_key_, tag}); -} - - -void -MatricPressureEvaluator::Evaluate_(const State& S, - const std::vector& result) -{ - Tag tag = my_keys_.front().second; - Teuchos::RCP phi = S.GetPtr(porosity_key_, tag); - Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); - Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); - Teuchos::RCP cv = S.GetPtr(cv_key_, tag); - - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); - const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->MatricPressure(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i]); - } - } -} - - -void -MatricPressureEvaluator::EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) -{ - Tag tag = my_keys_.front().second; - Teuchos::RCP phi = S.GetPtr(porosity_key_, tag); - Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); - Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); - Teuchos::RCP cv = S.GetPtr(cv_key_, tag); - - if (wrt_key == porosity_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); - const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DMatricPressureDPorosity(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i]); - } - } - - } - else { - AMANZI_ASSERT(0); - } -} - - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh deleted file mode 100644 index 76a674b81..000000000 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh +++ /dev/null @@ -1,57 +0,0 @@ -/* - The hydraulic conductivity evaluator is an algebraic evaluator of a given model. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#ifndef AMANZI_FLOW_MATRIC_PRESSURE_EVALUATOR_HH_ -#define AMANZI_FLOW_MATRIC_PRESSURE_EVALUATOR_HH_ - -#include "Factory.hh" -#include "EvaluatorSecondaryMonotype.hh" - -namespace Amanzi { -namespace Flow { -namespace Relations { - -class MatricPressureModel; - -class MatricPressureEvaluator : public EvaluatorSecondaryMonotypeCV { - public: - explicit - MatricPressureEvaluator(Teuchos::ParameterList& plist); - MatricPressureEvaluator(const MatricPressureEvaluator& other) = default; - virtual Teuchos::RCP Clone() const override; - - Teuchos::RCP get_model() { return model_; } - - protected: - // Required methods from EvaluatorSecondaryMonotypeCV - virtual void Evaluate_(const State& S, - const std::vector& result) override; - virtual void EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) override; - - void InitializeFromPlist_(); - - protected: - Key porosity_key_; - Key water_content_key_; - Key mdens_liquid_key_; - Key cv_key_; - - Teuchos::RCP model_; - - private: - static Utils::RegisteredFactory reg_; - -}; - -} //namespace -} //namespace -} //namespace - -#endif diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh deleted file mode 100644 index 3d994ab2f..000000000 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh +++ /dev/null @@ -1,11 +0,0 @@ -#include "matric_pressure_evaluator.hh" - -namespace Amanzi { -namespace Flow { -namespace Relations { - -Utils::RegisteredFactory MatricPressureEvaluator::reg_("matric pressure"); - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc deleted file mode 100644 index 8b35907b2..000000000 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* - The hydraulic conductivity model is an algebraic model with dependencies. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#include "Teuchos_ParameterList.hpp" -#include "dbc.hh" -#include "matric_pressure_model.hh" - -namespace Amanzi { -namespace Flow { -namespace Relations { - -// Constructor from ParameterList -MatricPressureModel::MatricPressureModel(Teuchos::ParameterList& plist) -{ - InitializeFromPlist_(plist); -} - - -// Initialize parameters -void MatricPressureModel::InitializeFromPlist_(Teuchos::ParameterList& plist) -{ - m_ = plist.get("van genuchten m"); - n_ = plist.get("van genuchten n"); - alpha_ = plist.get("van genuchten alpha"); - sr_ = plist.get("residual saturation [-]"); -} - - -// main method -double MatricPressureModel::MatricPressure(double phi, double theta, double rho, double cv) const -{ - //theta_r_ = cv*rho*phi*sr_; This is water content at residual saturation - //theta_s = cv*rho*phi; This is the water content at saturation - return -1.0 / std::pow(alpha_, n_) * std::pow(1.0 - std::pow((theta - cv*rho*phi*sr_) / ((cv*rho*phi) - cv*rho*phi*sr_), 1.0 / m_), -n_); -} - -double MatricPressureModel::DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const -{ - return 1.0; -} - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh b/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh deleted file mode 100644 index a0afa5b99..000000000 --- a/src/pks/flow/constitutive_relations/matric_pressure/matric_pressure_model.hh +++ /dev/null @@ -1,46 +0,0 @@ -/* - The hydraulic conductivity model is an algebraic model with dependencies. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#ifndef AMANZI_FLOW_MATRIC_PRESSURE_MODEL_HH_ -#define AMANZI_FLOW_MATRIC_PRESSURE_MODEL_HH_ - -namespace Amanzi { -namespace Flow { -namespace Relations { - -class MatricPressureModel { - - public: - explicit - - MatricPressureModel(Teuchos::ParameterList& plist); - - double MatricPressure(double phi, double theta, double rho, double cv) const; - - double DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const; - - protected: - void InitializeFromPlist_(Teuchos::ParameterList& plist); - - private: - - double m_; - double n_; - double alpha_; - double theta_r_; - double sr_; - double theta_s; - -}; - -} //namespace -} //namespace -} //namespace - -#endif From cad0d454275c77f7bc0b9613fb1860a0c727a2c5 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 21 Dec 2023 11:34:02 -0800 Subject: [PATCH 526/582] permafrost changes --- src/pks/mpc/mpc_permafrost.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pks/mpc/mpc_permafrost.cc b/src/pks/mpc/mpc_permafrost.cc index a58ab7d65..252a66205 100644 --- a/src/pks/mpc/mpc_permafrost.cc +++ b/src/pks/mpc/mpc_permafrost.cc @@ -404,9 +404,11 @@ MPCPermafrost::FunctionalResidual(double t_old, Teuchos::RCP u_new, Teuchos::RCP g) { + Teuchos::OSTab tab = vo_->getOSTab(); // propagate updated info into state Solution_to_State(*u_new, tag_next_); + *vo_->os() << "Computing residuals for flow and energy" << std::endl; // Evaluate the surface flow residual surf_flow_pk_->FunctionalResidual( t_old, t_new, u_old->SubVector(2), u_new->SubVector(2), g->SubVector(2)); @@ -439,6 +441,9 @@ MPCPermafrost::FunctionalResidual(double t_old, esource = *g->SubVector(3)->Data()->ViewComponent("cell", false); changedEvaluatorPrimary(energy_exchange_key_, tag_next_, *S_); + *vo_->os() << "Water flux: " << source << std::endl; + *vo_->os() << "Energy flux: " << esource << std::endl; + // Evaluate the subsurface energy residual. domain_energy_pk_->FunctionalResidual( t_old, t_new, u_old->SubVector(1), u_new->SubVector(1), g->SubVector(1)); From 610f6080649a8efd86f9af342e0a6cbab388b4c3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 23 Jan 2024 15:25:43 -0800 Subject: [PATCH 527/582] Changes to allow compilation even without EcoSIM --- src/executables/CMakeLists.txt | 7 + src/executables/ats_registration_files.hh | 8 +- src/pks/ecosim/CMakeLists.txt | 156 +++++++++++----------- 3 files changed, 92 insertions(+), 79 deletions(-) diff --git a/src/executables/CMakeLists.txt b/src/executables/CMakeLists.txt index e4b8a3463..f0c9432fa 100644 --- a/src/executables/CMakeLists.txt +++ b/src/executables/CMakeLists.txt @@ -62,6 +62,8 @@ include_evaluators_directories(LISTNAME ATS_SURFACE_BALANCE_REG_INCLUDES) include_evaluators_directories(LISTNAME ATS_BGC_REG_INCLUDES) include_evaluators_directories(LISTNAME ATS_MPC_REG_INCLUDES) include_evaluators_directories(LISTNAME SED_TRANSPORT_REG_INCLUDES) + + include_evaluators_directories(LISTNAME ATS_ECOSIM_REG_INCLUDES) include_evaluators_directories(LISTNAME ATS_ECOSIM_RELATIONS_REG_INCLUDES) include_evaluators_directories(LISTNAME ATS_ECOSIM_DATA_REG_INCLUDES) @@ -129,6 +131,11 @@ set(ats_link_libs ats_ecosim_relations ) +#In theory covered by ECOSIM_LIBRARIES: +#If not place this in an if statement? +# ats_ecosim +# ats_ecosim_data +# ats_ecosim_relations # note, we can be inclusive here, because if they aren't enabled, # these won't be defined and will result in empty strings. diff --git a/src/executables/ats_registration_files.hh b/src/executables/ats_registration_files.hh index f7ecb5ce2..00d28be94 100644 --- a/src/executables/ats_registration_files.hh +++ b/src/executables/ats_registration_files.hh @@ -25,6 +25,8 @@ #ifdef ALQUIMIA_ENABLED # include "pks_chemistry_registration.hh" #endif -#include "ats_ecosim_registration.hh" -#include "ats_ecosim_relations_registration.hh" -#include "ats_ecosim_data_registration.hh" +#ifdef ECOSIM_ENABLED +# include "ats_ecosim_registration.hh" +# include "ats_ecosim_relations_registration.hh" +# include "ats_ecosim_data_registration.hh" +#endif \ No newline at end of file diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 90244e18a..ffed9263f 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -1,61 +1,64 @@ # -*- mode: cmake -*- - -add_subdirectory(constitutive_relations) -add_subdirectory(data) - -set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") -set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") -set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") -set(NETCDF_LIB "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") - -include_directories(${ATS_SOURCE_DIR}/src/pks) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/data) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) -include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) -include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) - -include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) - -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) - -include_directories(${ECOSIM_INCLUDE_DIRS}) - -message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") - -# ATS EcoSIM pk -# For adding F90 files add the F90 file to the ecosim source files and -# inc files. The inc file also needs a header - -#set(ats_ecosim_src_files -# EcoSIM_ATS_interface.cc -# BGCEngine.cc -# ecosim_wrappers.F90 -# data/bgc_fortran_memory_mod.F90 -#) - -set(ats_ecosim_src_files +#Everything here depends on EcoSIM +#so we put everything in an if statement + +if(ENABLE_ECOSIM) + add_subdirectory(constitutive_relations) + add_subdirectory(data) + + set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") + set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") + set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") + set(NETCDF_LIB "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") + + include_directories(${ATS_SOURCE_DIR}/src/pks) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/data) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) + include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) + + include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) + include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) + + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) + include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) + + include_directories(${ECOSIM_INCLUDE_DIRS}) + + message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") + + # ATS EcoSIM pk + # For adding F90 files add the F90 file to the ecosim source files and + # inc files. The inc file also needs a header + + #set(ats_ecosim_src_files + # EcoSIM_ATS_interface.cc + # BGCEngine.cc + # ecosim_wrappers.F90 + # data/bgc_fortran_memory_mod.F90 + #) + + set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 @@ -66,22 +69,22 @@ set(ats_ecosim_src_files ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMAdvanceMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 -) + ) -set(ats_ecosim_inc_files + set(ats_ecosim_inc_files ecosim_mod_test_wrapper.h EcoSIM_ATS_interface.hh BGCEngine.hh ecosim_interface.h -) + ) -file(GLOB ECOSIM_LIBRARIES + file(GLOB ECOSIM_LIBRARIES ${ECOSIM_LIB_LOCATION}/*.a -) + ) -find_package(NetCDF REQUIRED) + find_package(NetCDF REQUIRED) -set(ats_ecosim_link_libs + set(ats_ecosim_link_libs ${Teuchos_LIBRARIES} ${Epetra_LIBRARIES} ${ECOSIM_LIBRARIES} @@ -101,25 +104,26 @@ set(ats_ecosim_link_libs ats_operators ats_ecosim_data ats_ecosim_relations -) + ) -message(inc_files="${ats_ecosim_inc_files}") + message(inc_files="${ats_ecosim_inc_files}") -add_amanzi_library(ats_ecosim - SOURCE ${ats_ecosim_src_files} - HEADERS ${ats_ecosim_inc_files} - LINK_LIBS ${ats_ecosim_link_libs}) + add_amanzi_library(ats_ecosim + SOURCE ${ats_ecosim_src_files} + HEADERS ${ats_ecosim_inc_files} + LINK_LIBS ${ats_ecosim_link_libs}) -#================================================ -# register evaluators/factories/pks + #================================================ + # register evaluators/factories/pks -register_evaluator_with_factory( + register_evaluator_with_factory( HEADERFILE EcoSIM_ATS_interface_reg.hh LISTNAME ATS_ECOSIM_REG -) + ) -generate_evaluators_registration_header( + generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh LISTNAME ATS_ECOSIM_REG INSTALL True -) + ) +endif() \ No newline at end of file From 34874aa6ec69a2275eda0609cf55c0a9bbd8a338 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 17 Apr 2024 09:50:47 -0700 Subject: [PATCH 528/582] Fixing the ATS build to remove hard links --- src/executables/CMakeLists.txt | 2 +- src/executables/ats_registration_files.hh | 8 +-- src/pks/ecosim/CMakeLists.txt | 61 ++++++++++++----- src/pks/ecosim/EcoSIM_ATS_interface.cc | 83 +++++++++++++++++++---- src/pks/ecosim/EcoSIM_ATS_interface.hh | 5 ++ src/pks/ecosim/data/CMakeLists.txt | 42 +++++++----- 6 files changed, 149 insertions(+), 52 deletions(-) diff --git a/src/executables/CMakeLists.txt b/src/executables/CMakeLists.txt index f0c9432fa..6d16dab44 100644 --- a/src/executables/CMakeLists.txt +++ b/src/executables/CMakeLists.txt @@ -152,7 +152,7 @@ set(tpl_link_libs ${HDF5_LIBRARIES} ${CLM_LIBRARIES} ${ECOSIM_LIBRARIES} - ) + ) add_amanzi_library(ats_executable SOURCE ${ats_src_files} diff --git a/src/executables/ats_registration_files.hh b/src/executables/ats_registration_files.hh index 00d28be94..f7ecb5ce2 100644 --- a/src/executables/ats_registration_files.hh +++ b/src/executables/ats_registration_files.hh @@ -25,8 +25,6 @@ #ifdef ALQUIMIA_ENABLED # include "pks_chemistry_registration.hh" #endif -#ifdef ECOSIM_ENABLED -# include "ats_ecosim_registration.hh" -# include "ats_ecosim_relations_registration.hh" -# include "ats_ecosim_data_registration.hh" -#endif \ No newline at end of file +#include "ats_ecosim_registration.hh" +#include "ats_ecosim_relations_registration.hh" +#include "ats_ecosim_data_registration.hh" diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index ffed9263f..6be13c246 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -6,10 +6,32 @@ if(ENABLE_ECOSIM) add_subdirectory(constitutive_relations) add_subdirectory(data) - set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") - set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") - set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") - set(NETCDF_LIB "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") + get_property(AMANZI_TPLS_DIR GLOBAL PROPERTY AMANZI_TPLS_DIR) + + message(STATUS "In ATS-Ecosim Cmake: ") + message(STATUS "ECOSIM_INCLUDE_DIRS: " ${ECOSIM_INCLUDE_DIRS}) + message(STATUS "ECOSIM_INCLUDE_DIR: " ${ECOSIM_INCLUDE_DIR}) + message(STATUS "ECOSIM_LIBRARY_DIR: " ${ECOSIM_LIBRARY_DIR}) + message(STATUS "ECOSIM_LIBRARIES: " ${ECOSIM_LIBRARIES}) + message(STATUS "ECOSIM_DIR:" ${ECOSIM_DIR}) + message(STATUS "AMANZI_TPLS_DIR: " ${AMANZI_TPLS_DIR}) + message(STATUS "ATS_BASE:" ${ATS_BASE}) + message(STATUS "AMANZI_DIR:" ${AMANZI_DIR}) + message(STATUS "AMANZI_TPLS_DIR: " ${AMANZI_TPLS_DIR}) + #set(ECOSIM_INSTALL_PREFIX "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") + #set(ECOSIM_LIB_LOCATION "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") + #set(ECOSIM_CMAKE_BINARY_DIR "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") + #set(NETCDF_LIB "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") + + set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) + set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) + set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) + set(NETCDF_LIB ${ECOSIM_DIR}/lib) + + message("ECOSIM_DIR:" ${ECOSIM_DIR}) + message("ECOSIM_INSTALL_PREFIX:" ${ECOSIM_INSTALL_PREFIX}) + message("ECOSIM_LIB_LOCATION:" ${ECOSIM_LIB_LOCATION}) + message("ECOSIM_CMAKE_BINARY_DIR:" ${ECOSIM_CMAKE_BINARY_DIR}) include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) @@ -17,19 +39,19 @@ if(ENABLE_ECOSIM) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) - include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) - - include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) - include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) + + #include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) + #nclude_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) @@ -58,6 +80,9 @@ if(ENABLE_ECOSIM) # data/bgc_fortran_memory_mod.F90 #) + #testing using link libs: + #file(GLOB ECOLIBS ${ECOSIM_LIB_LOCATION}/*.a) + set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc @@ -126,4 +151,4 @@ if(ENABLE_ECOSIM) LISTNAME ATS_ECOSIM_REG INSTALL True ) -endif() \ No newline at end of file +endif() diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index eca7ee6d1..6649184b5 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -125,7 +125,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, pressure_at_wilting_point = plist_->get("Wilting Point [Mpa]"); dt_ = plist_->get("initial time step"); - c_m_ = plist_->get("heat capacity [J mol^-1 K^-1]"); + c_m_ = plist_->get("heat capacity [MJ mol^-1 K^-1]"); //Teuchos::OSTab tab = vo_->getOSTab(); //*vo_->os() << vo_->color("green") << "heat capacity: " << c_m_; @@ -677,6 +677,8 @@ void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID column, AmanziGeometry::Point neg_z(3); neg_z.set(0.,0.,-1); + Teuchos::OSTab tab = vo_->getOSTab(); + for (std::size_t i=0; i!=col_iter.size(); ++i) { // depth centroid (*depth)[i] = surf_centroid[2] - mesh_->cell_centroid(col_iter[i])[2]; @@ -687,6 +689,56 @@ void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID column, std::vector dirs; mesh_->cell_get_faces_and_dirs(col_iter[i], &faces, &dirs); + double vol = mesh_->cell_volume(col_iter[i]); + + // -- mimics implementation of build_columns() in Mesh + double mindp = 999.0; + AmanziMesh::Entity_ID f_below = -1; + for (std::size_t j=0; j!=faces.size(); ++j) { + AmanziGeometry::Point normal = mesh_->face_normal(faces[j]); + if (dirs[j] == -1) normal *= -1; + normal /= AmanziGeometry::norm(normal); + + double dp = -normal * neg_z; + if (dp < mindp) { + mindp = dp; + f_below = faces[j]; + } + } + + // -- fill the val + (*dz)[i] = mesh_->face_centroid(f_above)[2] - mesh_->face_centroid(f_below)[2]; + AMANZI_ASSERT( (*dz)[i] > 0. ); + f_above = f_below; + } +} + +// helper function for collecting dz, depth, and volume for a given column +void EcoSIM::VolDepthDz_(AmanziMesh::Entity_ID column, + Teuchos::Ptr depth, + Teuchos::Ptr dz, + Teuchos::Ptr volume) { + AmanziMesh::Entity_ID f_above = mesh_surf_->entity_get_parent(AmanziMesh::CELL, column); + auto& col_iter = mesh_->cells_of_column(column); + ncells_per_col_ = col_iter.size(); + + AmanziGeometry::Point surf_centroid = mesh_->face_centroid(f_above); + AmanziGeometry::Point neg_z(3); + neg_z.set(0.,0.,-1); + + for (std::size_t i=0; i!=col_iter.size(); ++i) { + // depth centroid + (*depth)[i] = surf_centroid[2] - mesh_->cell_centroid(col_iter[i])[2]; + + // dz + // -- find face_below + AmanziMesh::Entity_ID_List faces; + std::vector dirs; + mesh_->cell_get_faces_and_dirs(col_iter[i], &faces, &dirs); + + //double vol = mesh_->cell_volume(col_iter[i]); + (*volume)[i] = mesh_->cell_volume(col_iter[i]); + // -- mimics implementation of build_columns() in Mesh double mindp = 999.0; AmanziMesh::Entity_ID f_below = -1; @@ -797,7 +849,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,relative_permeability,col_relative_permeability.ptr()); FieldToColumn_(column,liquid_density,col_l_dens.ptr()); FieldToColumn_(column,rock_density,col_r_dens.ptr()); - FieldToColumn_(column,cell_volume,col_vol.ptr()); + //FieldToColumn_(column,cell_volume,col_vol.ptr()); FieldToColumn_(column,hydraulic_conductivity,col_h_cond.ptr()); FieldToColumn_(column,bulk_density,col_b_dens.ptr()); FieldToColumn_(column,plant_wilting_factor,col_wp.ptr()); @@ -831,8 +883,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); // This is for computing depth - ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); + //ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); + VolDepthDz_(column, col_depth.ptr(), col_dz.ptr(), col_vol.ptr()); double sum = 0.0; for (int i = ncells_per_col_ - 1; i >= 0; --i) { sum += (*col_dz)[i]; @@ -880,14 +933,21 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.surface_energy_source.data[column] = surface_energy_source[column]; - /**vo_->os() << "printing temperature:"; + /**vo_->os() << "printing porosity:"; for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "temp["<< i << "] = " << (*col_temp)[i] << std::endl; + *vo_->os() << "porosity["<< i << "] = " << (*col_porosity)[i] << std::endl + << " struct_porosity["<< i << "] = " << state.porosity.data[column][i] << std::endl; + } + + vo_->os() << "printing depth:"; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "col_depth["<< i << "] = " << (*col_depth)[i] + << "struct_depth["<< i << "] = " << props.depth.data[column][i] << std::endl; }*/ - *vo_->os() << "Column " << column << std::endl; - *vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; - *vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; + //*vo_->os() << "Column " << column << std::endl; + //*vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; + //*vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; state.surface_water_source.data[column] = surface_water_source[column]; @@ -1093,6 +1153,9 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) */ int EcoSIM::InitializeSingleProcess(int proc) { + int num_iterations = 1; + int num_columns = 1; + CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); //ecosim_datatest_wrapper(column, &bgc_props_, &bgc_sizes_); @@ -1101,12 +1164,8 @@ int EcoSIM::InitializeSingleProcess(int proc) /*need some sort of assertions here to double check that the data is actually What I want it to be*/ - int num_iterations = 1; - int num_columns = 1; - bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns,ncells_per_col_); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - } int EcoSIM::AdvanceSingleProcess(double dt, int proc) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 5fcac6466..f4544d3a3 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -159,6 +159,11 @@ class EcoSIM : public PK_Physical { Teuchos::Ptr depth, Teuchos::Ptr dz); + void VolDepthDz_(AmanziMesh::Entity_ID column, + Teuchos::Ptr depth, + Teuchos::Ptr dz, + Teuchos::Ptr volume); + void ColumnToField_(AmanziMesh::Entity_ID column, Epetra_Vector& vec, Teuchos::Ptr col_vec); diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index f55f488b6..83b87206d 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -12,23 +12,33 @@ # bgc_fortran_memory_mod.F90 #) -set(ECOSIM_INSTALL_PREFIX "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") -set(ECOSIM_LIB_LOCATION "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") -set(ECOSIM_CMAKE_BINARY_DIR "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") -set(NETCDF_LIB "/global/home/users/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") +get_property(AMANZI_TPLS_DIR GLOBAL PROPERTY AMANZI_TPLS_DIR) -include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) -include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) +message(STATUS "In ATS-Ecosim Data Cmake: ") +message(STATUS "ECOSIM_INCLUDE_DIRS: " ${ECOSIM_INCLUDE_DIRS}) +message(STATUS "ECOSIM_INCLUDE_DIR: " ${ECOSIM_INCLUDE_DIR}) +message(STATUS "ECOSIM_LIBRARY_DIR: " ${ECOSIM_LIBRARY_DIR}) +message(STATUS "ECOSIM_LIBRARIES: " ${ECOSIM_LIBRARIES}) +message(STATUS "ATS_BASE:" ${ATS_BASE}) +message(STATUS "AMANZI_DIR:" ${AMANZI_DIR}) +message(STATUS "AMANZI_TPLS_DIR: " ${AMANZI_TPLS_DIR}) + + +#set(ECOSIM_INSTALL_PREFIX "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") +#set(ECOSIM_LIB_LOCATION "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") +#set(ECOSIM_CMAKE_BINARY_DIR "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") +#set(NETCDF_LIB "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") + +set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) +#set(ECOSIM_LIB_LOCATION ${ECOSIM_LIBRARY_DIR}) +set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) +set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) +set(NETCDF_LIB ${ECOSIM_DIR}/lib) + +message("ECOSIM_DIR:" ${ECOSIM_DIR}) +message("ECOSIM_INSTALL_PREFIX:" ${ECOSIM_INSTALL_PREFIX}) +message("ECOSIM_LIB_LOCATION:" ${ECOSIM_LIB_LOCATION}) +message("ECOSIM_CMAKE_BINARY_DIR:" ${ECOSIM_CMAKE_BINARY_DIR}) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) From 35f14f670b9fc4863d5b539de7611eb64a1085a2 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 16 May 2024 13:32:23 -0700 Subject: [PATCH 529/582] various build fixes --- src/executables/CMakeLists.txt | 10 ++-- src/executables/ats_registration_files.hh | 8 ++-- src/pks/CMakeLists.txt | 5 +- src/pks/ecosim/CMakeLists.txt | 56 +++++++++++++---------- src/pks/ecosim/data/CMakeLists.txt | 49 +++++++++++--------- 5 files changed, 74 insertions(+), 54 deletions(-) diff --git a/src/executables/CMakeLists.txt b/src/executables/CMakeLists.txt index 6d16dab44..80fbcb678 100644 --- a/src/executables/CMakeLists.txt +++ b/src/executables/CMakeLists.txt @@ -126,11 +126,15 @@ set(ats_link_libs ats_surface_balance ats_mpc ats_mpc_relations - ats_ecosim - ats_ecosim_data - ats_ecosim_relations ) +if (ENABLE_ECOSIM) + list(APPEND ats_link_libs + ats_ecosim + ats_ecosim_data + ats_ecosim_relations) +endif() + #In theory covered by ECOSIM_LIBRARIES: #If not place this in an if statement? # ats_ecosim diff --git a/src/executables/ats_registration_files.hh b/src/executables/ats_registration_files.hh index f7ecb5ce2..c9998f7a9 100644 --- a/src/executables/ats_registration_files.hh +++ b/src/executables/ats_registration_files.hh @@ -25,6 +25,8 @@ #ifdef ALQUIMIA_ENABLED # include "pks_chemistry_registration.hh" #endif -#include "ats_ecosim_registration.hh" -#include "ats_ecosim_relations_registration.hh" -#include "ats_ecosim_data_registration.hh" +#ifdef ECOSIM_ENABLED +# include "ats_ecosim_registration.hh" +# include "ats_ecosim_relations_registration.hh" +# include "ats_ecosim_data_registration.hh" +#endif diff --git a/src/pks/CMakeLists.txt b/src/pks/CMakeLists.txt index b6c78b6fa..01db715cc 100644 --- a/src/pks/CMakeLists.txt +++ b/src/pks/CMakeLists.txt @@ -57,4 +57,7 @@ add_subdirectory(deform) add_subdirectory(surface_balance) add_subdirectory(biogeochemistry) add_subdirectory(mpc) -add_subdirectory(ecosim) + +if (ENABLE_ECOSIM) + add_subdirectory(ecosim) +endif() diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 6be13c246..871a59871 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -8,16 +8,6 @@ if(ENABLE_ECOSIM) get_property(AMANZI_TPLS_DIR GLOBAL PROPERTY AMANZI_TPLS_DIR) - message(STATUS "In ATS-Ecosim Cmake: ") - message(STATUS "ECOSIM_INCLUDE_DIRS: " ${ECOSIM_INCLUDE_DIRS}) - message(STATUS "ECOSIM_INCLUDE_DIR: " ${ECOSIM_INCLUDE_DIR}) - message(STATUS "ECOSIM_LIBRARY_DIR: " ${ECOSIM_LIBRARY_DIR}) - message(STATUS "ECOSIM_LIBRARIES: " ${ECOSIM_LIBRARIES}) - message(STATUS "ECOSIM_DIR:" ${ECOSIM_DIR}) - message(STATUS "AMANZI_TPLS_DIR: " ${AMANZI_TPLS_DIR}) - message(STATUS "ATS_BASE:" ${ATS_BASE}) - message(STATUS "AMANZI_DIR:" ${AMANZI_DIR}) - message(STATUS "AMANZI_TPLS_DIR: " ${AMANZI_TPLS_DIR}) #set(ECOSIM_INSTALL_PREFIX "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") #set(ECOSIM_LIB_LOCATION "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") #set(ECOSIM_CMAKE_BINARY_DIR "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") @@ -25,13 +15,15 @@ if(ENABLE_ECOSIM) set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) - set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) + set(ECOSIM_BUILD_PREFIX ${ECOSIM_DIR}/ecosim/build) + #set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) set(NETCDF_LIB ${ECOSIM_DIR}/lib) + message("In ATS-EcoSIM CMakeLists:") message("ECOSIM_DIR:" ${ECOSIM_DIR}) message("ECOSIM_INSTALL_PREFIX:" ${ECOSIM_INSTALL_PREFIX}) message("ECOSIM_LIB_LOCATION:" ${ECOSIM_LIB_LOCATION}) - message("ECOSIM_CMAKE_BINARY_DIR:" ${ECOSIM_CMAKE_BINARY_DIR}) + message("ECOSIM_BUILD_PREFIX:" ${ECOSIM_BUILD_PREFIX}) include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) @@ -41,7 +33,7 @@ if(ENABLE_ECOSIM) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) #include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) - #nclude_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) #include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) #include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) @@ -53,17 +45,31 @@ if(ENABLE_ECOSIM) #include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) - include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) + + message("At includ_directories") + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/utils/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/minimath/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/modelconfig/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/mesh/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/modelpars/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/balances/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_datatype/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SoilPhys/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_mods/) + include_directories(${ECOSIM_INCLUDE_DIRS}) @@ -94,7 +100,7 @@ if(ENABLE_ECOSIM) ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMAdvanceMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 - ) + ) set(ats_ecosim_inc_files ecosim_mod_test_wrapper.h diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 83b87206d..d0d337495 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -14,16 +14,6 @@ get_property(AMANZI_TPLS_DIR GLOBAL PROPERTY AMANZI_TPLS_DIR) -message(STATUS "In ATS-Ecosim Data Cmake: ") -message(STATUS "ECOSIM_INCLUDE_DIRS: " ${ECOSIM_INCLUDE_DIRS}) -message(STATUS "ECOSIM_INCLUDE_DIR: " ${ECOSIM_INCLUDE_DIR}) -message(STATUS "ECOSIM_LIBRARY_DIR: " ${ECOSIM_LIBRARY_DIR}) -message(STATUS "ECOSIM_LIBRARIES: " ${ECOSIM_LIBRARIES}) -message(STATUS "ATS_BASE:" ${ATS_BASE}) -message(STATUS "AMANZI_DIR:" ${AMANZI_DIR}) -message(STATUS "AMANZI_TPLS_DIR: " ${AMANZI_TPLS_DIR}) - - #set(ECOSIM_INSTALL_PREFIX "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") #set(ECOSIM_LIB_LOCATION "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") #set(ECOSIM_CMAKE_BINARY_DIR "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") @@ -32,25 +22,40 @@ message(STATUS "AMANZI_TPLS_DIR: " ${AMANZI_TPLS_DIR}) set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) #set(ECOSIM_LIB_LOCATION ${ECOSIM_LIBRARY_DIR}) set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) +set(ECOSIM_BUILD_PREFIX ${ECOSIM_DIR}/ecosim/build) set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) set(NETCDF_LIB ${ECOSIM_DIR}/lib) +message("In ATS-EcoSIM data CMakeLists:") message("ECOSIM_DIR:" ${ECOSIM_DIR}) message("ECOSIM_INSTALL_PREFIX:" ${ECOSIM_INSTALL_PREFIX}) message("ECOSIM_LIB_LOCATION:" ${ECOSIM_LIB_LOCATION}) -message("ECOSIM_CMAKE_BINARY_DIR:" ${ECOSIM_CMAKE_BINARY_DIR}) +message("ECOSIM_BUILD_PREFIX:" ${ECOSIM_BUILD_PREFIX}) + +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) +#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) -include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) +message("At include_directories in data") +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/utils/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/minimath/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/modelconfig/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/mesh/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/modelpars/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/balances/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_datatype/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SoilPhys/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_mods/) set(ats_ecosim_data_src_files BGC_constants.cc From 40175eba4784fa6a7b39be952e351fb7ff1c5004 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 1 Jul 2024 14:03:55 -0700 Subject: [PATCH 530/582] added snow precipitation to the ATS side of the coupler --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 22 +++++++++++++++++----- src/pks/ecosim/EcoSIM_ATS_interface.hh | 3 ++- src/pks/ecosim/data/BGC_containers.hh | 1 + src/pks/ecosim/data/BGC_memory.cc | 2 ++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 6649184b5..57e3e15b6 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -108,7 +108,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, air_temp_key_ = Keys::readKey(*plist_, domain_surface_, "air temperature", "air_temperature"); vp_air_key_ = Keys::readKey(*plist_, domain_surface_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surface_, "wind speed", "wind_speed"); - prain_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation rain", "precipitation_rain"); + p_rain_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation rain", "precipitation_rain"); + p_snow_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation snow", "precipitation_snow") elev_key_ = Keys::readKey(*plist_, domain_surface_, "elevation", "elevation"); aspect_key_ = Keys::readKey(*plist_, domain_surface_, "aspect", "aspect"); slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); @@ -291,7 +292,7 @@ void EcoSIM::Initialize() { //Surface properties from met data /*S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(p_rain_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); @@ -434,7 +435,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(prain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(p_rain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(p_snow_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); @@ -542,6 +544,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& p_rain = *(*S_->Get("surface-precipitation_rain", tag_next_) .ViewComponent("cell",false))(0); + S_->GetEvaluator("surface-precipitation_snow", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& p_snow = *(*S_->Get("surface-precipitation_snow", tag_next_) + .ViewComponent("cell",false))(0); + S_->GetEvaluator("surface-elevation", tag_next_).Update(*S_, name_); const Epetra_MultiVector& elevation = *S_->Get("surface-elevation", tag_next_) .ViewComponent("cell",false); @@ -791,7 +797,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& precipitation = *(*S_->Get(prain_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& precipitation = *(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); @@ -957,6 +964,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.vapor_pressure_air.data[column] = vapor_pressure_air[column]; props.wind_speed.data[column] = wind_speed[column]; props.precipitation.data[column] = precipitation[column]; + props.precipitation_snow.data[column] = precipitation_snow[column]; props.elevation.data[column] = elevation[column]; props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; @@ -1105,9 +1113,13 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, *vo_->os() << "Rate to conserve total energy from EcoSIM: " << energy_source_tot/dt_ << " MJ/s" <os() << "testing using flux conservation: " << std::endl; + //As EcoSIM is hourly, but ATS is per second we need to divide the source by seconds per hour surface_energy_source[column] = state.surface_energy_source.data[column]/(3600.0); + surface_water_source[column] = state.surface_water_source.data[column]/(3600.0); - auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); + //AG - 7/1/24 I'm not sure what this is doing I think it's from when I was testing comparing old to new values + //auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); + //auto& new_w_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); ColumnToField_(column,water_content,col_wc.ptr()); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index f4544d3a3..c0fc79b7e 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -210,7 +210,8 @@ class EcoSIM : public PK_Physical { Key air_temp_key_; Key vp_air_key_; Key wind_speed_key_; - Key prain_key_; + Key p_rain_key_; + Key p_snow_key_; Key f_wp_key_; Key f_root_key_; Key matric_pressure_key_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 764e470a3..e1d84f95e 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -135,6 +135,7 @@ extern "C" { BGCVectorDouble vapor_pressure_air; BGCVectorDouble wind_speed; BGCVectorDouble precipitation; + BGCVectorDouble precipitation_snow; BGCVectorDouble elevation; BGCVectorDouble aspect; BGCVectorDouble slope; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 460a5a660..3ad9616b1 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -403,6 +403,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCVectorDouble(sizes->num_columns, &(properties->vapor_pressure_air)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->wind_speed)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->precipitation)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->precipitation_snow)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->elevation)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->aspect)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->slope)); @@ -427,6 +428,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCVectorDouble(&(properties->vapor_pressure_air)); FreeBGCVectorDouble(&(properties->wind_speed)); FreeBGCVectorDouble(&(properties->precipitation)); + FreeBGCVectorDouble(&(properties->precipitation_snow)); FreeBGCVectorDouble(&(properties->elevation)); FreeBGCVectorDouble(&(properties->aspect)); FreeBGCVectorDouble(&(properties->slope)); From a79b84fffcd3925a9d6e075152f4ae52df7be440 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 3 Jul 2024 10:35:48 -0700 Subject: [PATCH 531/582] minor bug fix --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 57e3e15b6..30dac6bd0 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -109,7 +109,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, vp_air_key_ = Keys::readKey(*plist_, domain_surface_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surface_, "wind speed", "wind_speed"); p_rain_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation rain", "precipitation_rain"); - p_snow_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation snow", "precipitation_snow") + p_snow_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation snow", "precipitation_snow"); elev_key_ = Keys::readKey(*plist_, domain_surface_, "elevation", "elevation"); aspect_key_ = Keys::readKey(*plist_, domain_surface_, "aspect", "aspect"); slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); From b2b3d5907333c48ebb78a3d1ef7d7be34026e3cc Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 1 Aug 2024 13:53:24 -0700 Subject: [PATCH 532/582] modifying prints and deleting some old ones --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 44 ++++++-------------------- src/pks/energy/energy_base_physics.cc | 2 -- src/pks/energy/energy_base_ti.cc | 3 -- src/pks/mpc/mpc_permafrost.cc | 3 -- 4 files changed, 10 insertions(+), 42 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 57e3e15b6..256a102c9 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -128,9 +128,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, dt_ = plist_->get("initial time step"); c_m_ = plist_->get("heat capacity [MJ mol^-1 K^-1]"); - //Teuchos::OSTab tab = vo_->getOSTab(); - //*vo_->os() << vo_->color("green") << "heat capacity: " << c_m_; - //This initialized the engine (found in BGCEngine.cc) This is the code that //actually points to the driver if (!plist_->isParameter("engine")) { @@ -643,7 +640,6 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Epetra_Vector& vec, auto& col_iter = mesh_->cells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { vec[col_iter[i]] = (*col_vec)[i]; - //*vo_->os() << "vel[col_iter] = " << vec[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; } } @@ -653,7 +649,6 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Teuchos::Ptrcells_of_column(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { (*vec)[col_iter[i]] = (*col_vec)[i]; - //*vo_->os() << "vel[col_iter] = " << (*vec)[col_iter[i]] << " (*col_vec)[i] = " << (*col_vec)[i] << std::endl; } } @@ -898,11 +893,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, sum += (*col_dz)[i]; (*col_depth_c)[i] = sum; } - - /**vo_->os() << "Column " << column << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "Depth["<< i << "] = " << (*col_depth)[i] << " Depth_Reversed["<< i << "] = " << (*col_depth_c)[i] << std::endl; - }*/ for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[column][i] = (*col_l_dens)[i]; @@ -939,23 +929,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, //fill surface variables state.surface_energy_source.data[column] = surface_energy_source[column]; - - /**vo_->os() << "printing porosity:"; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "porosity["<< i << "] = " << (*col_porosity)[i] << std::endl - << " struct_porosity["<< i << "] = " << state.porosity.data[column][i] << std::endl; - } - - vo_->os() << "printing depth:"; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "col_depth["<< i << "] = " << (*col_depth)[i] - << "struct_depth["<< i << "] = " << props.depth.data[column][i] << std::endl; - }*/ - - //*vo_->os() << "Column " << column << std::endl; - //*vo_->os() << "energy from dict: " << state.surface_energy_source.data[column] << std::endl; - //*vo_->os() << "energy from State: " << surface_energy_source[column] << std::endl; - state.surface_water_source.data[column] = surface_water_source[column]; props.shortwave_radiation.data[column] = shortwave_radiation[column]; @@ -1052,7 +1025,15 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, MPI_Barrier(MPI_COMM_WORLD); num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - + double energy_source_tot = state.surface_energy_source.data[0]; + double water_source_tot = state.surface_water_source.data[0] + *vo_->os() << "Reporting Energy data from EcoSIM:" + *vo_->os() << "Total energy source from EcoSIM: " << energy_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << energy_source_tot/(3600.0) << " ?/s" <os() << "Reporting Water data from EcoSIM:" + *vo_->os() << "Total water source from EcoSIM: " << water_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << water_source_tot/(3600.0) << " ?/s" <os() << "ATS timestep: " << dt_ << " s" << std::endl; - *vo_->os() << "Total energy from EcoSIM: " << energy_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << energy_source_tot/(3600.0) << " MJ/s" <os() << "Rate to conserve total energy from EcoSIM: " << energy_source_tot/dt_ << " MJ/s" <os() << "testing using flux conservation: " << std::endl; - //As EcoSIM is hourly, but ATS is per second we need to divide the source by seconds per hour surface_energy_source[column] = state.surface_energy_source.data[column]/(3600.0); surface_water_source[column] = state.surface_water_source.data[column]/(3600.0); @@ -1130,6 +1105,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, //ColumnToField_(column,rooting_depth_fraction,col_rf.ptr()); } } + /* int EcoSIM::InitializeSingleColumn(int col) { diff --git a/src/pks/energy/energy_base_physics.cc b/src/pks/energy/energy_base_physics.cc index c64541633..3904086cc 100644 --- a/src/pks/energy/energy_base_physics.cc +++ b/src/pks/energy/energy_base_physics.cc @@ -134,7 +134,6 @@ EnergyBase::AddSources_(const Tag& tag, const Teuchos::Ptr& g) Teuchos::OSTab tab = vo_->getOSTab(); Epetra_MultiVector& g_c = *g->ViewComponent("cell", false); - *vo_->os() << "In AddSources"; S_->GetEvaluator(cell_vol_key_, tag_next_).Update(*S_, name_); const Epetra_MultiVector& cv = *S_->Get(cell_vol_key_, tag_next_).ViewComponent("cell", false); @@ -149,7 +148,6 @@ EnergyBase::AddSources_(const Tag& tag, const Teuchos::Ptr& g) // Add into residual unsigned int ncells = g_c.MyLength(); for (unsigned int c = 0; c != ncells; ++c) { - *vo_->os() << "source: " << source1[0][c]; g_c[0][c] -= source1[0][c] * cv[0][c]; } diff --git a/src/pks/energy/energy_base_ti.cc b/src/pks/energy/energy_base_ti.cc index d0c41e90d..83938268e 100644 --- a/src/pks/energy/energy_base_ti.cc +++ b/src/pks/energy/energy_base_ti.cc @@ -73,11 +73,8 @@ EnergyBase::FunctionalResidual(double t_old, db_->WriteBoundaryConditions(bc_markers(), bc_values()); // zero out residual - *vo_->os() << "In Functional Residual" << std::endl; Teuchos::RCP res = g->Data(); - *vo_->os() << "g = " << g << std::endl; res->PutScalar(0.0); - *vo_->os() << "(should be zero): g = " << g << std::endl; // diffusion term, implicit ApplyDiffusion_(tag_next_, res.ptr()); diff --git a/src/pks/mpc/mpc_permafrost.cc b/src/pks/mpc/mpc_permafrost.cc index 252a66205..297e05f4d 100644 --- a/src/pks/mpc/mpc_permafrost.cc +++ b/src/pks/mpc/mpc_permafrost.cc @@ -441,9 +441,6 @@ MPCPermafrost::FunctionalResidual(double t_old, esource = *g->SubVector(3)->Data()->ViewComponent("cell", false); changedEvaluatorPrimary(energy_exchange_key_, tag_next_, *S_); - *vo_->os() << "Water flux: " << source << std::endl; - *vo_->os() << "Energy flux: " << esource << std::endl; - // Evaluate the subsurface energy residual. domain_energy_pk_->FunctionalResidual( t_old, t_new, u_old->SubVector(1), u_new->SubVector(1), g->SubVector(1)); From 9ad30f1612467bbe9b9cefc5a52ff8f21e4d78d4 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 6 Aug 2024 10:51:41 -0700 Subject: [PATCH 533/582] minor bugfix --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 63fe09c70..8922f61d9 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1026,19 +1026,19 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); double energy_source_tot = state.surface_energy_source.data[0]; - double water_source_tot = state.surface_water_source.data[0] - *vo_->os() << "Reporting Energy data from EcoSIM:" + double water_source_tot = state.surface_water_source.data[0]; + + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "Reporting Energy data from EcoSIM: " << std::endl; *vo_->os() << "Total energy source from EcoSIM: " << energy_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << energy_source_tot/(3600.0) << " ?/s" <os() << "Reporting Water data from EcoSIM:" + *vo_->os() << "Reporting Water data from EcoSIM: " << std::endl; *vo_->os() << "Total water source from EcoSIM: " << water_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << water_source_tot/(3600.0) << " ?/s" <getOSTab(); - if (has_gas) { auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Tags::DEFAULT, saturation_gas_key_).ViewComponent("cell",false))(0); auto& gas_density = *(*S_->GetW(gas_density_key_, Tags::DEFAULT, gas_density_key_).ViewComponent("cell",false))(0); From 0fee41739d4afd6a39f7f2c817649d4d79b9de55 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 21 Aug 2024 20:53:43 -0700 Subject: [PATCH 534/582] removing snow precipitation --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 8922f61d9..b4abf7f18 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -109,7 +109,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, vp_air_key_ = Keys::readKey(*plist_, domain_surface_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surface_, "wind speed", "wind_speed"); p_rain_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation rain", "precipitation_rain"); - p_snow_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation snow", "precipitation_snow"); + //p_snow_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation snow", "precipitation_snow"); elev_key_ = Keys::readKey(*plist_, domain_surface_, "elevation", "elevation"); aspect_key_ = Keys::readKey(*plist_, domain_surface_, "aspect", "aspect"); slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); @@ -433,7 +433,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(p_rain_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(p_snow_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(p_snow_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); @@ -541,9 +541,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& p_rain = *(*S_->Get("surface-precipitation_rain", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("surface-precipitation_snow", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& p_snow = *(*S_->Get("surface-precipitation_snow", tag_next_) - .ViewComponent("cell",false))(0); + //S_->GetEvaluator("surface-precipitation_snow", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& p_snow = *(*S_->Get("surface-precipitation_snow", tag_next_) + // .ViewComponent("cell",false))(0); S_->GetEvaluator("surface-elevation", tag_next_).Update(*S_, name_); const Epetra_MultiVector& elevation = *S_->Get("surface-elevation", tag_next_) @@ -793,7 +793,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& precipitation = *(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); @@ -937,7 +937,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.vapor_pressure_air.data[column] = vapor_pressure_air[column]; props.wind_speed.data[column] = wind_speed[column]; props.precipitation.data[column] = precipitation[column]; - props.precipitation_snow.data[column] = precipitation_snow[column]; + //props.precipitation_snow.data[column] = precipitation_snow[column]; props.elevation.data[column] = elevation[column]; props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; From 48082af9fe2f47f0769f31dda7de1fbd5d6b5df8 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 1 Oct 2024 16:07:50 -0700 Subject: [PATCH 535/582] minor changes to prints --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 21 ++++++++++++++++++++- src/pks/ecosim/ecosim_wrappers.F90 | 9 ++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index b4abf7f18..8e34637e1 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -962,6 +962,15 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.heat_capacity = c_m_; props.field_capacity = pressure_at_field_capacity; props.wilting_point = pressure_at_wilting_point; + + Teuchos::OSTab tab = vo_->getOSTab(); + + /*for (int column=0; column!=num_columns_local; ++column) { + *vo_->os() << "for column: " << column << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + *vo_->os() << "T["<< i << "] = " << state.temperature.data[column][i] << std::endl; + } + }*/ } void EcoSIM::CopyFromEcoSIM_process(const int column, @@ -1143,7 +1152,11 @@ int EcoSIM::InitializeSingleProcess(int proc) { int num_iterations = 1; int num_columns = 1; - + + num_columns = num_columns_local; + + Teuchos::OSTab tab = vo_->getOSTab(); + CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); //ecosim_datatest_wrapper(column, &bgc_props_, &bgc_sizes_); @@ -1152,6 +1165,10 @@ int EcoSIM::InitializeSingleProcess(int proc) /*need some sort of assertions here to double check that the data is actually What I want it to be*/ + //Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "num_columns: " << num_columns << std::endl; + *vo_->os() << "ncells_per_col_: " << ncells_per_col_ << std::endl; + bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns,ncells_per_col_); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); } @@ -1165,6 +1182,8 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) int num_iterations = 1; int num_columns = 1; + num_columns = num_columns_local; + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns); diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index 26bcb28e9..b8db0330b 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -63,10 +63,17 @@ subroutine EcoSIM_Setup(properties, state, sizes, num_iterations,& write(*,*) "starting driver transfer ATS2EcoSIMData" - call ATS2EcoSIMData(num_columns, state, properties, sizes) + !write(*,*) "num_columns: ", num_columns + !write(*,*) "ncells_per_col_: ", ncells_per_col_ + + sizes%num_components = 1 + sizes%ncells_per_col_ = 100 + sizes%num_columns = 25 call Init_EcoSIM(sizes) + call ATS2EcoSIMData(num_columns, state, properties, sizes) + write(*,*) "starting driver transfer EcoSIM2ATSData" call EcoSIM2ATSData(num_columns, state, sizes) From 5db6db5885be8913dad428472cc3bf1f7263d972 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 2 Oct 2024 17:30:37 -0700 Subject: [PATCH 536/582] adding snow depth dataset --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 23 +++++++++++++++++------ src/pks/ecosim/EcoSIM_ATS_interface.hh | 1 + src/pks/ecosim/data/BGC_containers.hh | 1 + src/pks/ecosim/data/BGC_memory.cc | 5 +++-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 8e34637e1..715f98a2f 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -87,6 +87,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, Keys::readKey(*plist_, domain_, "subsurface energy source", "total_energy_source"); surface_energy_source_ecosim_key_ = Keys::readKey(*plist_, domain_surface_, "surface energy source ecosim", "ecosim_source"); + surface_water_source_ecosim_key_ = + Keys::readKey(*plist_, domain_surface_, "surface water source ecosim", "ecosim_water_source"); + + //Snow + snow_depth_key_ = Keys::readKey(*plist_, domain_, "snow depth", "snow_depth"); //snow_source_key_ = Keys::readKey(plist, domain_snow_, "snow mass source - sink", "source_sink"); //new_snow_key_ = Keys::readKey(plist, domain_snow_, "new snow source", "source"); @@ -439,6 +444,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(snow_depth_key_, Tags::DEFAULT).Update(*S_, name_); if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); @@ -802,7 +808,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_energy_source = *(*S_->Get(subsurface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -998,9 +1005,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, surface_energy_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Tags::DEFAULT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); - auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); + //auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); + auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); + auto& snow_depth = *(*S_->GetW(snow_depth_key_, Tags::DEFAULT, snow_depth_key_).ViewComponent("cell", false))(0); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1036,15 +1045,16 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); double energy_source_tot = state.surface_energy_source.data[0]; double water_source_tot = state.surface_water_source.data[0]; + double snow_depth_cell = state.snow_depth.data[0]; Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "Reporting Energy data from EcoSIM: " << std::endl; - *vo_->os() << "Total energy source from EcoSIM: " << energy_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << energy_source_tot/(3600.0) << " ?/s" <os() << "Total energy source from EcoSIM: " << energy_source_tot << " MJ/hr" <os() << "Rate to conserve flux from EcoSIM: " << energy_source_tot/(3600.0) << " MJ/s" <os() << "Reporting Water data from EcoSIM: " << std::endl; - *vo_->os() << "Total water source from EcoSIM: " << water_source_tot << " MJ" <os() << "Rate to conserve flux from EcoSIM: " << water_source_tot/(3600.0) << " ?/s" <os() << "Total water source from EcoSIM: " << water_source_tot << " m/hr" <os() << "Rate to conserve flux from EcoSIM: " << water_source_tot/(3600.0) << " m/s" <GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index c0fc79b7e..1662cff9b 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -222,6 +222,7 @@ class EcoSIM : public PK_Physical { Key surface_water_source_key_; Key subsurface_water_source_key_; Key surface_energy_source_ecosim_key_; + Key surface_water_source_ecosim_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index e1d84f95e..b13589d2e 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -114,6 +114,7 @@ extern "C" { BGCMatrixDouble subsurface_energy_source; BGCVectorDouble surface_energy_source; BGCVectorDouble surface_water_source; + BGCVectorDouble snow_depth; BGCTensorDouble total_component_concentration; } BGCState; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 3ad9616b1..3c1914991 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -323,11 +323,11 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->bulk_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->subsurface_energy_source)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->subsurface_water_source)); - AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_water_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_energy_source)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->snow_depth)); + AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); - } /* end AllocateBGCState() */ void FreeBGCState(BGCState* state) { @@ -345,6 +345,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(state->subsurface_water_source)); FreeBGCVectorDouble(&(state->surface_energy_source)); FreeBGCVectorDouble(&(state->surface_water_source)); + FreeBGCVectorDouble(&(state->snow_depth)); FreeBGCTensorDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ From e6df55dc96d4173380e1489a1cf3a5327632874e Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 10 Oct 2024 12:55:51 -0700 Subject: [PATCH 537/582] added snow-depth dataset --- src/pks/ecosim/CMakeLists.txt | 1 + src/pks/ecosim/EcoSIM_ATS_interface.cc | 39 ++++++++++++++++++++------ src/pks/ecosim/data/CMakeLists.txt | 1 + 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 871a59871..df3ab783b 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -68,6 +68,7 @@ if(ENABLE_ECOSIM) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SoilPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_mods/) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 715f98a2f..ad7bd6028 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -91,7 +91,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, Keys::readKey(*plist_, domain_surface_, "surface water source ecosim", "ecosim_water_source"); //Snow - snow_depth_key_ = Keys::readKey(*plist_, domain_, "snow depth", "snow_depth"); + ecosim_snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "ecosim snow depth", "ecosim_snow_depth"); //snow_source_key_ = Keys::readKey(plist, domain_snow_, "snow mass source - sink", "source_sink"); //new_snow_key_ = Keys::readKey(plist, domain_snow_, "new snow source", "source"); @@ -118,6 +118,10 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, elev_key_ = Keys::readKey(*plist_, domain_surface_, "elevation", "elevation"); aspect_key_ = Keys::readKey(*plist_, domain_surface_, "aspect", "aspect"); slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); + surface_snow_depth_key_ = Keys::readKey(*plist_, domain_, "surface snow depth", "surface-snow-depth"); + snow_depth_key_ = Keys::readKey(*plist_, domain_, "snow depth", "snow-depth"); + //surface_snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "surface snow depth", "surface-snow-depth"); + //snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "snow depth", "snow-depth"); //Atmospheric abundance keys atm_n2_ = plist_->get("atmospheric N2"); @@ -230,6 +234,14 @@ void EcoSIM::Setup() { requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); + /*requireAtNext(matric_pressure_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); + */ + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -329,6 +341,16 @@ void EcoSIM::Initialize() { has_energy = false; } */ + if (S_->HasRecord(surface_snow_depth_key_, Tags::DEFAULT)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found surface_snow_depth_key" << std::endl; + } else if (S_->HasRecord(snow_depth_key_, Tags::DEFAULT)) { + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "found snow_depth_key" << std::endl; + } else { + *vo_->os() << "neither snow depth key found" << std::endl; + } + if (S_->HasRecord(ice_density_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found ice key" << std::endl; @@ -351,6 +373,8 @@ void EcoSIM::Initialize() { S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); + //S_->GetW(ecosim_snow_depth_key_, Tags::DEFAULT, "ecosim_snow_depth").PutScalar(0.0); + //S_->GetRecordW(ecosim_snow_depth_key_, Tags::DEFAULT, "ecosim_snow_depth").set_initialized(); int num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -812,6 +836,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& snow_depth = *(*S_->Get(snow_depth_key_, water_tag).ViewComponent("cell", false))(0); + + //const Epetra_Vector& ecosim_snow_depth = *(*S_->Get(ecosim_snow_depth_key_, water_tag).ViewComponent("cell", false))(0); + auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1048,13 +1076,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, double snow_depth_cell = state.snow_depth.data[0]; Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Reporting Energy data from EcoSIM: " << std::endl; - *vo_->os() << "Total energy source from EcoSIM: " << energy_source_tot << " MJ/hr" <os() << "Rate to conserve flux from EcoSIM: " << energy_source_tot/(3600.0) << " MJ/s" <os() << "snow depth (ATS): " << snow_depth_cell << " m" <os() << "Reporting Water data from EcoSIM: " << std::endl; - *vo_->os() << "Total water source from EcoSIM: " << water_source_tot << " m/hr" <os() << "Rate to conserve flux from EcoSIM: " << water_source_tot/(3600.0) << " m/s" <GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index d0d337495..30c800c5e 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -54,6 +54,7 @@ include_directories(${ECOSIM_BUILD_PREFIX}/f90src/balances/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_datatype/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SoilPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_mods/) From 8f28d40733c799db9d99304255115f2ff6e3ebe3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 10 Oct 2024 14:23:16 -0700 Subject: [PATCH 538/582] adding test dataset --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 7 +++++++ src/pks/ecosim/EcoSIM_ATS_interface.hh | 1 + src/pks/ecosim/data/BGC_containers.hh | 1 + src/pks/ecosim/data/BGC_memory.cc | 2 ++ 4 files changed, 11 insertions(+) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index ad7bd6028..d06d3aa8f 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -90,6 +90,9 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, surface_water_source_ecosim_key_ = Keys::readKey(*plist_, domain_surface_, "surface water source ecosim", "ecosim_water_source"); + surface_test_key = + Keys::readKey(*plist_, domain_surface_, "surface test", "test"); + //Snow ecosim_snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "ecosim snow depth", "ecosim_snow_depth"); //snow_source_key_ = Keys::readKey(plist, domain_snow_, "snow mass source - sink", "source_sink"); @@ -836,6 +839,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& surface_test = *(*S_->Get(surface_test_key, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& snow_depth = *(*S_->Get(snow_depth_key_, water_tag).ViewComponent("cell", false))(0); //const Epetra_Vector& ecosim_snow_depth = *(*S_->Get(ecosim_snow_depth_key_, water_tag).ViewComponent("cell", false))(0); @@ -965,6 +969,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.surface_energy_source.data[column] = surface_energy_source[column]; state.surface_water_source.data[column] = surface_water_source[column]; + state.surface_test.data[column] = surface_test[column] props.shortwave_radiation.data[column] = shortwave_radiation[column]; props.longwave_radiation.data[column] = longwave_radiation[column]; @@ -1037,6 +1042,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); + auto& surface_test = *(*S_->GetW(surface_test_key_, Tags::DEFAULT, surface_test_key_).ViewComponent("cell", false))(0); auto& snow_depth = *(*S_->GetW(snow_depth_key_, Tags::DEFAULT, snow_depth_key_).ViewComponent("cell", false))(0); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1133,6 +1139,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, //As EcoSIM is hourly, but ATS is per second we need to divide the source by seconds per hour surface_energy_source[column] = state.surface_energy_source.data[column]/(3600.0); surface_water_source[column] = state.surface_water_source.data[column]/(3600.0); + surface_test[column] = state.surface_test.data[column]; snow_depth[column] = state.snow_depth.data[column]; //AG - 7/1/24 I'm not sure what this is doing I think it's from when I was testing comparing old to new values diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 1662cff9b..774ea9762 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -223,6 +223,7 @@ class EcoSIM : public PK_Physical { Key subsurface_water_source_key_; Key surface_energy_source_ecosim_key_; Key surface_water_source_ecosim_key_; + Key surface_test_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index b13589d2e..a5e08964a 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -114,6 +114,7 @@ extern "C" { BGCMatrixDouble subsurface_energy_source; BGCVectorDouble surface_energy_source; BGCVectorDouble surface_water_source; + BGCVectorDouble surface_test; BGCVectorDouble snow_depth; BGCTensorDouble total_component_concentration; } BGCState; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 3c1914991..5b2468e28 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -325,6 +325,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->subsurface_water_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_water_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_energy_source)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_test)); AllocateBGCVectorDouble(sizes->num_columns, &(state->snow_depth)); AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); @@ -345,6 +346,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(state->subsurface_water_source)); FreeBGCVectorDouble(&(state->surface_energy_source)); FreeBGCVectorDouble(&(state->surface_water_source)); + FreeBGCVectorDouble(&(state->surface_test)); FreeBGCVectorDouble(&(state->snow_depth)); FreeBGCTensorDouble(&(state->total_component_concentration)); } From acb036a44301f8663dc02fb01dedfa77cefffdcb Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 15 Oct 2024 15:24:24 -0700 Subject: [PATCH 539/582] added working surface-snow_depth dataset --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 58 ++++++++++---------------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 2 +- src/pks/ecosim/data/BGC_containers.hh | 1 - src/pks/ecosim/data/BGC_memory.cc | 2 - 4 files changed, 23 insertions(+), 40 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index d06d3aa8f..693dda067 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -90,13 +90,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, surface_water_source_ecosim_key_ = Keys::readKey(*plist_, domain_surface_, "surface water source ecosim", "ecosim_water_source"); - surface_test_key = - Keys::readKey(*plist_, domain_surface_, "surface test", "test"); - //Snow - ecosim_snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "ecosim snow depth", "ecosim_snow_depth"); - //snow_source_key_ = Keys::readKey(plist, domain_snow_, "snow mass source - sink", "source_sink"); - //new_snow_key_ = Keys::readKey(plist, domain_snow_, "new snow source", "source"); //Other cell_volume_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); @@ -117,14 +111,10 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, vp_air_key_ = Keys::readKey(*plist_, domain_surface_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surface_, "wind speed", "wind_speed"); p_rain_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation rain", "precipitation_rain"); - //p_snow_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation snow", "precipitation_snow"); elev_key_ = Keys::readKey(*plist_, domain_surface_, "elevation", "elevation"); aspect_key_ = Keys::readKey(*plist_, domain_surface_, "aspect", "aspect"); slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); - surface_snow_depth_key_ = Keys::readKey(*plist_, domain_, "surface snow depth", "surface-snow-depth"); - snow_depth_key_ = Keys::readKey(*plist_, domain_, "snow depth", "snow-depth"); - //surface_snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "surface snow depth", "surface-snow-depth"); - //snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "snow depth", "snow-depth"); + snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "snow depth", "snow_depth"); //Atmospheric abundance keys atm_n2_ = plist_->get("atmospheric N2"); @@ -237,14 +227,19 @@ void EcoSIM::Setup() { requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); - /*requireAtNext(matric_pressure_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::CELL, 1); - - requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); + /*S_->RequireEvaluator(test_key_, tag_current_); + S_->Require(test_key_, tag_current_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + S_->RequireEvaluator(test_key_, tag_current_); */ + S_->RequireEvaluator(snow_depth_key_, tag_current_); + S_->Require(snow_depth_key_, tag_current_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + S_->RequireEvaluator(snow_depth_key_, tag_current_); + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -344,7 +339,7 @@ void EcoSIM::Initialize() { has_energy = false; } */ - if (S_->HasRecord(surface_snow_depth_key_, Tags::DEFAULT)) { + /*if (S_->HasRecord(surface_snow_depth_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found surface_snow_depth_key" << std::endl; } else if (S_->HasRecord(snow_depth_key_, Tags::DEFAULT)) { @@ -352,7 +347,7 @@ void EcoSIM::Initialize() { *vo_->os() << "found snow_depth_key" << std::endl; } else { *vo_->os() << "neither snow depth key found" << std::endl; - } + }*/ if (S_->HasRecord(ice_density_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); @@ -376,9 +371,6 @@ void EcoSIM::Initialize() { S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); - //S_->GetW(ecosim_snow_depth_key_, Tags::DEFAULT, "ecosim_snow_depth").PutScalar(0.0); - //S_->GetRecordW(ecosim_snow_depth_key_, Tags::DEFAULT, "ecosim_snow_depth").set_initialized(); - int num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); //Looping over the columns and initializing @@ -465,13 +457,11 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(p_rain_key_, Tags::DEFAULT).Update(*S_, name_); - //S_->GetEvaluator(p_snow_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(snow_depth_key_, Tags::DEFAULT).Update(*S_, name_); if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); @@ -608,6 +598,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& thermal_conductivity = *(*S_->Get("thermal_conductivity", tag_next_) .ViewComponent("cell",false))(0); + S_->GetEvaluator(snow_depth_key_, tag_current_).Update(*S_, name_); + const Epetra_MultiVector& snow_depth = + *S_->Get(snow_depth_key_, tag_current_).ViewComponent("cell", false); + //loop over processes instead: num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -826,24 +820,17 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& precipitation = *(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_energy_source = *(*S_->Get(subsurface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); - - const Epetra_Vector& surface_test = *(*S_->Get(surface_test_key, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& snow_depth = *(*S_->Get(snow_depth_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& ecosim_snow_depth = *(*S_->Get(ecosim_snow_depth_key_, water_tag).ViewComponent("cell", false))(0); - auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -969,7 +956,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.surface_energy_source.data[column] = surface_energy_source[column]; state.surface_water_source.data[column] = surface_water_source[column]; - state.surface_test.data[column] = surface_test[column] + state.snow_depth.data[column] = snow_depth[column]; props.shortwave_radiation.data[column] = shortwave_radiation[column]; props.longwave_radiation.data[column] = longwave_radiation[column]; @@ -977,7 +964,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.vapor_pressure_air.data[column] = vapor_pressure_air[column]; props.wind_speed.data[column] = wind_speed[column]; props.precipitation.data[column] = precipitation[column]; - //props.precipitation_snow.data[column] = precipitation_snow[column]; props.elevation.data[column] = elevation[column]; props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; @@ -1042,7 +1028,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); - auto& surface_test = *(*S_->GetW(surface_test_key_, Tags::DEFAULT, surface_test_key_).ViewComponent("cell", false))(0); + //auto& surface_test = *(*S_->GetW(surface_test_key_, Tags::DEFAULT, surface_test_key_).ViewComponent("cell", false))(0); auto& snow_depth = *(*S_->GetW(snow_depth_key_, Tags::DEFAULT, snow_depth_key_).ViewComponent("cell", false))(0); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1134,12 +1120,12 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; } - double energy_source_tot = state.surface_energy_source.data[column]; + //double energy_source_tot = state.surface_energy_source.data[column]; //As EcoSIM is hourly, but ATS is per second we need to divide the source by seconds per hour surface_energy_source[column] = state.surface_energy_source.data[column]/(3600.0); surface_water_source[column] = state.surface_water_source.data[column]/(3600.0); - surface_test[column] = state.surface_test.data[column]; + //surface_test[column] = state.surface_test.data[column]; snow_depth[column] = state.snow_depth.data[column]; //AG - 7/1/24 I'm not sure what this is doing I think it's from when I was testing comparing old to new values diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 774ea9762..cdf73a51c 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -223,7 +223,7 @@ class EcoSIM : public PK_Physical { Key subsurface_water_source_key_; Key surface_energy_source_ecosim_key_; Key surface_water_source_ecosim_key_; - Key surface_test_key_; + Key snow_depth_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index a5e08964a..b13589d2e 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -114,7 +114,6 @@ extern "C" { BGCMatrixDouble subsurface_energy_source; BGCVectorDouble surface_energy_source; BGCVectorDouble surface_water_source; - BGCVectorDouble surface_test; BGCVectorDouble snow_depth; BGCTensorDouble total_component_concentration; } BGCState; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 5b2468e28..3c1914991 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -325,7 +325,6 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->subsurface_water_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_water_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_energy_source)); - AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_test)); AllocateBGCVectorDouble(sizes->num_columns, &(state->snow_depth)); AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); @@ -346,7 +345,6 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(state->subsurface_water_source)); FreeBGCVectorDouble(&(state->surface_energy_source)); FreeBGCVectorDouble(&(state->surface_water_source)); - FreeBGCVectorDouble(&(state->surface_test)); FreeBGCVectorDouble(&(state->snow_depth)); FreeBGCTensorDouble(&(state->total_component_concentration)); } From 8ef13d0740398e19f041a91fceac733920fa4d2c Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 22 Oct 2024 16:40:35 -0700 Subject: [PATCH 540/582] Put in a fixed version of the snow_depth dataset --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 64 ++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 693dda067..3e875abf0 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -181,6 +181,31 @@ void EcoSIM::Setup() { } } + //Lets try this has record thing + /*if (!S_->HasRecord(snow_depth_key_)) { + S_->Require( + snow_depth_key_ , tag_next_, snow_depth_key_, "surface-snow_depth") + .SetMesh(mesh_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + }*/ + + /*if (!S_->HasRecord(snow_depth_key_)) { + S_->Require(alquimia_aux_data_key_, tag_next_, passwd_) + .SetMesh(mesh_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, num_aux_data); + }*/ + + //Key snow_depth_get_key = Keys::getKey(domain_surface_, "surface-snow_depth"); + + if (!S_->HasRecord(snow_depth_key_,tag_next_)) { + S_->Require(snow_depth_key_, tag_next_, snow_depth_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + } + //This is for the Auxiliary Data which we will need //commenting for now because we don't need it yet /* @@ -234,12 +259,12 @@ void EcoSIM::Setup() { S_->RequireEvaluator(test_key_, tag_current_); */ - S_->RequireEvaluator(snow_depth_key_, tag_current_); + /*S_->RequireEvaluator(snow_depth_key_, tag_current_); S_->Require(snow_depth_key_, tag_current_) .SetMesh(mesh_surf_) ->AddComponent("cell", AmanziMesh::CELL, 1); S_->RequireEvaluator(snow_depth_key_, tag_current_); - + */ if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -598,9 +623,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& thermal_conductivity = *(*S_->Get("thermal_conductivity", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator(snow_depth_key_, tag_current_).Update(*S_, name_); + /*S_->GetEvaluator(snow_depth_key_, tag_current_).Update(*S_, name_); const Epetra_MultiVector& snow_depth = *S_->Get(snow_depth_key_, tag_current_).ViewComponent("cell", false); + */ //loop over processes instead: num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); @@ -830,6 +856,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& snow_depth = *(*S_->Get(snow_depth_key_, water_tag).ViewComponent("cell", false))(0); + //trying alquimia's method + const auto& snow_depth_alt = *S_->Get(snow_depth_key_, tag_next_).ViewComponent("cell"); + auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1028,8 +1057,14 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); - //auto& surface_test = *(*S_->GetW(surface_test_key_, Tags::DEFAULT, surface_test_key_).ViewComponent("cell", false))(0); + //Following Alquimia's example: + + auto& snow_depth_alt = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); auto& snow_depth = *(*S_->GetW(snow_depth_key_, Tags::DEFAULT, snow_depth_key_).ViewComponent("cell", false))(0); + + //This is how surface quantities are grabbed in copy to, is this better??? + //Epetra_Vector& snow_depth_const = *(*S_->GetW(snow_depth_key_, water_tag).ViewComponent("cell", false))(0); + //Epetra_MultiVector& snow_depth_EMV = *S_->GetW("surface-snow_depth", tag_next_, "surface-snow_depth").ViewComponent("cell", false); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1068,7 +1103,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, double snow_depth_cell = state.snow_depth.data[0]; Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "snow depth (ATS): " << snow_depth_cell << " m" <os() << "snow depth (ATS): " << snow_depth_cell << " m" <os() << "cell: " << i << " snow_depth: " << snow_depth[ii] << " m, state: " << state.snow_depth.data[i] << " m" <os() << "col: " << col << " snow_depth: " << state.snow_depth.data[col] << ", snow_depth_auto: " << snow_depth_auto[col] + // << ", snow_depth_EMV: " << snow_depth_EMV[col] << std::endl; + + //*vo_->os() << "col: " << col << " snow_depth: " << state.snow_depth.data[col] << ", snow_depth_auto: " << snow_depth_auto[col] + // << std::endl; //AG - 7/1/24 I'm not sure what this is doing I think it's from when I was testing comparing old to new values //auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); From 488b04182f78931c2ef1c12891cb32e8bfb92c38 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 24 Oct 2024 09:22:54 -0700 Subject: [PATCH 541/582] Code cleanup from the snow depth test --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 209 ++----------------------- 1 file changed, 12 insertions(+), 197 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 3e875abf0..fe708331b 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -181,24 +181,6 @@ void EcoSIM::Setup() { } } - //Lets try this has record thing - /*if (!S_->HasRecord(snow_depth_key_)) { - S_->Require( - snow_depth_key_ , tag_next_, snow_depth_key_, "surface-snow_depth") - .SetMesh(mesh_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::CELL, 1); - }*/ - - /*if (!S_->HasRecord(snow_depth_key_)) { - S_->Require(alquimia_aux_data_key_, tag_next_, passwd_) - .SetMesh(mesh_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::CELL, num_aux_data); - }*/ - - //Key snow_depth_get_key = Keys::getKey(domain_surface_, "surface-snow_depth"); - if (!S_->HasRecord(snow_depth_key_,tag_next_)) { S_->Require(snow_depth_key_, tag_next_, snow_depth_key_) .SetMesh(mesh_surf_) @@ -206,31 +188,6 @@ void EcoSIM::Setup() { ->SetComponent("cell", AmanziMesh::CELL, 1); } - //This is for the Auxiliary Data which we will need - //commenting for now because we don't need it yet - /* - if (plist_->isParameter("auxiliary data")) { - auto names = plist_->get >("auxiliary data"); - - for (auto it = names.begin(); it != names.end(); ++it) { - Key aux_field_name = Keys::getKey(domain_, *it); - if (!S_->HasRecord(aux_field_name)) { - S_->Require(aux_field_name, tag_next_, passwd_) - .SetMesh(mesh_)->SetGhosted(false)->SetComponent("cell", AmanziMesh::CELL, 1); - } - } - } - - // Setup more auxiliary data - if (!S_->HasRecord(alquimia_aux_data_key_, tag_next_)) { - int num_aux_data = bgc_engine_->Sizes().num_aux_integers + bgc_engine_->Sizes().num_aux_doubles; - S_->Require(alquimia_aux_data_key_, tag_next_, passwd_) - .SetMesh(mesh_)->SetGhosted(false)->SetComponent("cell", AmanziMesh::CELL, num_aux_data); - - S_->GetRecordW(alquimia_aux_data_key_, tag_next_, passwd_).set_io_vis(false); - } - */ - //Setup Evaluators requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) @@ -252,19 +209,6 @@ void EcoSIM::Setup() { requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); - /*S_->RequireEvaluator(test_key_, tag_current_); - S_->Require(test_key_, tag_current_) - .SetMesh(mesh_surf_) - ->AddComponent("cell", AmanziMesh::CELL, 1); - S_->RequireEvaluator(test_key_, tag_current_); - */ - - /*S_->RequireEvaluator(snow_depth_key_, tag_current_); - S_->Require(snow_depth_key_, tag_current_) - .SetMesh(mesh_surf_) - ->AddComponent("cell", AmanziMesh::CELL, 1); - S_->RequireEvaluator(snow_depth_key_, tag_current_); - */ if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -287,93 +231,6 @@ void EcoSIM::Initialize() { int ierr = 0; - /*if (S_->HasRecord(suc_key_, Tags::DEFAULT)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "has suction key." << std::endl; - } else { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Does not have suction key at default." << std::endl; - } - if (S_->HasRecord(suc_key_, Tags::CURRENT)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "has suction key at current" << std::endl; - } else { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Does not have suction key at current" << std::endl; - } - if (S_->HasRecord(suc_key_, Tags::NEXT)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "has suction key at next" << std::endl; - } else { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Does not have suction key at next" << std::endl; - }*/ - - // Ensure dependencies are filled - // May not need to update (also causes an assertion error if called before - // The PK that owns the variable - /*S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(relative_permeability_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(liquid_density_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(rock_density_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); - */ - //S_->GetEvaluator(suc_key_, Tags::DEFAULT).Update(*S_, name_); - - //Surface properties from met data - /*S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(p_rain_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); - - if (S_->HasRecord(gas_density_key_test_, Tags::DEFAULT)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found mass density gas key" << std::endl; - S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(gas_density_key_, Tags::DEFAULT).Update(*S_, name_); - has_gas = true; - } else { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Did not find gas key" << std::endl; - has_gas = false; - } - - if (S_->HasRecord(T_key_, Tags::DEFAULT)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found temp key" << std::endl; - S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(thermal_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(cell_volume_key_, Tags::DEFAULT).Update(*S_, name_); - has_energy = true; - } else { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Did not find temp key" << std::endl; - has_energy = false; - } - */ - /*if (S_->HasRecord(surface_snow_depth_key_, Tags::DEFAULT)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found surface_snow_depth_key" << std::endl; - } else if (S_->HasRecord(snow_depth_key_, Tags::DEFAULT)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found snow_depth_key" << std::endl; - } else { - *vo_->os() << "neither snow depth key found" << std::endl; - }*/ - if (S_->HasRecord(ice_density_key_, Tags::DEFAULT)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "found ice key" << std::endl; @@ -398,11 +255,6 @@ void EcoSIM::Initialize() { int num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - //Looping over the columns and initializing - /*for (int col=0; col!=num_columns_; ++col) { - ierr = InitializeSingleColumn(col); - }*/ - //loop over processes instead: num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -490,7 +342,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(gas_density_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(gas_density_key_, Tags::DEFAULT).Update(*S_, name_); } if (has_ice) { @@ -555,9 +407,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false))(0);*/ if (has_gas) { - S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) - .ViewComponent("cell",false))(0); + //S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) + // .ViewComponent("cell",false))(0); S_->GetEvaluator("saturation_gas", tag_next_).Update(*S_, name_); const Epetra_MultiVector& gas_saturation = *(*S_->Get("saturation_gas", tag_next_) @@ -623,11 +475,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& thermal_conductivity = *(*S_->Get("thermal_conductivity", tag_next_) .ViewComponent("cell",false))(0); - /*S_->GetEvaluator(snow_depth_key_, tag_current_).Update(*S_, name_); - const Epetra_MultiVector& snow_depth = - *S_->Get(snow_depth_key_, tag_current_).ViewComponent("cell", false); - */ - //loop over processes instead: num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); @@ -855,10 +702,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& snow_depth = *(*S_->Get(snow_depth_key_, water_tag).ViewComponent("cell", false))(0); - //trying alquimia's method - const auto& snow_depth_alt = *S_->Get(snow_depth_key_, tag_next_).ViewComponent("cell"); - auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -919,10 +762,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, if (has_gas) { const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& gas_density = *(*S_->Get(gas_density_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& gas_density = *(*S_->Get(gas_density_key_, water_tag).ViewComponent("cell", false))(0); FieldToColumn_(column,gas_saturation,col_g_sat.ptr()); - FieldToColumn_(column,gas_density,col_g_dens.ptr()); + //FieldToColumn_(column,gas_density,col_g_dens.ptr()); } if (has_ice) { @@ -970,7 +813,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, if (has_gas) { props.gas_saturation.data[column][i] = (*col_g_sat)[i]; - state.gas_density.data[column][i] = (*col_g_dens)[i]; + //state.gas_density.data[column][i] = (*col_g_dens)[i]; } if (has_ice) { @@ -985,7 +828,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.surface_energy_source.data[column] = surface_energy_source[column]; state.surface_water_source.data[column] = surface_water_source[column]; - state.snow_depth.data[column] = snow_depth[column]; props.shortwave_radiation.data[column] = shortwave_radiation[column]; props.longwave_radiation.data[column] = longwave_radiation[column]; @@ -1057,14 +899,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); - //Following Alquimia's example: - - auto& snow_depth_alt = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); - auto& snow_depth = *(*S_->GetW(snow_depth_key_, Tags::DEFAULT, snow_depth_key_).ViewComponent("cell", false))(0); - //This is how surface quantities are grabbed in copy to, is this better??? - //Epetra_Vector& snow_depth_const = *(*S_->GetW(snow_depth_key_, water_tag).ViewComponent("cell", false))(0); - //Epetra_MultiVector& snow_depth_EMV = *S_->GetW("surface-snow_depth", tag_next_, "surface-snow_depth").ViewComponent("cell", false); + auto& snow_depth = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1102,26 +938,19 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, double water_source_tot = state.surface_water_source.data[0]; double snow_depth_cell = state.snow_depth.data[0]; - Teuchos::OSTab tab = vo_->getOSTab(); - //*vo_->os() << "snow depth (ATS): " << snow_depth_cell << " m" <os() << "cell: " << i << " snow_depth: " << snow_depth[ii] << " m, state: " << state.snow_depth.data[i] << " m" <GetW(saturation_gas_key_, Tags::DEFAULT, saturation_gas_key_).ViewComponent("cell",false))(0); - auto& gas_density = *(*S_->GetW(gas_density_key_, Tags::DEFAULT, gas_density_key_).ViewComponent("cell",false))(0); + //auto& gas_density = *(*S_->GetW(gas_density_key_, Tags::DEFAULT, gas_density_key_).ViewComponent("cell",false))(0); for (int i=0; i < ncells_per_col_; ++i) { - (*col_g_dens)[i] = state.gas_density.data[column][i]; + //(*col_g_dens)[i] = state.gas_density.data[column][i]; (*col_g_sat)[i] = props.gas_saturation.data[column][i]; } ColumnToField_(column,gas_saturation,col_g_sat.ptr()); - ColumnToField_(column,gas_density,col_g_dens.ptr()); + //ColumnToField_(column,gas_density,col_g_dens.ptr()); } if (has_ice) { @@ -1164,21 +993,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, //As EcoSIM is hourly, but ATS is per second we need to divide the source by seconds per hour surface_energy_source[col] = state.surface_energy_source.data[col]/(3600.0); surface_water_source[col] = state.surface_water_source.data[col]/(3600.0); - //surface_test[column] = state.surface_test.data[column]; - //snow_depth[col] = state.snow_depth.data[col]; - snow_depth_alt[0][col] = state.snow_depth.data[col]; - //snow_depth_alt[col][0] = state.snow_depth.data[col]; - //snow_depth_EMV[col] = &state.snow_depth.data[col]; - - //*vo_->os() << "col: " << col << " snow_depth: " << state.snow_depth.data[col] << ", snow_depth_auto: " << snow_depth_auto[col] - // << ", snow_depth_EMV: " << snow_depth_EMV[col] << std::endl; - - //*vo_->os() << "col: " << col << " snow_depth: " << state.snow_depth.data[col] << ", snow_depth_auto: " << snow_depth_auto[col] - // << std::endl; - - //AG - 7/1/24 I'm not sure what this is doing I think it's from when I was testing comparing old to new values - //auto& new_e_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); - //auto& new_w_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); + snow_depth[0][col] = state.snow_depth.data[col]; ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); ColumnToField_(column,water_content,col_wc.ptr()); From 94be8841aaa55ef38ec29bce23ce864dcd904455 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 11 Nov 2024 17:31:54 -0800 Subject: [PATCH 542/582] added data flattening for coupler --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 200 +++++++++++-------------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 1 + src/pks/ecosim/data/BGC_containers.hh | 6 +- src/pks/ecosim/data/BGC_memory.cc | 17 ++- src/pks/ecosim/ecosim_wrappers.F90 | 3 +- 5 files changed, 105 insertions(+), 122 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index fe708331b..9972682f4 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -686,6 +686,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); @@ -741,6 +743,17 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + //Now that the arrays are flat we need to be a little more careful about how we load an unload the data + /*const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); + for (int column=0; column!=num_columns_local; ++column) { + FieldToColumn_(column, temp, col_temp.ptr()); + + for (int i=0; i < ncells_per_col_; ++i) { + state.temperature.data[column * ncells_per_col_ + i] = (*col_temp)[i]; + state.temperature.data[column * ncells_per_col_ + i] = 222.0; + } + }*/ + //Loop over columns on this process for (int column=0; column!=num_columns_local; ++column) { FieldToColumn_(column,porosity,col_porosity.ptr()); @@ -757,31 +770,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,subsurface_water_source,col_ss_water_source.ptr()); FieldToColumn_(column,subsurface_energy_source,col_ss_energy_source.ptr()); FieldToColumn_(column,matric_pressure,col_mat_p.ptr()); - - MatrixFieldToColumn_(column, tcc, col_tcc.ptr()); - - if (has_gas) { - const Epetra_Vector& gas_saturation = *(*S_->Get(saturation_gas_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& gas_density = *(*S_->Get(gas_density_key_, water_tag).ViewComponent("cell", false))(0); - - FieldToColumn_(column,gas_saturation,col_g_sat.ptr()); - //FieldToColumn_(column,gas_density,col_g_dens.ptr()); - } - - if (has_ice) { - const Epetra_Vector& ice_saturation = *(*S_->Get(saturation_ice_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& ice_density = *(*S_->Get(ice_density_key_, water_tag).ViewComponent("cell", false))(0); - - FieldToColumn_(column,ice_saturation,col_i_sat.ptr()); - FieldToColumn_(column,ice_density,col_i_dens.ptr()); - } - - const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - + FieldToColumn_(column,temp, col_temp.ptr()); + FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); FieldToColumn_(column,temp, col_temp.ptr()); FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); + //MatrixFieldToColumn_(column, tcc, col_tcc.ptr()); + // This is for computing depth //ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); @@ -793,36 +788,35 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } for (int i=0; i < ncells_per_col_; ++i) { - state.liquid_density.data[column][i] = (*col_l_dens)[i]; - state.porosity.data[column][i] = (*col_porosity)[i]; - state.water_content.data[column][i] = (*col_wc)[i]; - state.hydraulic_conductivity.data[column][i] = (*col_h_cond)[i]; - state.bulk_density.data[column][i] = (*col_b_dens)[i]; - state.subsurface_water_source.data[column][i] = (*col_ss_water_source)[i]; - state.subsurface_energy_source.data[column][i] = (*col_ss_energy_source)[i]; - state.matric_pressure.data[column][i] = (*col_mat_p)[i]; - - props.plant_wilting_factor.data[column][i] = (*col_wp)[i]; - props.rooting_depth_fraction.data[column][i] = (*col_rf)[i]; - props.liquid_saturation.data[column][i] = (*col_l_sat)[i]; - props.relative_permeability.data[column][i] = (*col_relative_permeability)[i]; - props.volume.data[column][i] = (*col_vol)[i]; - props.depth.data[column][i] = (*col_depth)[i]; - props.depth_c.data[column][i] = (*col_depth_c)[i]; - props.dz.data[column][i] = (*col_dz)[i]; + state.liquid_density.data[column * ncells_per_col_ + i] = (*col_l_dens)[i]; + state.porosity.data[column * ncells_per_col_ + i] = (*col_porosity)[i]; + state.water_content.data[column * ncells_per_col_ + i] = (*col_wc)[i]; + state.hydraulic_conductivity.data[column * ncells_per_col_ + i] = (*col_h_cond)[i]; + state.bulk_density.data[column * ncells_per_col_ + i] = (*col_b_dens)[i]; + state.subsurface_water_source.data[column * ncells_per_col_ + i] = (*col_ss_water_source)[i]; + state.subsurface_energy_source.data[column * ncells_per_col_ + i] = (*col_ss_energy_source)[i]; + state.matric_pressure.data[column * ncells_per_col_ + i] = (*col_mat_p)[i]; + state.temperature.data[column * ncells_per_col_ + i] = (*col_temp)[i]; + + props.plant_wilting_factor.data[column * ncells_per_col_ + i] = (*col_wp)[i]; + props.rooting_depth_fraction.data[column * ncells_per_col_ + i] = (*col_rf)[i]; + props.liquid_saturation.data[column * ncells_per_col_ + i] = (*col_l_sat)[i]; + props.relative_permeability.data[column * ncells_per_col_ + i] = (*col_relative_permeability)[i]; + props.volume.data[column * ncells_per_col_ + i] = (*col_vol)[i]; + props.depth.data[column * ncells_per_col_ + i] = (*col_depth)[i]; + props.depth_c.data[column * ncells_per_col_ + i] = (*col_depth_c)[i]; + props.dz.data[column * ncells_per_col_ + i] = (*col_dz)[i]; if (has_gas) { - props.gas_saturation.data[column][i] = (*col_g_sat)[i]; + props.gas_saturation.data[column * ncells_per_col_ + i] = (*col_g_sat)[i]; //state.gas_density.data[column][i] = (*col_g_dens)[i]; } if (has_ice) { - state.ice_density.data[column][i] = (*col_i_dens)[i]; - props.ice_saturation.data[column][i] = (*col_i_sat)[i]; + state.ice_density.data[column * ncells_per_col_ + i] = (*col_i_dens)[i]; + props.ice_saturation.data[column * ncells_per_col_ + i] = (*col_i_sat)[i]; } - state.temperature.data[column][i] = (*col_temp)[i]; - props.thermal_conductivity.data[column][i] = (*col_cond)[i]; } //fill surface variables @@ -846,7 +840,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } } } - + //Fill the atmospheric abundances //NOTE: probably want to add an if statement here to only do this only once props.atm_n2 = atm_n2_; @@ -898,6 +892,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, //auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); + auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); + auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); auto& snow_depth = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); @@ -938,71 +934,29 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, double water_source_tot = state.surface_water_source.data[0]; double snow_depth_cell = state.snow_depth.data[0]; - //Loop over columns on this process for (int col=0; col!=num_columns_local; ++col) { - - if (has_gas) { - auto& gas_saturation = *(*S_->GetW(saturation_gas_key_, Tags::DEFAULT, saturation_gas_key_).ViewComponent("cell",false))(0); - //auto& gas_density = *(*S_->GetW(gas_density_key_, Tags::DEFAULT, gas_density_key_).ViewComponent("cell",false))(0); - for (int i=0; i < ncells_per_col_; ++i) { - //(*col_g_dens)[i] = state.gas_density.data[column][i]; - (*col_g_sat)[i] = props.gas_saturation.data[column][i]; - } - - ColumnToField_(column,gas_saturation,col_g_sat.ptr()); - //ColumnToField_(column,gas_density,col_g_dens.ptr()); - } - - if (has_ice) { - auto& ice_saturation = *(*S_->GetW(saturation_ice_key_, Tags::DEFAULT, saturation_ice_key_).ViewComponent("cell",false))(0); - auto& ice_density = *(*S_->GetW(ice_density_key_, Tags::DEFAULT, ice_density_key_).ViewComponent("cell",false))(0); - - for (int i=0; i < ncells_per_col_; ++i) { - (*col_i_dens)[i] = state.ice_density.data[column][i]; - (*col_i_sat)[i] = props.ice_saturation.data[column][i]; - } - - ColumnToField_(column,ice_saturation,col_i_sat.ptr()); - ColumnToField_(column,ice_density,col_i_dens.ptr()); - } - - auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); - auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); - - for (int i=0; i < ncells_per_col_; ++i) { - (*col_temp)[i] = state.temperature.data[column][i]; - (*col_cond)[i] = props.thermal_conductivity.data[column][i]; - } - - ColumnToField_(column,temp, col_temp.ptr()); - ColumnToField_(column,thermal_conductivity,col_cond.ptr()); - - for (int i=0; i < ncells_per_col_; ++i) { - (*col_l_dens)[i] = state.liquid_density.data[column][i]; - (*col_porosity)[i] = state.porosity.data[column][i]; - (*col_wc)[i] = state.water_content.data[column][i]; - (*col_h_cond)[i] = state.hydraulic_conductivity.data[column][i]; - (*col_b_dens)[i] = state.bulk_density.data[column][i]; - - (*col_ss_water_source)[i] = state.subsurface_water_source.data[column][i]; - (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column][i]; - } - - //double energy_source_tot = state.surface_energy_source.data[column]; - - //As EcoSIM is hourly, but ATS is per second we need to divide the source by seconds per hour surface_energy_source[col] = state.surface_energy_source.data[col]/(3600.0); surface_water_source[col] = state.surface_water_source.data[col]/(3600.0); snow_depth[0][col] = state.snow_depth.data[col]; + } + + /*auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); + for (int column = 0; column != num_columns_local; ++column) { + for (int i = 0; i < ncells_per_col_; ++i) { + (*col_temp)[i] = state.temperature.data[column * ncells_per_col_ + i]; + } - ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); - ColumnToField_(column,water_content,col_wc.ptr()); - ColumnToField_(column,relative_permeability,col_relative_permeability.ptr()); - ColumnToField_(column,hydraulic_conductivity,col_h_cond.ptr()); - ColumnToField_(column,bulk_density,col_b_dens.ptr()); + ColumnToField_(column, temp, col_temp.ptr()); + }*/ + + + //ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); + //ColumnToField_(column,water_content,col_wc.ptr()); + //ColumnToField_(column,relative_permeability,col_relative_permeability.ptr()); + //ColumnToField_(column,hydraulic_conductivity,col_h_cond.ptr()); + //ColumnToField_(column,bulk_density,col_b_dens.ptr()); //ColumnToField_(column,plant_wilting_factor,col_wp.ptr()); //ColumnToField_(column,rooting_depth_fraction,col_rf.ptr()); - } } /* @@ -1038,6 +992,7 @@ int EcoSIM::AdvanceSingleColumn(double dt, int col) return num_iterations; } */ + int EcoSIM::InitializeSingleProcess(int proc) { int num_iterations = 1; @@ -1056,8 +1011,8 @@ int EcoSIM::InitializeSingleProcess(int proc) What I want it to be*/ //Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "num_columns: " << num_columns << std::endl; - *vo_->os() << "ncells_per_col_: " << ncells_per_col_ << std::endl; + //*vo_->os() << "num_columns: " << num_columns << std::endl; + //*vo_->os() << "ncells_per_col_: " << ncells_per_col_ << std::endl; bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns,ncells_per_col_); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); @@ -1067,22 +1022,49 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) { // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but // should use the same tag as transport. See #673 - CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + //CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); int num_iterations = 1; int num_columns = 1; num_columns = num_columns_local; - bgc_engine_->Advance(dt, bgc_props_, bgc_state_, + Teuchos::OSTab tab = vo_->getOSTab(); + if (t_ecosim <= 3600.0) { + *vo_->os() << "t_ecosim: " << t_ecosim << ", dt: " << dt << std::endl; + t_ecosim = t_ecosim + dt; + } else { + *vo_->os() << "It has been an hour, running EcoSIM Advance: " << std::endl; + + CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns); + + CopyFromEcoSIM_process(proc, + bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + + t_ecosim = 0.0; + } + + //bgc_engine_->Advance(dt, bgc_props_, bgc_state_, + // bgc_sizes_, num_iterations, num_columns); // Move the information back into Amanzi's state, updating the given total concentration vector. - CopyFromEcoSIM_process(proc, - bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + //CopyFromEcoSIM_process(proc, + // bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); return num_iterations; } +double** ConvertTo2DArray(BGCMatrixDouble* matrix) { + double** data_2d = new double*[matrix->cells]; + for (int i = 0; i < matrix->cells; ++i) { + data_2d[i] = &(matrix->data[i * matrix->capacity_columns]); + } + return data_2d; +} + + } // namespace EcoSIM } // namespace Amanzi diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index cdf73a51c..34b97c7f0 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -184,6 +184,7 @@ class EcoSIM : public PK_Physical { int num_columns_global_ptype; double saved_time_; double current_time_; + double t_ecosim = 0.0; // keys Key tcc_key_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index b13589d2e..19ef22b2d 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -66,17 +66,17 @@ extern "C" { typedef struct { int cells, columns, capacity_cells, capacity_columns; - double** data; + double* data; } BGCMatrixDouble; typedef struct { int cells, columns, capacity_cells, capacity_columns; - int** data; + int* data; } BGCMatrixInt; typedef struct { int cells, columns, capacity; - char** data; + char* data; } BGCMatrixString; typedef struct { diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 3c1914991..00e8b3597 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -151,10 +151,11 @@ void AllocateBGCMatrixDouble(const int cells, const int columns, BGCMatrixDouble matrix->columns = columns; matrix->capacity_cells = nearest_power_of_2(cells); matrix->capacity_columns = nearest_power_of_2(columns); - matrix->data = (double**) calloc((size_t)matrix->capacity_columns, sizeof(double*)); - for (int i = 0; i < matrix->columns; ++i) { - matrix->data[i] = (double*) calloc((size_t)matrix->capacity_cells, sizeof(double)); - } + matrix->data = (double*) calloc((size_t)matrix->capacity_cells * matrix->capacity_columns, sizeof(double)); + + //for (int i = 0; i < matrix->columns; ++i) { + // matrix->data[i] = (double*) calloc((size_t)matrix->capacity_cells, sizeof(double)); + //} //ALQUIMIA_ASSERT(NULL != matrix->data); } else { matrix->cells= 0; @@ -182,10 +183,10 @@ void AllocateBGCMatrixInt(const int cells, const int columns, BGCMatrixInt* matr matrix->columns= columns; matrix->capacity_cells= nearest_power_of_2(cells); matrix->capacity_columns= nearest_power_of_2(columns); - matrix->data = (int**) calloc((size_t)matrix->capacity_columns, sizeof(int*)); - for (int i = 0; i < matrix->columns; ++i) { - matrix->data[i] = (int*) calloc((size_t)matrix->capacity_cells, sizeof(int)); - } + matrix->data = (int*) calloc((size_t)matrix->capacity_cells * matrix->capacity_columns, sizeof(int)); + //for (int i = 0; i < matrix->columns; ++i) { + // matrix->data[i] = (int*) calloc((size_t)matrix->capacity_cells, sizeof(int)); + //} //ALQUIMIA_ASSERT(NULL != matrix->data); } else { matrix->cells= 0; diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index b8db0330b..78446a097 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -70,10 +70,9 @@ subroutine EcoSIM_Setup(properties, state, sizes, num_iterations,& sizes%ncells_per_col_ = 100 sizes%num_columns = 25 - call Init_EcoSIM(sizes) - call ATS2EcoSIMData(num_columns, state, properties, sizes) + call Init_EcoSIM(sizes) write(*,*) "starting driver transfer EcoSIM2ATSData" call EcoSIM2ATSData(num_columns, state, sizes) From 57310cf8b2b2fc2a866001f76e1306b70fcf3a48 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 3 Feb 2025 16:41:32 -0800 Subject: [PATCH 543/582] minor changes to reflect EcoSIM changes --- src/pks/ecosim/CMakeLists.txt | 16 ++++++++-------- src/pks/ecosim/data/CMakeLists.txt | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index df3ab783b..da1c7e84b 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -58,18 +58,18 @@ if(ENABLE_ECOSIM) #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) message("At includ_directories") - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/utils/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/minimath/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/modelconfig/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/mesh/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/modelpars/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/balances/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_datatype/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelconfig/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Mesh/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelpars/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Balances/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_datatype/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SoilPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_mods/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_mods/) include_directories(${ECOSIM_INCLUDE_DIRS}) diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 30c800c5e..3f689c80f 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -45,18 +45,18 @@ message("ECOSIM_BUILD_PREFIX:" ${ECOSIM_BUILD_PREFIX}) #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) message("At include_directories in data") -include_directories(${ECOSIM_BUILD_PREFIX}/f90src/utils/) -include_directories(${ECOSIM_BUILD_PREFIX}/f90src/minimath/) -include_directories(${ECOSIM_BUILD_PREFIX}/f90src/modelconfig/) -include_directories(${ECOSIM_BUILD_PREFIX}/f90src/mesh/) -include_directories(${ECOSIM_BUILD_PREFIX}/f90src/modelpars/) -include_directories(${ECOSIM_BUILD_PREFIX}/f90src/balances/) -include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_datatype/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelconfig/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Mesh/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelpars/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Balances/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_datatype/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SoilPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) -include_directories(${ECOSIM_BUILD_PREFIX}/f90src/ecosim_mods/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_mods/) set(ats_ecosim_data_src_files BGC_constants.cc From 49c4284466aceef051af7c50a38418deb76781e2 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 17 Feb 2025 12:45:52 -0800 Subject: [PATCH 544/582] Minor changes for snow buildup and mass balance check --- src/pks/ecosim/CMakeLists.txt | 13 +++++++++---- src/pks/ecosim/EcoSIM_ATS_interface.cc | 10 +++++++++- src/pks/ecosim/data/CMakeLists.txt | 7 +++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index da1c7e84b..e2b8b202a 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -57,7 +57,7 @@ if(ENABLE_ECOSIM) #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) - message("At includ_directories") + message("At include_directories") include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelconfig/) @@ -73,7 +73,8 @@ if(ENABLE_ECOSIM) include_directories(${ECOSIM_INCLUDE_DIRS}) - + + message("EcoSIM inc dirs: ") message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") # ATS EcoSIM pk @@ -113,8 +114,9 @@ if(ENABLE_ECOSIM) file(GLOB ECOSIM_LIBRARIES ${ECOSIM_LIB_LOCATION}/*.a ) - - find_package(NetCDF REQUIRED) + + +find_package(NetCDF REQUIRED) set(ats_ecosim_link_libs ${Teuchos_LIBRARIES} @@ -136,8 +138,11 @@ if(ENABLE_ECOSIM) ats_operators ats_ecosim_data ats_ecosim_relations + /global2/packages/software/gcc/12.3.0/lib64/libgfortran.so.5 ) + message(STATUS "ats_ecosim_link_libs: ${ats_ecosim_link_libs}") + message(inc_files="${ats_ecosim_inc_files}") add_amanzi_library(ats_ecosim diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 9972682f4..e7b78a3d0 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -705,6 +705,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + auto& snow_depth = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); + auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -822,6 +824,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.surface_energy_source.data[column] = surface_energy_source[column]; state.surface_water_source.data[column] = surface_water_source[column]; + state.snow_depth.data[column] = snow_depth[0][column]; props.shortwave_radiation.data[column] = shortwave_radiation[column]; props.longwave_radiation.data[column] = longwave_radiation[column]; @@ -833,6 +836,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; + for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { @@ -855,7 +859,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.wilting_point = pressure_at_wilting_point; Teuchos::OSTab tab = vo_->getOSTab(); - + *vo_->os() << "(CopyToEcoSIM) precipitation = " << props.precipitation.data[1] << " m/s" << std::endl; + /*for (int column=0; column!=num_columns_local; ++column) { *vo_->os() << "for column: " << column << std::endl; for (int i=0; i < ncells_per_col_; ++i) { @@ -940,6 +945,9 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, snow_depth[0][col] = state.snow_depth.data[col]; } + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "(CopyFromEcoSIM) Q_w = " << surface_water_source[1] << " m/s " << "snow_depth = " << snow_depth[0][1] << std::endl; + /*auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); for (int column = 0; column != num_columns_local; ++column) { for (int i = 0; i < ncells_per_col_; ++i) { diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 3f689c80f..fe3bd65f1 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -23,7 +23,7 @@ set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) #set(ECOSIM_LIB_LOCATION ${ECOSIM_LIBRARY_DIR}) set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) set(ECOSIM_BUILD_PREFIX ${ECOSIM_DIR}/ecosim/build) -set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) +#set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) set(NETCDF_LIB ${ECOSIM_DIR}/lib) message("In ATS-EcoSIM data CMakeLists:") @@ -79,7 +79,7 @@ set(ats_ecosim_data_inc_files ) file(GLOB ECOSIM_LIBRARIES - ${ECOSIM_LIB_LOCATION}/*.a + ${ECOSIM_LIB_LOCATION}/*.a ) set(ats_ecosim_data_link_libs @@ -105,8 +105,11 @@ set(ats_ecosim_data_link_libs ${NETCDF_LIB}/libnetcdff.so ${NETCDF_LIB}/libnetcdff.so.7 ${NETCDF_LIB}/libnetcdff.so.7.1.0 + /global2/packages/software/gcc/12.3.0/lib64/libgfortran.so.5 ) +message(STATUS "ats_ecosim_data_link_libs: ${ats_ecosim_data_link_libs}") + # make the library add_amanzi_library(ats_ecosim_data SOURCE ${ats_ecosim_data_src_files} From 49a5d24aa89542a8d7836d52765683a61fb9b565 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 5 Mar 2025 14:28:25 -0800 Subject: [PATCH 545/582] changes to function calls to make code compile after rebase --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 109 +++++++++++++------------ src/pks/ecosim/EcoSIM_ATS_interface.hh | 2 +- src/pks/ecosim/ecosim_wrappers.F90 | 6 +- 3 files changed, 63 insertions(+), 54 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index e7b78a3d0..1f038a748 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -46,7 +46,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& global_list, const Teuchos::RCP& S, const Teuchos::RCP& solution): - PK_Physical(pk_tree, global_list, S, solution), + PK_Physical_Default(pk_tree, global_list, S, solution), PK(pk_tree, global_list, S, solution), ncells_per_col_(-1), saved_time_(0.0) @@ -165,14 +165,16 @@ EcoSIM::~EcoSIM() void EcoSIM::Setup() { //Need to do some basic setup of the columns: mesh_surf_ = S_->GetMesh(domain_surface_); - num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + //num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Parallel_type::OWNED, AmanziMesh::Parallel_kind::OWNED); + int num_columns_ = + mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); for (unsigned int column = 0; column != num_columns_; ++column) { - int f = mesh_surf_->entity_get_parent(AmanziMesh::CELL, column); - auto& col_iter = mesh_->cells_of_column(column); + int f = mesh_surf_->getEntityParent(AmanziMesh::Entity_kind::CELL, column); + auto col_iter = mesh_->columns.getCells(column); std::size_t ncol_cells = col_iter.size(); - double column_area = mesh_->face_area(f); + double column_area = mesh_->getFaceArea(f); if (ncells_per_col_ < 0) { ncells_per_col_ = ncol_cells; @@ -224,7 +226,7 @@ void EcoSIM::Initialize() { int tcc_num = tcc.NumVectors(); Teuchos::OSTab tab = vo_->getOSTab(); - num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //Now we call the engine's init state function which allocates the data bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num, num_columns_); @@ -253,12 +255,12 @@ void EcoSIM::Initialize() { S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); - int num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + int num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //loop over processes instead: - num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + num_columns_global = mesh_surf_->getMap(AmanziMesh::Entity_kind::CELL, false).NumGlobalElements(); + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + num_columns_global_ptype = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); //Trying to loop over processors now: int numProcesses, p_rank; @@ -267,7 +269,7 @@ void EcoSIM::Initialize() { for (int k = 0; k < numProcesses; ++k) { MPI_Barrier(MPI_COMM_WORLD); if (p_rank==k) { - num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); InitializeSingleProcess(p_rank); } @@ -363,7 +365,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { Teuchos::RCP matric_pressure = S_->GetPtr(matric_pressure_key_, Tags::DEFAULT); S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); - AmanziMesh::Entity_ID num_columns_ = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + AmanziMesh::Entity_ID num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); // grab the required fields S_->GetEvaluator("porosity", tag_next_).Update(*S_, name_); @@ -476,9 +478,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false))(0); //loop over processes instead: - num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + num_columns_global = mesh_surf_->getMap(AmanziMesh::Entity_kind::CELL,false).NumGlobalElements(); + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + num_columns_global_ptype = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); //Trying to loop over processors now: int numProcesses, p_rank; @@ -487,7 +489,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { for (int k = 0; k < numProcesses; ++k) { MPI_Barrier(MPI_COMM_WORLD); if (p_rank==k) { - num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); AdvanceSingleProcess(dt, p_rank); } @@ -499,7 +501,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_Vector& vec, Teuchos::Ptr col_vec) { - auto& col_iter = mesh_->cells_of_column(column); + auto col_iter = mesh_->columns.getCells(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { std::size_t vec_index = col_iter[i]; @@ -511,7 +513,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_Vector& v void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID column, const Teuchos::Ptr vec, Teuchos::Ptr col_vec) { - auto& col_iter = mesh_->cells_of_column(column); + auto col_iter = mesh_->columns.getCells(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { std::size_t vec_index = col_iter[i]; @@ -524,7 +526,7 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_Mul Teuchos::Ptr col_arr) { int n_comp = m_arr.NumVectors(); - auto& col_iter = mesh_->cells_of_column(column); + auto col_iter = mesh_->columns.getCells(column); for (int j=0; j!=n_comp; ++j){ for (std::size_t i=0; i!=col_iter.size(); ++i) { @@ -537,7 +539,7 @@ void EcoSIM::MatrixFieldToColumn_(AmanziMesh::Entity_ID column, const Epetra_Mul void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Epetra_Vector& vec, Teuchos::Ptr col_vec) { - auto& col_iter = mesh_->cells_of_column(column); + auto col_iter = mesh_->columns.getCells(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { vec[col_iter[i]] = (*col_vec)[i]; } @@ -546,7 +548,7 @@ void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Epetra_Vector& vec, void EcoSIM::ColumnToField_(AmanziMesh::Entity_ID column, Teuchos::Ptr vec, Teuchos::Ptr col_vec) { - auto& col_iter = mesh_->cells_of_column(column); + auto col_iter = mesh_->columns.getCells(column); for (std::size_t i=0; i!=col_iter.size(); ++i) { (*vec)[col_iter[i]] = (*col_vec)[i]; } @@ -556,7 +558,7 @@ void EcoSIM::MatrixColumnToField_(AmanziMesh::Entity_ID column, Epetra_MultiVect Teuchos::Ptr col_arr) { int n_comp = m_arr.NumVectors(); - auto& col_iter = mesh_->cells_of_column(column); + auto col_iter = mesh_->columns.getCells(column); for (int j=0; j!=n_comp; ++j){ for (std::size_t i=0; i!=col_iter.size(); ++i) { @@ -570,11 +572,11 @@ void EcoSIM::MatrixColumnToField_(AmanziMesh::Entity_ID column, Epetra_MultiVect void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID column, Teuchos::Ptr depth, Teuchos::Ptr dz) { - AmanziMesh::Entity_ID f_above = mesh_surf_->entity_get_parent(AmanziMesh::CELL, column); - auto& col_iter = mesh_->cells_of_column(column); + AmanziMesh::Entity_ID f_above = mesh_surf_->getEntityParent(AmanziMesh::Entity_kind::CELL, column); + auto col_iter = mesh_->columns.getCells(column); ncells_per_col_ = col_iter.size(); - AmanziGeometry::Point surf_centroid = mesh_->face_centroid(f_above); + AmanziGeometry::Point surf_centroid = mesh_->getFaceCentroid(f_above); AmanziGeometry::Point neg_z(3); neg_z.set(0.,0.,-1); @@ -582,21 +584,22 @@ void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID column, for (std::size_t i=0; i!=col_iter.size(); ++i) { // depth centroid - (*depth)[i] = surf_centroid[2] - mesh_->cell_centroid(col_iter[i])[2]; + (*depth)[i] = surf_centroid[2] - mesh_->getCellCentroid(col_iter[i])[2]; // dz // -- find face_below - AmanziMesh::Entity_ID_List faces; - std::vector dirs; - mesh_->cell_get_faces_and_dirs(col_iter[i], &faces, &dirs); + //AmanziMesh::Entity_ID_List faces; + //std::vector dirs; + //mesh_->cell_get_faces_and_dirs(col_iter[i], &faces, &dirs); + ///double vol = mesh_->cell_volume(col_iter[i]); - double vol = mesh_->cell_volume(col_iter[i]); + const auto& [faces, dirs] = mesh_->getCellFacesAndDirections(col_iter[i]); // -- mimics implementation of build_columns() in Mesh double mindp = 999.0; AmanziMesh::Entity_ID f_below = -1; for (std::size_t j=0; j!=faces.size(); ++j) { - AmanziGeometry::Point normal = mesh_->face_normal(faces[j]); + AmanziGeometry::Point normal = mesh_->getFaceNormal(faces[j]); if (dirs[j] == -1) normal *= -1; normal /= AmanziGeometry::norm(normal); @@ -608,7 +611,7 @@ void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID column, } // -- fill the val - (*dz)[i] = mesh_->face_centroid(f_above)[2] - mesh_->face_centroid(f_below)[2]; + (*dz)[i] = mesh_->getFaceCentroid(f_above)[2] - mesh_->getFaceCentroid(f_below)[2]; AMANZI_ASSERT( (*dz)[i] > 0. ); f_above = f_below; } @@ -619,32 +622,34 @@ void EcoSIM::VolDepthDz_(AmanziMesh::Entity_ID column, Teuchos::Ptr depth, Teuchos::Ptr dz, Teuchos::Ptr volume) { - AmanziMesh::Entity_ID f_above = mesh_surf_->entity_get_parent(AmanziMesh::CELL, column); - auto& col_iter = mesh_->cells_of_column(column); + AmanziMesh::Entity_ID f_above = mesh_surf_->getEntityParent(AmanziMesh::Entity_kind::CELL, column); + auto col_iter = mesh_->columns.getCells(column); ncells_per_col_ = col_iter.size(); - AmanziGeometry::Point surf_centroid = mesh_->face_centroid(f_above); + AmanziGeometry::Point surf_centroid = mesh_->getFaceCentroid(f_above); AmanziGeometry::Point neg_z(3); neg_z.set(0.,0.,-1); for (std::size_t i=0; i!=col_iter.size(); ++i) { // depth centroid - (*depth)[i] = surf_centroid[2] - mesh_->cell_centroid(col_iter[i])[2]; + (*depth)[i] = surf_centroid[2] - mesh_->getCellCentroid(col_iter[i])[2]; // dz // -- find face_below - AmanziMesh::Entity_ID_List faces; - std::vector dirs; - mesh_->cell_get_faces_and_dirs(col_iter[i], &faces, &dirs); + //AmanziMesh::Entity_ID_List faces; + //std::vector dirs; + //mesh_->cell_get_faces_and_dirs(col_iter[i], &faces, &dirs); + + const auto& [faces, dirs] = mesh_->getCellFacesAndDirections(col_iter[i]); //double vol = mesh_->cell_volume(col_iter[i]); - (*volume)[i] = mesh_->cell_volume(col_iter[i]); + (*volume)[i] = mesh_->getCellVolume(col_iter[i]); // -- mimics implementation of build_columns() in Mesh double mindp = 999.0; AmanziMesh::Entity_ID f_below = -1; for (std::size_t j=0; j!=faces.size(); ++j) { - AmanziGeometry::Point normal = mesh_->face_normal(faces[j]); + AmanziGeometry::Point normal = mesh_->getFaceNormal(faces[j]); if (dirs[j] == -1) normal *= -1; normal /= AmanziGeometry::norm(normal); @@ -656,7 +661,7 @@ void EcoSIM::VolDepthDz_(AmanziMesh::Entity_ID column, } // -- fill the val - (*dz)[i] = mesh_->face_centroid(f_above)[2] - mesh_->face_centroid(f_below)[2]; + (*dz)[i] = mesh_->getFaceCentroid(f_above)[2] - mesh_->getFaceCentroid(f_below)[2]; AMANZI_ASSERT( (*dz)[i] > 0. ); f_above = f_below; } @@ -734,16 +739,16 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); //Gather columns on this process: - num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + num_columns_global = mesh_surf_->getMap(AmanziMesh::Entity_kind::CELL,false).NumGlobalElements(); + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + num_columns_global_ptype = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); //Trying to loop over processors now: int p_rank; MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); MPI_Barrier(MPI_COMM_WORLD); - num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //Now that the arrays are flat we need to be a little more careful about how we load an unload the data /*const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); @@ -925,16 +930,16 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); //Gather columns on this process: - num_columns_global = mesh_surf_->cell_map(AmanziMesh::Entity_kind::CELL).NumGlobalElements(); - num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); - num_columns_global_ptype = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::ALL); + num_columns_global = mesh_surf_->getMap(AmanziMesh::Entity_kind::CELL, false).NumGlobalElements(); + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + num_columns_global_ptype = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); //Trying to loop over processors now: int p_rank; MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); MPI_Barrier(MPI_COMM_WORLD); - num_columns_local = mesh_surf_->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED); + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); double energy_source_tot = state.surface_energy_source.data[0]; double water_source_tot = state.surface_water_source.data[0]; double snow_depth_cell = state.snow_depth.data[0]; @@ -1022,6 +1027,10 @@ int EcoSIM::InitializeSingleProcess(int proc) //*vo_->os() << "num_columns: " << num_columns << std::endl; //*vo_->os() << "ncells_per_col_: " << ncells_per_col_ << std::endl; + bgc_sizes_.num_columns = num_columns; + bgc_sizes_.ncells_per_col_ = ncells_per_col_; + bgc_sizes_.num_components = 1; + bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns,ncells_per_col_); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); } diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 34b97c7f0..4c00fe1fa 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -47,7 +47,7 @@ namespace Amanzi { namespace EcoSIM { -class EcoSIM : public PK_Physical { +class EcoSIM : public PK_Physical_Default { public: diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index 78446a097..2d1709159 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -66,9 +66,9 @@ subroutine EcoSIM_Setup(properties, state, sizes, num_iterations,& !write(*,*) "num_columns: ", num_columns !write(*,*) "ncells_per_col_: ", ncells_per_col_ - sizes%num_components = 1 - sizes%ncells_per_col_ = 100 - sizes%num_columns = 25 + !sizes%num_components = 1 + !sizes%ncells_per_col_ = 100 + !sizes%num_columns = 25 call ATS2EcoSIMData(num_columns, state, properties, sizes) From ce81ae2825ec0ec006cfec0e9de28241af9e4a19 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Mon, 10 Mar 2025 15:34:01 -0700 Subject: [PATCH 546/582] minor bug fixes --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 35 ++++++++++--------- .../bulk_density/bulk_density_evaluator.cc | 6 ++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 1f038a748..5704a65b5 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -52,7 +52,9 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saved_time_(0.0) { //grab the surface and subsurface domains - domain_ = plist_->get("domain name", "domain"); + //May need to edit this as well + //domain_ = plist_->get("domain name", "domain"); + domain_ = Keys::readDomain(*plist_, "domain", "domain"); domain_surface_ = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); // transport @@ -163,6 +165,7 @@ EcoSIM::~EcoSIM() // -- Setup step void EcoSIM::Setup() { + PK_Physical_Default::Setup(); //Need to do some basic setup of the columns: mesh_surf_ = S_->GetMesh(domain_surface_); //num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Parallel_type::OWNED, AmanziMesh::Parallel_kind::OWNED); @@ -191,7 +194,7 @@ void EcoSIM::Setup() { } //Setup Evaluators - requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) + /*requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); @@ -210,7 +213,7 @@ void EcoSIM::Setup() { ->AddComponent("cell", AmanziMesh::CELL, 1); requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); - + */ if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -220,7 +223,7 @@ void EcoSIM::Setup() { // -- Initialize owned (dependent) variables. void EcoSIM::Initialize() { - + PK_Physical_Default::Initialize(); //Need to know the number of components to initialize data structures const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); int tcc_num = tcc.NumVectors(); @@ -246,7 +249,7 @@ void EcoSIM::Initialize() { } //Initialize owned evaluators - S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); + /*S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); S_->GetW(bulk_density_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); @@ -254,7 +257,7 @@ void EcoSIM::Initialize() { S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); - + */ int num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //loop over processes instead: @@ -327,7 +330,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); //Surface data from met data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); @@ -356,7 +359,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(thermal_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); //Update owned evaluators - Teuchos::RCP hydra_cond = S_->GetPtr(hydraulic_conductivity_key_, Tags::DEFAULT); + /*Teuchos::RCP hydra_cond = S_->GetPtr(hydraulic_conductivity_key_, Tags::DEFAULT); S_->GetEvaluator(hydraulic_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); Teuchos::RCP bulk_dens = S_->GetPtr(bulk_density_key_, Tags::DEFAULT); @@ -364,7 +367,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { Teuchos::RCP matric_pressure = S_->GetPtr(matric_pressure_key_, Tags::DEFAULT); S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); - + */ AmanziMesh::Entity_ID num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); // grab the required fields @@ -384,9 +387,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("matric_pressure", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& suction_head = *(*S_->Get("matric_pressure", tag_next_) - .ViewComponent("cell",false))(0); + //S_->GetEvaluator("matric_pressure", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& suction_head = *(*S_->Get("matric_pressure", tag_next_) + // .ViewComponent("cell",false))(0); S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) @@ -770,13 +773,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,liquid_density,col_l_dens.ptr()); FieldToColumn_(column,rock_density,col_r_dens.ptr()); //FieldToColumn_(column,cell_volume,col_vol.ptr()); - FieldToColumn_(column,hydraulic_conductivity,col_h_cond.ptr()); + //FieldToColumn_(column,hydraulic_conductivity,col_h_cond.ptr()); FieldToColumn_(column,bulk_density,col_b_dens.ptr()); FieldToColumn_(column,plant_wilting_factor,col_wp.ptr()); FieldToColumn_(column,rooting_depth_fraction,col_rf.ptr()); FieldToColumn_(column,subsurface_water_source,col_ss_water_source.ptr()); FieldToColumn_(column,subsurface_energy_source,col_ss_energy_source.ptr()); - FieldToColumn_(column,matric_pressure,col_mat_p.ptr()); + //FieldToColumn_(column,matric_pressure,col_mat_p.ptr()); FieldToColumn_(column,temp, col_temp.ptr()); FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); FieldToColumn_(column,temp, col_temp.ptr()); @@ -798,11 +801,11 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.liquid_density.data[column * ncells_per_col_ + i] = (*col_l_dens)[i]; state.porosity.data[column * ncells_per_col_ + i] = (*col_porosity)[i]; state.water_content.data[column * ncells_per_col_ + i] = (*col_wc)[i]; - state.hydraulic_conductivity.data[column * ncells_per_col_ + i] = (*col_h_cond)[i]; + //state.hydraulic_conductivity.data[column * ncells_per_col_ + i] = (*col_h_cond)[i]; state.bulk_density.data[column * ncells_per_col_ + i] = (*col_b_dens)[i]; state.subsurface_water_source.data[column * ncells_per_col_ + i] = (*col_ss_water_source)[i]; state.subsurface_energy_source.data[column * ncells_per_col_ + i] = (*col_ss_energy_source)[i]; - state.matric_pressure.data[column * ncells_per_col_ + i] = (*col_mat_p)[i]; + //state.matric_pressure.data[column * ncells_per_col_ + i] = (*col_mat_p)[i]; state.temperature.data[column * ncells_per_col_ + i] = (*col_temp)[i]; props.plant_wilting_factor.data[column * ncells_per_col_ + i] = (*col_wp)[i]; diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc index 93c11a6ef..6387dfcd2 100644 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc +++ b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc @@ -69,7 +69,7 @@ BulkDensityEvaluator::InitializeFromPlist_() dependencies_.insert(KeyTag{ sl_key_, tag}); // dependency: molar_density_liquid - nl_key_ = Keys::readKey(plist_, domain_name, "molar density liquid", "molar_density_liquid"); + nl_key_ = Keys::readKey(plist_, domain_name, "molar density", "molar_density_liquid"); dependencies_.insert(KeyTag{ nl_key_,tag}); // dependency: saturation_ice @@ -77,7 +77,7 @@ BulkDensityEvaluator::InitializeFromPlist_() dependencies_.insert(KeyTag{ si_key_, tag}); // dependency: molar_density_ice - ni_key_ = Keys::readKey(plist_, domain_name, "molar density ice", "molar_density_ice"); + ni_key_ = Keys::readKey(plist_, domain_name, "molar density", "molar_density_ice"); dependencies_.insert(KeyTag{ ni_key_, tag}); // dependency: saturation_gas @@ -85,7 +85,7 @@ BulkDensityEvaluator::InitializeFromPlist_() dependencies_.insert(KeyTag{ sg_key_, tag}); // dependency: molar_density_gas - ng_key_ = Keys::readKey(plist_, domain_name, "molar density gas", "molar_density_gas"); + ng_key_ = Keys::readKey(plist_, domain_name, "molar density", "molar_density_gas"); dependencies_.insert(KeyTag{ ng_key_, tag}); } From b6777a84d600590e9c2fd74d5d9556be3357d049 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 19 Mar 2025 19:29:15 -0700 Subject: [PATCH 547/582] changing the ownership methods of the source variables, the coupler seems to be working again --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 48 ++++++++++++++++++++------ 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 5704a65b5..9a96e7944 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -192,6 +192,24 @@ void EcoSIM::Setup() { ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); } + //surface_energy_source_ecosim_key_ + //surface_water_source_ecosim_key_ + S_->Require(surface_energy_source_ecosim_key_ , tag_next_, name_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(surface_water_source_ecosim_key_ , tag_next_, name_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + //May need to setup surface evaluators as they are now owned by surface_balance PK insteady of surface energy?? + // + + S_->RequireEvaluator(sw_key_, tag_next_); + S_->Require(sw_key_, tag_next_).SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); //Setup Evaluators /*requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) @@ -247,6 +265,13 @@ void EcoSIM::Initialize() { *vo_->os() << "Did not find ice key" << std::endl; has_ice = false; } + S_->GetW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").PutScalar(0.0); + S_->GetRecordW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").set_initialized(); + //surface_energy_source_ecosim_key_ + //surface_water_source_ecosim_key_ + + S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, name_).PutScalar(0.0); + S_->GetRecordW(surface_water_source_ecosim_key_, Tags::DEFAULT, name_).set_initialized(); //Initialize owned evaluators /*S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); @@ -689,14 +714,15 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& liquid_density = *(*S_->Get(liquid_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rock_density = *(*S_->Get(rock_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cell_volume_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydraulic_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& matric_pressure = *(*S_->Get(matric_pressure_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydraulic_conductivity_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& matric_pressure = *(*S_->Get(matric_pressure_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - + + //const auto& shortwave_radiation = *S_.Get(sw_key_, water_tag).ViewComponent("cell", false); const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); @@ -774,7 +800,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,rock_density,col_r_dens.ptr()); //FieldToColumn_(column,cell_volume,col_vol.ptr()); //FieldToColumn_(column,hydraulic_conductivity,col_h_cond.ptr()); - FieldToColumn_(column,bulk_density,col_b_dens.ptr()); + //FieldToColumn_(column,bulk_density,col_b_dens.ptr()); FieldToColumn_(column,plant_wilting_factor,col_wp.ptr()); FieldToColumn_(column,rooting_depth_fraction,col_rf.ptr()); FieldToColumn_(column,subsurface_water_source,col_ss_water_source.ptr()); @@ -802,7 +828,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.porosity.data[column * ncells_per_col_ + i] = (*col_porosity)[i]; state.water_content.data[column * ncells_per_col_ + i] = (*col_wc)[i]; //state.hydraulic_conductivity.data[column * ncells_per_col_ + i] = (*col_h_cond)[i]; - state.bulk_density.data[column * ncells_per_col_ + i] = (*col_b_dens)[i]; + //state.bulk_density.data[column * ncells_per_col_ + i] = (*col_b_dens)[i]; state.subsurface_water_source.data[column * ncells_per_col_ + i] = (*col_ss_water_source)[i]; state.subsurface_energy_source.data[column * ncells_per_col_ + i] = (*col_ss_energy_source)[i]; //state.matric_pressure.data[column * ncells_per_col_ + i] = (*col_mat_p)[i]; @@ -895,15 +921,17 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& liquid_density = *(*S_->GetW(liquid_density_key_, Tags::DEFAULT, liquid_density_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_density_key_, Tags::DEFAULT, rock_density_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cell_volume_key_, Tags::DEFAULT, cell_volume_key_).ViewComponent("cell",false))(0); - auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); - auto& bulk_density = *(*S_->GetW(bulk_density_key_, Tags::DEFAULT, bulk_density_key_).ViewComponent("cell",false))(0); + //auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); + //auto& bulk_density = *(*S_->GetW(bulk_density_key_, Tags::DEFAULT, bulk_density_key_).ViewComponent("cell",false))(0); //auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); - auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, surface_energy_source_ecosim_key_).ViewComponent("cell", false))(0); + auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, name_).ViewComponent("cell", false))(0); + //Epetra_MultiVector& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, tag_next_, name_).ViewComponent("cell", false))(0); + //Epetra_MultiVector& surface_energy_source = *(S_->GetW(surface_energy_source_ecosim_key_, tag_next_, name_).ViewComponent("cell", false)); auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Tags::DEFAULT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); //auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); - auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); + auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, name_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); From d21361826eee95311363408b0bb3d310a3398479 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 10 Apr 2025 18:12:41 -0700 Subject: [PATCH 548/582] minor fixes to keys and shared libraries --- src/pks/ecosim/CMakeLists.txt | 2 +- src/pks/ecosim/EcoSIM_ATS_interface.cc | 8 ++++---- src/pks/ecosim/data/CMakeLists.txt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index e2b8b202a..f363d6022 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -138,7 +138,7 @@ find_package(NetCDF REQUIRED) ats_operators ats_ecosim_data ats_ecosim_relations - /global2/packages/software/gcc/12.3.0/lib64/libgfortran.so.5 + gfortran ) message(STATUS "ats_ecosim_link_libs: ${ats_ecosim_link_libs}") diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 9a96e7944..e227f6851 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -199,7 +199,7 @@ void EcoSIM::Setup() { ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); - S_->Require(surface_water_source_ecosim_key_ , tag_next_, name_) + S_->Require(surface_water_source_ecosim_key_ , tag_next_, surface_water_source_ecosim_key_) .SetMesh(mesh_surf_) ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); @@ -270,8 +270,8 @@ void EcoSIM::Initialize() { //surface_energy_source_ecosim_key_ //surface_water_source_ecosim_key_ - S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, name_).PutScalar(0.0); - S_->GetRecordW(surface_water_source_ecosim_key_, Tags::DEFAULT, name_).set_initialized(); + S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).PutScalar(0.0); + S_->GetRecordW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).set_initialized(); //Initialize owned evaluators /*S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); @@ -931,7 +931,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Tags::DEFAULT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); //auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); - auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, name_).ViewComponent("cell", false))(0); + auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index fe3bd65f1..901b975db 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -105,7 +105,7 @@ set(ats_ecosim_data_link_libs ${NETCDF_LIB}/libnetcdff.so ${NETCDF_LIB}/libnetcdff.so.7 ${NETCDF_LIB}/libnetcdff.so.7.1.0 - /global2/packages/software/gcc/12.3.0/lib64/libgfortran.so.5 + gfortran ) message(STATUS "ats_ecosim_data_link_libs: ${ats_ecosim_data_link_libs}") From 54e35f6c9e64c907ae6a1b645d1166b7cf1459b8 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 17 Apr 2025 20:36:59 -0700 Subject: [PATCH 549/582] bugfixes to owned evaluators --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 51 ++--- .../bulk_density/bulk_density_evaluator.cc | 181 +----------------- .../bulk_density/bulk_density_evaluator.hh | 6 - .../bulk_density/bulk_density_model.cc | 46 +---- .../bulk_density/bulk_density_model.hh | 14 +- .../matric_pressure_evaluator.cc | 20 +- .../matric_pressure_evaluator.hh | 1 + .../matric_pressure/matric_pressure_model.cc | 17 +- .../matric_pressure/matric_pressure_model.hh | 4 +- 9 files changed, 66 insertions(+), 274 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index e227f6851..ce2bef5d8 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -35,6 +35,7 @@ // include custom evaluators here #include "hydraulic_conductivity_evaluator.hh" #include "bulk_density_evaluator.hh" +#include "matric_pressure_evaluator.hh" #include "pk_helpers.hh" #include "EcoSIM_ATS_interface.hh" @@ -212,7 +213,7 @@ void EcoSIM::Setup() { ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); //Setup Evaluators - /*requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) + requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); @@ -231,7 +232,7 @@ void EcoSIM::Setup() { ->AddComponent("cell", AmanziMesh::CELL, 1); requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); - */ + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -274,7 +275,7 @@ void EcoSIM::Initialize() { S_->GetRecordW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).set_initialized(); //Initialize owned evaluators - /*S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); + S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); S_->GetW(bulk_density_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); @@ -282,7 +283,7 @@ void EcoSIM::Initialize() { S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); - */ + int num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //loop over processes instead: @@ -384,15 +385,17 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(thermal_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); //Update owned evaluators - /*Teuchos::RCP hydra_cond = S_->GetPtr(hydraulic_conductivity_key_, Tags::DEFAULT); + Teuchos::RCP hydra_cond = S_->GetPtr(hydraulic_conductivity_key_, Tags::DEFAULT); S_->GetEvaluator(hydraulic_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); Teuchos::RCP bulk_dens = S_->GetPtr(bulk_density_key_, Tags::DEFAULT); S_->GetEvaluator(bulk_density_key_, Tags::DEFAULT).Update(*S_, name_); - Teuchos::RCP matric_pressure = S_->GetPtr(matric_pressure_key_, Tags::DEFAULT); + Teuchos::RCP mat_p = S_->GetPtr(matric_pressure_key_, Tags::DEFAULT); S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); - */ + const Epetra_MultiVector& matric_pressure = *(*S_->Get("matric_pressure", tag_next_) + .ViewComponent("cell",false))(0); + AmanziMesh::Entity_ID num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); // grab the required fields @@ -412,10 +415,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) .ViewComponent("cell",false))(0); - //S_->GetEvaluator("matric_pressure", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& suction_head = *(*S_->Get("matric_pressure", tag_next_) - // .ViewComponent("cell",false))(0); - S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) .ViewComponent("cell",false))(0); @@ -714,9 +713,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& liquid_density = *(*S_->Get(liquid_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rock_density = *(*S_->Get(rock_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cell_volume_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydraulic_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& matric_pressure = *(*S_->Get(matric_pressure_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydraulic_conductivity_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& matric_pressure = *(*S_->Get(matric_pressure_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); @@ -778,7 +777,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, MPI_Barrier(MPI_COMM_WORLD); num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); - + std::cout << "MP: " << matric_pressure << std::endl; //Now that the arrays are flat we need to be a little more careful about how we load an unload the data /*const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); for (int column=0; column!=num_columns_local; ++column) { @@ -798,14 +797,14 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,relative_permeability,col_relative_permeability.ptr()); FieldToColumn_(column,liquid_density,col_l_dens.ptr()); FieldToColumn_(column,rock_density,col_r_dens.ptr()); - //FieldToColumn_(column,cell_volume,col_vol.ptr()); - //FieldToColumn_(column,hydraulic_conductivity,col_h_cond.ptr()); - //FieldToColumn_(column,bulk_density,col_b_dens.ptr()); + FieldToColumn_(column,cell_volume,col_vol.ptr()); + FieldToColumn_(column,hydraulic_conductivity,col_h_cond.ptr()); + FieldToColumn_(column,bulk_density,col_b_dens.ptr()); FieldToColumn_(column,plant_wilting_factor,col_wp.ptr()); FieldToColumn_(column,rooting_depth_fraction,col_rf.ptr()); FieldToColumn_(column,subsurface_water_source,col_ss_water_source.ptr()); FieldToColumn_(column,subsurface_energy_source,col_ss_energy_source.ptr()); - //FieldToColumn_(column,matric_pressure,col_mat_p.ptr()); + FieldToColumn_(column,matric_pressure,col_mat_p.ptr()); FieldToColumn_(column,temp, col_temp.ptr()); FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); FieldToColumn_(column,temp, col_temp.ptr()); @@ -822,16 +821,16 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, sum += (*col_dz)[i]; (*col_depth_c)[i] = sum; } - + for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[column * ncells_per_col_ + i] = (*col_l_dens)[i]; state.porosity.data[column * ncells_per_col_ + i] = (*col_porosity)[i]; state.water_content.data[column * ncells_per_col_ + i] = (*col_wc)[i]; - //state.hydraulic_conductivity.data[column * ncells_per_col_ + i] = (*col_h_cond)[i]; - //state.bulk_density.data[column * ncells_per_col_ + i] = (*col_b_dens)[i]; + state.hydraulic_conductivity.data[column * ncells_per_col_ + i] = (*col_h_cond)[i]; + state.bulk_density.data[column * ncells_per_col_ + i] = (*col_b_dens)[i]; state.subsurface_water_source.data[column * ncells_per_col_ + i] = (*col_ss_water_source)[i]; state.subsurface_energy_source.data[column * ncells_per_col_ + i] = (*col_ss_energy_source)[i]; - //state.matric_pressure.data[column * ncells_per_col_ + i] = (*col_mat_p)[i]; + state.matric_pressure.data[column * ncells_per_col_ + i] = (*col_mat_p)[i]; state.temperature.data[column * ncells_per_col_ + i] = (*col_temp)[i]; props.plant_wilting_factor.data[column * ncells_per_col_ + i] = (*col_wp)[i]; @@ -843,6 +842,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.depth_c.data[column * ncells_per_col_ + i] = (*col_depth_c)[i]; props.dz.data[column * ncells_per_col_ + i] = (*col_dz)[i]; + Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "(Copy loop) i = " << i << " matric pressure = " << (*col_mat_p)[i] << std::endl; if (has_gas) { props.gas_saturation.data[column * ncells_per_col_ + i] = (*col_g_sat)[i]; //state.gas_density.data[column][i] = (*col_g_dens)[i]; @@ -870,7 +871,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; - for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { @@ -893,6 +893,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.wilting_point = pressure_at_wilting_point; Teuchos::OSTab tab = vo_->getOSTab(); + *vo_->os() << "(CopyToEcoSIM) hydraulic conductivity = " << state.hydraulic_conductivity.data[1] << std::endl; + *vo_->os() << "(CopyToEcoSIM) bulk density = " << state.bulk_density.data[1] << std::endl; + *vo_->os() << "(CopyToEcoSIM) matric pressure = " << state.matric_pressure.data[1] << std::endl; *vo_->os() << "(CopyToEcoSIM) precipitation = " << props.precipitation.data[1] << " m/s" << std::endl; /*for (int column=0; column!=num_columns_local; ++column) { diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc index 6387dfcd2..41f1af152 100644 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc +++ b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc @@ -27,12 +27,6 @@ BulkDensityEvaluator::BulkDensityEvaluator(Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(other), phi_key_(other.phi_key_), nr_key_(other.nr_key_), - sl_key_(other.sl_key_), - nl_key_(other.nl_key_), - si_key_(other.si_key_), - ni_key_(other.ni_key_), - sg_key_(other.sg_key_), - ng_key_(other.ng_key_), model_(other.model_) {}*/ @@ -63,30 +57,6 @@ BulkDensityEvaluator::InitializeFromPlist_() // dependency: density_rock nr_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); dependencies_.insert(KeyTag{ nr_key_, tag}); - - // dependency: saturation_liquid - sl_key_ = Keys::readKey(plist_, domain_name, "saturation liquid", "saturation_liquid"); - dependencies_.insert(KeyTag{ sl_key_, tag}); - - // dependency: molar_density_liquid - nl_key_ = Keys::readKey(plist_, domain_name, "molar density", "molar_density_liquid"); - dependencies_.insert(KeyTag{ nl_key_,tag}); - - // dependency: saturation_ice - si_key_ = Keys::readKey(plist_, domain_name, "saturation ice", "saturation_ice"); - dependencies_.insert(KeyTag{ si_key_, tag}); - - // dependency: molar_density_ice - ni_key_ = Keys::readKey(plist_, domain_name, "molar density", "molar_density_ice"); - dependencies_.insert(KeyTag{ ni_key_, tag}); - - // dependency: saturation_gas - sg_key_ = Keys::readKey(plist_, domain_name, "saturation gas", "saturation_gas"); - dependencies_.insert(KeyTag{ sg_key_, tag}); - - // dependency: molar_density_gas - ng_key_ = Keys::readKey(plist_, domain_name, "molar density", "molar_density_gas"); - dependencies_.insert(KeyTag{ ng_key_, tag}); } @@ -97,28 +67,16 @@ BulkDensityEvaluator::Evaluate_(const State& S, Tag tag = my_keys_.front().second; Teuchos::RCP phi = S.GetPtr(phi_key_, tag); Teuchos::RCP nr = S.GetPtr(nr_key_, tag); - Teuchos::RCP sl = S.GetPtr(sl_key_, tag); - Teuchos::RCP nl = S.GetPtr(nl_key_, tag); - Teuchos::RCP si = S.GetPtr(si_key_, tag); - Teuchos::RCP ni = S.GetPtr(ni_key_, tag); - Teuchos::RCP sg = S.GetPtr(sg_key_, tag); - Teuchos::RCP ng = S.GetPtr(ng_key_, tag); for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->BulkDensity(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + result_v[0][i] = model_->BulkDensity(phi_v[0][i], nr_v[0][i]); } } } @@ -131,30 +89,17 @@ BulkDensityEvaluator::EvaluatePartialDerivative_(const State& S, Tag tag = my_keys_.front().second; Teuchos::RCP phi = S.GetPtr(phi_key_, tag); Teuchos::RCP nr = S.GetPtr(nr_key_, tag); - Teuchos::RCP sl = S.GetPtr(sl_key_, tag); - Teuchos::RCP nl = S.GetPtr(nl_key_, tag); - Teuchos::RCP si = S.GetPtr(si_key_, tag); - Teuchos::RCP ni = S.GetPtr(ni_key_, tag); - Teuchos::RCP sg = S.GetPtr(sg_key_, tag); - Teuchos::RCP ng = S.GetPtr(ng_key_, tag); - if (wrt_key == phi_key_) { for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDPorosity(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + result_v[0][i] = model_->DBulkDensityDPorosity(phi_v[0][i], nr_v[0][i]); } } @@ -163,131 +108,11 @@ BulkDensityEvaluator::EvaluatePartialDerivative_(const State& S, comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDDensityRock(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); - } - } - - } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDSaturationLiquid(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); - } - } - - } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDMolarDensityLiquid(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); - } - } - - } else if (wrt_key == si_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDSaturationIce(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); - } - } - - } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDMolarDensityIce(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); - } - } - - } else if (wrt_key == sg_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDSaturationGas(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); - } - } - - } else if (wrt_key == ng_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); - const Epetra_MultiVector& si_v = *si->ViewComponent(*comp, false); - const Epetra_MultiVector& ni_v = *ni->ViewComponent(*comp, false); - const Epetra_MultiVector& sg_v = *sg->ViewComponent(*comp, false); - const Epetra_MultiVector& ng_v = *ng->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDMolarDensityGas(phi_v[0][i], nr_v[0][i], sl_v[0][i], nl_v[0][i], si_v[0][i], ni_v[0][i], sg_v[0][i], ng_v[0][i]); + result_v[0][i] = model_->DBulkDensityDDensityRock(phi_v[0][i], nr_v[0][i]); } } diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh index cda44091d..a7eb3eed4 100644 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh +++ b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh @@ -40,12 +40,6 @@ class BulkDensityEvaluator : public EvaluatorSecondaryMonotypeCV { protected: Key phi_key_; Key nr_key_; - Key sl_key_; - Key nl_key_; - Key si_key_; - Key ni_key_; - Key sg_key_; - Key ng_key_; Teuchos::RCP model_; diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc index 146b91e62..449e8e7f6 100644 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc +++ b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc @@ -32,59 +32,23 @@ BulkDensityModel::InitializeFromPlist_(Teuchos::ParameterList& plist) // main method double -BulkDensityModel::BulkDensity(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +BulkDensityModel::BulkDensity(double phi, double nr) const { - return nr*(1 - phi) + phi*(ng*sg + ni*si + nl*sl); + return nr*(1 - phi); } double -BulkDensityModel::DBulkDensityDPorosity(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +BulkDensityModel::DBulkDensityDPorosity(double phi, double nr) const { - return ng*sg + ni*si + nl*sl - nr; + return -1.0*nr; } double -BulkDensityModel::DBulkDensityDDensityRock(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const +BulkDensityModel::DBulkDensityDDensityRock(double phi, double nr) const { return 1 - phi; } -double -BulkDensityModel::DBulkDensityDSaturationLiquid(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const -{ - return nl*phi; -} - -double -BulkDensityModel::DBulkDensityDMolarDensityLiquid(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const -{ - return phi*sl; -} - -double -BulkDensityModel::DBulkDensityDSaturationIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const -{ - return ni*phi; -} - -double -BulkDensityModel::DBulkDensityDMolarDensityIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const -{ - return phi*si; -} - -double -BulkDensityModel::DBulkDensityDSaturationGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const -{ - return ng*phi; -} - -double -BulkDensityModel::DBulkDensityDMolarDensityGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const -{ - return phi*sg; -} - } //namespace } //namespace } //namespace diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh index af45aba74..f4ca13355 100644 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh +++ b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh @@ -20,16 +20,10 @@ class BulkDensityModel { explicit BulkDensityModel(Teuchos::ParameterList& plist); - double BulkDensity(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - - double DBulkDensityDPorosity(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - double DBulkDensityDDensityRock(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - double DBulkDensityDSaturationLiquid(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - double DBulkDensityDMolarDensityLiquid(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - double DBulkDensityDSaturationIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - double DBulkDensityDMolarDensityIce(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - double DBulkDensityDSaturationGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; - double DBulkDensityDMolarDensityGas(double phi, double nr, double sl, double nl, double si, double ni, double sg, double ng) const; + double BulkDensity(double phi, double nr) const; + + double DBulkDensityDPorosity(double phi, double nr) const; + double DBulkDensityDDensityRock(double phi, double nr) const; protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc index bf7614cce..166c77f36 100644 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc @@ -65,6 +65,9 @@ MatricPressureEvaluator::InitializeFromPlist_() // dependency: cell volume cv_key_ = Keys::readKey(plist_, domain_name, "cell volume", "cell_volume"); dependencies_.insert(KeyTag{ cv_key_, tag}); + + sl_key_ = Keys::readKey(plist_, domain_name, "liquid saturation", "saturation_liquid"); + dependencies_.insert(KeyTag{ sl_key_, tag}); } @@ -77,6 +80,7 @@ MatricPressureEvaluator::Evaluate_(const State& S, Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); Teuchos::RCP cv = S.GetPtr(cv_key_, tag); + Teuchos::RCP sl = S.GetPtr(sl_key_, tag); for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { @@ -84,11 +88,12 @@ MatricPressureEvaluator::Evaluate_(const State& S, const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->MatricPressure(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i]); + result_v[0][i] = model_->MatricPressure(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i], sl_v[0][i]); } } } @@ -103,19 +108,22 @@ MatricPressureEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); Teuchos::RCP cv = S.GetPtr(cv_key_, tag); + Teuchos::RCP sl = S.GetPtr(sl_key_, tag); if (wrt_key == porosity_key_) { for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); - const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); + const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); + const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); + const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); + const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); + const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); + Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DMatricPressureDPorosity(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i]); + result_v[0][i] = model_->DMatricPressureDPorosity(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i], sl_v[0][i]); } } diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh index 854d33e40..c8c974457 100644 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh @@ -41,6 +41,7 @@ class MatricPressureEvaluator : public EvaluatorSecondaryMonotypeCV { Key water_content_key_; Key mdens_liquid_key_; Key cv_key_; + Key sl_key_; Teuchos::RCP model_; diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc index 87f74aa8b..b2d0b8d5a 100644 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc @@ -25,22 +25,25 @@ MatricPressureModel::MatricPressureModel(Teuchos::ParameterList& plist) // Initialize parameters void MatricPressureModel::InitializeFromPlist_(Teuchos::ParameterList& plist) { - m_ = plist.get("van genuchten m [-]", 0.3671); - n_ = plist.get("van genuchten n [-]", 1.58); - alpha_ = plist.get("van genuchten alpha [Pa^-1]", 2e-05); - sr_ = plist.get("residual saturation [-]", 0.2); + m_ = plist.get("van genuchten m [-]", 0.2308); + n_ = plist.get("van genuchten n [-]", 1.3); + alpha_ = plist.get("van genuchten alpha [Pa^-1]", 5e-5); + sr_ = plist.get("residual saturation [-]", 0.5); } // main method -double MatricPressureModel::MatricPressure(double phi, double theta, double rho, double cv) const +double MatricPressureModel::MatricPressure(double phi, double theta, double rho, double cv, double sl) const { //theta_r_ = cv*rho*phi*sr_; This is water content at residual saturation //theta_s = cv*rho*phi; This is the water content at saturation - return -1.0 / std::pow(alpha_, n_) * std::pow(1.0 - std::pow((theta - cv*rho*phi*sr_) / ((cv*rho*phi) - cv*rho*phi*sr_), 1.0 / m_), -n_); + //return -1.0 / std::pow(alpha_, n_) * std::pow(1.0 - std::pow((theta - cv*rho*phi*sr_) / ((cv*rho*phi) - cv*rho*phi*sr_), 1.0 / m_), -n_); + double Se = (sl - sr_) / (1.0 - sr_); + double Mat_p = -(1.0 / alpha_) * std::pow(std::pow(Se, -1.0 / m_) - 1.0, 1.0 / n_); + return Mat_p; } -double MatricPressureModel::DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const +double MatricPressureModel::DMatricPressureDPorosity(double phi, double theta, double rho, double cv, double sl) const { return 1.0; } diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh index 2b565c932..978d18468 100644 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh +++ b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh @@ -19,9 +19,9 @@ class MatricPressureModel { public: explicit MatricPressureModel(Teuchos::ParameterList& plist); - double MatricPressure(double phi, double theta, double rho, double cv) const; + double MatricPressure(double phi, double theta, double rho, double cv, double sl) const; - double DMatricPressureDPorosity(double phi, double theta, double rho, double cv) const; + double DMatricPressureDPorosity(double phi, double theta, double rho, double cv, double sl) const; protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); From 02402d1fa9393f295f983a3c222e2b39e80f9529 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Tue, 22 Apr 2025 10:35:01 -0700 Subject: [PATCH 550/582] minor clean up --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index ce2bef5d8..19f9e3059 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -777,7 +777,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, MPI_Barrier(MPI_COMM_WORLD); num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); - std::cout << "MP: " << matric_pressure << std::endl; //Now that the arrays are flat we need to be a little more careful about how we load an unload the data /*const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); for (int column=0; column!=num_columns_local; ++column) { @@ -842,8 +841,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.depth_c.data[column * ncells_per_col_ + i] = (*col_depth_c)[i]; props.dz.data[column * ncells_per_col_ + i] = (*col_dz)[i]; - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "(Copy loop) i = " << i << " matric pressure = " << (*col_mat_p)[i] << std::endl; if (has_gas) { props.gas_saturation.data[column * ncells_per_col_ + i] = (*col_g_sat)[i]; //state.gas_density.data[column][i] = (*col_g_dens)[i]; From 1dd5c7c05a955c3311e19a048110726f4805f3cf Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 14 May 2025 10:00:46 -0700 Subject: [PATCH 551/582] adding in the phenology dataset --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 39 ++++++++++++++++++++++++-- src/pks/ecosim/EcoSIM_ATS_interface.hh | 3 ++ src/pks/ecosim/data/BGC_containers.hh | 3 ++ src/pks/ecosim/data/BGC_memory.cc | 6 ++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 19f9e3059..7452a0233 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -119,6 +119,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "snow depth", "snow_depth"); + //Plant Phenology Datasets + lai_key_ = Keys::readKey(*plist_, domain_surface_, "LAI", "LAI"); + sai_key_ = Keys::readKey(*plist_, domain_surface_, "SAI", "SAI"); + v_type_key_ = Keys::readKey(*plist_, domain_surface_, "vegetation type", "vegetation_type"); + //Atmospheric abundance keys atm_n2_ = plist_->get("atmospheric N2"); atm_o2_ = plist_->get("atmospheric O2"); @@ -358,7 +363,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); - //Surface data from met data + //Surface data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); @@ -368,6 +373,11 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); + + S_->GetEvaluator(lai_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(sai_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(v_type_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); @@ -486,6 +496,18 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& slope = *S_->Get("surface-slope_magnitude", tag_next_) .ViewComponent("cell",false); + S_->GetEvaluator("surface-LAI", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& LAI = *S_->Get("surface-LAI", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("surface-SAI", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& SAI = *S_->Get("surface-SAI", tag_next_) + .ViewComponent("cell",false); + + S_->GetEvaluator("surface-vegetation_type", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& v_type = *S_->Get("surface-vegetation_type", tag_next_) + .ViewComponent("cell",false); + if (has_ice) { S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); const Epetra_MultiVector& ice_density = *(*S_->Get("mass_density_ice", tag_next_) @@ -732,6 +754,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& LAI = *(*S_->Get(lai_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& SAI = *(*S_->Get(sai_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& vegetation_type = *(*S_->Get(v_type_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& subsurface_energy_source = *(*S_->Get(subsurface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); @@ -760,6 +786,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_dz = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_wp = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_rf = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_lai = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_sai = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_v_type = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_energy_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_depth_c = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -806,8 +835,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,matric_pressure,col_mat_p.ptr()); FieldToColumn_(column,temp, col_temp.ptr()); FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); - FieldToColumn_(column,temp, col_temp.ptr()); - FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); //MatrixFieldToColumn_(column, tcc, col_tcc.ptr()); @@ -840,6 +867,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.depth.data[column * ncells_per_col_ + i] = (*col_depth)[i]; props.depth_c.data[column * ncells_per_col_ + i] = (*col_depth_c)[i]; props.dz.data[column * ncells_per_col_ + i] = (*col_dz)[i]; + props.LAI.data[column * ncells_per_col_ + i] = (*col_lai)[i]; + props.SAI.data[column * ncells_per_col_ + i] = (*col_sai)[i]; + props.vegetation_type.data[column * ncells_per_col_ + i] = (*col_v_type)[i]; if (has_gas) { props.gas_saturation.data[column * ncells_per_col_ + i] = (*col_g_sat)[i]; @@ -867,6 +897,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.elevation.data[column] = elevation[column]; props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; + props.LAI.data[column] = LAI[column]; + props.SAI.data[column] = SAI[column]; + props.vegetation_type.data[column] = vegetation_type[column]; for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 4c00fe1fa..02da73c9b 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -218,6 +218,9 @@ class EcoSIM : public PK_Physical_Default { Key matric_pressure_key_; Key aspect_key_; Key slope_key_; + Key lai_key_; + Key sai_key_; + Key v_type_key_; Key surface_energy_source_key_; Key subsurface_energy_source_key_; Key surface_water_source_key_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 19ef22b2d..67f1be358 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -140,6 +140,9 @@ extern "C" { BGCVectorDouble elevation; BGCVectorDouble aspect; BGCVectorDouble slope; + BGCVectorDouble LAI; + BGCVectorDouble SAI; + BGCVectorDouble vegetation_type; double atm_n2; double atm_o2; double atm_co2; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 00e8b3597..a748e87ca 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -409,6 +409,9 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCVectorDouble(sizes->num_columns, &(properties->elevation)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->aspect)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->slope)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->LAI)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->SAI)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->vegetation_type)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* properties) { @@ -434,6 +437,9 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCVectorDouble(&(properties->elevation)); FreeBGCVectorDouble(&(properties->aspect)); FreeBGCVectorDouble(&(properties->slope)); + FreeBGCVectorDouble(&(properties->LAI)); + FreeBGCVectorDouble(&(properties->SAI)); + FreeBGCVectorDouble(&(properties->vegetation_type)); } } From 5343c95ceb7323ffc51b5c4e34795e808f1c73bf Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Wed, 14 May 2025 17:00:26 -0700 Subject: [PATCH 552/582] minor tweaks to datasets - running --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 42 ++++++++++++++++++-------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 7452a0233..80f5264bc 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -198,6 +198,11 @@ void EcoSIM::Setup() { ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); } + + /*S_->Require(lai_key_, tag_next_, lai_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1);*/ //surface_energy_source_ecosim_key_ //surface_water_source_ecosim_key_ S_->Require(surface_energy_source_ecosim_key_ , tag_next_, name_) @@ -217,6 +222,18 @@ void EcoSIM::Setup() { S_->Require(sw_key_, tag_next_).SetMesh(mesh_surf_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + S_->RequireEvaluator(lai_key_, tag_next_); + S_->Require(lai_key_, tag_next_).SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + + S_->RequireEvaluator(sai_key_, tag_next_); + S_->Require(sai_key_, tag_next_).SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + + S_->RequireEvaluator(v_type_key_, tag_next_); + S_->Require(v_type_key_, tag_next_).SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + //Setup Evaluators requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) @@ -273,6 +290,9 @@ void EcoSIM::Initialize() { } S_->GetW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").PutScalar(0.0); S_->GetRecordW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").set_initialized(); + + //S_->GetW(lai_key_, Tags::DEFAULT, "surface-LAI").PutScalar(0.0); + //S_->GetRecordW(lai_key_, Tags::DEFAULT, "surface-LAI").set_initialized(); //surface_energy_source_ecosim_key_ //surface_water_source_ecosim_key_ @@ -497,16 +517,16 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { .ViewComponent("cell",false); S_->GetEvaluator("surface-LAI", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& LAI = *S_->Get("surface-LAI", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& LAI = *(*S_->Get("surface-LAI", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("surface-SAI", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& SAI = *S_->Get("surface-SAI", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& SAI = *(*S_->Get("surface-SAI", tag_next_) + .ViewComponent("cell",false))(0); S_->GetEvaluator("surface-vegetation_type", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& v_type = *S_->Get("surface-vegetation_type", tag_next_) - .ViewComponent("cell",false); + const Epetra_MultiVector& vegetation_type = *(*S_->Get("surface-vegetation_type", tag_next_) + .ViewComponent("cell",false))(0); if (has_ice) { S_->GetEvaluator("mass_density_ice", tag_next_).Update(*S_, name_); @@ -867,9 +887,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.depth.data[column * ncells_per_col_ + i] = (*col_depth)[i]; props.depth_c.data[column * ncells_per_col_ + i] = (*col_depth_c)[i]; props.dz.data[column * ncells_per_col_ + i] = (*col_dz)[i]; - props.LAI.data[column * ncells_per_col_ + i] = (*col_lai)[i]; - props.SAI.data[column * ncells_per_col_ + i] = (*col_sai)[i]; - props.vegetation_type.data[column * ncells_per_col_ + i] = (*col_v_type)[i]; if (has_gas) { props.gas_saturation.data[column * ncells_per_col_ + i] = (*col_g_sat)[i]; @@ -923,11 +940,12 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.wilting_point = pressure_at_wilting_point; Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "(CopyToEcoSIM) hydraulic conductivity = " << state.hydraulic_conductivity.data[1] << std::endl; - *vo_->os() << "(CopyToEcoSIM) bulk density = " << state.bulk_density.data[1] << std::endl; - *vo_->os() << "(CopyToEcoSIM) matric pressure = " << state.matric_pressure.data[1] << std::endl; + *vo_->os() << "(CopyToEcoSIM) LAI = " << props.LAI.data[1] << std::endl; + *vo_->os() << "(CopyToEcoSIM) SAI = " << props.SAI.data[1] << std::endl; + *vo_->os() << "(CopyToEcoSIM) VEG = " << props.vegetation_type.data[1] << std::endl; *vo_->os() << "(CopyToEcoSIM) precipitation = " << props.precipitation.data[1] << " m/s" << std::endl; + /*for (int column=0; column!=num_columns_local; ++column) { *vo_->os() << "for column: " << column << std::endl; for (int i=0; i < ncells_per_col_; ++i) { From c10fe494566d68c2ba30919f8d35cdb8c395675b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 15 May 2025 11:34:26 -0700 Subject: [PATCH 553/582] Linking up subsurface sources --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 80f5264bc..d1278596a 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1027,6 +1027,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, double snow_depth_cell = state.snow_depth.data[0]; for (int col=0; col!=num_columns_local; ++col) { + for (int i=0; i < ncells_per_col_; ++i) { + (*col_ss_water_source)[i] = state.subsurface_water_source.data[column * ncells_per_col_ + i]; + (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column * ncells_per_col_ + i]; + } + surface_energy_source[col] = state.surface_energy_source.data[col]/(3600.0); surface_water_source[col] = state.surface_water_source.data[col]/(3600.0); snow_depth[0][col] = state.snow_depth.data[col]; @@ -1035,23 +1040,18 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << "(CopyFromEcoSIM) Q_w = " << surface_water_source[1] << " m/s " << "snow_depth = " << snow_depth[0][1] << std::endl; - /*auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); + //auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); + for (int column = 0; column != num_columns_local; ++column) { - for (int i = 0; i < ncells_per_col_; ++i) { - (*col_temp)[i] = state.temperature.data[column * ncells_per_col_ + i]; + for (int i=0; i < ncells_per_col_; ++i) { + (*col_ss_water_source)[i]/(3600.0) = state.subsurface_water_source.data[column * ncells_per_col_ + i]; + (*col_ss_energy_source)[i]/(3600.0) = state.subsurface_energy_source.data[column * ncells_per_col_ + i]; } - ColumnToField_(column, temp, col_temp.ptr()); - }*/ + ColumnToField_(column, subsurface_water_source, col_ss_water_source.ptr()); + ColumnToField_(column, subsurface_energy_source, col_ss_energy_source.ptr()); + } - - //ColumnToField_(column,liquid_saturation,col_l_sat.ptr()); - //ColumnToField_(column,water_content,col_wc.ptr()); - //ColumnToField_(column,relative_permeability,col_relative_permeability.ptr()); - //ColumnToField_(column,hydraulic_conductivity,col_h_cond.ptr()); - //ColumnToField_(column,bulk_density,col_b_dens.ptr()); - //ColumnToField_(column,plant_wilting_factor,col_wp.ptr()); - //ColumnToField_(column,rooting_depth_fraction,col_rf.ptr()); } /* From 9a831472a6273f204be784e914465399a0c20fc0 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 15 May 2025 13:32:38 -0700 Subject: [PATCH 554/582] minor bugfix to sources --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index d1278596a..5b6746b94 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1044,8 +1044,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, for (int column = 0; column != num_columns_local; ++column) { for (int i=0; i < ncells_per_col_; ++i) { - (*col_ss_water_source)[i]/(3600.0) = state.subsurface_water_source.data[column * ncells_per_col_ + i]; - (*col_ss_energy_source)[i]/(3600.0) = state.subsurface_energy_source.data[column * ncells_per_col_ + i]; + (*col_ss_water_source)[i] = state.subsurface_water_source.data[column * ncells_per_col_ + i]*3600.0; + (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column * ncells_per_col_ + i]*3600.0; } ColumnToField_(column, subsurface_water_source, col_ss_water_source.ptr()); From 9d8ceab49bef4e520100094ad1b89155d62249cb Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 15 May 2025 16:14:28 -0700 Subject: [PATCH 555/582] Updated precipitation handling and water tests --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 78 ++++++++++++++++---------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 3 +- src/pks/ecosim/data/BGC_containers.hh | 1 + 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 5b6746b94..e0e0f14f6 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -114,6 +114,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, vp_air_key_ = Keys::readKey(*plist_, domain_surface_, "vapor pressure air", "vapor_pressure_air"); wind_speed_key_ = Keys::readKey(*plist_, domain_surface_, "wind speed", "wind_speed"); p_rain_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation rain", "precipitation_rain"); + p_snow_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation snow", "precipitation_snow"); + p_total_key_ = Keys::readKey(*plist_, domain_surface_, "precipitation total", "precipitation_total"); elev_key_ = Keys::readKey(*plist_, domain_surface_, "elevation", "elevation"); aspect_key_ = Keys::readKey(*plist_, domain_surface_, "aspect", "aspect"); slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); @@ -278,16 +280,24 @@ void EcoSIM::Initialize() { int ierr = 0; if (S_->HasRecord(ice_density_key_, Tags::DEFAULT)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "found ice key" << std::endl; + //Teuchos::OSTab tab = vo_->getOSTab(); + //*vo_->os() << "found ice key" << std::endl; S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(ice_density_key_, Tags::DEFAULT).Update(*S_, name_); has_ice = true; } else { Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Did not find ice key" << std::endl; + //*vo_->os() << "Did not find ice key" << std::endl; has_ice = false; } + + //Check for total precipitation and set the record if it's there + if (S_HasRecord(p_total_key_, Tags::DEFAULT)) { + S_->GetW(p_total_key_, Tags::DEFAULT, "surface-precipitation_total").PutScalar(0.0); + S_->GetRecordW(p_total_key_, Tags::DEFAULT, "surface-precipitation_total").set_initialized(); + p_bool = true; //Use precipitation total instead of snow/rain + } + S_->GetW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").PutScalar(0.0); S_->GetRecordW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").set_initialized(); @@ -389,7 +399,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(p_rain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); @@ -398,6 +408,13 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(sai_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(v_type_key_, Tags::DEFAULT).Update(*S_, name_); + if (p_bool){ + S_->GetEvaluator(p_total_key_, Tags::DEFAULT).Update(*S_, name_); + } else { + S_->GetEvaluator(p_rain_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(p_snow_key_, Tags::DEFAULT).Update(*S_, name_); + } + S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); @@ -457,19 +474,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& cell_volume = *(*S_->Get("cell_volume", tag_next_) .ViewComponent("cell",false))(0); - /*S_->GetEvaluator("plant_wilting_factor", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& plant_wilting_factor = *(*S_->Get("plant_wilting_factor", tag_next_) - .ViewComponent("cell",false))(0); - - S_->GetEvaluator("rooting_depth_fraction", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& rooting_depth_fraction = *(*S_->Get("rooting_depth_fraction", tag_next_) - .ViewComponent("cell",false))(0);*/ - if (has_gas) { - //S_->GetEvaluator("mass_density_gas", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& gas_density = *(*S_->Get("mass_density_gas", tag_next_) - // .ViewComponent("cell",false))(0); - S_->GetEvaluator("saturation_gas", tag_next_).Update(*S_, name_); const Epetra_MultiVector& gas_saturation = *(*S_->Get("saturation_gas", tag_next_) .ViewComponent("cell",false))(0); @@ -496,13 +501,18 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& v_wind = *(*S_->Get("surface-wind_speed", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("surface-precipitation_rain", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& p_rain = *(*S_->Get("surface-precipitation_rain", tag_next_) + if(p_bool){ + S_->GetEvaluator("surface-precipitation_total", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& p_tot = *(*S_->Get("surface-precipitation_total", tag_next_) .ViewComponent("cell",false))(0); - - //S_->GetEvaluator("surface-precipitation_snow", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& p_snow = *(*S_->Get("surface-precipitation_snow", tag_next_) - // .ViewComponent("cell",false))(0); + } else { + S_->GetEvaluator("surface-precipitation_rain", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& p_rain = *(*S_->Get("surface-precipitation_rain", tag_next_) + .ViewComponent("cell",false))(0); + S_->GetEvaluator("surface-precipitation_snow", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& p_snow = *(*S_->Get("surface-precipitation_snow", tag_next_) + .ViewComponent("cell",false))(0); + } S_->GetEvaluator("surface-elevation", tag_next_).Update(*S_, name_); const Epetra_MultiVector& elevation = *S_->Get("surface-elevation", tag_next_) @@ -551,6 +561,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); num_columns_global_ptype = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); + *vo_->os() << "Before Advance, p_rain: " << p_rain[1] << " m/s, p_snow: " << p_snow << "m SWE/s, water_content: " << water_content[1][1] << " mol" << std::endl; + //Trying to loop over processors now: int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); @@ -769,8 +781,14 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& precipitation = *(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); + + if(p_bool){ + const Epetra_Vector& precipitation = *(*S_->Get(p_total_key_, water_tag).ViewComponent("cell", false))(0); + } else { + const Epetra_Vector& precipitation = *(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); + } + const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); @@ -911,6 +929,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.vapor_pressure_air.data[column] = vapor_pressure_air[column]; props.wind_speed.data[column] = wind_speed[column]; props.precipitation.data[column] = precipitation[column]; + props.precipitation_snow.data[column] = precipitation_snow[column]; props.elevation.data[column] = elevation[column]; props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; @@ -938,12 +957,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.heat_capacity = c_m_; props.field_capacity = pressure_at_field_capacity; props.wilting_point = pressure_at_wilting_point; + props.p_bool = p_bool; - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "(CopyToEcoSIM) LAI = " << props.LAI.data[1] << std::endl; - *vo_->os() << "(CopyToEcoSIM) SAI = " << props.SAI.data[1] << std::endl; - *vo_->os() << "(CopyToEcoSIM) VEG = " << props.vegetation_type.data[1] << std::endl; - *vo_->os() << "(CopyToEcoSIM) precipitation = " << props.precipitation.data[1] << " m/s" << std::endl; + //Teuchos::OSTab tab = vo_->getOSTab(); + //*vo_->os() << "(CopyToEcoSIM) LAI = " << props.LAI.data[1] << std::endl; + //*vo_->os() << "(CopyToEcoSIM) SAI = " << props.SAI.data[1] << std::endl; + //*vo_->os() << "(CopyToEcoSIM) VEG = " << props.vegetation_type.data[1] << std::endl; + //*vo_->os() << "(CopyToEcoSIM) precipitation = " << props.precipitation.data[1] << " m/s" << std::endl; /*for (int column=0; column!=num_columns_local; ++column) { diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 02da73c9b..8d6e69c79 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -213,6 +213,7 @@ class EcoSIM : public PK_Physical_Default { Key wind_speed_key_; Key p_rain_key_; Key p_snow_key_; + Key p_total_key; Key f_wp_key_; Key f_root_key_; Key matric_pressure_key_; @@ -244,7 +245,7 @@ class EcoSIM : public PK_Physical_Default { Teuchos::RCP column_wc_save; bool bgc_initialized_; - bool has_energy, has_gas, has_ice; + bool has_energy, has_gas, has_ice, p_bool; std::vector component_names_; int num_components; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 67f1be358..5ce5e9fc5 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -153,6 +153,7 @@ extern "C" { double heat_capacity; double field_capacity; double wilting_point; + bool p_bool; } BGCProperties; /* From 3dcdb59a247021b521ddb38c4fa4f9668a48e779 Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Fri, 20 Jun 2025 09:55:56 -0700 Subject: [PATCH 556/582] fix for parallel issues --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 118 ++++++++++++++++++++----- src/pks/ecosim/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 99 insertions(+), 21 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index e0e0f14f6..e0e5fd6bf 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -136,6 +136,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, atm_nh3_ = plist_->get("atmospheric NH3"); pressure_at_field_capacity = plist_->get("Field Capacity [Mpa]"); pressure_at_wilting_point = plist_->get("Wilting Point [Mpa]"); + p_bool = plist_->get("EcoSIM Precipitation"); dt_ = plist_->get("initial time step"); c_m_ = plist_->get("heat capacity [MJ mol^-1 K^-1]"); @@ -236,6 +237,19 @@ void EcoSIM::Setup() { S_->Require(v_type_key_, tag_next_).SetMesh(mesh_surf_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + Teuchos::OSTab tab = vo_->getOSTab(); + + //Check for total precipitation and set the record if it's there + if (p_bool) { + S_->RequireEvaluator(p_total_key_, tag_next_); + S_->Require(p_total_key_, tag_next_).SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + } else { + S_->RequireEvaluator(p_snow_key_, tag_next_); + S_->Require(p_snow_key_, tag_next_).SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + } + //Setup Evaluators requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) @@ -292,10 +306,13 @@ void EcoSIM::Initialize() { } //Check for total precipitation and set the record if it's there - if (S_HasRecord(p_total_key_, Tags::DEFAULT)) { + + if (p_bool) { S_->GetW(p_total_key_, Tags::DEFAULT, "surface-precipitation_total").PutScalar(0.0); S_->GetRecordW(p_total_key_, Tags::DEFAULT, "surface-precipitation_total").set_initialized(); - p_bool = true; //Use precipitation total instead of snow/rain + } else { + S_->GetW(p_snow_key_, Tags::DEFAULT, "surface-precipitation_snow").PutScalar(0.0); + S_->GetRecordW(p_snow_key_, Tags::DEFAULT, "surface-precipitation_snow").set_initialized(); } S_->GetW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").PutScalar(0.0); @@ -501,17 +518,24 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& v_wind = *(*S_->Get("surface-wind_speed", tag_next_) .ViewComponent("cell",false))(0); + //Define before loop to prevent scope issues: + const Epetra_MultiVector* p_tot = nullptr; + const Epetra_MultiVector* p_rain = nullptr; + const Epetra_MultiVector* p_snow = nullptr; + if(p_bool){ S_->GetEvaluator("surface-precipitation_total", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& p_tot = *(*S_->Get("surface-precipitation_total", tag_next_) - .ViewComponent("cell",false))(0); + p_tot = &(*(*S_->Get("surface-precipitation_total", tag_next_) + .ViewComponent("cell",false))(0)); + } else { S_->GetEvaluator("surface-precipitation_rain", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& p_rain = *(*S_->Get("surface-precipitation_rain", tag_next_) - .ViewComponent("cell",false))(0); + p_rain = &(*(*S_->Get("surface-precipitation_rain", tag_next_) + .ViewComponent("cell",false))(0)); S_->GetEvaluator("surface-precipitation_snow", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& p_snow = *(*S_->Get("surface-precipitation_snow", tag_next_) - .ViewComponent("cell",false))(0); + p_snow = &(*(*S_->Get("surface-precipitation_snow", tag_next_) + .ViewComponent("cell",false))(0)); + } S_->GetEvaluator("surface-elevation", tag_next_).Update(*S_, name_); @@ -561,7 +585,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); num_columns_global_ptype = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); - *vo_->os() << "Before Advance, p_rain: " << p_rain[1] << " m/s, p_snow: " << p_snow << "m SWE/s, water_content: " << water_content[1][1] << " mol" << std::endl; + //*vo_->os() << "Before Advance, p_rain: " << p_rain[1] << " m/s, p_snow: " << p_snow << "m SWE/s, water_content: " << water_content[1][1] << " mol" << std::endl; //Trying to loop over processors now: int numProcesses, p_rank; @@ -781,12 +805,18 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); + //define these outside of the loop to prevent issues: + const Epetra_Vector* precipitation = nullptr; + const Epetra_Vector* precipitation_snow = nullptr; if(p_bool){ - const Epetra_Vector& precipitation = *(*S_->Get(p_total_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& precipitation = *(*S_->Get(p_total_key_, water_tag).ViewComponent("cell", false))(0); + precipitation = &(*(*S_->Get(p_total_key_, water_tag).ViewComponent("cell", false))(0)); } else { - const Epetra_Vector& precipitation = *(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& precipitation = *(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); + precipitation = &(*(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0)); + precipitation_snow = &(*(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0)); } const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); @@ -843,6 +873,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); MPI_Barrier(MPI_COMM_WORLD); + std::cout << "ATS2EcoSIM rank: " << p_rank <getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //Now that the arrays are flat we need to be a little more careful about how we load an unload the data /*const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); @@ -928,8 +959,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.air_temperature.data[column] = air_temperature[column]; props.vapor_pressure_air.data[column] = vapor_pressure_air[column]; props.wind_speed.data[column] = wind_speed[column]; - props.precipitation.data[column] = precipitation[column]; - props.precipitation_snow.data[column] = precipitation_snow[column]; props.elevation.data[column] = elevation[column]; props.aspect.data[column] = aspect[column]; props.slope.data[column] = slope[column]; @@ -937,6 +966,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.SAI.data[column] = SAI[column]; props.vegetation_type.data[column] = vegetation_type[column]; + if(p_bool){ + props.precipitation.data[column] = (*precipitation)[column]; + } else { + props.precipitation.data[column] = (*precipitation)[column]; + props.precipitation_snow.data[column] = (*precipitation_snow)[column]; + } + for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { @@ -959,6 +995,26 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.wilting_point = pressure_at_wilting_point; props.p_bool = p_bool; + std::cout << "Data from struct after setting: " << std::endl; + for (int col=0; col!=num_columns_local; ++col) { + if (std::isnan(state.surface_water_source.data[col]) || + std::isinf(state.surface_water_source.data[col])) { + std::cout << "Process " << p_rank << " found bad value at column " + << col << ": " << state.surface_water_source.data[col] << std::endl; + } + } + + std::cout << "Data from state after setting struct: " << std::endl; + for (int col=0; col!=num_columns_local; ++col) { + if (std::isnan(surface_water_source[col]) || + std::isinf(surface_water_source[col])) { + std::cout << "Process " << p_rank << " found bad value at column " + << col << ": " << surface_water_source[col] << std::endl; + } + } + + + //Teuchos::OSTab tab = vo_->getOSTab(); //*vo_->os() << "(CopyToEcoSIM) LAI = " << props.LAI.data[1] << std::endl; //*vo_->os() << "(CopyToEcoSIM) SAI = " << props.SAI.data[1] << std::endl; @@ -1041,6 +1097,16 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); MPI_Barrier(MPI_COMM_WORLD); + std::cout << "Data from struct after pass back: " << std::endl; + for (int col=0; col!=num_columns_local; ++col) { + if (std::isnan(state.surface_water_source.data[col]) || + std::isinf(state.surface_water_source.data[col])) { + std::cout << "Process " << p_rank << " found bad value at column " + << col << ": " << state.surface_water_source.data[col] << std::endl; + } + } + + num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); double energy_source_tot = state.surface_energy_source.data[0]; double water_source_tot = state.surface_water_source.data[0]; @@ -1048,21 +1114,33 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, for (int col=0; col!=num_columns_local; ++col) { for (int i=0; i < ncells_per_col_; ++i) { - (*col_ss_water_source)[i] = state.subsurface_water_source.data[column * ncells_per_col_ + i]; - (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column * ncells_per_col_ + i]; + (*col_ss_water_source)[i] = state.subsurface_water_source.data[col * ncells_per_col_ + i]; + (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[col * ncells_per_col_ + i]; } + ColumnToField_(col, subsurface_water_source, col_ss_water_source.ptr()); + ColumnToField_(col, subsurface_energy_source, col_ss_energy_source.ptr()); + surface_energy_source[col] = state.surface_energy_source.data[col]/(3600.0); surface_water_source[col] = state.surface_water_source.data[col]/(3600.0); snow_depth[0][col] = state.snow_depth.data[col]; } - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "(CopyFromEcoSIM) Q_w = " << surface_water_source[1] << " m/s " << "snow_depth = " << snow_depth[0][1] << std::endl; + /*std::cout << "Data from state after pass back: " << std::endl; + for (int col=0; col!=num_columns_local; ++col) { + if (std::isnan(surface_water_source[col]) || + std::isinf(surface_water_source[col])) { + std::cout << "Process " << p_rank << " found bad value at column " + << col << ": " << surface_water_source[col] << std::endl; + } + }*/ + + //Teuchos::OSTab tab = vo_->getOSTab(); + //*vo_->os() << "(CopyFromEcoSIM) Q_w = " << surface_water_source[1] << " m/s " << "snow_depth = " << snow_depth[0][1] << std::endl; //auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); - for (int column = 0; column != num_columns_local; ++column) { + /*for (int column = 0; column != num_columns_local; ++column) { for (int i=0; i < ncells_per_col_; ++i) { (*col_ss_water_source)[i] = state.subsurface_water_source.data[column * ncells_per_col_ + i]*3600.0; (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column * ncells_per_col_ + i]*3600.0; @@ -1070,7 +1148,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, ColumnToField_(column, subsurface_water_source, col_ss_water_source.ptr()); ColumnToField_(column, subsurface_energy_source, col_ss_energy_source.ptr()); - } + }*/ } diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 8d6e69c79..8ade555e1 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -213,7 +213,7 @@ class EcoSIM : public PK_Physical_Default { Key wind_speed_key_; Key p_rain_key_; Key p_snow_key_; - Key p_total_key; + Key p_total_key_; Key f_wp_key_; Key f_root_key_; Key matric_pressure_key_; From 5c3664e851b8584bf037da24456a0264e3746642 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 24 Jul 2025 20:53:44 -0700 Subject: [PATCH 557/582] working version of coupled phenology --- src/pks/ecosim/CMakeLists.txt | 1 + src/pks/ecosim/EcoSIM_ATS_interface.cc | 83 ++++++++++++++++---------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 2 + src/pks/ecosim/data/CMakeLists.txt | 1 + 4 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index f363d6022..f5cbc51f6 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -70,6 +70,7 @@ if(ENABLE_ECOSIM) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_mods/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Prescribed_pheno/) include_directories(${ECOSIM_INCLUDE_DIRS}) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index e0e5fd6bf..92932ef03 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -93,6 +93,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, surface_water_source_ecosim_key_ = Keys::readKey(*plist_, domain_surface_, "surface water source ecosim", "ecosim_water_source"); + subsurface_energy_source_ecosim_key_ = + Keys::readKey(*plist_, domain_, "subsurface energy source ecosim", "subsurface_ecosim_source"); + subsurface_water_source_ecosim_key_ = + Keys::readKey(*plist_, domain_, "subsurface water source ecosim", "subsurface_ecosim_water_source"); + //Snow //Other @@ -177,6 +182,7 @@ void EcoSIM::Setup() { PK_Physical_Default::Setup(); //Need to do some basic setup of the columns: mesh_surf_ = S_->GetMesh(domain_surface_); + mesh_ = S_->GetMesh(domain_); //num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Parallel_type::OWNED, AmanziMesh::Parallel_kind::OWNED); int num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); @@ -202,12 +208,6 @@ void EcoSIM::Setup() { ->SetComponent("cell", AmanziMesh::CELL, 1); } - /*S_->Require(lai_key_, tag_next_, lai_key_) - .SetMesh(mesh_surf_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::CELL, 1);*/ - //surface_energy_source_ecosim_key_ - //surface_water_source_ecosim_key_ S_->Require(surface_energy_source_ecosim_key_ , tag_next_, name_) .SetMesh(mesh_surf_) ->SetGhosted(false) @@ -218,6 +218,16 @@ void EcoSIM::Setup() { ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); + S_->Require(subsurface_energy_source_ecosim_key_ , tag_next_, subsurface_energy_source_ecosim_key_) + .SetMesh(mesh_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(subsurface_water_source_ecosim_key_ , tag_next_, subsurface_water_source_ecosim_key_) + .SetMesh(mesh_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + //May need to setup surface evaluators as they are now owned by surface_balance PK insteady of surface energy?? // @@ -326,6 +336,12 @@ void EcoSIM::Initialize() { S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).PutScalar(0.0); S_->GetRecordW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).set_initialized(); + S_->GetW(subsurface_water_source_ecosim_key_, Tags::DEFAULT, subsurface_water_source_ecosim_key_).PutScalar(0.0); + S_->GetRecordW(subsurface_water_source_ecosim_key_, Tags::DEFAULT, subsurface_water_source_ecosim_key_).set_initialized(); + + S_->GetW(subsurface_energy_source_ecosim_key_, Tags::DEFAULT, subsurface_energy_source_ecosim_key_).PutScalar(0.0); + S_->GetRecordW(subsurface_energy_source_ecosim_key_, Tags::DEFAULT, subsurface_energy_source_ecosim_key_).set_initialized(); + //Initialize owned evaluators S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); @@ -527,7 +543,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator("surface-precipitation_total", tag_next_).Update(*S_, name_); p_tot = &(*(*S_->Get("surface-precipitation_total", tag_next_) .ViewComponent("cell",false))(0)); - } else { S_->GetEvaluator("surface-precipitation_rain", tag_next_).Update(*S_, name_); p_rain = &(*(*S_->Get("surface-precipitation_rain", tag_next_) @@ -535,7 +550,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator("surface-precipitation_snow", tag_next_).Update(*S_, name_); p_snow = &(*(*S_->Get("surface-precipitation_snow", tag_next_) .ViewComponent("cell",false))(0)); - } S_->GetEvaluator("surface-elevation", tag_next_).Update(*S_, name_); @@ -827,10 +841,10 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& vegetation_type = *(*S_->Get(v_type_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& surface_energy_source = *(*S_->Get(surface_energy_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& subsurface_energy_source = *(*S_->Get(subsurface_energy_source_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& subsurface_energy_source = *(*S_->Get(subsurface_energy_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& surface_water_source = *(*S_->Get(surface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& subsurface_water_source = *(*S_->Get(subsurface_water_source_ecosim_key_, water_tag).ViewComponent("cell", false))(0); auto& snow_depth = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); @@ -995,15 +1009,20 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.wilting_point = pressure_at_wilting_point; props.p_bool = p_bool; - std::cout << "Data from struct after setting: " << std::endl; + std::cout << "(CopyToEcoSIM) subsurface energy flux: " << std::endl; + for (int col=0; col!=num_columns_local; ++col) { - if (std::isnan(state.surface_water_source.data[col]) || - std::isinf(state.surface_water_source.data[col])) { - std::cout << "Process " << p_rank << " found bad value at column " - << col << ": " << state.surface_water_source.data[col] << std::endl; + for (int i=0; i < ncells_per_col_; ++i) { + std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_energy_source[col*ncells_per_col_+i] << std::endl; } } + for (int col=0; col!=num_columns_local; ++col) { + for (int i=0; i < ncells_per_col_; ++i) { + std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_water_source[col*ncells_per_col_+i] << std::endl; + } + } + std::cout << "Data from state after setting struct: " << std::endl; for (int col=0; col!=num_columns_local; ++col) { if (std::isnan(surface_water_source[col]) || @@ -1013,21 +1032,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } } - - - //Teuchos::OSTab tab = vo_->getOSTab(); - //*vo_->os() << "(CopyToEcoSIM) LAI = " << props.LAI.data[1] << std::endl; - //*vo_->os() << "(CopyToEcoSIM) SAI = " << props.SAI.data[1] << std::endl; - //*vo_->os() << "(CopyToEcoSIM) VEG = " << props.vegetation_type.data[1] << std::endl; - //*vo_->os() << "(CopyToEcoSIM) precipitation = " << props.precipitation.data[1] << " m/s" << std::endl; - - - /*for (int column=0; column!=num_columns_local; ++column) { - *vo_->os() << "for column: " << column << std::endl; - for (int i=0; i < ncells_per_col_; ++i) { - *vo_->os() << "T["<< i << "] = " << state.temperature.data[column][i] << std::endl; - } - }*/ } void EcoSIM::CopyFromEcoSIM_process(const int column, @@ -1055,11 +1059,11 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, name_).ViewComponent("cell", false))(0); //Epetra_MultiVector& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, tag_next_, name_).ViewComponent("cell", false))(0); //Epetra_MultiVector& surface_energy_source = *(S_->GetW(surface_energy_source_ecosim_key_, tag_next_, name_).ViewComponent("cell", false)); - auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_key_, Tags::DEFAULT, subsurface_energy_source_key_).ViewComponent("cell", false))(0); + auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_ecosim_key_, Tags::DEFAULT, subsurface_energy_source_ecosim_key_).ViewComponent("cell", false))(0); //auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); - auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_key_, Tags::DEFAULT, subsurface_water_source_key_).ViewComponent("cell", false))(0); + auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_ecosim_key_, Tags::DEFAULT, subsurface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); @@ -1106,7 +1110,6 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, } } - num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); double energy_source_tot = state.surface_energy_source.data[0]; double water_source_tot = state.surface_water_source.data[0]; @@ -1126,6 +1129,20 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, snow_depth[0][col] = state.snow_depth.data[col]; } + std::cout << "(CopyFromEcoSIM) subsurface energy flux: " << std::endl; + + for (int col=0; col!=num_columns_local; ++col) { + for (int i=0; i < ncells_per_col_; ++i) { + std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_energy_source[col*ncells_per_col_+i] << std::endl; + } + } + + for (int col=0; col!=num_columns_local; ++col) { + for (int i=0; i < ncells_per_col_; ++i) { + std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_water_source[col*ncells_per_col_+i] << std::endl; + } + } + /*std::cout << "Data from state after pass back: " << std::endl; for (int col=0; col!=num_columns_local; ++col) { if (std::isnan(surface_water_source[col]) || diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 8ade555e1..023dacf2e 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -228,6 +228,8 @@ class EcoSIM : public PK_Physical_Default { Key subsurface_water_source_key_; Key surface_energy_source_ecosim_key_; Key surface_water_source_ecosim_key_; + Key subsurface_energy_source_ecosim_key_; + Key subsurface_water_source_ecosim_key_; Key snow_depth_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 901b975db..7d7bb0d62 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -57,6 +57,7 @@ include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_mods/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Prescribed_pheno/) set(ats_ecosim_data_src_files BGC_constants.cc From 60700c5dd58d13edc75e20dd34109cc60b4c5519 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 30 Jul 2025 15:57:23 -0700 Subject: [PATCH 558/582] updated EcoSIM timers to be more stable and account for day and year --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 55 +++++++++++++++++--------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 1 + src/pks/ecosim/data/BGC_containers.hh | 3 ++ src/pks/ecosim/data/BGC_memory.cc | 2 + 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 92932ef03..cfcb0a6af 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -145,6 +145,11 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, dt_ = plist_->get("initial time step"); c_m_ = plist_->get("heat capacity [MJ mol^-1 K^-1]"); + day0_ = plist_->get("Starting day of year [0-364]"); + year0_ = plist_->get("Starting year"); + + curr_day_ = day0_; + curr_year_ = year0_; //This initialized the engine (found in BGCEngine.cc) This is the code that //actually points to the driver @@ -394,19 +399,13 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { double dt = t_new - t_old; current_time_ = saved_time_ + dt; - // If we are given a dt that is less than the one we wanted, we don't record it. - // This is in alquimia but I'm not quite sure why - //if (dt < dt_next_) { - // dt_prev_ = dt_next_; - //} else { - // dt_prev_ = dt; - //} Teuchos::OSTab out = vo_->getOSTab(); if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "----------------------------------------------------------------" << std::endl << "Advancing: t0 = " << S_->get_time(tag_current_) << " t1 = " << S_->get_time(tag_next_) << " h = " << dt << std::endl + << "Current day: " << curr_day_ << "Current year: " << curr_year_ << std::endl << "----------------------------------------------------------------" << std::endl; @@ -613,6 +612,13 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { AdvanceSingleProcess(dt, p_rank); } } + // PLACE TIME AND YEAR ITERATOR HERE + if (curr_day_ != 364) { + curr_day_ = curr_day_ + 1; + } else { + curr_day_ = 0; + curr_year_ = curr_year_ + 1; + } } @@ -1242,24 +1248,35 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) int num_columns = 1; num_columns = num_columns_local; + + // Time tracking variables + current_time_ = S_->get_time(); //Current time + static double last_ecosim_time = 0.0; + int total_days = static_cast(current_time_ / 86400.0); + int current_day = (day0_ + total_days) % 365; + int current_year = year0_ + ((day0_ + total_days)/365); + + bgc_props_.current_day = current_day; + bgc_props_.current_year = current_year; Teuchos::OSTab tab = vo_->getOSTab(); - if (t_ecosim <= 3600.0) { - *vo_->os() << "t_ecosim: " << t_ecosim << ", dt: " << dt << std::endl; - t_ecosim = t_ecosim + dt; - } else { - *vo_->os() << "It has been an hour, running EcoSIM Advance: " << std::endl; + + std::cout << "in ASP" << std::endl; + std::cout << "t = " << current_time_ << " t_last = " << last_ecosim_time << std::endl; + + if (current_time_ - last_ecosim_time >= 3600.0) { + *vo_->os() << "Hour completed at total_time: " << current_time_ + << ", Year: " << current_year << ", Day: " << current_day << std::endl; + *vo_->os() << "Running EcoSIM Advance: " << std::endl; - CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - bgc_engine_->Advance(dt, bgc_props_, bgc_state_, - bgc_sizes_, num_iterations, num_columns); + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns); - CopyFromEcoSIM_process(proc, - bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - t_ecosim = 0.0; - } + last_ecosim_time = current_time_; + } //bgc_engine_->Advance(dt, bgc_props_, bgc_state_, // bgc_sizes_, num_iterations, num_columns); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 023dacf2e..68930f721 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -182,6 +182,7 @@ class EcoSIM : public PK_Physical_Default { int num_columns_local; int num_columns_global; int num_columns_global_ptype; + int day0_, year0_, curr_day_, curr_year_; double saved_time_; double current_time_; double t_ecosim = 0.0; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 5ce5e9fc5..a4f6adaab 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -115,6 +115,7 @@ extern "C" { BGCVectorDouble surface_energy_source; BGCVectorDouble surface_water_source; BGCVectorDouble snow_depth; + BGCVectorDouble canopy_height; BGCTensorDouble total_component_concentration; } BGCState; @@ -153,6 +154,8 @@ extern "C" { double heat_capacity; double field_capacity; double wilting_point; + int current_day; + int current_year; bool p_bool; } BGCProperties; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index a748e87ca..6c1995b64 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -327,6 +327,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_water_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_energy_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->snow_depth)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->canopy_height)); AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateBGCState() */ @@ -347,6 +348,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCVectorDouble(&(state->surface_energy_source)); FreeBGCVectorDouble(&(state->surface_water_source)); FreeBGCVectorDouble(&(state->snow_depth)); + FreeBGCVectorDouble(&(state->canopy_height)); FreeBGCTensorDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ From 028485603950b9e35e79746cd7e2ccbeb570053b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 1 Aug 2025 10:37:55 -0700 Subject: [PATCH 559/582] adding some additonal vars --- src/pks/ecosim/CMakeLists.txt | 1 + src/pks/ecosim/data/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index f5cbc51f6..428b88ea4 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -101,6 +101,7 @@ if(ENABLE_ECOSIM) ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSCPLMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMInitMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMAdvanceMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSUtilsMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 ) diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 7d7bb0d62..ff89b04a4 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -71,6 +71,7 @@ set(ats_ecosim_data_src_files ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSEcoSIMAdvanceMod.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSUtilsMod.F90 ) set(ats_ecosim_data_inc_files From 6f1ee3cd63f43c9f5bdb9563a298eb0ce210475e Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 7 Aug 2025 09:48:54 -0700 Subject: [PATCH 560/582] minor updates to cmake files --- src/pks/ecosim/CMakeLists.txt | 207 +++++++++++++++-------------- src/pks/ecosim/data/CMakeLists.txt | 8 +- 2 files changed, 109 insertions(+), 106 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 428b88ea4..472077954 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -3,96 +3,97 @@ #so we put everything in an if statement if(ENABLE_ECOSIM) - add_subdirectory(constitutive_relations) - add_subdirectory(data) - - get_property(AMANZI_TPLS_DIR GLOBAL PROPERTY AMANZI_TPLS_DIR) - - #set(ECOSIM_INSTALL_PREFIX "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") - #set(ECOSIM_LIB_LOCATION "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") - #set(ECOSIM_CMAKE_BINARY_DIR "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") - #set(NETCDF_LIB "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") - - set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) - set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) - set(ECOSIM_BUILD_PREFIX ${ECOSIM_DIR}/ecosim/build) - #set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) - set(NETCDF_LIB ${ECOSIM_DIR}/lib) - - message("In ATS-EcoSIM CMakeLists:") - message("ECOSIM_DIR:" ${ECOSIM_DIR}) - message("ECOSIM_INSTALL_PREFIX:" ${ECOSIM_INSTALL_PREFIX}) - message("ECOSIM_LIB_LOCATION:" ${ECOSIM_LIB_LOCATION}) - message("ECOSIM_BUILD_PREFIX:" ${ECOSIM_BUILD_PREFIX}) - - include_directories(${ATS_SOURCE_DIR}/src/pks) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/data) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) - - #include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) - - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) - - message("At include_directories") - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelconfig/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Mesh/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelpars/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Balances/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_datatype/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SoilPhys/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_mods/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Prescribed_pheno/) - - - include_directories(${ECOSIM_INCLUDE_DIRS}) - - message("EcoSIM inc dirs: ") - message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") - - # ATS EcoSIM pk - # For adding F90 files add the F90 file to the ecosim source files and - # inc files. The inc file also needs a header - - #set(ats_ecosim_src_files - # EcoSIM_ATS_interface.cc - # BGCEngine.cc - # ecosim_wrappers.F90 - # data/bgc_fortran_memory_mod.F90 - #) - - #testing using link libs: - #file(GLOB ECOLIBS ${ECOSIM_LIB_LOCATION}/*.a) - - set(ats_ecosim_src_files + add_subdirectory(constitutive_relations) + add_subdirectory(data) + + get_property(AMANZI_TPLS_DIR GLOBAL PROPERTY AMANZI_TPLS_DIR) + + #set(ECOSIM_INSTALL_PREFIX "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") + #set(ECOSIM_LIB_LOCATION "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") + #set(ECOSIM_CMAKE_BINARY_DIR "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") + #set(NETCDF_LIB "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") + + set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) + set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) + set(ECOSIM_BUILD_PREFIX ${ECOSIM_DIR}/ecosim/build) + #set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) + set(NETCDF_LIB ${ECOSIM_DIR}/lib) + + message("In ATS-EcoSIM CMakeLists:") + message("ECOSIM_DIR:" ${ECOSIM_DIR}) + message("ECOSIM_INSTALL_PREFIX:" ${ECOSIM_INSTALL_PREFIX}) + message("ECOSIM_LIB_LOCATION:" ${ECOSIM_LIB_LOCATION}) + message("ECOSIM_BUILD_PREFIX:" ${ECOSIM_BUILD_PREFIX}) + + include_directories(${ATS_SOURCE_DIR}/src/pks) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/data) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) + include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) + + #include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) + #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) + + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) + #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) + + message("At include_directories") + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelconfig/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Mesh/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelpars/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Balances/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_datatype/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SoilPhys/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SurfPhys/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_mods/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Prescribed_pheno/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Plant_bgc/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIs/) + + include_directories(${ECOSIM_INCLUDE_DIRS}) + + message("EcoSIM inc dirs: ") + message(eco_inc_file="${ECOSIM_INCLUDE_DIRS}") + + # ATS EcoSIM pk + # For adding F90 files add the F90 file to the ecosim source files and + # inc files. The inc file also needs a header + + #set(ats_ecosim_src_files + # EcoSIM_ATS_interface.cc + # BGCEngine.cc + # ecosim_wrappers.F90 + # data/bgc_fortran_memory_mod.F90 + #) + + #testing using link libs: + #file(GLOB ECOLIBS ${ECOSIM_LIB_LOCATION}/*.a) + + set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc ecosim_wrappers.F90 @@ -106,21 +107,21 @@ if(ENABLE_ECOSIM) ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 ) - set(ats_ecosim_inc_files + set(ats_ecosim_inc_files ecosim_mod_test_wrapper.h EcoSIM_ATS_interface.hh BGCEngine.hh ecosim_interface.h ) - file(GLOB ECOSIM_LIBRARIES + file(GLOB ECOSIM_LIBRARIES ${ECOSIM_LIB_LOCATION}/*.a ) - - -find_package(NetCDF REQUIRED) - set(ats_ecosim_link_libs + + find_package(NetCDF REQUIRED) + + set(ats_ecosim_link_libs ${Teuchos_LIBRARIES} ${Epetra_LIBRARIES} ${ECOSIM_LIBRARIES} @@ -143,24 +144,24 @@ find_package(NetCDF REQUIRED) gfortran ) - message(STATUS "ats_ecosim_link_libs: ${ats_ecosim_link_libs}") + message(STATUS "ats_ecosim_link_libs: ${ats_ecosim_link_libs}") - message(inc_files="${ats_ecosim_inc_files}") + message(inc_files="${ats_ecosim_inc_files}") - add_amanzi_library(ats_ecosim + add_amanzi_library(ats_ecosim SOURCE ${ats_ecosim_src_files} HEADERS ${ats_ecosim_inc_files} LINK_LIBS ${ats_ecosim_link_libs}) - #================================================ - # register evaluators/factories/pks + #================================================ + # register evaluators/factories/pks - register_evaluator_with_factory( + register_evaluator_with_factory( HEADERFILE EcoSIM_ATS_interface_reg.hh LISTNAME ATS_ECOSIM_REG ) - generate_evaluators_registration_header( + generate_evaluators_registration_header( HEADERFILE ats_ecosim_registration.hh LISTNAME ATS_ECOSIM_REG INSTALL True diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index ff89b04a4..a5652cd2c 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -58,6 +58,8 @@ include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/SnowPhys/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/HydroTherm/PhysData/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_mods/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Prescribed_pheno/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Plant_bgc/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIs/) set(ats_ecosim_data_src_files BGC_constants.cc @@ -102,8 +104,8 @@ set(ats_ecosim_data_link_libs ats_pks ats_eos ats_operators - ${NETCDF_LIB}/libnetcdf.so - ${NETCDF_LIB}/libnetcdf.so.19 + ${NETCDF_LIB}/libnetcdf.so + ${NETCDF_LIB}/libnetcdf.so.19 ${NETCDF_LIB}/libnetcdff.so ${NETCDF_LIB}/libnetcdff.so.7 ${NETCDF_LIB}/libnetcdff.so.7.1.0 @@ -116,7 +118,7 @@ message(STATUS "ats_ecosim_data_link_libs: ${ats_ecosim_data_link_libs}") add_amanzi_library(ats_ecosim_data SOURCE ${ats_ecosim_data_src_files} HEADERS ${ats_ecosim_data_inc_files} - LINK_LIBS ${ats_ecosim_data_link_libs}) + LINK_LIBS ${ats_ecosim_data_link_libs}) generate_evaluators_registration_header( HEADERFILE ats_ecosim_data_registration.hh From 205a582c61b8438169cf1e0b9204c272dd8cb18d Mon Sep 17 00:00:00 2001 From: Andrew Graus Date: Thu, 21 Aug 2025 15:47:06 -0700 Subject: [PATCH 561/582] added snow albedo modifications --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 19 ++++++++++++------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 1 + src/pks/ecosim/data/BGC_containers.hh | 1 + src/pks/ecosim/data/BGC_memory.cc | 2 ++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index cfcb0a6af..7b567f692 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -125,6 +125,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, aspect_key_ = Keys::readKey(*plist_, domain_surface_, "aspect", "aspect"); slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "snow depth", "snow_depth"); + snow_albedo_key_ = Keys::readKey(*plist_, domain_surface_, "snow_albedo", "snow_albedo"); //Plant Phenology Datasets lai_key_ = Keys::readKey(*plist_, domain_surface_, "LAI", "LAI"); @@ -235,6 +236,9 @@ void EcoSIM::Setup() { //May need to setup surface evaluators as they are now owned by surface_balance PK insteady of surface energy?? // + S_->RequireEvaluator(snow_albedo_key_, tag_next_); + S_->Require(snow_albedo_key_, tag_next_).SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); S_->RequireEvaluator(sw_key_, tag_next_); S_->Require(sw_key_, tag_next_).SetMesh(mesh_surf_) @@ -435,7 +439,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(elev_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(aspect_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(slope_key_, Tags::DEFAULT).Update(*S_, name_); - + S_->GetEvaluator(snow_albedo_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(lai_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(sai_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(v_type_key_, Tags::DEFAULT).Update(*S_, name_); @@ -841,7 +846,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); - + const Epetra_Vector& snow_albedo = *(*S_->Get(snow_albedo_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& LAI = *(*S_->Get(lai_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& SAI = *(*S_->Get(sai_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& vegetation_type = *(*S_->Get(v_type_key_, water_tag).ViewComponent("cell", false))(0); @@ -984,8 +990,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.slope.data[column] = slope[column]; props.LAI.data[column] = LAI[column]; props.SAI.data[column] = SAI[column]; + props.snow_albedo.data[column] = snow_albedo[column]; props.vegetation_type.data[column] = vegetation_type[column]; - + if(p_bool){ props.precipitation.data[column] = (*precipitation)[column]; } else { @@ -1014,18 +1021,16 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.field_capacity = pressure_at_field_capacity; props.wilting_point = pressure_at_wilting_point; props.p_bool = p_bool; - - std::cout << "(CopyToEcoSIM) subsurface energy flux: " << std::endl; for (int col=0; col!=num_columns_local; ++col) { for (int i=0; i < ncells_per_col_; ++i) { - std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_energy_source[col*ncells_per_col_+i] << std::endl; + //std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_energy_source[col*ncells_per_col_+i] << std::endl; } } for (int col=0; col!=num_columns_local; ++col) { for (int i=0; i < ncells_per_col_; ++i) { - std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_water_source[col*ncells_per_col_+i] << std::endl; + //std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_water_source[col*ncells_per_col_+i] << std::endl; } } diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 68930f721..e11b272ae 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -232,6 +232,7 @@ class EcoSIM : public PK_Physical_Default { Key subsurface_energy_source_ecosim_key_; Key subsurface_water_source_ecosim_key_; Key snow_depth_key_; + Key snow_albedo_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index a4f6adaab..fd1d3410d 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -144,6 +144,7 @@ extern "C" { BGCVectorDouble LAI; BGCVectorDouble SAI; BGCVectorDouble vegetation_type; + BGCVectorDouble snow_albedo; double atm_n2; double atm_o2; double atm_co2; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 6c1995b64..2c6eec9de 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -414,6 +414,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCVectorDouble(sizes->num_columns, &(properties->LAI)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->SAI)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->vegetation_type)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->snow_albedo)); } /* end AllocateAlquimiaProperties() */ void FreeBGCProperties(BGCProperties* properties) { @@ -442,6 +443,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCVectorDouble(&(properties->LAI)); FreeBGCVectorDouble(&(properties->SAI)); FreeBGCVectorDouble(&(properties->vegetation_type)); + FreeBGCVectorDouble(&(properties->snow_albedo)); } } From f26e0adebbfcaf56660fadb1456f8512a8bd5f8f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 9 Sep 2025 14:06:52 -0700 Subject: [PATCH 562/582] minor Cmakelists fixes to allow the coupler access to the plant api --- src/pks/ecosim/CMakeLists.txt | 1 + src/pks/ecosim/data/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 472077954..1f6bfcd8d 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -73,6 +73,7 @@ if(ENABLE_ECOSIM) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Prescribed_pheno/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Plant_bgc/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIs/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIData/) include_directories(${ECOSIM_INCLUDE_DIRS}) diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index a5652cd2c..a869fa772 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -60,6 +60,7 @@ include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Ecosim_mods/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Prescribed_pheno/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Plant_bgc/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIs/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIData/) set(ats_ecosim_data_src_files BGC_constants.cc From d1b858abe41c71de05e20ad59d7b186a3c81204b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Sat, 13 Sep 2025 09:15:40 -0700 Subject: [PATCH 563/582] Adding runtime options Added runtime options for turning on Albedo modification and prescribed phenology. Albedo modification appears to be working but phenology currently needs more debugging. --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 82 ++++++++++++++------------ src/pks/ecosim/EcoSIM_ATS_interface.hh | 2 +- src/pks/ecosim/data/BGC_containers.hh | 2 + 3 files changed, 46 insertions(+), 40 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 7b567f692..74a2e7559 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -143,6 +143,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, pressure_at_field_capacity = plist_->get("Field Capacity [Mpa]"); pressure_at_wilting_point = plist_->get("Wilting Point [Mpa]"); p_bool = plist_->get("EcoSIM Precipitation"); + a_bool = plist_->get("Prescribe Albedo"); + pheno_bool = plist_->get("Prescribe Phenology"); dt_ = plist_->get("initial time step"); c_m_ = plist_->get("heat capacity [MJ mol^-1 K^-1]"); @@ -185,7 +187,7 @@ EcoSIM::~EcoSIM() // -- Setup step void EcoSIM::Setup() { - PK_Physical_Default::Setup(); + PK_Physical_Default::Setup(); //Need to do some basic setup of the columns: mesh_surf_ = S_->GetMesh(domain_surface_); mesh_ = S_->GetMesh(domain_); @@ -212,27 +214,27 @@ void EcoSIM::Setup() { .SetMesh(mesh_surf_) ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); - } + } S_->Require(surface_energy_source_ecosim_key_ , tag_next_, name_) .SetMesh(mesh_surf_) ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::CELL, 1); + ->SetComponent("cell", AmanziMesh::CELL, 1); S_->Require(surface_water_source_ecosim_key_ , tag_next_, surface_water_source_ecosim_key_) .SetMesh(mesh_surf_) ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::CELL, 1); + ->SetComponent("cell", AmanziMesh::CELL, 1); S_->Require(subsurface_energy_source_ecosim_key_ , tag_next_, subsurface_energy_source_ecosim_key_) .SetMesh(mesh_) ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::CELL, 1); + ->SetComponent("cell", AmanziMesh::CELL, 1); S_->Require(subsurface_water_source_ecosim_key_ , tag_next_, subsurface_water_source_ecosim_key_) .SetMesh(mesh_) ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::CELL, 1); + ->SetComponent("cell", AmanziMesh::CELL, 1); //May need to setup surface evaluators as they are now owned by surface_balance PK insteady of surface energy?? // @@ -247,7 +249,7 @@ void EcoSIM::Setup() { S_->RequireEvaluator(lai_key_, tag_next_); S_->Require(lai_key_, tag_next_).SetMesh(mesh_surf_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - + S_->RequireEvaluator(sai_key_, tag_next_); S_->Require(sai_key_, tag_next_).SetMesh(mesh_surf_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -262,7 +264,7 @@ void EcoSIM::Setup() { if (p_bool) { S_->RequireEvaluator(p_total_key_, tag_next_); S_->Require(p_total_key_, tag_next_).SetMesh(mesh_surf_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } else { S_->RequireEvaluator(p_snow_key_, tag_next_); S_->Require(p_snow_key_, tag_next_).SetMesh(mesh_surf_) @@ -289,7 +291,7 @@ void EcoSIM::Setup() { ->AddComponent("cell", AmanziMesh::CELL, 1); requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); - + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -331,7 +333,7 @@ void EcoSIM::Initialize() { S_->GetRecordW(p_total_key_, Tags::DEFAULT, "surface-precipitation_total").set_initialized(); } else { S_->GetW(p_snow_key_, Tags::DEFAULT, "surface-precipitation_snow").PutScalar(0.0); - S_->GetRecordW(p_snow_key_, Tags::DEFAULT, "surface-precipitation_snow").set_initialized(); + S_->GetRecordW(p_snow_key_, Tags::DEFAULT, "surface-precipitation_snow").set_initialized(); } S_->GetW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").PutScalar(0.0); @@ -339,9 +341,9 @@ void EcoSIM::Initialize() { //S_->GetW(lai_key_, Tags::DEFAULT, "surface-LAI").PutScalar(0.0); //S_->GetRecordW(lai_key_, Tags::DEFAULT, "surface-LAI").set_initialized(); - //surface_energy_source_ecosim_key_ + //surface_energy_source_ecosim_key_ //surface_water_source_ecosim_key_ - + S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).PutScalar(0.0); S_->GetRecordW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).set_initialized(); @@ -360,7 +362,7 @@ void EcoSIM::Initialize() { S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); - + int num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //loop over processes instead: @@ -412,7 +414,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { << "Current day: " << curr_day_ << "Current year: " << curr_year_ << std::endl << "----------------------------------------------------------------" << std::endl; - + // Ensure dependencies are filled S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); @@ -541,7 +543,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { //Define before loop to prevent scope issues: const Epetra_MultiVector* p_tot = nullptr; const Epetra_MultiVector* p_rain = nullptr; - const Epetra_MultiVector* p_snow = nullptr; + const Epetra_MultiVector* p_snow = nullptr; if(p_bool){ S_->GetEvaluator("surface-precipitation_total", tag_next_).Update(*S_, name_); @@ -554,7 +556,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator("surface-precipitation_snow", tag_next_).Update(*S_, name_); p_snow = &(*(*S_->Get("surface-precipitation_snow", tag_next_) .ViewComponent("cell",false))(0)); - } + } S_->GetEvaluator("surface-elevation", tag_next_).Update(*S_, name_); const Epetra_MultiVector& elevation = *S_->Get("surface-elevation", tag_next_) @@ -617,7 +619,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { AdvanceSingleProcess(dt, p_rank); } } - // PLACE TIME AND YEAR ITERATOR HERE + // PLACE TIME AND YEAR ITERATOR HERE if (curr_day_ != 364) { curr_day_ = curr_day_ + 1; } else { @@ -823,7 +825,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - + //const auto& shortwave_radiation = *S_.Get(sw_key_, water_tag).ViewComponent("cell", false); const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); @@ -842,12 +844,12 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, //const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); precipitation = &(*(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0)); precipitation_snow = &(*(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0)); - } + } const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& snow_albedo = *(*S_->Get(snow_albedo_key_, water_tag).ViewComponent("cell", false))(0); - + const Epetra_Vector& LAI = *(*S_->Get(lai_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& SAI = *(*S_->Get(sai_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& vegetation_type = *(*S_->Get(v_type_key_, water_tag).ViewComponent("cell", false))(0); @@ -882,7 +884,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_rf = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_lai = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_sai = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_v_type = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_v_type = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_energy_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_depth_c = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -905,13 +907,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, /*const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); for (int column=0; column!=num_columns_local; ++column) { FieldToColumn_(column, temp, col_temp.ptr()); - + for (int i=0; i < ncells_per_col_; ++i) { state.temperature.data[column * ncells_per_col_ + i] = (*col_temp)[i]; state.temperature.data[column * ncells_per_col_ + i] = 222.0; } - }*/ - + }*/ + //Loop over columns on this process for (int column=0; column!=num_columns_local; ++column) { FieldToColumn_(column,porosity,col_porosity.ptr()); @@ -992,12 +994,12 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.SAI.data[column] = SAI[column]; props.snow_albedo.data[column] = snow_albedo[column]; props.vegetation_type.data[column] = vegetation_type[column]; - + if(p_bool){ props.precipitation.data[column] = (*precipitation)[column]; } else { props.precipitation.data[column] = (*precipitation)[column]; - props.precipitation_snow.data[column] = (*precipitation_snow)[column]; + props.precipitation_snow.data[column] = (*precipitation_snow)[column]; } for (int i = 0; i < state.total_component_concentration.columns; i++) { @@ -1007,7 +1009,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, } } } - + //Fill the atmospheric abundances //NOTE: probably want to add an if statement here to only do this only once props.atm_n2 = atm_n2_; @@ -1021,7 +1023,9 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.field_capacity = pressure_at_field_capacity; props.wilting_point = pressure_at_wilting_point; props.p_bool = p_bool; - + props.a_bool = a_bool; + props.pheno_bool = pheno_bool; + for (int col=0; col!=num_columns_local; ++col) { for (int i=0; i < ncells_per_col_; ++i) { //std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_energy_source[col*ncells_per_col_+i] << std::endl; @@ -1033,7 +1037,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, //std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_water_source[col*ncells_per_col_+i] << std::endl; } } - + std::cout << "Data from state after setting struct: " << std::endl; for (int col=0; col!=num_columns_local; ++col) { if (std::isnan(surface_water_source[col]) || @@ -1078,7 +1082,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); - + auto& snow_depth = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1141,7 +1145,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, } std::cout << "(CopyFromEcoSIM) subsurface energy flux: " << std::endl; - + for (int col=0; col!=num_columns_local; ++col) { for (int i=0; i < ncells_per_col_; ++i) { std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_energy_source[col*ncells_per_col_+i] << std::endl; @@ -1167,7 +1171,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, //*vo_->os() << "(CopyFromEcoSIM) Q_w = " << surface_water_source[1] << " m/s " << "snow_depth = " << snow_depth[0][1] << std::endl; //auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); - + /*for (int column = 0; column != num_columns_local; ++column) { for (int i=0; i < ncells_per_col_; ++i) { (*col_ss_water_source)[i] = state.subsurface_water_source.data[column * ncells_per_col_ + i]*3600.0; @@ -1177,7 +1181,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, ColumnToField_(column, subsurface_water_source, col_ss_water_source.ptr()); ColumnToField_(column, subsurface_energy_source, col_ss_energy_source.ptr()); }*/ - + } /* @@ -1218,7 +1222,7 @@ int EcoSIM::InitializeSingleProcess(int proc) { int num_iterations = 1; int num_columns = 1; - + num_columns = num_columns_local; Teuchos::OSTab tab = vo_->getOSTab(); @@ -1253,19 +1257,19 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) int num_columns = 1; num_columns = num_columns_local; - + // Time tracking variables current_time_ = S_->get_time(); //Current time - static double last_ecosim_time = 0.0; + static double last_ecosim_time = 0.0; int total_days = static_cast(current_time_ / 86400.0); int current_day = (day0_ + total_days) % 365; int current_year = year0_ + ((day0_ + total_days)/365); - + bgc_props_.current_day = current_day; bgc_props_.current_year = current_year; Teuchos::OSTab tab = vo_->getOSTab(); - + std::cout << "in ASP" << std::endl; std::cout << "t = " << current_time_ << " t_last = " << last_ecosim_time << std::endl; @@ -1277,7 +1281,7 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns); - + CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); last_ecosim_time = current_time_; diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index e11b272ae..3bb909922 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -249,7 +249,7 @@ class EcoSIM : public PK_Physical_Default { Teuchos::RCP column_wc_save; bool bgc_initialized_; - bool has_energy, has_gas, has_ice, p_bool; + bool has_energy, has_gas, has_ice, p_bool, a_bool, pheno_bool; std::vector component_names_; int num_components; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index fd1d3410d..7652f30eb 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -158,6 +158,8 @@ extern "C" { int current_day; int current_year; bool p_bool; + bool a_bool; + bool pheno_bool; } BGCProperties; /* From ccdbd9fc28fe8b4354b88012021b0c9862a452ae Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 30 Sep 2025 13:59:48 -0700 Subject: [PATCH 564/582] Minor fix to CMake files --- src/pks/ecosim/CMakeLists.txt | 3 ++- src/pks/ecosim/data/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 1f6bfcd8d..db0ce4d4e 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -61,6 +61,7 @@ if(ENABLE_ECOSIM) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelconfig/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelforc/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Mesh/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelpars/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Balances/) @@ -73,7 +74,7 @@ if(ENABLE_ECOSIM) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Prescribed_pheno/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Plant_bgc/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIs/) - include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIData/) + include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIData/) include_directories(${ECOSIM_INCLUDE_DIRS}) diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index a869fa772..9cfb90454 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -48,6 +48,7 @@ message("At include_directories in data") include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelconfig/) +include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelforc/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Mesh/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Modelpars/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Balances/) From 00d2b9336c5d50e30d1fe5e017f5d28f634d4763 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 13 Oct 2025 12:31:55 -0700 Subject: [PATCH 565/582] First large code clean up This is an update to clean up some of the code and document the ATS side better. Cleaned up some old templates and code related to Alquimia. No actual code was modified. --- src/pks/ecosim/BGCEngine.cc | 471 +------------------------ src/pks/ecosim/BGCEngine.hh | 33 +- src/pks/ecosim/EcoSIM_ATS_interface.cc | 126 +------ src/pks/ecosim/EcoSIM_ATS_interface.hh | 8 - src/pks/ecosim/ecosim_interface.h | 31 +- src/pks/ecosim/ecosim_wrappers.F90 | 14 +- 6 files changed, 24 insertions(+), 659 deletions(-) diff --git a/src/pks/ecosim/BGCEngine.cc b/src/pks/ecosim/BGCEngine.cc index f11dd2469..2900bcca5 100644 --- a/src/pks/ecosim/BGCEngine.cc +++ b/src/pks/ecosim/BGCEngine.cc @@ -1,7 +1,8 @@ /* - Alquimia + Basic architecture based on the Alquima interfece adapted for + use in the ATSEcoSIM PK - Copyright 2010-201x held jointly by LANS/LANL, LBNL, and PNNL. + Copyright 2010-202x held jointly by LANS/LANL, LBNL, and PNNL. Amanzi is released under the three-clause BSD License. The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. @@ -29,43 +30,6 @@ namespace Amanzi { namespace EcoSIM { -/*namespace { -void CopyBGCState(BGCState* dest, BGCState* src) -{ - memcpy(dest->liquid_density.data, src->liquid_density.data, sizeof(double) * src->liquid_density.size); - memcpy(dest->gas_density.data, src->gas_density.data, sizeof(double) * src->gas_density.size); - memcpy(dest->ice_density.data, src->ice_density.data, sizeof(double) * src->ice_density.size); - memcpy(dest->porosity.data, src->porosity.data, sizeof(double) * src->porosity.size); - memcpy(dest->water_content.data, src->water_content.data, sizeof(double) * src->water_content.size); - memcpy(dest->temperature.data, src->temperature.data, sizeof(double) * src->temperature.size); - memcpy(dest->hydraulic_conductivity.data, src->hydraulic_conductivity.data, sizeof(double) * src->hydraulic_conductivity.size); - //memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); - - //dest->water_density = src->water_density; - //memcpy(dest->total_mobile.data, src->total_mobile.data, sizeof(double) * src->total_mobile.size); -} - -// These functions are going into the next release of Alquimia. -void CopyBGCProperties(BGCProperties* dest, BGCProperties* src) -{ - //NEED TO EDIT STILL - memcpy(dest->liquid_saturation.data, src->liquid_saturation.data, sizeof(double) * src->liquid_saturation.size); - memcpy(dest->gas_saturation.data, src->gas_saturation.data, sizeof(double) * src->gas_saturation.size); - memcpy(dest->ice_saturation.data, src->ice_saturation.data, sizeof(double) * src->ice_saturation.size); - memcpy(dest->relative_permeability.data, src->relative_permeability.data, sizeof(double) * src->relative_permeability.size); - memcpy(dest->thermal_conductivity.data, src->thermal_conductivity.data, sizeof(double) * src->thermal_conductivity.size); - memcpy(dest->volume.data, src->volume.data, sizeof(double) * src->volume.size); -} - -void CopyBGCAuxiliaryData(BGCAuxiliaryData* dest, BGCAuxiliaryData* src) -{ - memcpy(dest->aux_ints.data, src->aux_ints.data, sizeof(int) * src->aux_ints.size); - memcpy(dest->aux_doubles.data, src->aux_doubles.data, sizeof(double) * src->aux_doubles.size); -} - -}*/ - - BGCEngine::BGCEngine(const std::string& engineName, const std::string& inputFile) : bgc_engine_name_(engineName), @@ -75,90 +39,14 @@ BGCEngine::BGCEngine(const std::string& engineName, CreateBGCInterface(bgc_engine_name_.c_str(), &bgc_); - /* - bool hands_off = false; - if (bgc_engine_name_ == "EcoSIM") hands_off = true; - - if (bgc_engine_name_ != "EcoSIM") - { - std::cout << "BGCEngine: Unsupported bgc engine: '" << bgc_engine_name_ << std::endl; - std::cout << " Only option for now is 'EcoSIM'" << std::endl; - Exceptions::amanzi_throw(msg); - std::cout << "Creating the BGC Engine interface" << std::endl; - CreateBGCInterface(bgc_engine_name_.c_str(), - &bgc_); - }*/ - - // All alquimia function calls require a status object. - // AllocateAlquimiaEngineStatus is in the alquimia code in alquimia_memory.c - // The Allocate engine status function creates an object called "status" - // and fills an element called message with calloc. This is maybe just - // for error handling so I think it can be ignored - //AllocateAlquimiaEngineStatus(&chem_status_); - - //CreateAlquimiaInterface - in alquimia code in alquimia_interface.c - //This points the code to the processes for the two geochemistry codes - // PFloTran and CrunchFlow and points the Chemistry engine functions to - // Their corresponding functions in the drivers depending on which - // of the geochemsitry codes. I think to start we can simply just point this - // code directly to the EcoSIM dirver functions for the following processes: - // Setup, Shutdown, ProcessCondition, ReactionStepOperatorSplit (advance), - // GetAquxiliaryOutput (not neccesary for now), - // GetProblemMetaData (not neccesary) - // Thefore, for now I don't think we need this - /*CreateAlquimiaInterface(chem_engine_name_.c_str(), &chem_, &chem_status_); - if (chem_status_.error != 0) - { - std::cout << chem_status_.message << std::endl; - msg << "ChemistryEngine: Could not create an interface to Alquimia."; - Exceptions::amanzi_throw(msg); - }*/ - - //This calls the Setup function that we pointed the code to within alquimia - /* - chem_.Setup(chem_engine_inputfile_.c_str(), - hands_off, - &engine_state_, - &sizes_, - &functionality_, - &chem_status_); - if (chem_status_.error != 0) - { - std::cout << chem_status_.message << std::endl; - PrintAlquimiaSizes(&sizes_, stdout); - msg << "Error in creation of ChemistryEngine."; - Exceptions::amanzi_throw(msg); - } - */ - //We don't need the chem interface call - //Place the call to the EcoSIM setup driver here: - - /******************************** - EcoSIMSetup(); - *********************************/ - - // Allocate storage for additional Alquimia data. - // Below this sets up Alquimia metadata I don't think we - //need this } BGCEngine::~BGCEngine() { bgc_.Shutdown(); - //FreeAlquimiaProblemMetaData(&chem_metadata_); - - // As there are no chemical conditions, am I just deleting variables? - /*for (GeochemicalConditionMap::iterator - iter = chem_conditions_.begin(); iter != chem_conditions_.end(); ++iter) - { - //FreeBGCGeochemicalCondition(&iter->second->condition); - FreeBGCState(&iter->second->chem_state); - FreeBGCProperties(&iter->second->mat_props); - FreeBGCAuxiliaryData(&iter->second->aux_data); - delete iter->second; - }*/ + //Did I forget to implement this? //FreeBGCProperties(&props); //FreeBGCState(&state); //FreeBGCAuxiliaryData(&aux_data); @@ -180,12 +68,6 @@ void BGCEngine::InitState(BGCProperties& properties, { AllocateBGCProperties(&sizes_, &properties, ncells_per_col_, num_columns); AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components, num_columns); - //AllocateBGCAuxiliaryData(&sizes_, &aux_data, ncells_per_col_); - //AllocateAlquimiaAuxiliaryOutputData(&sizes_, &aux_output); - - // Make sure the auxiliary ints/doubles are zeroed out. - //std::fill(aux_data.aux_ints.data, aux_data.aux_ints.data + aux_data.aux_ints.size, 0); - //std::fill(aux_data.aux_doubles.data, aux_data.aux_doubles.data + aux_data.aux_doubles.size, 0.0); } void BGCEngine::FreeState(BGCProperties& properties, @@ -194,8 +76,6 @@ void BGCEngine::FreeState(BGCProperties& properties, { FreeBGCProperties(&properties); FreeBGCState(&state); - //FreeBGCAuxiliaryData(&aux_data); - //FreeAlquimiaAuxiliaryOutputData(&aux_output); } void BGCEngine::DataTest() { @@ -210,7 +90,6 @@ bool BGCEngine::Setup(BGCProperties& properties, int num_columns, int ncells_per_col_) { - // Advance the chemical reaction all operator-split-like. bgc_.Setup(&properties, &state, &sizes_, @@ -218,12 +97,6 @@ bool BGCEngine::Setup(BGCProperties& properties, num_columns, ncells_per_col_); - //This is alquimia's advance function which we won't need - //calling EcoSIM advance driver - - /************************* - EcoSIMAdvance(); - *************************/ } bool BGCEngine::Advance(const double delta_time, @@ -233,7 +106,6 @@ bool BGCEngine::Advance(const double delta_time, int num_iterations, int num_columns) { - // Advance the chemical reaction all operator-split-like. bgc_.Advance(delta_time, &properties, &state, @@ -241,342 +113,7 @@ bool BGCEngine::Advance(const double delta_time, num_iterations, num_columns); - //This is alquimia's advance function which we won't need - //calling EcoSIM advance driver - - /************************* - EcoSIMAdvance(); - *************************/ -} - - -/*void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) - { - - interface->Setup = &ecosim_setup; - interface->Shutdown = &ecosim_shutdown; - interface->Advance = &ecosim_advance; - - } -*/ -//For now I don't need any of the rest of this code yet. Just commenting -//out in case I need it later. - -/* -void ChemistryEngine::CreateCondition(const std::string& condition_name) -{ - // NOTE: a condition with zero aqueous/mineral constraints is assumed to be defined in - // NOTE: the backend engine's input file. - GeochemicalConditionData* condition = new GeochemicalConditionData(); - condition->processed = false; - int num_aq = 0, num_min = 0; - AllocateAlquimiaProperties(&sizes_, &condition->mat_props); - AllocateAlquimiaGeochemicalCondition(kAlquimiaMaxStringLength, num_aq, num_min, &condition->condition); - AllocateAlquimiaState(&sizes_, &condition->chem_state); - AllocateAlquimiaAuxiliaryData(&sizes_, &condition->aux_data); - std::strcpy(condition->condition.name, condition_name.c_str()); - - // Add this to the conditions map. - chem_conditions_[condition_name] = condition; -} - -void ChemistryEngine::AddAqueousConstraint(const std::string& condition_name, - const std::string& primary_species_name, - const std::string& constraint_type, - const std::string& associated_species) -{ - assert(condition_name.length() > 0); - assert(primary_species_name.length() > 0); - assert((constraint_type == "total_aqueous") || (constraint_type == "charge") || - (constraint_type == "free") || (constraint_type == "mineral") || - (constraint_type == "gas") || (constraint_type == "pH")); - - GeochemicalConditionMap::iterator iter = chem_conditions_.find(condition_name); - if (iter != chem_conditions_.end()) - { - AlquimiaGeochemicalCondition* condition = &iter->second->condition; - - // Do we have an existing constraint? - int index = -1; - for (int i = 0; i < condition->aqueous_constraints.size; ++i) - { - if (!std::strcmp(condition->aqueous_constraints.data[i].primary_species_name, primary_species_name.c_str())) - { - // Overwrite the old constraint. - index = i; - free(condition->aqueous_constraints.data[index].primary_species_name); - free(condition->aqueous_constraints.data[index].constraint_type); - if (condition->aqueous_constraints.data[index].associated_species != NULL) - free(condition->aqueous_constraints.data[index].associated_species); - } - } - if (index == -1) - { - // New constraint! - index = condition->aqueous_constraints.size; - condition->aqueous_constraints.size++; - condition->aqueous_constraints.data = (AlquimiaAqueousConstraint*)realloc(condition->aqueous_constraints.data, sizeof(AlquimiaAqueousConstraint) * (index+1)); - } - - // Add the aqueous constraint. - condition->aqueous_constraints.data[index].primary_species_name = strdup(primary_species_name.c_str()); - condition->aqueous_constraints.data[index].constraint_type = strdup(constraint_type.c_str()); - if (!associated_species.empty()) - condition->aqueous_constraints.data[index].associated_species = strdup(associated_species.c_str()); - else - condition->aqueous_constraints.data[index].associated_species = NULL; - } - else - { - Errors::Message msg; - msg << "ChemistryEngine::AddAqueousConstraint: no condition named '" << condition_name << "'."; - Exceptions::amanzi_throw(msg); - } -} - -void ChemistryEngine::EnforceCondition(const std::string& condition_name, - const double time, - const AlquimiaProperties& mat_props, - AlquimiaState& chem_state, - AlquimiaAuxiliaryData& aux_data, - AlquimiaAuxiliaryOutputData& aux_output) -{ - Errors::Message msg; - - // Retrieve the chemical condition for the given name. - GeochemicalConditionMap::iterator iter = chem_conditions_.find(condition_name); - if (iter == chem_conditions_.end()) - { - CreateCondition(condition_name); - iter = chem_conditions_.find(condition_name); - } - -#ifdef AMANZI_USE_FENV - // Disable divide-by-zero floating point exceptions. - int fpe_mask = fedisableexcept(FE_DIVBYZERO); -#endif - - AlquimiaGeochemicalCondition* condition = &iter->second->condition; - AlquimiaProperties& nc_mat_props = const_cast(mat_props); - if (!iter->second->processed) - { - // Copy the given state data into place for this condition. - CopyAlquimiaProperties(&iter->second->mat_props, &nc_mat_props); - CopyAlquimiaState(&iter->second->chem_state, &chem_state); - CopyAlquimiaAuxiliaryData(&iter->second->aux_data, &aux_data); - - // Process the condition on the given array at the given time. - // FIXME: Time is ignored for the moment. - chem_.ProcessCondition(&engine_state_, condition, &iter->second->mat_props, - &iter->second->chem_state, &iter->second->aux_data, &chem_status_); - iter->second->processed = true; - } - - // Copy the constraint's data into place. - // Here, condition names are used but Alquimia properties are - // given as "Material" zones in Amanzi's inputthus disconnecting them - // from "Initial" conditions (i.e. condition names) - // For the sake of performance, we avoid here to re-process conditions - // but we need to retain materical properties as provided in Amanzi inputs - // CopyAlquimiaProperties(&nc_mat_props, &iter->second->mat_props); - CopyAlquimiaState(&chem_state, &iter->second->chem_state); - CopyAlquimiaAuxiliaryData(&aux_data, &iter->second->aux_data); - -#ifdef AMANZI_USE_FENV - // Re-enable pre-existing floating point exceptions. - feclearexcept(fpe_mask); - fpe_mask = feenableexcept(fpe_mask); -#endif - -// FIXME: Figure out a neutral parallel-friendly way to report errors. - assert(chem_status_.error == 0); - -#if 0 - if (chem_status_.error != 0) - ierr = -1; - - // figure out if any of the processes threw an error, if so all processes will re-throw - int recv = 0; - mesh_->get_comm()->MaxAll(&ierr, &recv, 1); - if (recv != 0) - { - msg << "Error in enforcement of chemical condition '" << condition_name << "'"; - Exceptions::amanzi_throw(msg); - } -#endif } -const std::string& ChemistryEngine::Name() const -{ - return chem_engine_name_; -} - -bool ChemistryEngine::IsThreadSafe() const -{ - Errors::Message msg; - - if (not chem_initialized_) - { - msg << "ChemistryEngine: Cannot query before initialization!"; - Exceptions::amanzi_throw(msg); - } - - return functionality_.thread_safe; -} - -int ChemistryEngine::NumPrimarySpecies() const -{ - return sizes_.num_primary; -} - -int ChemistryEngine::NumAqueousComplexes() const -{ - return sizes_.num_aqueous_complexes; -} - -int ChemistryEngine::NumSorbedSpecies() const -{ - return sizes_.num_sorbed; -} - -void ChemistryEngine::GetPrimarySpeciesNames(std::vector& species_names) const -{ - const AlquimiaProblemMetaData* metadata = &chem_metadata_; - int N = metadata->primary_names.size; - species_names.resize(N); - for (int i = 0; i < N; ++i) - species_names[i] = std::string(metadata->primary_names.data[i]); -} - -int ChemistryEngine::NumMinerals() const -{ - return sizes_.num_minerals; -} - -void ChemistryEngine::GetMineralNames(std::vector& mineral_names) const -{ - const AlquimiaProblemMetaData* metadata = &chem_metadata_; - int N = metadata->mineral_names.size; - mineral_names.resize(N); - for (int i = 0; i < N; ++i) - mineral_names[i] = std::string(metadata->mineral_names.data[i]); -} - -int ChemistryEngine::NumSurfaceSites() const -{ - return sizes_.num_surface_sites; -} - -void ChemistryEngine::GetSurfaceSiteNames(std::vector& site_names) const -{ - const AlquimiaProblemMetaData* metadata = &chem_metadata_; - int N = metadata->surface_site_names.size; - site_names.resize(N); - for (int i = 0; i < N; ++i) - site_names[i] = std::string(metadata->surface_site_names.data[i]); -} - -int ChemistryEngine::NumIonExchangeSites() const -{ - return sizes_.num_ion_exchange_sites; -} - -void ChemistryEngine::GetIonExchangeNames(std::vector& ion_exchange_names) const -{ - const AlquimiaProblemMetaData* metadata = &chem_metadata_; - int N = metadata->ion_exchange_names.size; - ion_exchange_names.resize(N); - for (int i = 0; i < N; ++i) - ion_exchange_names[i] = std::string(metadata->ion_exchange_names.data[i]); -} - -int ChemistryEngine::NumIsothermSpecies() const -{ - return sizes_.num_isotherm_species; -} - -void ChemistryEngine::GetIsothermSpeciesNames(std::vector& species_names) const -{ - const AlquimiaProblemMetaData* metadata = &chem_metadata_; - int N = metadata->isotherm_species_names.size; - species_names.resize(N); - for (int i = 0; i < N; ++i) - species_names[i] = std::string(metadata->isotherm_species_names.data[i]); -} - -int ChemistryEngine::NumFreeIonSpecies() const -{ - return sizes_.num_primary; -} - -void ChemistryEngine::GetAuxiliaryOutputNames(std::vector& aux_names, - std::vector>& subfield_names) const -{ - aux_names.clear(); - subfield_names.clear(); - aux_names.emplace_back("pH"); - subfield_names.emplace_back(std::vector{"0"}); - - const AlquimiaProblemMetaData* metadata = &chem_metadata_; - - // Mineral data -- one per mineral. - int N = metadata->mineral_names.size; - if (N > 0) { - std::vector mineral_names; - for (int i = 0; i < N; ++i) { - mineral_names.emplace_back(metadata->mineral_names.data[i]); - } - aux_names.emplace_back("mineral_saturation_index"); - subfield_names.emplace_back(mineral_names); - aux_names.emplace_back("mineral_reaction_rate"); - subfield_names.emplace_back(std::move(mineral_names)); - } - - // Auxiliary data per primary species. - N = metadata->primary_names.size; - if (N > 0) { - std::vector primary_names; - for (int i = 0; i < N; ++i) { - primary_names.emplace_back(metadata->primary_names.data[i]); - } - aux_names.emplace_back("primary_free_ion_concentration"); - subfield_names.emplace_back(primary_names); - aux_names.emplace_back("primary_activity_coeff"); - subfield_names.emplace_back(std::move(primary_names)); - } - - // Secondary auxiliary data. - N = this->NumAqueousComplexes(); - if (N > 0) { - std::vector secondary_names; - for (int i = 0; i < N; ++i) { - secondary_names.emplace_back(std::to_string(i)); - } - aux_names.emplace_back("secondary_free_ion_concentration"); - subfield_names.emplace_back(secondary_names); - aux_names.emplace_back("secondary_activity_coeff"); - subfield_names.emplace_back(std::move(secondary_names)); - } -} - -int ChemistryEngine::NumAqueousKinetics() const -{ - return sizes_.num_aqueous_kinetics; -} - -void ChemistryEngine::GetAqueousKineticNames(std::vector& kinetics_names) const -{ - const AlquimiaProblemMetaData* metadata = &chem_metadata_; - int N = metadata->aqueous_kinetic_names.size; - kinetics_names.resize(N); - for (int i = 0; i < N; ++i) - kinetics_names[i] = std::string(metadata->aqueous_kinetic_names.data[i]); -} - -const AlquimiaSizes& ChemistryEngine::Sizes() const -{ - return sizes_; -}*/ - } // namespace } // namespace diff --git a/src/pks/ecosim/BGCEngine.hh b/src/pks/ecosim/BGCEngine.hh index 2ba44b2f9..05bd4f901 100644 --- a/src/pks/ecosim/BGCEngine.hh +++ b/src/pks/ecosim/BGCEngine.hh @@ -1,7 +1,7 @@ /* - Alqumia + ATS-EcoSIM, Code Adapted for use from Alquimia - Copyright 2010-201x held jointly by LANS/LANL, LBNL, and PNNL. + Copyright 2010-202x held jointly by LANS/LANL, LBNL, and PNNL. Amanzi is released under the three-clause BSD License. The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. @@ -25,10 +25,6 @@ #include "BGC_constants.hh" #include "VerboseObject.hh" -/*#include "alquimia/alquimia_util.h" -#include "alquimia/alquimia_constants.h" -#include "alquimia/alquimia_containers.h" -#include "alquimia/alquimia_interface.h"*/ namespace Amanzi { namespace EcoSIM { @@ -64,12 +60,6 @@ class BGCEngine { void FreeState(BGCProperties& properties, BGCState& state, BGCAuxiliaryData& aux_data); - /* Don't need for now - void EnforceCondition(const std::string& condition_name, - const double time, - const AlquimiaProperties& properties, - AlquimiaState& state, - AlquimiaAuxiliaryData& aux_data);*/ void DataTest(); @@ -80,10 +70,6 @@ class BGCEngine { int num_columns, int ncells_per_col_); - // Advances the species represented by the given array of concentrations, replacing old values - // with new values. The order of the concentrations in the array matches that of the species names - // returned by GetSpeciesNames. Returns true if the advance is successful, - // false if it fails. bool Advance(const double delta_time, BGCProperties& properties, BGCState& state, @@ -91,39 +77,24 @@ class BGCEngine { int num_iterations, int num_columns); - //Functions from the alquimia util section, I don't think I need the full code so I think - //I can just copy these functions over void CopyBGCState(const BGCState* const source, BGCState* destination); void CopyBGCProperties(const BGCProperties* const source, BGCProperties* destination); - //void CreateBGCInterface(const char* engine_name, BGCInterface* interface); - private: // bgc data structures. bool bgc_initialized_; void* engine_state_; - //BGCEngineFunctionality functionality_; BGCSizes sizes_; BGCInterface bgc_; - //BGCEngineStatus bgc_status_; - //BGCProblemMetaData bgc_metadata_; - - /*AlquimiaEngineFunctionality functionality_; - AlquimiaSizes sizes_; - AlquimiaInterface chem_; - AlquimiaEngineStatus chem_status_; - AlquimiaProblemMetaData chem_metadata_;*/ Teuchos::RCP vo_; // Back-end engine name and input file. std::string bgc_engine_name_; std::string bgc_engine_inputfile_; - //Teuchos::RCP bgc_engine_; - // forbidden. BGCEngine(); BGCEngine(const BGCEngine&); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 74a2e7559..4b1cb361c 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -53,8 +53,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saved_time_(0.0) { //grab the surface and subsurface domains - //May need to edit this as well - //domain_ = plist_->get("domain name", "domain"); domain_ = Keys::readDomain(*plist_, "domain", "domain"); domain_surface_ = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); @@ -98,8 +96,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, subsurface_water_source_ecosim_key_ = Keys::readKey(*plist_, domain_, "subsurface water source ecosim", "subsurface_ecosim_water_source"); - //Snow - //Other cell_volume_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); //ecosim_aux_data_key_ = Keys::readKey(*plist_, domain_, "ecosim aux data", "ecosim_aux_data"); @@ -140,12 +136,16 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, atm_n2o_ = plist_->get("atmospheric N2O"); atm_h2_ = plist_->get("atmospheric H2"); atm_nh3_ = plist_->get("atmospheric NH3"); + + //Starting values and parameters for precribed phenology / albedo + pressure_at_field_capacity = plist_->get("Field Capacity [Mpa]"); pressure_at_wilting_point = plist_->get("Wilting Point [Mpa]"); p_bool = plist_->get("EcoSIM Precipitation"); a_bool = plist_->get("Prescribe Albedo"); pheno_bool = plist_->get("Prescribe Phenology"); + //Parameters for times and time of year dt_ = plist_->get("initial time step"); c_m_ = plist_->get("heat capacity [MJ mol^-1 K^-1]"); day0_ = plist_->get("Starting day of year [0-364]"); @@ -154,7 +154,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, curr_day_ = day0_; curr_year_ = year0_; - //This initialized the engine (found in BGCEngine.cc) This is the code that + //This initializes the engine (found in BGCEngine.cc) This is the code that //actually points to the driver if (!plist_->isParameter("engine")) { Errors::Message msg; @@ -370,7 +370,7 @@ void EcoSIM::Initialize() { num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); num_columns_global_ptype = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); - //Trying to loop over processors now: + //Loop over processes and Initalize EcoSIM on that process int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); @@ -654,6 +654,7 @@ void EcoSIM::FieldToColumn_(AmanziMesh::Entity_ID column, const Teuchos::Ptr col_arr) { @@ -1001,13 +1002,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.precipitation.data[column] = (*precipitation)[column]; props.precipitation_snow.data[column] = (*precipitation_snow)[column]; } - + /*Don't need this loop until transport is implemented for (int i = 0; i < state.total_component_concentration.columns; i++) { for (int j = 0; j < state.total_component_concentration.cells; j++) { for (int k = 0; k < state.total_component_concentration.components; k++) { } } - } + }*/ } //Fill the atmospheric abundances @@ -1026,18 +1027,6 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, props.a_bool = a_bool; props.pheno_bool = pheno_bool; - for (int col=0; col!=num_columns_local; ++col) { - for (int i=0; i < ncells_per_col_; ++i) { - //std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_energy_source[col*ncells_per_col_+i] << std::endl; - } - } - - for (int col=0; col!=num_columns_local; ++col) { - for (int i=0; i < ncells_per_col_; ++i) { - //std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_water_source[col*ncells_per_col_+i] << std::endl; - } - } - std::cout << "Data from state after setting struct: " << std::endl; for (int col=0; col!=num_columns_local; ++col) { if (std::isnan(surface_water_source[col]) || @@ -1067,16 +1056,10 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& liquid_density = *(*S_->GetW(liquid_density_key_, Tags::DEFAULT, liquid_density_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_density_key_, Tags::DEFAULT, rock_density_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cell_volume_key_, Tags::DEFAULT, cell_volume_key_).ViewComponent("cell",false))(0); - //auto& hydraulic_conductivity = *(*S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, hydraulic_conductivity_key_).ViewComponent("cell",false))(0); - //auto& bulk_density = *(*S_->GetW(bulk_density_key_, Tags::DEFAULT, bulk_density_key_).ViewComponent("cell",false))(0); - //auto& surface_energy_source = *(*S_->GetW(surface_energy_source_key_, Tags::DEFAULT, surface_energy_source_key_).ViewComponent("cell", false))(0); auto& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, Tags::DEFAULT, name_).ViewComponent("cell", false))(0); - //Epetra_MultiVector& surface_energy_source = *(*S_->GetW(surface_energy_source_ecosim_key_, tag_next_, name_).ViewComponent("cell", false))(0); - //Epetra_MultiVector& surface_energy_source = *(S_->GetW(surface_energy_source_ecosim_key_, tag_next_, name_).ViewComponent("cell", false)); auto& subsurface_energy_source = *(*S_->GetW(subsurface_energy_source_ecosim_key_, Tags::DEFAULT, subsurface_energy_source_ecosim_key_).ViewComponent("cell", false))(0); - //auto& surface_water_source = *(*S_->GetW(surface_water_source_key_, Tags::DEFAULT, surface_water_source_key_).ViewComponent("cell", false))(0); auto& surface_water_source = *(*S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_ecosim_key_, Tags::DEFAULT, subsurface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); @@ -1157,67 +1140,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_water_source[col*ncells_per_col_+i] << std::endl; } } - - /*std::cout << "Data from state after pass back: " << std::endl; - for (int col=0; col!=num_columns_local; ++col) { - if (std::isnan(surface_water_source[col]) || - std::isinf(surface_water_source[col])) { - std::cout << "Process " << p_rank << " found bad value at column " - << col << ": " << surface_water_source[col] << std::endl; - } - }*/ - - //Teuchos::OSTab tab = vo_->getOSTab(); - //*vo_->os() << "(CopyFromEcoSIM) Q_w = " << surface_water_source[1] << " m/s " << "snow_depth = " << snow_depth[0][1] << std::endl; - - //auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); - - /*for (int column = 0; column != num_columns_local; ++column) { - for (int i=0; i < ncells_per_col_; ++i) { - (*col_ss_water_source)[i] = state.subsurface_water_source.data[column * ncells_per_col_ + i]*3600.0; - (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[column * ncells_per_col_ + i]*3600.0; - } - - ColumnToField_(column, subsurface_water_source, col_ss_water_source.ptr()); - ColumnToField_(column, subsurface_energy_source, col_ss_energy_source.ptr()); - }*/ - -} - -/* -int EcoSIM::InitializeSingleColumn(int col) -{ - CopyToEcoSIM(column, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - - //ecosim_datatest_wrapper(column, &bgc_props_, &bgc_sizes_); - bgc_engine_->DataTest(); - - int num_iterations = 1; - - bgc_engine_->Setup(bgc_props_, bgc_state_, bgc_sizes_, num_iterations, col); - CopyEcoSIMStateToAmanzi(column, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - } -int EcoSIM::AdvanceSingleColumn(double dt, int col) -{ - // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but - // should use the same tag as transport. See #673 - CopyToEcoSIM(column, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - - int num_iterations = 1; - - bgc_engine_->Advance(dt, bgc_props_, bgc_state_, - bgc_sizes_, num_iterations, col); - - // Move the information back into Amanzi's state, updating the given total concentration vector. - CopyEcoSIMStateToAmanzi(column, - bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - - return num_iterations; - } -*/ - int EcoSIM::InitializeSingleProcess(int proc) { int num_iterations = 1; @@ -1229,16 +1153,6 @@ int EcoSIM::InitializeSingleProcess(int proc) CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - //ecosim_datatest_wrapper(column, &bgc_props_, &bgc_sizes_); - //bgc_engine_->DataTest(); - - /*need some sort of assertions here to double check that the data is actually - What I want it to be*/ - - //Teuchos::OSTab tab = vo_->getOSTab(); - //*vo_->os() << "num_columns: " << num_columns << std::endl; - //*vo_->os() << "ncells_per_col_: " << ncells_per_col_ << std::endl; - bgc_sizes_.num_columns = num_columns; bgc_sizes_.ncells_per_col_ = ncells_per_col_; bgc_sizes_.num_components = 1; @@ -1249,9 +1163,9 @@ int EcoSIM::InitializeSingleProcess(int proc) int EcoSIM::AdvanceSingleProcess(double dt, int proc) { - // NOTE: this should get set not to be hard-coded to Tags::DEFAULT, but - // should use the same tag as transport. See #673 - //CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + //Function to run EcoSIMs advance function, ecosim is run as an hourly model + // Every hour the data is taken from ATS state copied to ecosim + // The model is run and passed back to ATS. int num_iterations = 1; int num_columns = 1; @@ -1270,30 +1184,20 @@ int EcoSIM::AdvanceSingleProcess(double dt, int proc) Teuchos::OSTab tab = vo_->getOSTab(); - std::cout << "in ASP" << std::endl; - std::cout << "t = " << current_time_ << " t_last = " << last_ecosim_time << std::endl; - if (current_time_ - last_ecosim_time >= 3600.0) { *vo_->os() << "Hour completed at total_time: " << current_time_ << ", Year: " << current_year << ", Day: " << current_day << std::endl; *vo_->os() << "Running EcoSIM Advance: " << std::endl; - CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); + CopyToEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns); + bgc_engine_->Advance(dt, bgc_props_, bgc_state_, bgc_sizes_, num_iterations, num_columns); CopyFromEcoSIM_process(proc, bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - last_ecosim_time = current_time_; + last_ecosim_time = current_time_; } - //bgc_engine_->Advance(dt, bgc_props_, bgc_state_, - // bgc_sizes_, num_iterations, num_columns); - - // Move the information back into Amanzi's state, updating the given total concentration vector. - //CopyFromEcoSIM_process(proc, - // bgc_props_, bgc_state_, bgc_aux_data_, Tags::DEFAULT); - return num_iterations; } diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 3bb909922..96fa68134 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -95,11 +95,6 @@ class EcoSIM : public PK_Physical_Default { //The Chemistry_PK even though it isn't used there, and then included Teuchos::RCP bgc_engine() { return bgc_engine_; } - /*void CopyToEcoSIM(int column, - BGCProperties& props, - BGCState& state, - BGCAuxiliaryData& aux_data);*/ - private: //Helper functions from Alquimia @@ -172,9 +167,6 @@ class EcoSIM : public PK_Physical_Default { void MatrixColumnToField_(AmanziMesh::Entity_ID column, Epetra_MultiVector& m_arr, Teuchos::Ptr col_arr); - //evaluator for transpiration; - //I don't think I need this anymore - //Teuchos::RCP p_root_eval_; int number_aqueous_components_; int ncells_per_col_; diff --git a/src/pks/ecosim/ecosim_interface.h b/src/pks/ecosim/ecosim_interface.h index 835c72188..ac4327127 100644 --- a/src/pks/ecosim/ecosim_interface.h +++ b/src/pks/ecosim/ecosim_interface.h @@ -1,33 +1,4 @@ -/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ - -/* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -** through Lawrence Berkeley National Laboratory (subject to receipt of any -** required approvals from the U.S. Dept. of Energy). All rights reserved. -** -** Alquimia is available under a BSD license. See LICENSE.txt for more -** information. -** -** If you have questions about your rights to use or distribute this software, -** please contact Berkeley Lab's Technology Transfer and Intellectual Property -** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -** -** NOTICE. This software was developed under funding from the U.S. Department -** of Energy. As such, the U.S. Government has been granted for itself and -** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -** license in the Software to reproduce, prepare derivative works, and perform -** publicly and display publicly. Beginning five (5) years after the date -** permission to assert copyright is obtained from the U.S. Department of Energy, -** and subject to any subsequent five (5) year renewals, the U.S. Government is -** granted for itself and others acting on its behalf a paid-up, nonexclusive, -** irrevocable, worldwide license in the Software to reproduce, prepare derivative -** works, distribute copies to the public, perform publicly and display publicly, -** and to permit others to do so. -** -** Authors: Benjamin Andre -*/ - -/******************************************************************************* + /***************************************************************************** ** ** C declarations of the ecosim interface ** diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 index 2d1709159..3f60e78c2 100644 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ b/src/pks/ecosim/ecosim_wrappers.F90 @@ -32,7 +32,7 @@ subroutine EcoSIM_DataTest() bind(c) use, intrinsic :: iso_c_binding - + !Simple test for wrapper functionality implicit none write(*,*) "in the data test" @@ -61,19 +61,9 @@ subroutine EcoSIM_Setup(properties, state, sizes, num_iterations,& integer, intent(inout) :: num_iterations integer, intent(inout) :: ncells_per_col_ - write(*,*) "starting driver transfer ATS2EcoSIMData" - - !write(*,*) "num_columns: ", num_columns - !write(*,*) "ncells_per_col_: ", ncells_per_col_ - - !sizes%num_components = 1 - !sizes%ncells_per_col_ = 100 - !sizes%num_columns = 25 - call ATS2EcoSIMData(num_columns, state, properties, sizes) - call Init_EcoSIM(sizes) - write(*,*) "starting driver transfer EcoSIM2ATSData" + call Init_EcoSIM(sizes) call EcoSIM2ATSData(num_columns, state, sizes) From 52c24150723065d908666a74927de7e701d2ff4f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 14 Oct 2025 10:33:19 -0700 Subject: [PATCH 566/582] Second clean up commit Cleaned up the data structures, and condensed some of the files as well. --- src/pks/ecosim/BGCEngine.hh | 1 - src/pks/ecosim/data/BGC_constants.cc | 58 --------- src/pks/ecosim/data/BGC_constants.hh | 69 ----------- src/pks/ecosim/data/BGC_containers.cc | 10 +- src/pks/ecosim/data/BGC_containers.hh | 114 +----------------- src/pks/ecosim/data/BGC_memory.cc | 5 +- src/pks/ecosim/data/CMakeLists.txt | 29 ----- .../ecosim/data/bgc_fortran_memory_mod.F90 | 4 +- 8 files changed, 14 insertions(+), 276 deletions(-) delete mode 100644 src/pks/ecosim/data/BGC_constants.cc delete mode 100644 src/pks/ecosim/data/BGC_constants.hh diff --git a/src/pks/ecosim/BGCEngine.hh b/src/pks/ecosim/BGCEngine.hh index 05bd4f901..75d0dc527 100644 --- a/src/pks/ecosim/BGCEngine.hh +++ b/src/pks/ecosim/BGCEngine.hh @@ -22,7 +22,6 @@ #include "BGC_memory.hh" #include "BGC_containers.hh" -#include "BGC_constants.hh" #include "VerboseObject.hh" diff --git a/src/pks/ecosim/data/BGC_constants.cc b/src/pks/ecosim/data/BGC_constants.cc deleted file mode 100644 index 328c1ce26..000000000 --- a/src/pks/ecosim/data/BGC_constants.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ - -/* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -** through Lawrence Berkeley National Laboratory (subject to receipt of any -** required approvals from the U.S. Dept. of Energy). All rights reserved. -** -** Alquimia is available under a BSD license. See LICENSE.txt for more -** information. -** -** If you have questions about your rights to use or distribute this software, -** please contact Berkeley Lab's Technology Transfer and Intellectual Property -** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -** -** NOTICE. This software was developed under funding from the U.S. Department -** of Energy. As such, the U.S. Government has been granted for itself and -** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -** license in the Software to reproduce, prepare derivative works, and perform -** publicly and display publicly. Beginning five (5) years after the date -** permission to assert copyright is obtained from the U.S. Department of Energy, -** and subject to any subsequent five (5) year renewals, the U.S. Government is -** granted for itself and others acting on its behalf a paid-up, nonexclusive, -** irrevocable, worldwide license in the Software to reproduce, prepare derivative -** works, distribute copies to the public, perform publicly and display publicly, -** and to permit others to do so. -** -** Authors: Benjamin Andre -*/ - -/*This code is a modification of the constants code contained within alquimia -as of right now it's only needed to hold the size of the string, it could be -eliminated eventually and this code could be removed along with the -corresponding header file*/ - -#include "BGC_constants.hh" - -/* String lengths */ -const int kBGCMaxStringLength = 512; -const int kBGCMaxWordLength = 32; - -/* Geochemistry Engine Strings */ -const char* kBGCStringPFloTran = "PFloTran"; -const char* kBGCStringCrunchFlow = "CrunchFlow"; -const char* kBGCStringTotal = "total_aqueous"; -const char* kBGCStringTotalSorbed = "total_sorbed"; -const char* kBGCStringTotalAqueousPlusSorbed = "total_aqueous_plus_sorbed"; -const char* kBGCStringFree = "free"; -const char* kBGCStringPH = "pH"; -const char* kBGCStringMineral = "mineral"; -const char* kBGCStringGas = "gas"; -const char* kBGCStringCharge = "charge"; - -/* Error Codes */ -const int kBGCNoError = 0; -const int kBGCErrorInvalidEngine = 1; -const int kBGCErrorUnknownConstraintName = 2; -const int kBGCErrorUnsupportedFunctionality = 3; -const int kBGCErrorEngineIntegrity = 4577; diff --git a/src/pks/ecosim/data/BGC_constants.hh b/src/pks/ecosim/data/BGC_constants.hh deleted file mode 100644 index 45daecf65..000000000 --- a/src/pks/ecosim/data/BGC_constants.hh +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ - -/* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -** through Lawrence Berkeley National Laboratory (subject to receipt of any -** required approvals from the U.S. Dept. of Energy). All rights reserved. -** -** Alquimia is available under a BSD license. See LICENSE.txt for more -** information. -** -** If you have questions about your rights to use or distribute this software, -** please contact Berkeley Lab's Technology Transfer and Intellectual Property -** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -** -** NOTICE. This software was developed under funding from the U.S. Department -** of Energy. As such, the U.S. Government has been granted for itself and -** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -** license in the Software to reproduce, prepare derivative works, and perform -** publicly and display publicly. Beginning five (5) years after the date -** permission to assert copyright is obtained from the U.S. Department of Energy, -** and subject to any subsequent five (5) year renewals, the U.S. Government is -** granted for itself and others acting on its behalf a paid-up, nonexclusive, -** irrevocable, worldwide license in the Software to reproduce, prepare derivative -** works, distribute copies to the public, perform publicly and display publicly, -** and to permit others to do so. -** -** Authors: Benjamin Andre -*/ - -/*This code is a modification of the constants code contained within alquimia -as of right now it's only needed to hold the size of the string, it could be -eliminated eventually and this code could be removed along with the -corresponding code file*/ - -#ifndef BGC_CONSTANTS_H_ -#define BGC_CONSTANTS_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* String lengths */ -extern const int kBGCMaxStringLength; -extern const int kBGCMaxWordLength; - -/* Geochemistry Engine Strings */ -extern const char* kBGCStringPFloTran; -extern const char* kBGCStringCrunchFlow; -extern const char* kBGCStringTotalAqueous; -extern const char* kBGCStringTotalSorbed; -extern const char* kBGCStringTotalAqueousPlusSorbed; -extern const char* kBGCStringFree; -extern const char* kBGCStringPH; -extern const char* kBGCStringMineral; -extern const char* kBGCStringGas; -extern const char* kBGCStringCharge; - -/* Error Codes */ -extern const int kBGCNoError; -extern const int kBGCErrorInvalidEngine; -extern const int kBGCErrorUnknownConstraintName; -extern const int kBGCErrorUnsupportedFunctionality; -extern const int kBGCErrorEngineIntegrity; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* BGC_CONSTANTS_H_ */ diff --git a/src/pks/ecosim/data/BGC_containers.cc b/src/pks/ecosim/data/BGC_containers.cc index cf8d3e854..ae5c04c3f 100644 --- a/src/pks/ecosim/data/BGC_containers.cc +++ b/src/pks/ecosim/data/BGC_containers.cc @@ -31,6 +31,10 @@ #include "../ecosim_interface.h" +//String lengths +const int kBGCMaxStringLength = 512; +const int kBGCMaxWordLength = 32; + /* Its kind of silly to have this as a separate code at this point, but this will in theory become the switching code if we add other bgc codes, in alquimia this switches between CrunchFlow and PFloTran*/ @@ -38,13 +42,9 @@ codes, in alquimia this switches between CrunchFlow and PFloTran*/ void CreateBGCInterface(const char* const engine_name, BGCInterface* interface) { - //interface->Setup = NULL; - //interface->Shutdown = NULL; - //interface->Advance = NULL; - interface->DataTest = &ecosim_datatest; interface->Setup = &ecosim_setup; interface->Shutdown = &ecosim_shutdown; interface->Advance = &ecosim_advance; - } /* end CreateAlquimiaInterface() */ + } /* end CreateBGCInterface() */ diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 7652f30eb..375e5eaf7 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -27,8 +27,8 @@ ** Authors: Benjamin Andre */ -#ifndef ALQUIMIA_CONTAINERS_H_ -#define ALQUIMIA_CONTAINERS_H_ +#ifndef BGC_CONTAINERS_H_ +#define BGC_CONTAINERS_H_ /******************************************************************************* ** @@ -39,8 +39,6 @@ ** ******************************************************************************/ -//#include "alquimia/alquimia.h" -//#include #include #include @@ -48,6 +46,10 @@ extern "C" { #endif /* __cplusplus */ +//Defining String Lengths +extern const int kBGCMaxStringLength; +extern const int kBGCMaxWordLength; + typedef struct { int size, capacity; double* data; @@ -162,50 +164,6 @@ extern "C" { bool pheno_bool; } BGCProperties; - /* - typedef struct { - BGCVectorDouble liquid_density; - BGCVectorDouble gas_density; - BGCVectorDouble ice_density; - BGCVectorDouble porosity; - BGCVectorDouble water_content; - BGCVectorDouble suction_head; - BGCVectorDouble temperature; - BGCVectorDouble hydraulic_conductivity; - BGCVectorDouble bulk_density; - BGCMatrixDouble total_component_concentration; - } BGCState; - - typedef struct { - BGCVectorDouble liquid_saturation; - BGCVectorDouble gas_saturation; - BGCVectorDouble ice_saturation; - BGCVectorDouble relative_permeability; - BGCVectorDouble thermal_conductivity; - BGCVectorDouble volume; - BGCVectorDouble depth; - BGCVectorDouble dz; - BGCVectorDouble plant_wilting_factor; - BGCVectorDouble rooting_depth_fraction; - double shortwave_radiation; - double longwave_radiation; - double air_temperature; - double vapor_pressure_air; - double wind_speed; - double precipitation; - double elevation; - double aspect; - double slope; - double atm_n2; - double atm_o2; - double atm_co2; - double atm_ch4; - double atm_n2o; - double atm_h2; - double atm_nh3; - } BGCProperties; - */ - typedef struct { BGCVectorInt aux_ints; /* [-] */ BGCVectorDouble aux_doubles; /* [-] */ @@ -227,16 +185,6 @@ extern "C" { /* gracefully shutdown the engine, cleanup memory */ void (*Shutdown)(); - /* constrain processing for boundary/initial constraints. Called - once for each IC/BC. */ - /*void (*Setup)( - void* pft_engine_state, - BGCGeochemicalCondition* condition, - BGCProperties* props, - BGCState* state, - BGCAuxiliaryData* aux_data, - BGCEngineStatus* status);*/ - /* take one (or more?) reaction steps in operator split mode */ void (*Advance)( double delta_t, @@ -246,59 +194,9 @@ extern "C" { int num_iterations, int num_columns); - /* Access to user selected geochemical data for output, i.e. pH, - mineral SI, reaction rates */ - /*void (*GetAuxiliaryOutput)( - void* pft_engine_state, - BGCProperties* props, - BGCState* state, - BGCAuxiliaryData* aux_data, - BGCAuxiliaryOutputData* aux_out, - BGCEngineStatus* status);*/ } BGCInterface; void CreateBGCInterface(const char* const engine_name, BGCInterface* interface); - /* - typedef struct { - int error; - char* message; - bool converged; - int num_rhs_evaluations; - int num_jacobian_evaluations; - int num_newton_iterations; - } BGCEngineStatus; - - typedef struct { - bool thread_safe; - bool temperature_dependent; - bool pressure_dependent; - bool porosity_update; - bool operator_splitting; - bool global_implicit; - int index_base; - } BGCEngineFunctionality; - - typedef struct { - AlquimiaVectorString primary_names; - AlquimiaVectorInt positivity; - AlquimiaVectorString mineral_names; - AlquimiaVectorString surface_site_names; - AlquimiaVectorString ion_exchange_names; - AlquimiaVectorString isotherm_species_names; - AlquimiaVectorString aqueous_kinetic_names; - } BGCProblemMetaData; - - typedef struct { - double pH; - AlquimiaVectorDouble aqueous_kinetic_rate; // [?] - AlquimiaVectorDouble mineral_saturation_index; // [mol/sec/m^3] - AlquimiaVectorDouble mineral_reaction_rate; // [mol/sec/m^3 bulk] - AlquimiaVectorDouble primary_free_ion_concentration; // [molality] - AlquimiaVectorDouble primary_activity_coeff; // [-] - AlquimiaVectorDouble secondary_free_ion_concentration; // [molality] - AlquimiaVectorDouble secondary_activity_coeff; // [-] - } BGCAuxiliaryOutputData; - */ #ifdef __cplusplus } diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 2c6eec9de..06047d276 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -48,7 +48,6 @@ #include #include "BGC_memory.hh" #include "BGC_containers.hh" -#include "BGC_constants.hh" // Returns the nearest power of 2 greater than or equal to n, or 0 if n == 0. static inline int nearest_power_of_2(int n) @@ -152,7 +151,7 @@ void AllocateBGCMatrixDouble(const int cells, const int columns, BGCMatrixDouble matrix->capacity_cells = nearest_power_of_2(cells); matrix->capacity_columns = nearest_power_of_2(columns); matrix->data = (double*) calloc((size_t)matrix->capacity_cells * matrix->capacity_columns, sizeof(double)); - + //for (int i = 0; i < matrix->columns; ++i) { // matrix->data[i] = (double*) calloc((size_t)matrix->capacity_cells, sizeof(double)); //} @@ -396,7 +395,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->thermal_conductivity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->volume)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->depth)); - AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->depth_c)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->depth_c)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->dz)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->plant_wilting_factor)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->rooting_depth_fraction)); diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 9cfb90454..0760f0721 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -4,26 +4,11 @@ # Data management programs for EcoSIM_ATS # -# collect all sources -#set(ats_ecosim_data_src_files -# BGC_constants.cc -# BGC_memory.cc -# BGC_containers.cc -# bgc_fortran_memory_mod.F90 -#) - get_property(AMANZI_TPLS_DIR GLOBAL PROPERTY AMANZI_TPLS_DIR) -#set(ECOSIM_INSTALL_PREFIX "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") -#set(ECOSIM_LIB_LOCATION "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") -#set(ECOSIM_CMAKE_BINARY_DIR "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") -#set(NETCDF_LIB "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") - set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) -#set(ECOSIM_LIB_LOCATION ${ECOSIM_LIBRARY_DIR}) set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) set(ECOSIM_BUILD_PREFIX ${ECOSIM_DIR}/ecosim/build) -#set(ECOSIM_CMAKE_BINARY_DIR ${ECOSIM_DIR}/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release) set(NETCDF_LIB ${ECOSIM_DIR}/lib) message("In ATS-EcoSIM data CMakeLists:") @@ -32,18 +17,6 @@ message("ECOSIM_INSTALL_PREFIX:" ${ECOSIM_INSTALL_PREFIX}) message("ECOSIM_LIB_LOCATION:" ${ECOSIM_LIB_LOCATION}) message("ECOSIM_BUILD_PREFIX:" ${ECOSIM_BUILD_PREFIX}) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) -#include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) - message("At include_directories in data") include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) @@ -64,7 +37,6 @@ include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIs/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/APIData/) set(ats_ecosim_data_src_files - BGC_constants.cc BGC_memory.cc BGC_containers.cc bgc_fortran_memory_mod.F90 @@ -79,7 +51,6 @@ set(ats_ecosim_data_src_files ) set(ats_ecosim_data_inc_files - BGC_constants.hh BGC_containers.hh BGC_memory.hh ) diff --git a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 index 1c144d860..323de3bb0 100644 --- a/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 +++ b/src/pks/ecosim/data/bgc_fortran_memory_mod.F90 @@ -1,6 +1,4 @@ -!It seems like the memory allocation functions need to know how do define the -!memory even if you do not do memory allocation in F90, so this code writes -!versions of the memory allocation functions +!Memory and interface mangling functions for the ATS-EcoSIM coupler. module bgc_fortran_memory_mod From 2d4909f39eb2501e71b749748529e445ad3d2762 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 15 Oct 2025 19:54:36 -0700 Subject: [PATCH 567/582] Adding vars to ATS-EcoSIM This update adds several datasets to the ATS-EcoSIM datastructures for carry over and analysis. This includes variables needed to carry over canopy properties between timesteps, and place EcoSIM fluxes into ATS's state for plotting purposes. The datesets are: canopy longwave radiation boundary latent heat flux boundary sensible heat flux canopy surface water evapotranspiration evaporation from bare ground evaporation from litter evaporation from snow sublimation from snow Note this update just makes the variables visible to ATS, but it has not been linked to ATS state yet. There will be a similar update on the EcoSIM side. --- src/pks/ecosim/data/BGC_containers.hh | 11 ++++++++++- src/pks/ecosim/data/BGC_memory.cc | 21 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 375e5eaf7..54603e4e5 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -117,7 +117,16 @@ extern const int kBGCMaxWordLength; BGCVectorDouble surface_energy_source; BGCVectorDouble surface_water_source; BGCVectorDouble snow_depth; - BGCVectorDouble canopy_height; + BGCVectorDouble canopy_longwave_radiation; + BGCVectorDouble boundary_latent_heat_flux; + BGCVectorDouble boundary_sensible_heat_flux; + BGCVectorDouble canopy_surface_water; + BGCVectorDouble evapotranspiration; + BGCVectorDouble evaporation_bare_ground; + BGCVectorDouble evaporation_litter; + BGCVectorDouble evaporation_snow; + BGCVectorDouble sublimation_snow; + BGCMatrixDouble snow_temperature; BGCTensorDouble total_component_concentration; } BGCState; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 06047d276..eb1076412 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -326,7 +326,16 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_water_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->surface_energy_source)); AllocateBGCVectorDouble(sizes->num_columns, &(state->snow_depth)); - AllocateBGCVectorDouble(sizes->num_columns, &(state->canopy_height)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->canopy_longwave_radiation)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->boundary_latent_heat_flux)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->boundary_sensible_heat_flux)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->canopy_surface_water)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->evapotranspiration)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->evaporation_bare_ground)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->evaporation_litter)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->evaporation_snow)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->sublimation_snow)); + AllocateBGCMatrixDouble(sizes->num_columns, sizes->num_columns, &(state->snow_temperature)); AllocateBGCTensorDouble(sizes->ncells_per_col_, sizes->num_columns, sizes->num_components, &(state->total_component_concentration)); //ALQUIMIA_ASSERT(state->total_mobile.data != NULL); } /* end AllocateBGCState() */ @@ -347,7 +356,15 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCVectorDouble(&(state->surface_energy_source)); FreeBGCVectorDouble(&(state->surface_water_source)); FreeBGCVectorDouble(&(state->snow_depth)); - FreeBGCVectorDouble(&(state->canopy_height)); + FreeBGCVectorDouble(&(state->canopy_longwave_radiation)); + FreeBGCVectorDouble(&(state->boundary_latent_heat_flux)); + FreeBGCVectorDouble(&(state->boundary_sensible_heat_flux)); + FreeBGCVectorDouble(&(state->canopy_surface_water)); + FreeBGCVectorDouble(&(state->evapotranspiration)); + FreeBGCVectorDouble(&(state->evaporation_bare_ground)); + FreeBGCVectorDouble(&(state->evaporation_litter)); + FreeBGCVectorDouble(&(state->evaporation_snow)); + FreeBGCVectorDouble(&(state->sublimation_snow)); FreeBGCTensorDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ From d048d178ce9c7683e63dcebb23c5b006608fb374 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 17 Nov 2025 09:47:56 -0800 Subject: [PATCH 568/582] Adding flux component datasets This adds datasets to ATS that hold the various components of the flux including evaporation, transpiration, and snow temperature. --- src/pks/ecosim/CMakeLists.txt | 30 ------ src/pks/ecosim/EcoSIM_ATS_interface.cc | 140 +++++++++++++++++++++++-- src/pks/ecosim/EcoSIM_ATS_interface.hh | 16 ++- src/pks/ecosim/data/BGC_memory.cc | 1 + 4 files changed, 147 insertions(+), 40 deletions(-) diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index db0ce4d4e..051293b45 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -8,11 +8,6 @@ if(ENABLE_ECOSIM) get_property(AMANZI_TPLS_DIR GLOBAL PROPERTY AMANZI_TPLS_DIR) - #set(ECOSIM_INSTALL_PREFIX "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim") - #set(ECOSIM_LIB_LOCATION "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/local/lib") - #set(ECOSIM_CMAKE_BINARY_DIR "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/ecosim/build/Linux-x86_64-static-not-set-mpicc-Release") - #set(NETCDF_LIB "/global2/agraus/code/ats_dev_dir/amanzi_tpls-install-master-Debug/lib") - set(ECOSIM_INSTALL_PREFIX ${ECOSIM_DIR}/ecosim) set(ECOSIM_LIB_LOCATION ${ECOSIM_DIR}/ecosim/local/lib) set(ECOSIM_BUILD_PREFIX ${ECOSIM_DIR}/ecosim/build) @@ -32,31 +27,6 @@ if(ENABLE_ECOSIM) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/ATSUtils/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/utils/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/minimath/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelconfig/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/mesh/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/modelpars/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_datatype/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SoilPhys/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/SurfPhys/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/HydroTherm/PhysData/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/balances/) - #include_directories(${TPL_INSTALL_PREFIX}/f90src/ecosim_mods/) - - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/utils/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/minimath/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelconfig/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/mesh/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/modelpars/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/balances/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_datatype/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SoilPhys/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/SurfPhys/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/HydroTherm/PhysData/) - #include_directories(${ECOSIM_CMAKE_BINARY_DIR}/f90src/ecosim_mods/) - message("At include_directories") include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Minimath/) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 4b1cb361c..a5e8b1746 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -122,6 +122,18 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, slope_key_ = Keys::readKey(*plist_, domain_surface_, "slope", "slope_magnitude"); snow_depth_key_ = Keys::readKey(*plist_, domain_surface_, "snow depth", "snow_depth"); snow_albedo_key_ = Keys::readKey(*plist_, domain_surface_, "snow_albedo", "snow_albedo"); + snow_temperature_key_ = Keys::readKey(*plist_, domain_surface_, "snow temperature", "snow_temperature"); + + //Canopy hold over vars for EcoSIM + canopy_lw_key_ = Keys::readKey(*plist_, domain_surface_, "canopy longwave radiation", "canopy_longwave_radiation"); + canopy_latent_heat_key_ = Keys::readKey(*plist_, domain_surface_, "canopy latent heat", "canopy_latent_heat"); + canopy_sensible_heat_key_ = Keys::readKey(*plist_, domain_surface_, "canopy sensible heat", "canopy_sensible_heat"); + canopy_surface_water_key_ = Keys::readKey(*plist_, domain_surface_, "canopy surface water", "canopy_surface_water"); + evapotranspiration_key_ = Keys::readKey(*plist_, domain_surface_, "evapotranspiration", "evapotranspiration"); + evaporation_ground_key_ = Keys::readKey(*plist_, domain_surface_, "evaporation ground", "evaporation_ground"); + evaporation_litter_key_ = Keys::readKey(*plist_, domain_surface_, "evaporation litter", "evaporation_litter"); + evaporation_snow_key_ = Keys::readKey(*plist_, domain_surface_, "evaporation snow", "evaporation_snow"); + sublimation_snow_key_ = Keys::readKey(*plist_, domain_surface_, "sublimation snow", "sublimation_snow"); //Plant Phenology Datasets lai_key_ = Keys::readKey(*plist_, domain_surface_, "LAI", "LAI"); @@ -169,12 +181,6 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, std::string engine_name = plist_->get("engine"); std::string engine_inputfile = plist_->get("engine input file"); bgc_engine_ = Teuchos::rcp(new BGCEngine(engine_name, engine_inputfile)); - - /*(AMANZI_ASSERT(plist_.isSublist("WRM parameters")); - Teuchos::ParameterList sublist = plist_.sublist("WRM parameters"); - wrms_ = createWRMPartition(sublist); - InitializeFromPlist_(); - */ } @@ -216,6 +222,51 @@ void EcoSIM::Setup() { ->SetComponent("cell", AmanziMesh::CELL, 1); } + S_->Require(canopy_lw_key_ , tag_next_, canopy_lw_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(canopy_latent_heat_key_ , tag_next_, canopy_latent_heat_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(canopy_sensible_heat_key_, tag_next_, canopy_sensible_heat_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(canopy_surface_water_key_ , tag_next_, canopy_surface_water_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(evapotranspiration_key_ , tag_next_, evapotranspiration_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(evaporation_ground_key_ , tag_next_, evaporation_ground_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(evaporation_litter_key_ , tag_next_, evaporation_litter_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(evaporation_snow_key_ , tag_next_, evaporation_snow_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(sublimation_snow_key_ , tag_next_, sublimation_snow_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + S_->Require(surface_energy_source_ecosim_key_ , tag_next_, name_) .SetMesh(mesh_surf_) ->SetGhosted(false) @@ -236,6 +287,11 @@ void EcoSIM::Setup() { ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); + S_->Require(snow_temperature_key_ , tag_next_, snow_temperature_key_) + .SetMesh(mesh_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + //May need to setup surface evaluators as they are now owned by surface_balance PK insteady of surface energy?? // S_->RequireEvaluator(snow_albedo_key_, tag_next_); @@ -339,6 +395,33 @@ void EcoSIM::Initialize() { S_->GetW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").PutScalar(0.0); S_->GetRecordW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").set_initialized(); + S_->GetW(canopy_lw_key_, Tags::DEFAULT, "surface-canopy_longwave_radiation").PutScalar(0.0); + S_->GetRecordW(canopy_lw_key_, Tags::DEFAULT, "surface-canopy_longwave_radiation").set_initialized(); + + S_->GetW(canopy_latent_heat_key_, Tags::DEFAULT, "surface-canopy_latent_heat").PutScalar(0.0); + S_->GetRecordW(canopy_latent_heat_key_, Tags::DEFAULT, "surface-canopy_latent_heat").set_initialized(); + + S_->GetW(canopy_sensible_heat_key_, Tags::DEFAULT, "surface-canopy_sensible_heat").PutScalar(0.0); + S_->GetRecordW(canopy_sensible_heat_key_, Tags::DEFAULT, "surface-canopy_sensible_heat").set_initialized(); + + S_->GetW(canopy_surface_water_key_, Tags::DEFAULT, "surface-canopy_surface_water").PutScalar(0.0); + S_->GetRecordW(canopy_surface_water_key_, Tags::DEFAULT, "surface-canopy_surface_water").set_initialized(); + + S_->GetW(evapotranspiration_key_, Tags::DEFAULT, "surface-evapotranspiration").PutScalar(0.0); + S_->GetRecordW(evapotranspiration_key_, Tags::DEFAULT, "surface-evapotranspiration").set_initialized(); + + S_->GetW(evaporation_ground_key_, Tags::DEFAULT, "surface-evaporation_ground").PutScalar(0.0); + S_->GetRecordW(evaporation_ground_key_, Tags::DEFAULT, "surface-evaporation_ground").set_initialized(); + + S_->GetW(evaporation_litter_key_, Tags::DEFAULT, "surface-evaporation_litter").PutScalar(0.0); + S_->GetRecordW(evaporation_litter_key_, Tags::DEFAULT, "surface-evaporation_litter").set_initialized(); + + S_->GetW(evaporation_snow_key_, Tags::DEFAULT, "surface-evaporation_snow").PutScalar(0.0); + S_->GetRecordW(evaporation_snow_key_, Tags::DEFAULT, "surface-evaporation_snow").set_initialized(); + + S_->GetW(sublimation_snow_key_, Tags::DEFAULT, "surface-sublimation_snow").PutScalar(0.0); + S_->GetRecordW(sublimation_snow_key_, Tags::DEFAULT, "surface-sublimation_snow").set_initialized(); + //S_->GetW(lai_key_, Tags::DEFAULT, "surface-LAI").PutScalar(0.0); //S_->GetRecordW(lai_key_, Tags::DEFAULT, "surface-LAI").set_initialized(); //surface_energy_source_ecosim_key_ @@ -353,6 +436,9 @@ void EcoSIM::Initialize() { S_->GetW(subsurface_energy_source_ecosim_key_, Tags::DEFAULT, subsurface_energy_source_ecosim_key_).PutScalar(0.0); S_->GetRecordW(subsurface_energy_source_ecosim_key_, Tags::DEFAULT, subsurface_energy_source_ecosim_key_).set_initialized(); + S_->GetW(snow_temperature_key_, Tags::DEFAULT, snow_temperature_key_).PutScalar(0.0); + S_->GetRecordW(snow_temperature_key_, Tags::DEFAULT, snow_temperature_key_).set_initialized(); + //Initialize owned evaluators S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); @@ -863,6 +949,16 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto& snow_depth = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); + auto& canopy_longwave_radiation = *S_->GetW(canopy_lw_key_, tag_next_, canopy_lw_key_).ViewComponent("cell"); + auto& canopy_latent_heat = *S_->GetW(canopy_latent_heat_key_, tag_next_, canopy_latent_heat_key_).ViewComponent("cell"); + auto& canopy_sensible_heat = *S_->GetW(canopy_sensible_heat_key_, tag_next_, canopy_sensible_heat_key_).ViewComponent("cell"); + auto& canopy_surface_water = *S_->GetW(canopy_surface_water_key_, tag_next_, canopy_surface_water_key_).ViewComponent("cell"); + auto& evapotranspiration = *S_->GetW(evapotranspiration_key_, tag_next_, evapotranspiration_key_).ViewComponent("cell"); + auto& evaporation_ground = *S_->GetW(evaporation_ground_key_, tag_next_, evaporation_ground_key_).ViewComponent("cell"); + auto& evaporation_litter = *S_->GetW(evaporation_litter_key_, tag_next_, evaporation_litter_key_).ViewComponent("cell"); + auto& evaporation_snow = *S_->GetW(evaporation_snow_key_, tag_next_, evaporation_snow_key_).ViewComponent("cell"); + auto& sublimation_snow = *S_->GetW(sublimation_snow_key_, tag_next_, sublimation_snow_key_).ViewComponent("cell"); + auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -982,6 +1078,15 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.surface_energy_source.data[column] = surface_energy_source[column]; state.surface_water_source.data[column] = surface_water_source[column]; state.snow_depth.data[column] = snow_depth[0][column]; + state.canopy_longwave_radiation.data[column] = canopy_longwave_radiation[0][column]; + state.boundary_latent_heat_flux.data[column] = canopy_latent_heat[0][column]; + state.boundary_sensible_heat_flux.data[column] = canopy_sensible_heat[0][column]; + state.canopy_surface_water.data[column] = canopy_surface_water[0][column]; + state.evapotranspiration.data[column] = evapotranspiration[0][column]; + state.evaporation_bare_ground.data[column] = evaporation_ground[0][column]; + state.evaporation_litter.data[column] = evaporation_litter[0][column]; + state.evaporation_snow.data[column] = evaporation_snow[0][column]; + state.sublimation_snow.data[column] = sublimation_snow[0][column]; props.shortwave_radiation.data[column] = shortwave_radiation[column]; props.longwave_radiation.data[column] = longwave_radiation[column]; @@ -1064,9 +1169,18 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& subsurface_water_source = *(*S_->GetW(subsurface_water_source_ecosim_key_, Tags::DEFAULT, subsurface_water_source_ecosim_key_).ViewComponent("cell", false))(0); auto& temp = *(*S_->GetW(T_key_, Tags::DEFAULT, "subsurface energy").ViewComponent("cell",false))(0); auto& thermal_conductivity = *(*S_->GetW(thermal_conductivity_key_, Tags::DEFAULT, thermal_conductivity_key_).ViewComponent("cell",false))(0); - + auto& snow_temperature = *(*S_->GetW(snow_temperature_key_, Tags::DEFAULT, snow_temperature_key_).ViewComponent("cell", false))(0); auto& snow_depth = *S_->GetW(snow_depth_key_,tag_next_,snow_depth_key_).ViewComponent("cell"); + auto& canopy_longwave_radiation = *S_->GetW(canopy_lw_key_, tag_next_, canopy_lw_key_).ViewComponent("cell"); + auto& canopy_latent_heat = *S_->GetW(canopy_latent_heat_key_, tag_next_, canopy_latent_heat_key_).ViewComponent("cell"); + auto& canopy_sensible_heat = *S_->GetW(canopy_sensible_heat_key_, tag_next_, canopy_sensible_heat_key_).ViewComponent("cell"); + auto& canopy_surface_water = *S_->GetW(canopy_surface_water_key_, tag_next_, canopy_surface_water_key_).ViewComponent("cell"); + auto& evapotranspiration = *S_->GetW(evapotranspiration_key_, tag_next_, evapotranspiration_key_).ViewComponent("cell"); + auto& evaporation_ground = *S_->GetW(evaporation_ground_key_, tag_next_, evaporation_ground_key_).ViewComponent("cell"); + auto& evaporation_litter = *S_->GetW(evaporation_litter_key_, tag_next_, evaporation_litter_key_).ViewComponent("cell"); + auto& evaporation_snow = *S_->GetW(evaporation_snow_key_, tag_next_, evaporation_snow_key_).ViewComponent("cell"); + auto& sublimation_snow = *S_->GetW(sublimation_snow_key_, tag_next_, sublimation_snow_key_).ViewComponent("cell"); auto col_porosity = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_l_sat = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); @@ -1086,6 +1200,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto col_b_dens = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_energy_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_snow_temperature = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); @@ -1117,14 +1232,25 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, for (int i=0; i < ncells_per_col_; ++i) { (*col_ss_water_source)[i] = state.subsurface_water_source.data[col * ncells_per_col_ + i]; (*col_ss_energy_source)[i] = state.subsurface_energy_source.data[col * ncells_per_col_ + i]; + (*col_snow_temperature)[i] = state.snow_temperature.data[col * ncells_per_col_ + i]; } ColumnToField_(col, subsurface_water_source, col_ss_water_source.ptr()); ColumnToField_(col, subsurface_energy_source, col_ss_energy_source.ptr()); + ColumnToField_(col, snow_temperature, col_snow_temperature.ptr()); surface_energy_source[col] = state.surface_energy_source.data[col]/(3600.0); surface_water_source[col] = state.surface_water_source.data[col]/(3600.0); snow_depth[0][col] = state.snow_depth.data[col]; + canopy_longwave_radiation[0][col] = state.canopy_longwave_radiation.data[col]; + canopy_latent_heat[0][col] = state.boundary_latent_heat_flux.data[col]; + canopy_sensible_heat[0][col] = state.boundary_sensible_heat_flux.data[col]; + canopy_surface_water[0][col] = state.canopy_surface_water.data[col]; + evapotranspiration[0][col] = state.evapotranspiration.data[col]; + evaporation_ground[0][col] = state.evaporation_bare_ground.data[col]; + evaporation_litter[0][col] = state.evaporation_litter.data[col]; + evaporation_snow[0][col] = state.evaporation_snow.data[col]; + sublimation_snow[0][col] = state.sublimation_snow.data[col]; } std::cout << "(CopyFromEcoSIM) subsurface energy flux: " << std::endl; diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 96fa68134..be622b90a 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -42,11 +42,13 @@ #include "pk_physical_default.hh" #include "PK_Physical.hh" #include "ecosim_mod_test_wrapper.h" - +#include "MeshPartition.hh" namespace Amanzi { namespace EcoSIM { +//using namespace Amanzi::Flow; + class EcoSIM : public PK_Physical_Default { public: @@ -59,7 +61,6 @@ class EcoSIM : public PK_Physical_Default { // Virtual destructor ~EcoSIM(); - //Teuchos::RCP get_WRMs() { return wrms_; } // is a PK // -- Setup data //virtual void Setup(const Teuchos::Ptr&S); @@ -130,7 +131,6 @@ class EcoSIM : public PK_Physical_Default { void ComputeNextTimeStep(); protected: - //Teuchos::RCP wrms_; double dt_; double c_m_; Teuchos::RCP mesh_surf_; //might need this? @@ -225,6 +225,16 @@ class EcoSIM : public PK_Physical_Default { Key subsurface_water_source_ecosim_key_; Key snow_depth_key_; Key snow_albedo_key_; + Key canopy_lw_key_; + Key canopy_latent_heat_key_; + Key canopy_sensible_heat_key_; + Key canopy_surface_water_key_; + Key evapotranspiration_key_; + Key evaporation_ground_key_; + Key evaporation_litter_key_; + Key evaporation_snow_key_; + Key sublimation_snow_key_; + Key snow_temperature_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index eb1076412..75331564c 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -365,6 +365,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCVectorDouble(&(state->evaporation_litter)); FreeBGCVectorDouble(&(state->evaporation_snow)); FreeBGCVectorDouble(&(state->sublimation_snow)); + FreeBGCMatrixDouble(&(state->snow_temperature)); FreeBGCTensorDouble(&(state->total_component_concentration)); } } /* end FreeAlquimiaState() */ From 9f73c1677f368bd01f9fb8faec72a1b06cf0651b Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Nov 2025 16:46:55 -0800 Subject: [PATCH 569/582] Updated ATS-EcoSIM fork with ATS-1.6 The versions should now be compatible. Some minor edits needed to be made outside of the merge, due to capitalization changes of some header files, and renaming of the requireAtCurrent/Next functions. This code compiles, but currently is not running due to some changes to transport in the input files. --- .github/workflows/ats-ci.yml | 89 +- README.md | 8 +- docs/documentation/Makefile | 12 + .../source/_static/versions.json | 10 +- docs/documentation/source/ats_demos | 2 +- docs/documentation/source/conf.py | 5 +- docs/documentation/source/index.rst | 8 +- .../source/input_spec/.gitignore | 45 + docs/documentation/source/input_spec/Makefile | 3 +- .../source/input_spec/common.rst.in | 6 +- .../input_spec/generate_ATSNativeSpec.py | 26 +- .../documentation/source/input_spec/index.rst | 12 +- .../source/input_spec/introduction.rst | 150 +- .../source/input_spec/io/index.rst.in | 11 +- .../source/input_spec/io/logfile.rst.in | 15 +- .../source/input_spec/math/operators.rst.in | 8 +- .../input_spec/process_kernels/base.rst.in | 14 +- .../input_spec/process_kernels/index.rst | 2 +- .../process_kernels/mpcs/base.rst.in | 18 +- .../process_kernels/mpcs/globalization.rst.in | 2 +- .../input_spec/process_kernels/mpcs/index.rst | 3 +- .../mpcs/multiple_domain.rst.in | 40 + .../process_kernels/mpcs/physical.rst.in | 30 - .../mpcs/tightly_coupled.rst.in | 28 + .../process_kernels/physical/bgc.rst.in | 16 + .../physical/deformation.rst.in | 18 + .../process_kernels/physical/energy.rst.in | 10 +- .../process_kernels/physical/flow.rst.in | 17 +- .../process_kernels/physical/index.rst | 2 + .../process_kernels/physical/physical.rst.in | 144 -- .../process_kernels/physical/seb.rst.in | 35 +- .../process_kernels/physical/transport.rst.in | 49 +- .../source/input_spec/region.rst.in | 72 +- .../source/input_spec/state/conserved.rst.in | 22 +- .../input_spec/state/engineered_water.rst.in | 32 + .../source/input_spec/state/eos.rst.in | 11 +- .../source/input_spec/state/index.rst.in | 41 +- .../source/input_spec/state/primary.rst.in | 4 + .../source/input_spec/state/seb.rst.in | 24 +- .../source/input_spec/state/secondary.rst.in | 44 - .../state/sediment_transport.rst.in | 22 + .../input_spec/state/subsurface_flow.rst.in | 74 +- .../input_spec/state/surface_flow.rst.in | 47 +- .../source/input_spec/state/thermo.rst.in | 4 +- .../source/input_spec/state/transport.rst.in | 25 + .../source/input_spec/symbol_table.org | 216 +- .../source/input_spec/symbol_table.rst | 427 ++-- .../source/input_spec/symbol_table_notes.rst | 11 +- .../column_integrators/ColumnSumEvaluator.cc | 8 +- .../column_integrators/ColumnSumEvaluator.hh | 4 +- .../EvaluatorColumnIntegrator.hh | 25 +- .../PerchedWaterTableColumnIntegrator.hh | 32 +- .../WaterTableColumnIntegrator.hh | 32 +- .../activelayer_average_temp_evaluator.hh | 4 +- .../column_integrators_reg.hh | 18 +- .../perched_water_table_depth_evaluator.cc | 11 +- .../perched_water_table_depth_evaluator.hh | 10 +- .../water_table_depth_evaluator.cc | 7 +- .../water_table_depth_evaluator.hh | 6 +- .../carbon_decomposition_rate_evaluator.cc | 5 +- src/constitutive_relations/eos/eos.hh | 8 +- .../eos/eos_constant.cc | 3 +- .../eos/eos_constant.hh | 39 +- .../eos/eos_constant_molar_mass.hh | 16 +- .../eos/eos_evaluator.cc | 44 +- .../eos/eos_evaluator.hh | 26 +- src/constitutive_relations/eos/eos_ice.cc | 6 +- src/constitutive_relations/eos/eos_ice.hh | 25 +- .../eos/eos_ideal_gas.cc | 11 +- .../eos/eos_ideal_gas.hh | 27 +- src/constitutive_relations/eos/eos_linear.cc | 17 +- src/constitutive_relations/eos/eos_linear.hh | 39 +- src/constitutive_relations/eos/eos_reg.hh | 16 +- src/constitutive_relations/eos/eos_sw.cc | 10 +- src/constitutive_relations/eos/eos_sw.hh | 8 +- .../eos/eos_vapor_in_gas.cc | 10 +- .../eos/eos_vapor_in_gas.hh | 22 +- src/constitutive_relations/eos/eos_water.cc | 21 +- src/constitutive_relations/eos/eos_water.hh | 25 +- .../eos/molar_fraction_gas_evaluator_reg.hh | 4 +- .../eos/vapor_pressure_relation.hh | 2 +- .../eos/vapor_pressure_water_reg.hh | 4 +- .../eos/viscosity_constant.cc | 3 +- .../eos/viscosity_constant_reg.hh | 4 +- .../eos/viscosity_evaluator.cc | 4 +- .../eos/viscosity_evaluator.hh | 8 +- .../eos/viscosity_relation.hh | 4 +- .../eos/viscosity_relation_factory.cc | 9 +- .../eos/viscosity_water.cc | 13 +- .../eos/viscosity_water.hh | 4 +- .../eos/viscosity_water_reg.hh | 4 +- .../generic_evaluators/AdditiveEvaluator.cc | 6 +- .../generic_evaluators/AdditiveEvaluator.hh | 4 +- .../AdditiveEvaluator_reg.hh | 4 +- .../ExtractionEvaluator_reg.hh | 4 +- .../InitialTimeEvaluator.hh | 4 +- .../InitialTimeEvaluator_reg.hh | 4 +- .../MultiplicativeEvaluator.cc | 8 +- .../MultiplicativeEvaluator.hh | 4 +- .../MultiplicativeEvaluator_reg.hh | 4 +- .../generic_evaluators/ReciprocalEvaluator.cc | 18 +- .../ReciprocalEvaluator_reg.hh | 4 +- .../SubgridAggregateEvaluator.cc | 2 +- .../SubgridAggregateEvaluator.hh | 4 +- .../SubgridAggregateEvaluator_reg.hh | 4 +- .../SubgridDisaggregateEvaluator.hh | 4 +- .../generic_evaluators/TimeMaxEvaluator.cc | 4 +- .../generic_evaluators/TimeMaxEvaluator.hh | 4 +- ...d_source_from_subsurface_flux_evaluator.cc | 4 +- .../surface_top_cells_evaluator_reg.hh | 4 +- .../top_cells_surface_evaluator_reg.hh | 4 +- .../volumetric_darcy_flux_evaluator.cc | 8 +- .../volumetric_darcy_flux_evaluator_reg.hh | 4 +- src/executables/ats_driver.cc | 2 +- src/executables/ats_driver.hh | 65 +- src/executables/ats_mesh_factory.cc | 12 +- src/executables/ats_mesh_factory.hh | 212 +- src/executables/ats_registration_files.hh | 2 +- src/executables/coordinator.cc | 41 +- src/executables/elm_ats_api/Indexer.hh | 66 +- src/executables/elm_ats_api/elm_ats_api.cc | 279 +-- src/executables/elm_ats_api/elm_ats_driver.cc | 480 ++-- src/executables/elm_ats_api/elm_ats_driver.hh | 90 +- .../elm_ats_api/test/elm_ats_test.cc | 24 +- src/executables/main.cc | 45 +- .../test/executable_coupled_water1.xml | 43 +- .../test/executable_coupled_water2.xml | 45 +- .../test/executable_coupled_water3.xml | 45 +- .../test/executable_mesh_factory.cc | 8 +- .../advection/advection_donor_upwind.cc | 19 +- .../advection/advection_donor_upwind.hh | 4 +- src/operators/advection/advection_factory.hh | 4 +- .../MatrixVolumetricDeformation.cc | 9 +- .../Matrix_PreconditionerDelegate.cc | 2 +- src/operators/divgrad/MatrixMFD.cc | 95 +- .../divgrad/MatrixMFD_Coupled_Surf.cc | 8 +- src/operators/upwinding/UpwindFluxFactory.hh | 11 +- .../upwinding/upwind_arithmetic_mean.cc | 8 +- .../upwinding/upwind_cell_centered.cc | 4 +- .../upwinding/upwind_elevation_stabilized.cc | 4 +- .../upwinding/upwind_flux_fo_cont.cc | 15 +- .../upwinding/upwind_flux_harmonic_mean.cc | 13 +- .../upwind_flux_split_denominator.cc | 4 +- .../upwinding/upwind_gravity_flux.cc | 10 +- .../upwinding/upwind_gravity_flux.hh | 7 +- .../upwinding/upwind_potential_difference.cc | 18 +- src/operators/upwinding/upwind_total_flux.cc | 6 +- src/pks/CMakeLists.txt | 6 +- src/pks/bc_factory.hh | 13 +- src/pks/biogeochemistry/bgc_simple/PFT.cc | 16 +- .../biogeochemistry/bgc_simple/bgc_simple.cc | 37 +- .../biogeochemistry/bgc_simple/bgc_simple.hh | 94 +- .../bgc_simple/bgc_simple_funcs.cc | 62 +- .../bgc_simple/bgc_simple_funcs.hh | 55 +- src/pks/biogeochemistry/bgc_simple/utils.hh | 13 +- .../biogeochemistry/bgc_simple/vegetation.hh | 75 +- .../carbon/simple/CarbonSimple.cc | 8 +- .../carbon/simple/CarbonSimple.hh | 9 +- .../carbon/bioturbation_evaluator.cc | 4 +- .../carbon/bioturbation_evaluator_reg.hh | 4 +- .../carbon/pool_decomposition_evaluator.hh | 4 +- .../pool_decomposition_evaluator_reg.hh | 4 +- .../carbon/pool_transfer_evaluator.hh | 8 +- src/pks/biogeochemistry/fates/fates_pk.cc | 10 +- src/pks/biogeochemistry/fates/fates_pk.hh | 10 +- src/pks/chem_pk_helpers.cc | 65 + src/pks/chem_pk_helpers.hh | 36 + src/pks/deform/volumetric_deformation.cc | 651 +++--- src/pks/deform/volumetric_deformation.hh | 62 +- .../advection_diffusion_ti.cc | 4 +- .../energy/interfrost_energy_evaluator_reg.hh | 4 +- .../energy/liquid_gas_energy_evaluator.cc | 22 +- .../energy/liquid_gas_energy_evaluator.hh | 6 +- .../energy/liquid_gas_energy_evaluator_reg.hh | 4 +- .../energy/liquid_ice_energy_evaluator.cc | 22 +- .../energy/liquid_ice_energy_evaluator.hh | 6 +- .../energy/liquid_ice_energy_evaluator_reg.hh | 4 +- .../energy/richards_energy_evaluator.cc | 16 +- .../energy/richards_energy_evaluator.hh | 6 +- .../energy/richards_energy_evaluator_reg.hh | 4 +- .../energy/surface_ice_energy_evaluator.cc | 14 +- .../energy/surface_ice_energy_evaluator.hh | 6 +- .../surface_ice_energy_evaluator_reg.hh | 4 +- .../energy/surface_ice_energy_model.hh | 20 +- .../energy/three_phase_energy_evaluator.cc | 28 +- .../energy/three_phase_energy_evaluator.hh | 6 +- .../three_phase_energy_evaluator_reg.hh | 4 +- .../enthalpy/enthalpy_evaluator.cc | 6 +- .../enthalpy/enthalpy_evaluator.hh | 14 +- .../internal_energy/iem_evaluator.cc | 11 +- .../internal_energy/iem_evaluator.hh | 12 +- .../internal_energy/iem_factory_reg.hh | 2 +- .../internal_energy/iem_linear.cc | 3 +- .../internal_energy/iem_linear.hh | 14 +- .../internal_energy/iem_quadratic.cc | 3 +- .../internal_energy/iem_quadratic.hh | 27 +- .../internal_energy/iem_water_vapor.cc | 3 +- .../internal_energy/iem_water_vapor.hh | 17 +- .../iem_water_vapor_evaluator.cc | 4 +- .../iem_water_vapor_evaluator.hh | 6 +- .../iem_water_vapor_evaluator_reg.hh | 4 +- .../advected_energy_source_evaluator.cc | 8 +- .../thermal_conductivity_surface_evaluator.hh | 4 +- .../thermal_conductivity_threephase.hh | 24 +- ...ermal_conductivity_threephase_evaluator.cc | 12 +- ...ermal_conductivity_threephase_evaluator.hh | 6 +- ...thermal_conductivity_threephase_factory.hh | 22 +- ...mal_conductivity_threephase_factory_reg.hh | 2 +- ...al_conductivity_threephase_peterslidard.hh | 1 - ...conductivity_threephase_volume_averaged.hh | 1 - .../thermal_conductivity_threephase_wetdry.hh | 18 +- ...thermal_conductivity_twophase_evaluator.cc | 4 +- ...thermal_conductivity_twophase_evaluator.hh | 12 +- .../thermal_conductivity_twophase_factory.hh | 22 +- ...ermal_conductivity_twophase_factory_reg.hh | 2 +- .../thermal_conductivity_twophase_wetdry.hh | 1 - src/pks/energy/energy_base.hh | 210 +- src/pks/energy/energy_base_physics.cc | 10 +- src/pks/energy/energy_base_pk.cc | 144 +- src/pks/energy/energy_base_ti.cc | 50 +- src/pks/energy/energy_bc_factory.hh | 2 +- src/pks/energy/energy_interfrost.cc | 2 +- src/pks/energy/energy_surface_ice.cc | 18 +- src/pks/energy/energy_surface_ice.hh | 38 +- src/pks/energy/energy_three_phase.cc | 6 +- src/pks/energy/energy_three_phase.hh | 16 +- src/pks/energy/energy_two_phase.hh | 15 +- src/pks/energy/test/energy_test_class.cc | 4 +- .../elevation/depth_evaluator.cc | 3 +- .../elevation/depth_evaluator.hh | 4 +- .../elevation/depth_model.hh | 6 +- .../elevation/effective_height_evaluator.hh | 16 +- .../effective_height_evaluator_reg.hh | 4 +- .../elevation/effective_height_model.hh | 3 +- .../elevation/elevation_evaluator.hh | 6 +- .../elevation/elevation_evaluator_column.cc | 8 +- .../elevation/elevation_evaluator_column.hh | 8 +- .../elevation_evaluator_column_reg.hh | 4 +- .../fractional_conductance_evaluator.hh | 4 +- .../elevation/height_evaluator.hh | 14 +- .../elevation/height_model.hh | 9 +- .../elevation/icy_height_evaluator.cc | 8 +- .../elevation/icy_height_evaluator.hh | 22 +- .../elevation/icy_height_evaluator_reg.hh | 4 +- .../elevation/icy_height_model.hh | 17 +- .../elevation/meshed_elevation_evaluator.cc | 2 +- .../elevation/meshed_elevation_evaluator.hh | 11 +- .../meshed_elevation_evaluator_reg.hh | 4 +- .../elevation/pres_elev_evaluator.cc | 63 - .../elevation/pres_elev_evaluator.hh | 66 - .../snow_skin_potential_evaluator.hh | 4 +- .../standalone_elevation_evaluator.cc | 2 +- .../standalone_elevation_evaluator.hh | 4 +- .../elevation/water_level_evaluator.cc | 8 +- .../elevation/water_level_evaluator.hh | 4 +- .../elevation/water_level_evaluator_reg.hh | 4 +- ...nning_coefficient_litter_constant_model.hh | 14 +- .../manning_coefficient_litter_evaluator.cc | 4 +- .../manning_coefficient_litter_evaluator.hh | 20 +- ...anning_coefficient_litter_evaluator_reg.hh | 2 +- .../manning_coefficient_litter_model.hh | 8 +- ...nning_coefficient_litter_variable_model.hh | 28 +- .../manning_conductivity_model.cc | 3 +- .../manning_conductivity_model.hh | 22 +- .../one_surface_relperm_model_reg.hh | 4 +- .../one_uf_relperm_model.cc | 3 +- .../one_uf_relperm_model_reg.hh | 4 +- .../overland_conductivity_evaluator.cc | 4 +- .../overland_conductivity_evaluator.hh | 25 +- .../overland_conductivity_model.hh | 16 +- ...overland_conductivity_subgrid_evaluator.hh | 4 +- .../surface_relperm_evaluator.cc | 8 +- .../surface_relperm_evaluator_reg.hh | 4 +- .../surface_relperm_model_factory.cc | 2 +- .../unfrozen_effective_depth_evaluator.hh | 22 +- .../unfrozen_fraction_evaluator.cc | 8 +- .../unfrozen_fraction_evaluator.hh | 4 +- .../unfrozen_fraction_evaluator_reg.hh | 4 +- .../zero_uf_relperm_model.cc | 3 +- .../zero_uf_relperm_model_reg.hh | 4 +- .../compressible_porosity_evaluator.cc | 8 +- .../compressible_porosity_evaluator.hh | 4 +- ...compressible_porosity_leijnse_evaluator.cc | 4 +- ...compressible_porosity_leijnse_evaluator.hh | 4 +- ...ressible_porosity_leijnse_evaluator_reg.hh | 2 +- .../compressible_porosity_leijnse_model.hh | 3 +- .../porosity/compressible_porosity_model.hh | 15 +- .../compressible_porosity_model_partition.hh | 4 +- .../sources/distributed_tiles_evaluator.cc | 8 +- .../sources/distributed_tiles_evaluator.hh | 7 +- .../impervious_interception_evaluator.cc | 106 + .../impervious_interception_evaluator.hh | 98 + .../impervious_interception_evaluator_reg.hh | 21 + .../soil_resistance_model_partition.hh | 4 +- ...oil_resistance_sakagucki_zeng_evaluator.cc | 4 +- ...oil_resistance_sakagucki_zeng_evaluator.hh | 45 +- .../soil_resistance_sakagucki_zeng_model.hh | 3 +- .../soil_resistance_sellers_evaluator.cc | 2 +- .../soil_resistance_sellers_evaluator.hh | 9 +- .../sources/surface_culvert_evaluator.cc | 196 ++ .../sources/surface_culvert_evaluator.hh | 160 ++ .../sources/surface_culvert_evaluator_reg.hh | 20 + .../surface_distributed_tiles_evaluator.cc | 8 +- .../surface_distributed_tiles_evaluator.hh | 4 +- .../surface_gate_structure_evaluator.cc | 159 ++ .../surface_gate_structure_evaluator.hh | 117 + .../surface_gate_structure_evaluator_reg.hh | 20 + .../sources/surface_pump_system_evaluator.cc | 252 +++ .../sources/surface_pump_system_evaluator.hh | 139 ++ .../surface_pump_system_evaluator_reg.hh | 20 + ...terfrost_denergy_dtemperature_evaluator.cc | 14 +- .../interfrost_denergy_dtemperature_model.hh | 10 +- .../interfrost_dtheta_dpressure_evaluator.cc | 6 +- .../interfrost_sl_wc_evaluator.cc | 10 +- .../interfrost_sl_wc_evaluator_reg.hh | 4 +- .../water_content/interfrost_sl_wc_model.hh | 21 +- .../water_content/interfrost_water_content.cc | 12 +- .../interfrost_water_content_reg.hh | 4 +- .../liquid_gas_water_content_evaluator.cc | 14 +- .../liquid_gas_water_content_evaluator.hh | 6 +- .../liquid_gas_water_content_model.hh | 10 +- .../liquid_ice_water_content_evaluator.cc | 12 +- .../liquid_ice_water_content_evaluator.hh | 6 +- .../liquid_ice_water_content_model.hh | 31 +- ...erland_pressure_water_content_evaluator.cc | 12 +- ...erland_pressure_water_content_evaluator.hh | 43 +- .../richards_water_content_evaluator.cc | 8 +- .../richards_water_content_evaluator.hh | 6 +- .../three_phase_water_content_evaluator.cc | 18 +- .../three_phase_water_content_evaluator.hh | 6 +- .../wrm/models/test/plot_wrm.cc | 4 +- .../wrm/pc_ice_evaluator.cc | 7 +- .../wrm/pc_ice_evaluator.hh | 27 +- .../wrm/pc_ice_evaluator_reg.hh | 4 +- .../wrm/pc_ice_water.cc | 3 +- .../wrm/pc_ice_water.hh | 29 +- .../wrm/pc_liquid_evaluator.hh | 16 +- .../wrm/pc_liquid_evaluator_reg.hh | 4 +- .../wrm/rel_perm_evaluator.cc | 16 +- .../wrm/rel_perm_evaluator.hh | 43 +- .../wrm/rel_perm_evaluator_reg.hh | 4 +- .../wrm/rel_perm_frzBC_evaluator.cc | 20 +- .../wrm/rel_perm_frzBC_evaluator.hh | 109 +- .../wrm/rel_perm_frzBC_evaluator_reg.hh | 4 +- .../wrm/rel_perm_sutraice_evaluator.cc | 20 +- .../wrm/rel_perm_sutraice_evaluator.hh | 53 +- .../wrm/rel_perm_sutraice_evaluator_reg.hh | 4 +- .../wrm/suction_head_evaluator_reg.hh | 4 +- .../wrm/wrm_brooks_corey.cc | 7 +- .../wrm/wrm_brooks_corey.hh | 6 +- .../wrm/wrm_constant.cc | 3 +- .../wrm/wrm_evaluator.cc | 4 +- .../wrm/wrm_evaluator.hh | 27 +- .../constitutive_relations/wrm/wrm_factory.cc | 8 +- .../wrm/wrm_factory_reg.hh | 2 +- .../wrm/wrm_fpd_permafrost_model.hh | 16 +- .../wrm/wrm_fpd_permafrost_model_reg.hh | 4 +- .../wrm/wrm_fpd_smoothed_permafrost_model.hh | 25 +- .../wrm/wrm_implicit_permafrost_model.cc | 16 +- .../wrm/wrm_implicit_permafrost_model.hh | 22 +- .../wrm/wrm_interfrost_permafrost_model.hh | 3 +- .../wrm/wrm_linear_relperm.cc | 3 +- .../wrm/wrm_linear_system.cc | 3 +- .../wrm/wrm_linear_system.hh | 30 +- .../wrm/wrm_macropore.cc | 3 +- .../wrm/wrm_mck_permafrost_model.hh | 3 +- .../wrm/wrm_mck_permafrost_model_reg.hh | 4 +- .../wrm/wrm_old_permafrost_model.hh | 4 +- .../wrm/wrm_old_permafrost_model_reg.hh | 4 +- .../wrm/wrm_partition.hh | 24 +- .../wrm/wrm_permafrost_evaluator.hh | 57 +- .../wrm/wrm_permafrost_evaluator_reg.hh | 4 +- .../wrm/wrm_permafrost_factory.hh | 4 +- .../wrm/wrm_permafrost_factory_reg.hh | 2 +- .../wrm/wrm_permafrost_model.hh | 4 +- .../wrm/wrm_plants_christoffersen.cc | 39 +- .../wrm/wrm_plants_christoffersen.hh | 4 +- .../wrm/wrm_plants_christoffersen_reg.hh | 4 +- .../wrm/wrm_sutra_permafrost_model.hh | 7 +- .../wrm/wrm_van_genuchten.cc | 14 +- .../wrm/wrm_van_genuchten.hh | 6 +- .../wrm/wrm_zero_relperm.cc | 3 +- src/pks/flow/flow_bc_factory.hh | 2 +- src/pks/flow/icy_overland.cc | 3 +- src/pks/flow/icy_overland.hh | 13 +- src/pks/flow/interfrost.cc | 11 +- src/pks/flow/overland_pressure.hh | 161 +- src/pks/flow/overland_pressure_physics.cc | 6 +- src/pks/flow/overland_pressure_pk.cc | 92 +- src/pks/flow/overland_pressure_pk_reg.hh | 4 +- src/pks/flow/overland_pressure_ti.cc | 27 +- src/pks/flow/permafrost.hh | 10 +- src/pks/flow/permafrost_pk.cc | 30 +- src/pks/flow/predictor_delegate_bc_flux.cc | 4 +- src/pks/flow/predictor_delegate_bc_flux.hh | 8 +- src/pks/flow/preferential.hh | 4 +- src/pks/flow/preferential_pk.cc | 33 +- src/pks/flow/richards.hh | 153 +- src/pks/flow/richards_physics.cc | 71 +- src/pks/flow/richards_pk.cc | 289 ++- src/pks/flow/richards_steadystate.cc | 16 +- src/pks/flow/richards_steadystate.hh | 10 +- src/pks/flow/richards_ti.cc | 26 +- src/pks/flow/snow_distribution.hh | 54 +- src/pks/flow/snow_distribution_pk.cc | 12 +- src/pks/flow/snow_distribution_ti.cc | 33 +- src/pks/mpc/CMakeLists.txt | 24 +- src/pks/mpc/biomass_evaluator.cc | 204 -- src/pks/mpc/biomass_evaluator.hh | 59 - .../mpc/constitutive_relations/CMakeLists.txt | 2 + .../EvaluatorSubgridReturn.cc | 116 + .../EvaluatorSubgridReturn.hh | 81 + .../EvaluatorSubgridReturn_reg.hh | 23 + .../mpc/constitutive_relations/ewc_model.hh | 19 +- .../constitutive_relations/ewc_model_base.cc | 4 +- .../constitutive_relations/ewc_model_base.hh | 7 +- .../liquid_ice_model.cc | 20 +- .../liquid_ice_model.hh | 9 +- .../permafrost_model.cc | 20 +- .../permafrost_model.hh | 9 +- .../surface_ice_model.cc | 4 +- .../surface_ice_model.hh | 9 +- .../thermal_richards_model.cc | 4 +- .../thermal_richards_model.hh | 8 +- src/pks/mpc/mpc.hh | 64 +- src/pks/mpc/mpc_coupled_cells.hh | 62 +- src/pks/mpc/mpc_coupled_cells_reg.hh | 4 +- src/pks/mpc/mpc_coupled_dualmedia_water.cc | 2 +- src/pks/mpc/mpc_coupled_dualmedia_water.hh | 2 +- .../mpc/mpc_coupled_dualmedia_water_reg.hh | 4 +- src/pks/mpc/mpc_coupled_reactivetransport.cc | 250 +-- src/pks/mpc/mpc_coupled_reactivetransport.hh | 39 +- .../mpc/mpc_coupled_reactivetransport_reg.hh | 4 +- src/pks/mpc/mpc_coupled_transport.cc | 44 +- src/pks/mpc/mpc_coupled_transport.hh | 16 +- src/pks/mpc/mpc_coupled_water.cc | 17 +- src/pks/mpc/mpc_coupled_water.hh | 81 +- src/pks/mpc/mpc_coupled_water_split_flux.cc | 63 +- src/pks/mpc/mpc_coupled_water_split_flux.hh | 119 +- .../mpc/mpc_coupled_water_split_flux_reg.hh | 4 +- src/pks/mpc/mpc_delegate_ewc.cc | 7 +- src/pks/mpc/mpc_delegate_ewc.hh | 70 +- src/pks/mpc/mpc_delegate_ewc_subsurface.cc | 12 +- src/pks/mpc/mpc_delegate_ewc_surface.cc | 8 +- src/pks/mpc/mpc_delegate_water_decl.hh | 111 +- src/pks/mpc/mpc_delegate_water_impl.hh | 20 +- src/pks/mpc/mpc_flow_transport.cc | 282 +++ src/pks/mpc/mpc_flow_transport.hh | 79 + src/pks/mpc/mpc_morphology_pk.cc | 508 ++--- src/pks/mpc/mpc_morphology_pk.hh | 64 +- src/pks/mpc/mpc_permafrost.cc | 36 +- src/pks/mpc/mpc_permafrost.hh | 57 +- src/pks/mpc/mpc_permafrost_split_flux.cc | 82 +- src/pks/mpc/mpc_permafrost_split_flux.hh | 55 +- src/pks/mpc/mpc_permafrost_split_flux_reg.hh | 4 +- src/pks/mpc/mpc_reactivetransport.cc | 135 +- src/pks/mpc/mpc_reactivetransport.hh | 34 +- src/pks/mpc/mpc_subcycled.cc | 36 +- src/pks/mpc/mpc_subcycled.hh | 25 +- src/pks/mpc/mpc_subcycled_reg.hh | 2 + src/pks/mpc/mpc_subsurface.cc | 62 +- src/pks/mpc/mpc_subsurface.hh | 86 +- src/pks/mpc/mpc_subsurface_reg.hh | 4 +- src/pks/mpc/mpc_surface.cc | 10 +- src/pks/mpc/mpc_surface.hh | 45 +- src/pks/mpc/mpc_surface_subsurface_helpers.hh | 25 +- src/pks/mpc/mpc_weak_subdomain.cc | 19 +- src/pks/mpc/mpc_weak_subdomain.hh | 29 +- src/pks/mpc/strong_mpc.hh | 80 +- src/pks/mpc/strong_mpc_reg.hh | 2 +- src/pks/mpc/weak_mpc.hh | 11 +- src/pks/pk_bdf_default.cc | 19 +- src/pks/pk_bdf_default.hh | 53 +- src/pks/pk_explicit_default.hh | 2 +- src/pks/pk_factory.hh | 119 - src/pks/pk_helpers.cc | 341 --- src/pks/pk_helpers.hh | 144 -- src/pks/pk_physical_bdf_default.cc | 62 +- src/pks/pk_physical_bdf_default.hh | 68 +- src/pks/pk_physical_default.cc | 125 -- src/pks/pk_physical_default.hh | 78 - src/pks/pk_physical_explicit_default.hh | 14 +- .../surface_balance/CLM/ats_clm_interface.hh | 124 +- .../CLM/surface_balance_CLM.cc | 10 +- .../land_cover/LandCover.cc | 9 +- .../land_cover/LandCover.hh | 164 +- .../albedo_threecomponent_evaluator.cc | 6 +- .../albedo_threecomponent_evaluator.hh | 17 +- .../albedo_twocomponent_evaluator.cc | 6 +- .../albedo_twocomponent_evaluator.hh | 17 +- ...area_fractions_threecomponent_evaluator.cc | 2 +- ...area_fractions_threecomponent_evaluator.hh | 33 +- ...hreecomponent_microtopography_evaluator.hh | 11 +- .../area_fractions_twocomponent_evaluator.cc | 3 +- .../area_fractions_twocomponent_evaluator.hh | 30 +- .../land_cover/canopy_radiation_evaluator.cc | 5 +- .../land_cover/canopy_radiation_evaluator.hh | 31 +- .../land_cover/drainage_evaluator.hh | 7 +- .../evaporation_downregulation_evaluator.hh | 25 +- .../incident_shortwave_radiation_evaluator.cc | 6 +- .../incident_shortwave_radiation_evaluator.hh | 19 +- .../incident_shortwave_radiation_model.cc | 12 +- .../incident_shortwave_radiation_model.hh | 44 +- .../interception_fraction_evaluator.cc | 4 +- .../interception_fraction_evaluator.hh | 7 +- .../land_cover/land_cover_evaluator_reg.hh | 36 +- .../land_cover/longwave_evaluator.cc | 14 - .../land_cover/longwave_evaluator.hh | 12 +- .../pet_priestley_taylor_evaluator.cc | 16 +- .../pet_priestley_taylor_evaluator.hh | 28 +- .../plant_wilting_factor_evaluator.cc | 2 +- .../plant_wilting_factor_evaluator.hh | 22 +- .../land_cover/plant_wilting_factor_model.cc | 4 +- .../land_cover/radiation_balance_evaluator.cc | 11 +- .../land_cover/radiation_balance_evaluator.hh | 48 +- .../rooting_depth_fraction_evaluator.cc | 2 +- .../rooting_depth_fraction_evaluator.hh | 26 +- .../land_cover/seb_physics_defs.hh | 11 +- .../land_cover/seb_physics_funcs.cc | 17 +- .../land_cover/seb_physics_funcs.hh | 154 +- .../seb_threecomponent_evaluator.cc | 4 +- .../seb_threecomponent_evaluator.hh | 14 +- .../land_cover/seb_twocomponent_evaluator.cc | 18 +- .../land_cover/seb_twocomponent_evaluator.hh | 12 +- .../land_cover/snow_meltrate_evaluator.cc | 2 +- .../land_cover/snow_meltrate_evaluator.hh | 4 +- .../transpiration_distribution_evaluator.cc | 6 +- .../transpiration_distribution_evaluator.hh | 31 +- ...piration_distribution_relperm_evaluator.cc | 34 +- ...piration_distribution_relperm_evaluator.hh | 11 +- .../evaporative_flux_relaxation_evaluator.cc | 6 +- .../micropore_macropore_flux_evaluator.cc | 14 +- .../micropore_macropore_flux_evaluator.hh | 4 +- .../litter/micropore_macropore_flux_model.hh | 7 +- .../surface_balance/surface_balance_base.cc | 21 +- .../surface_balance/surface_balance_base.hh | 63 +- .../surface_balance_implicit_subgrid.cc | 28 +- .../surface_balance_implicit_subgrid.hh | 64 +- src/pks/test_pks/divgrad_test/divgrad_test.cc | 18 +- src/pks/transport/CMakeLists.txt | 19 +- src/pks/transport/SedimentTransportDefs.hh | 63 - .../constitutive_relations/CMakeLists.txt | 3 +- .../sediment_transport/biomass_evaluator.cc | 131 ++ .../sediment_transport/biomass_evaluator.hh | 101 + .../biomass_evaluator_reg.hh | 0 .../sediment_transport/erosion_evaluator.cc | 34 +- .../sediment_transport/erosion_evaluator.hh | 30 +- .../erosion_evaluator_reg.hh | 4 +- .../organic_matter_evaluator.cc | 10 +- .../organic_matter_evaluator.hh | 25 +- .../settlement_evaluator.cc | 26 +- .../settlement_evaluator.hh | 33 +- .../settlement_evaluator_reg.hh | 4 +- .../sediment_transport/trapping_evaluator.cc | 28 +- .../sediment_transport/trapping_evaluator.hh | 38 +- .../trapping_evaluator_reg.hh | 4 +- .../sources/qc_relation_field_evaluator.cc | 40 +- .../sources/qc_relation_field_evaluator.hh | 21 +- .../qc_relation_field_evaluator_reg.hh | 4 +- .../sources/qc_relation_overland_evaluator.cc | 31 +- .../sources/qc_relation_overland_evaluator.hh | 13 +- .../qc_relation_overland_evaluator_reg.hh | 4 +- src/pks/transport/sediment_transport_pk.cc | 1642 ++------------ src/pks/transport/sediment_transport_pk.hh | 317 +-- src/pks/transport/transport_ats.hh | 523 ++--- src/pks/transport/transport_ats_dispersion.cc | 20 +- src/pks/transport/transport_ats_pk.cc | 1942 +++++++---------- src/pks/transport/transport_ats_ti.cc | 417 +++- src/pks/transport/transport_ats_vandv.cc | 9 +- testing/CMakeLists.txt | 2 +- testing/ats-regression-tests | 2 +- .../templates/evaluator.cc | 98 +- .../templates/evaluator.hh | 2 +- .../templates/evaluator_keyEpetraVector.cc | 2 +- .../evaluator_keyEpetraVectorIndented.cc | 2 +- tools/evaluator_generator/templates/model.cc | 14 +- tools/evaluator_generator/templates/model.hh | 6 +- .../test/results/eos_ideal_gas_evaluator.hh | 4 +- .../results/eos_ideal_gas_evaluator_reg.hh | 4 +- .../test2/results/eos_ideal_gas_evaluator.hh | 4 +- .../results/eos_ideal_gas_evaluator_reg.hh | 4 +- tools/input_converters/xml-1.5-1.6.py | 698 ++++++ tools/input_converters/xml-1.5-master.py | 101 - .../extrude/extrude_homogeneous_variable.cc | 18 +- tools/meshing/extrude/extrude_uniform.cc | 4 +- tools/meshing/extrude/extrude_variable.cc | 9 +- tools/meshing/extrude/src/Mesh.cc | 16 +- tools/meshing/extrude/src/Mesh2D.cc | 8 +- tools/meshing/extrude/src/Mesh3D.cc | 8 +- tools/meshing/extrude/src/Point.hh | 2 +- tools/meshing/extrude/src/dbc.cc | 2 +- tools/meshing/extrude/src/dbc.hh | 19 +- tools/meshing/extrude/src/exceptions.hh | 17 +- tools/meshing/extrude/src/readMesh2D.hh | 13 +- tools/meshing/extrude/src/writeMesh3D.cc | 8 +- tools/meshing/extrude/src/writeMesh3D.hh | 3 +- tools/testing/test_manager.py | 62 +- tools/utils/ats_xdmf.py | 160 +- tools/utils/plot_column_data.py | 148 +- tools/utils/plot_lines.py | 57 + 600 files changed, 12240 insertions(+), 11142 deletions(-) create mode 100644 docs/documentation/source/input_spec/.gitignore create mode 100644 docs/documentation/source/input_spec/process_kernels/mpcs/multiple_domain.rst.in delete mode 100644 docs/documentation/source/input_spec/process_kernels/mpcs/physical.rst.in create mode 100644 docs/documentation/source/input_spec/process_kernels/mpcs/tightly_coupled.rst.in create mode 100644 docs/documentation/source/input_spec/process_kernels/physical/bgc.rst.in create mode 100644 docs/documentation/source/input_spec/process_kernels/physical/deformation.rst.in delete mode 100644 docs/documentation/source/input_spec/process_kernels/physical/physical.rst.in create mode 100644 docs/documentation/source/input_spec/state/engineered_water.rst.in delete mode 100644 docs/documentation/source/input_spec/state/secondary.rst.in create mode 100644 docs/documentation/source/input_spec/state/sediment_transport.rst.in create mode 100644 docs/documentation/source/input_spec/state/transport.rst.in create mode 100644 src/pks/chem_pk_helpers.cc create mode 100644 src/pks/chem_pk_helpers.hh delete mode 100644 src/pks/flow/constitutive_relations/elevation/pres_elev_evaluator.cc delete mode 100644 src/pks/flow/constitutive_relations/elevation/pres_elev_evaluator.hh create mode 100644 src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator.cc create mode 100644 src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator.hh create mode 100644 src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator_reg.hh create mode 100644 src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator.cc create mode 100644 src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator.hh create mode 100644 src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator_reg.hh create mode 100644 src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator.cc create mode 100644 src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator.hh create mode 100644 src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator_reg.hh create mode 100644 src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator.cc create mode 100644 src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator.hh create mode 100644 src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator_reg.hh delete mode 100644 src/pks/mpc/biomass_evaluator.cc delete mode 100644 src/pks/mpc/biomass_evaluator.hh create mode 100644 src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn.cc create mode 100644 src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn.hh create mode 100644 src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn_reg.hh create mode 100644 src/pks/mpc/mpc_flow_transport.cc create mode 100644 src/pks/mpc/mpc_flow_transport.hh delete mode 100644 src/pks/pk_factory.hh delete mode 100644 src/pks/pk_helpers.cc delete mode 100644 src/pks/pk_helpers.hh delete mode 100644 src/pks/pk_physical_default.cc delete mode 100644 src/pks/pk_physical_default.hh delete mode 100644 src/pks/transport/SedimentTransportDefs.hh create mode 100644 src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator.cc create mode 100644 src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator.hh rename src/pks/{mpc => transport/constitutive_relations/sediment_transport}/biomass_evaluator_reg.hh (100%) create mode 100644 tools/input_converters/xml-1.5-1.6.py delete mode 100644 tools/input_converters/xml-1.5-master.py create mode 100644 tools/utils/plot_lines.py diff --git a/.github/workflows/ats-ci.yml b/.github/workflows/ats-ci.yml index b52bb094f..294d50c25 100644 --- a/.github/workflows/ats-ci.yml +++ b/.github/workflows/ats-ci.yml @@ -12,7 +12,10 @@ on: jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ ubuntu-latest, ubuntu-24.04-arm ] + runs-on: ${{ matrix.os }} name: Build Docker steps: - name: Check out the Amanzi repo @@ -58,22 +61,35 @@ jobs: echo "ats-regression-tests branch = ${{env.ATS_TESTS_BRANCH}}"; echo "Tag reference = ${{env.ATS_BRANCH_TAG}}" echo "TPLs version = ${{env.AMANZI_TPLS_VER}}" + - name: Get runner architecture + run: | + if [[ ${{matrix.os}} == "ubuntu-24.04-arm" ]]; then + echo "ARCH=arm64" >> $GITHUB_ENV + else + echo "ARCH=amd64" >> $GITHUB_ENV + fi - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{secrets.DOCKERHUB_USERNAME}} password: ${{secrets.DOCKERHUB_PASSWORD}} - - name: Docker build + - name: Docker build and push id: docker working-directory: Docker - run: - docker build --build-arg amanzi_branch=${{env.AMANZI_BRANCH}} --build-arg ats_branch=${{env.ATS_BRANCH}} --build-arg ats_tests_branch=${{env.ATS_TESTS_BRANCH}} --build-arg amanzi_tpls_ver=${{env.AMANZI_TPLS_VER}} -t metsi/ats:${{env.ATS_BRANCH_TAG}}-latest -f Dockerfile-ATS-build . - - name: Docker push - working-directory: Docker - run: - docker push ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-latest + shell: bash + run: | + docker build --build-arg ARCH=linux/${{env.ARCH}} \ + --build-arg amanzi_tpls_ver=${{env.AMANZI_TPLS_VER}} \ + --build-arg amanzi_branch=${{env.AMANZI_BRANCH}} \ + --build-arg ats_branch=${{env.ATS_BRANCH}} \ + --build-arg ats_tests_branch=${{env.ATS_TESTS_BRANCH}} \ + -t metsi/ats:${{env.ATS_BRANCH_TAG}}-${{env.ARCH}}-latest -f Dockerfile-ATS-build . + docker push ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-${{env.ARCH}}-latest serial-reg15-tests: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ ubuntu-latest, ubuntu-24.04-arm ] + runs-on: ${{ matrix.os }} name: serial and regression 1-5 series tests needs: build steps: @@ -92,13 +108,23 @@ jobs: id: tag run: | echo "ATS_BRANCH_TAG=$(echo ${{env.ATS_BRANCH}} | sed -e 's/\//--/g')" >> $GITHUB_ENV + - name: Get runner architecture + run: | + if [[ ${{matrix.os}} == "ubuntu-24.04-arm" ]]; then + echo "ARCH=arm64" >> $GITHUB_ENV + else + echo "ARCH=amd64" >> $GITHUB_ENV + fi - name: Run tests id: tests working-directory: Docker run: - docker run --rm ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-latest /bin/bash -c "cd ~/amanzi_builddir/ats; ctest --output-on-failure -LE PARALLEL -E 'ats_regression_test-[1-9][0-9]|ats_regression_test-0[6-9]'" + docker run --rm ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-${{env.ARCH}}-latest /bin/bash -c "cd ~/amanzi_builddir/ats; ctest --output-on-failure -LE PARALLEL -E 'ats_regression_test-[1-9][0-9]|ats_regression_test-0[6-9]'" parallel-tests: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ ubuntu-latest, ubuntu-24.04-arm ] + runs-on: ${{ matrix.os }} name: parallel and regression 6-10 series tests needs: build steps: @@ -117,9 +143,46 @@ jobs: id: tag run: | echo "ATS_BRANCH_TAG=$(echo ${{env.ATS_BRANCH}} | sed -e 's/\//--/g')" >> $GITHUB_ENV + - name: Get runner architecture + run: | + if [[ ${{matrix.os}} == "ubuntu-24.04-arm" ]]; then + echo "ARCH=arm64" >> $GITHUB_ENV + else + echo "ARCH=amd64" >> $GITHUB_ENV + fi - name: Run tests id: tests working-directory: Docker - run: - docker run --rm ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-latest /bin/bash -c "cd ~/amanzi_builddir/ats; ctest --output-on-failure -L PARALLEL; ctest --output-on-failure -R 'ats_regression_test-0[6-9]|ats_regression_test-[1-9][0-9]'" + run: | + docker run --rm ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-${{env.ARCH}}-latest /bin/bash -c "cd ~/amanzi_builddir/ats; ctest --output-on-failure -L PARALLEL; ctest --output-on-failure -R 'ats_regression_test-0[6-9]|ats_regression_test-[1-9][0-9]'" + fix-manifest: + runs-on: ubuntu-latest + needs: [serial-reg15-tests, parallel-tests] + if: success() + steps: + - name: Check out the ATS repo + uses: actions/checkout@v4 + with: + repository: amanzi/amanzi + ref: master + submodules: recursive + - name: Filter the branch name to generate a tag for Docker + id: tag + run: | + echo "ATS_BRANCH_TAG=$(echo $GITHUB_REF_NAME | sed -e 's/\//--/g')" >> $GITHUB_ENV + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_PASSWORD}} + - name: Pull images (remove with artifacts??) + run: | + docker pull ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-arm64-latest + docker pull ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-amd64-latest + - name: Edit manifest + run: | + docker manifest create ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-latest \ + --amend ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-arm64-latest \ + --amend ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-amd64-latest + docker manifest push ${{secrets.DOCKERHUB_USERNAME}}/ats:${{env.ATS_BRANCH_TAG}}-latest diff --git a/README.md b/README.md index 05cd9d9fc..1b8508268 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ ATS: The Advanced Terrestrial Simulator ======================================= -The Advanced Terrestrial Simulator (formerly sometimes known as the Arctic Terrestrial Simulator) is a code for solving ecosystem-based, integrated, distributed hydrology. +The Advanced Terrestrial Simulator (ATS) is a code for solving watershed-to-river basin scale problems on integrated, distributed ecohydrology, including the built environment. -Capabilities are largely based on solving various forms of Richards equation coupled to a surface flow equation, along with the needed sources and sinks for ecosystem and climate models. This can (but need not) include thermal processes (especially ice for frozen soils), evapo-transpiration, albedo-driven surface energy balances, snow, biogeochemistry, plant dynamics, deformation, transport, and much more. In addition, we solve problems of reactive transport in both the subsurface and surface, leveraging external geochemical engines through the Alquimia interface. +Capabilities are largely based on solving various forms of Richards equation coupled to a surface flow equation, along with the needed sources and sinks. This can (but need not) include thermal processes (especially ice for frozen soils), evapo-transpiration, surface energy exchange with the atmosphere, snow, deformation, gray and green infrastructure, and much more. In addition, we solve problems of reactive transport in both the subsurface and surface, leveraging external geochemical engines through the Alquimia interface. + +ATS is a suite of physics processes built for Amanzi. Amanzi includes the underlying mesh, data structure, multi-physics APIs, and math libraries for defining and solving the physics implemented in ATS. Join the Community ------------------ @@ -23,6 +25,8 @@ Our [Documentation](https://amanzi.github.io/ats/) covers the input spec, and is See also our [Wiki](https://github.com/amanzi/ats/wiki) and [Frequently Asked Questions](https://github.com/amanzi/ats/wiki/FAQs), or take our online [Short Course](https://github.com/amanzi/ats-short-course). +Setting up watershed- and river basin-scale problems is frequently done through [Watershed Worfklow](https://environmental-modeling-workflows.github.io/watershed-workflow/), a workflow tool that downloads and adapts a wide variety of open data for this purpose. + License and Copyright --------------------- diff --git a/docs/documentation/Makefile b/docs/documentation/Makefile index 33782bba1..a86e319ff 100644 --- a/docs/documentation/Makefile +++ b/docs/documentation/Makefile @@ -39,8 +39,13 @@ input_spec: $(MAKE) -C source/input_spec clean rst deploy_master: + mkdir -p deploy/html/dev cp -r build/html/* deploy/html/dev/ +deploy_stable: + mkdir -p deploy/html/stable + cp -r build/html/* deploy/html/stable/ + deploy: cd deploy/html && \ git add --all && \ @@ -53,6 +58,13 @@ clean: allclean: rm -rf build/* + +temp: clean + rm -f source/input_spec/process_kernels/mpcs/globalization.rst + $(MAKE) -C source/input_spec process_kernels/mpcs/globalization.rst + $(MAKE) html + + # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). #%: Makefile diff --git a/docs/documentation/source/_static/versions.json b/docs/documentation/source/_static/versions.json index 09183d742..bd5a2534c 100644 --- a/docs/documentation/source/_static/versions.json +++ b/docs/documentation/source/_static/versions.json @@ -1,9 +1,13 @@ [ { - "name": "1.5 (stable)", - "version": "1.5", + "name": "1.6 (stable)", + "version": "1.6", "url": "https://amanzi.github.io/ats/stable/", - "preferred": "1.5" + "preferred": "1.6" + }, + { + "version": "1.5", + "url": "https://amanzi.github.io/ats/v1.5/" }, { "version": "dev", diff --git a/docs/documentation/source/ats_demos b/docs/documentation/source/ats_demos index 2ef0d582a..978d90338 160000 --- a/docs/documentation/source/ats_demos +++ b/docs/documentation/source/ats_demos @@ -1 +1 @@ -Subproject commit 2ef0d582aa5339bb40fd6ef5ca2bccfc77a14026 +Subproject commit 978d90338416978bb1cd6147de031a6fa944ce3f diff --git a/docs/documentation/source/conf.py b/docs/documentation/source/conf.py index 00f1845ad..239fce445 100644 --- a/docs/documentation/source/conf.py +++ b/docs/documentation/source/conf.py @@ -89,7 +89,7 @@ "secondary_sidebar_items": [], "switcher": { "json_url": "https://raw.githubusercontent.com/amanzi/ats/master/docs/documentation/source/_static/versions.json", - "version_match": 'v1.5', + "version_match": 'v1.6', }, # "navbar_start" : ["navbar-logo", ], } @@ -112,7 +112,8 @@ -nb_execution_excludepatterns = ['IHMIP_units.ipynb', 'mesh_gen.ipynb'] +nb_execution_excludepatterns = ['*',] +#nb_execution_excludepatterns = ['IHMIP_units.ipynb', 'mesh_gen.ipynb'] diff --git a/docs/documentation/source/index.rst b/docs/documentation/source/index.rst index 59b8eee13..27b6ea381 100644 --- a/docs/documentation/source/index.rst +++ b/docs/documentation/source/index.rst @@ -3,12 +3,11 @@ $$$$$$$$$$$$$ .. image:: _static/images/coweeta.png -Amanzi-ATS is a code for solving ecosystem-based, integrated, distributed hydrology. +The Advanced Terrestrial Simulator (ATS) is a code for solving watershed-to-river basin scale problems on integrated, distributed ecohydrology, including the built environment. -Capabilities are largely based on solving various forms of Richards equation, coupled to a surface flow equation, along with the needed sources and sinks for ecosystem and climate models. This can (but need not) include thermal processes (especially ice for frozen soils), evapotranspiration, surface energy balances, snow, biogeochemistry, plant dynamics, deformation, transport, and much more. - -ATS is a suite of physics processes built for Amanzi. As such documentation is split between process documentation here and framework documentation in Amanzi. Links across the related projects attempt to build a uniform interface for the user. +Capabilities are largely based on solving various forms of Richards equation coupled to a surface flow equation, along with the needed sources and sinks. This can (but need not) include thermal processes (especially ice for frozen soils), evapo-transpiration, surface energy exchange with the atmosphere, snow, deformation, gray and green infrastructure, and much more. In addition, we solve problems of reactive transport in both the subsurface and surface, leveraging external geochemical engines through the Alquimia interface. +ATS is a suite of physics processes built for Amanzi. Amanzi includes the underlying mesh, data structure, multi-physics APIs, and math libraries for defining and solving the physics implemented in ATS. Join the Community %%%%%%%%%%%%%%%%%% @@ -28,7 +27,6 @@ License and Copyright Please see the `LICENSE `_ and `COPYRIGHT `_ files included in the top level directory of your ATS download. - Citation %%%%%%%% diff --git a/docs/documentation/source/input_spec/.gitignore b/docs/documentation/source/input_spec/.gitignore new file mode 100644 index 000000000..1b112ac92 --- /dev/null +++ b/docs/documentation/source/input_spec/.gitignore @@ -0,0 +1,45 @@ +main.rst +mesh.rst +process_kernels/physical/bgc.rst +process_kernels/physical/seb.rst +process_kernels/physical/energy.rst +process_kernels/physical/flow.rst +process_kernels/physical/transport.rst +process_kernels/physical/deformation.rst +process_kernels/mpcs/multiple_domain.rst +process_kernels/mpcs/tightly_coupled.rst +process_kernels/mpcs/globalization.rst +process_kernels/mpcs/base.rst +process_kernels/base.rst +io/observations.rst +io/logfile.rst +io/checkpoint.rst +io/index.rst +io/ioevent.rst +io/visualization.rst +state/bgc.rst +state/seb.rst +state/generic.rst +state/subsurface_flow.rst +state/conserved.rst +state/eos.rst +state/thermo.rst +state/multiscale.rst +state/primary.rst +state/geometric.rst +state/surface_flow.rst +state/independent.rst +state/index.rst +state/canopy.rst +state/transport.rst +state/snow.rst +state/secondary.rst +math/preconditioners.rst +math/nonlinear_solvers.rst +math/time_integrators.rst +math/operators.rst +math/linear_solvers.rst +common.rst +region.rst +state/engineered_water.rst +state/sediment_transport.rst diff --git a/docs/documentation/source/input_spec/Makefile b/docs/documentation/source/input_spec/Makefile index ce703b720..547d88b98 100644 --- a/docs/documentation/source/input_spec/Makefile +++ b/docs/documentation/source/input_spec/Makefile @@ -1,7 +1,7 @@ # # Makefile: generating rst from rst.in -SRC = $(shell find . -name \*.in) +SRC = $(shell find . -name \*.in | cut -c 3-) RST = $(SRC:%.rst.in=%.rst) # generic rules for targets @@ -10,6 +10,7 @@ all : rst %.rst: ./generate_ATSNativeSpec.py $< $@ + grep -q '^$@' .gitignore || echo "$@" >> .gitignore rst : $(RST) diff --git a/docs/documentation/source/input_spec/common.rst.in b/docs/documentation/source/input_spec/common.rst.in index bcc59e557..3dd8ac51f 100644 --- a/docs/documentation/source/input_spec/common.rst.in +++ b/docs/documentation/source/input_spec/common.rst.in @@ -5,15 +5,15 @@ Shared Specs Initial Conditions ================== -Initial condition specs are used in three places: +Initial conditions specs are used in three places: * In the `"initial conditions`" sublist of state, in which the value of atomic constants are provided (not really initial conditions and should be renamed). These atomic values are not controlled by evaluators, and are not included in the DaG. -* Within the PK_ spec which describes the initial condition of primary variables (true - initial conditions). +* Within physical PK specs which describes the initial conditions of + primary variables (true initial conditions). * In :ref:`Independent Variable Constant` diff --git a/docs/documentation/source/input_spec/generate_ATSNativeSpec.py b/docs/documentation/source/input_spec/generate_ATSNativeSpec.py index f5f8eb4a5..38bd8ae24 100755 --- a/docs/documentation/source/input_spec/generate_ATSNativeSpec.py +++ b/docs/documentation/source/input_spec/generate_ATSNativeSpec.py @@ -9,9 +9,26 @@ "tools", "amanzi_xml")) import amanzi_xml.utils.io -def readFileDoc(filename): +def filenameToLink(filename, branch): + filename_relto_amanzi = os.path.relpath(filename, os.environ['AMANZI_SRC_DIR']) + if filename_relto_amanzi.startswith(os.path.join('src', 'physics', 'ats')): + filename_relto_ats = os.path.relpath(filename, os.environ['ATS_SRC_DIR']) + assert not filename_relto_ats.startswith('..') + + # an ATS source file + rel_url = '/'.join(os.path.split(filename_relto_ats)) + link = f"https://github.com/amanzi/ats/blob/{branch}/{rel_url}" + + else: + assert not filename_relto_amanzi.startswith('..') + rel_url = '/'.join(os.path.split(filename_relto_amanzi)) + link = f"https://github.com/amanzi/amanzi/blob/{branch}/{rel_url}" + + return f'`{filename_relto_amanzi} <{link}>`_' + +def readFileDoc(filename, branch='master'): """Parses provided file for doc strings, returning a header that starts with "//!" and any blocks that start with "/*!" """ - header = None + header = '\n'.join([filenameToLink(filename, branch), '']) doc = [] with open(filename) as fid: @@ -24,8 +41,8 @@ def readFileDoc(filename): done = True continue - if header is None and line.strip().startswith("//!"): - header = line.strip()[3:] + if line.strip().startswith("//!"): + header = '\n'.join([header, line.strip()[3:].strip()]) elif line.strip().startswith("/*!"): example = [line.strip()[3:].split("*/")[0]+"\n",] @@ -43,6 +60,7 @@ def readFileDoc(filename): line = fid.readline() + if header is not None: doc.insert(0, header) diff --git a/docs/documentation/source/input_spec/index.rst b/docs/documentation/source/input_spec/index.rst index 664a9c762..2792b5e1c 100644 --- a/docs/documentation/source/input_spec/index.rst +++ b/docs/documentation/source/input_spec/index.rst @@ -16,11 +16,17 @@ input spec is what it is, making this documentation critical. The input spec changes slightly from version to version, but an input file should never stop working due to commits within the same ATS -release version. Furthermore, whenever possible, we try to include -python scripts for taking an input file that worked in one version and -updating it to the next newer version. These are available at +release branch, nor for patch-level releases with the same minor +version number. Furthermore, whenever possible, we try to include +python scripts for taking an input file that worked in one minor +version and updating it to the next newer minor version. These are +available at ``_ +Following Amanzi's release history, ATS has only incremented its major +version once; this will only be done for major fundamental changes in +how Amanzi and ATS work. + .. toctree:: :maxdepth: 1 diff --git a/docs/documentation/source/input_spec/introduction.rst b/docs/documentation/source/input_spec/introduction.rst index 71a93820d..01dbd866b 100644 --- a/docs/documentation/source/input_spec/introduction.rst +++ b/docs/documentation/source/input_spec/introduction.rst @@ -15,6 +15,11 @@ designed for the code, not necessarily for the user. In general, avoid writing input files from scratch, and prefer to modify existing demos or examples. +Additionally, the `ATS Input Spec `_ +tool can be used to generate ATS input files through a python script. +Despite this tool, it is important to be able to parse and understand +the resulting xml file. + Here we document the input spec by defining what each possible element used by the code needs to be well posed. @@ -27,33 +32,55 @@ initial data might be uniform (the value is required), or linear in y (the value and its gradient are required). Where ATS supports a number of parameterized models for quantity Z, the available models will be listed by name, and then will be described in the subsequent -section. For example, the specification for an `"X`" list might look +section. For example, the specification for an `"apple`" list might look like: -.. _X-spec: -.. admonition:: X-spec +.. _apple-spec: +.. admonition:: apple-spec + + * `"apple kind`" ``[string]`` A string defining the kind of apple; + valid choices include `"cosmic crisp`", `"granny smith`", or + `"golden delicious`" + + * `"color`" ``[string]`` **red** The color of the apple, defaults to + `"red`". + +An `"apple-spec`" might be used when defining a pie recipe: - * `"Y`" ``[string]`` **default_value** Documentation desribing Y. - * `"Z`" ``[Z-spec]`` Model for Z, One of `"z1`" or `"z2`" (see below) +.. _apple-pie-spec: +.. admonition:: apple-pie-spec -Here, an `"X`" is defined by a `"Y`" and a `"Z`". The `"Y`" is a -string parameter but the `"Z`" is given by a model (which will require -its own set of parameters). The options for `"Z`" will then be -described seperately as a `"Z-spec`" + * `"apple`" ``[apple-spec]`` + * `"apple volume [cups]`" ``[double]`` **1** + +Note that the `"apple`" entry would be a `ParameterList`, named +`"apple`", that includes all of the parameters required to define an +`"apple-spec`". Also, note that, wherever possible, units are defined +in the name of the parameter. An example of using such a specification: .. code-block:: xml - - - - - + + + + + - + +or equivalently, + +.. code-block:: yaml + + my apple pie: + apple volume [cups]: 1.5 + apple: + apple kind: granny smith + color: green + Syntax ====== @@ -71,15 +98,40 @@ Syntax * Bold values are default values, and are used if the Parameter is not provided. -Naming -====== + +Units +===== -Variables are named according to a very strong convention. While some -variables may be overridden by the user, users should choose to follow -these conventions or things like visualization scripts may not behave -as expected. +Wherever possible, units for a parameter are included in the parameter +name, in brackets, and in SI units. When there are common alternative +units (e.g. g/mL) we sometimes provide a second parameter option with +the same name, but different units. -A variable name looks like one of: +All units are written in the numerator. `^` is used to indicate +powers, including negative powers. For example, a parameter +prescribing the density of water might be: `"density of water [kg +m^-3]`". + + +Variable Naming +=============== + +Unlike parameters (which can only be spelled one way), variables are +often named with user-defined strings which have a default value. For +instance, a Richards equation might need a variable defining the +saturation of the liquid phase. By default, we would call this +`"saturation_liquid`", but the user may choose to override this name. +This makes variables hard to define with certainty, because the user +may change these things. This is a feature, but to a new user, it may +seem confusing. Prefer to use default names wherever possible, unless +there is a good reason not to do so. + +Variables are named according to a very strong convention. While +variable names may be overridden by the user, users should choose to +follow these conventions or things like visualization scripts may not +behave as expected. + +A **variable name** looks like one of: - ROOT_NAME - DOMAIN-ROOT_NAME @@ -87,34 +139,58 @@ A variable name looks like one of: where: +- ROOT_NAME is the root of the variable, e.g. `"temperature`". - When DOMAIN is not supplied, it is implied to be the "default" mesh, called `"domain`" in the mesh list. Otherwise the domain name is - the same as the mesh name (e.g. `"surface`"). + the same as the mesh name (e.g. `"surface`"). This distinguishes + between `"surface-temperature`" (the temperature on the surface + mesh) and `"temperature`" (the temperature on the subsurface/domain + mesh). - DOMAIN_SET:ID is itself a DOMAIN, where the set defines the collection as a whole (from the mesh list) and the ID is defined by - an index across the collection, e.g. `"column:4`" - -Tags indicate the use of a variable at a specific time in the + an index across the collection, e.g. `"column:4`". So + `"column:4-temperature`" is the temperature on the 4th domain of the + domain set `"column`". + +Additionally, a variable name may include a **component name** and a +**subfield name**, e.g. ROOT_NAME.COMPONENT_NAME.SUBFIELD_NAME. The +component name refers to a component of the field, and typically is +named according to the entity on which it is defined, e.g. `"cell`" or +`"face`". The SUBFIELD_NAME refers to a name for each degree of +freedom in the vector. Typically this is used for n-dimensional +vector-valued fields such as velocity, where the names are e.g. `"x`", +`"y`", and `"z`", or chemical specie names. If multiple degrees of +freedom are needed but subfield names are not provided, they are +assigned integer values indexing the degree of freedom. + +**Tags** indicate the use of a variable at a specific time in the discretized time interval. Default tags include `"current`" and `"next`" indicating the variable at the beginning and end of the interval, respectively. Often subcycling and other schemes will designate special-purpose tags which may be used internally by a subset of the equations begin solved. Tags are combined with variables to indicate a specific data structure, -e.g. `"surface-pressure@NEXT`". +e.g. `"surface-pressure@next`". Note that the default tag `"`" is +equivalent to `"next`". -Lastly, derivatives are named using the `"d`" and the `"|`" character, -e.g. `"dsurface-water_content|dsurface-pressure`" is the derivative of -the `"water_content`" variable on the `"surface`" domain with respect -to the `"pressure`" on the same domain. +Lastly, **derivatives** are named using the `"d`" and the `"|`" +character, e.g. `"dsurface-water_content|dsurface-pressure`" is the +derivative of the `"water_content`" variable on the `"surface`" domain +with respect to the `"pressure`" on the same domain. + +As a result of these conventions, none of the above individual +strings, (root names, domains, domain sets, or IDs) can contain any of +the following reserved characters: `:`, `-`, `|`, `@`. The lone +exception to this rule is that subfield names may include trailing `-` +characters to indicate charge, +e.g. `total_component_concentration.NO3-`. + +Avoid including spaces in variable names. This doesn't break the +code, but it does break some visualization tools. -As a result of these conventions, none of the above individual strings, -(root names, domains, domain sets, or IDs) can contain any of the -following reserved characters: `:`, `-`, `|`, `@`. - -Name and Symbol Index -===================== +Default Names, Symbols, and Units +================================= .. include:: symbol_table.rst diff --git a/docs/documentation/source/input_spec/io/index.rst.in b/docs/documentation/source/input_spec/io/index.rst.in index f9839f614..a12c4fb6b 100644 --- a/docs/documentation/source/input_spec/io/index.rst.in +++ b/docs/documentation/source/input_spec/io/index.rst.in @@ -1,9 +1,10 @@ IO ### -ATS IO includes three types: Visualization_, Observation_, and -Checkpoint_. The latter is mostly an internal format that supports -checkpoint/restart capabilities to allow runs to be continued. +ATS IO includes three output file types: visualization files, +observation files, and checkpoint files. The latter is mostly an +internal format that supports checkpoint/restart capabilities to allow +runs to be continued and is used in regression testing. The first two are both ways that the user interacts with simulation results. Visualization is *dense in space but sparse in time*. It @@ -14,9 +15,6 @@ of) cells, but can be saved much more frequently (even every timestep). Therefore, they are complementary, and care should be taken to use the right one to adress a given goal. -Control of how frequently to write IO is shared across all three -- -each include an IOEvent_ as a part of their spec. - .. toctree:: :maxdepth: 1 @@ -24,4 +22,5 @@ each include an IOEvent_ as a part of their spec. visualization observations checkpoint + logfile diff --git a/docs/documentation/source/input_spec/io/logfile.rst.in b/docs/documentation/source/input_spec/io/logfile.rst.in index 01b21ac43..86d080bfe 100644 --- a/docs/documentation/source/input_spec/io/logfile.rst.in +++ b/docs/documentation/source/input_spec/io/logfile.rst.in @@ -7,15 +7,12 @@ will forward this to a file, e.g.:: ats --verbosity=LEVEL path_to_input.xml &> out.log -The verbosity LEVEL controls how much is written to the logfile: - -* `"none`" Literally nothing. This is useful for large ensembles of runs, but is not recommended. -* `"low`" Very little -- effectively just a summary of each timestep with no PK-level granularity. -* `"medium`" All of the above plus each PK provides a summary for each timestep. -* `"high`" All of the above plus each iteration in a solve of each PK at each timestep. This also turns on `debug cells `_. -* `"extreme`" All of the above plus each evaluator will provide a summary of whether it gets updated or not. Recommended only for input file debugging. - -This option sets the default verbosity of all evaluators, PKs, operators, solvers, etc of the simulation. For more fine-grained control, each component also accepts a `Verbose Object`_ spec which overrides the global verbosity to control output from that component. +The verbosity LEVEL controls how much is written to the logfile (see +below for valid options). This option sets the default verbosity of +all evaluators, PKs, operators, solvers, etc of the simulation. For +more fine-grained control, each component also accepts a `Verbose +Object`_ spec which overrides the global verbosity to control output +from that component. Verbose Object diff --git a/docs/documentation/source/input_spec/math/operators.rst.in b/docs/documentation/source/input_spec/math/operators.rst.in index 720c4a07c..538efc62f 100644 --- a/docs/documentation/source/input_spec/math/operators.rst.in +++ b/docs/documentation/source/input_spec/math/operators.rst.in @@ -3,12 +3,12 @@ Operators { Operator } -PDE_Accumulation ----------------- +Accumulation +------------ { PDE_Accumulation } -PDE_Diffusion -------------- +Diffusion +--------- { PDE_DiffusionFactory } { PDE_Diffusion } diff --git a/docs/documentation/source/input_spec/process_kernels/base.rst.in b/docs/documentation/source/input_spec/process_kernels/base.rst.in index 3f1cb3b2f..365492c72 100644 --- a/docs/documentation/source/input_spec/process_kernels/base.rst.in +++ b/docs/documentation/source/input_spec/process_kernels/base.rst.in @@ -1,17 +1,17 @@ Base PKs ======== -There are several types of PKs, and each PK has its own valid input -spec. However, there are three main types of PKs, from which nearly -all PKs derive. Note that none of these are true PKs and cannot stand -alone. -PK base class -------------- +There are many PKs, and each PK has its own valid input spec. +However, there are three main types of PKs, from which nearly all PKs +derive. Note that none of these are true PKs and cannot stand alone. + +PK +--- { PK } PK: Physical ------------ -{ pk_physical_default } +{ PK_Physical_Default } PK: BDF diff --git a/docs/documentation/source/input_spec/process_kernels/index.rst b/docs/documentation/source/input_spec/process_kernels/index.rst index a8cf80492..0c1225e19 100644 --- a/docs/documentation/source/input_spec/process_kernels/index.rst +++ b/docs/documentation/source/input_spec/process_kernels/index.rst @@ -5,7 +5,7 @@ Process Kernels Process Kernels, or PKs, are the fundamental unit of a model, and represent a single or system of Partial Differential Equations (PDEs) or Differential Algebraic Equations (DAEs). PKs are broadly split -into individual equations (Physical PKs) and systems of equations, +into individual equations, called Physical PKs, and systems of equations, called Multi-Process Coordinators (MPCs). The PK tree forms the fundamental definition of the entire system of diff --git a/docs/documentation/source/input_spec/process_kernels/mpcs/base.rst.in b/docs/documentation/source/input_spec/process_kernels/mpcs/base.rst.in index c5f6fb7b5..e3d3c8948 100644 --- a/docs/documentation/source/input_spec/process_kernels/mpcs/base.rst.in +++ b/docs/documentation/source/input_spec/process_kernels/mpcs/base.rst.in @@ -6,10 +6,18 @@ MPC { mpc } -WeakMPC -------- -{ weak_mpc } - -StrongMPC +Strong MPC ---------- { strong_mpc } + +Weak MPC +-------- +{ weak_mpc } + +Subcycling MPC +-------------- +{ mpc_subcycled } + +Weakly Coupled Subdomains +------------------------- +{ mpc_weak_subdomain } diff --git a/docs/documentation/source/input_spec/process_kernels/mpcs/globalization.rst.in b/docs/documentation/source/input_spec/process_kernels/mpcs/globalization.rst.in index 6241bdf44..a604b689c 100644 --- a/docs/documentation/source/input_spec/process_kernels/mpcs/globalization.rst.in +++ b/docs/documentation/source/input_spec/process_kernels/mpcs/globalization.rst.in @@ -17,7 +17,7 @@ them are always welcome contributions. Coupled Water Globalization Delegate ------------------------------------ -{ mpc_delegate_water } +{ mpc_delegate_water_decl } EWC Globalization Delegate -------------------------- diff --git a/docs/documentation/source/input_spec/process_kernels/mpcs/index.rst b/docs/documentation/source/input_spec/process_kernels/mpcs/index.rst index b44dd448e..124e76f6f 100644 --- a/docs/documentation/source/input_spec/process_kernels/mpcs/index.rst +++ b/docs/documentation/source/input_spec/process_kernels/mpcs/index.rst @@ -19,5 +19,6 @@ other things. Think of these as the custom couplers. :maxdepth: 1 base - physical + tightly_coupled + multiple_domain globalization diff --git a/docs/documentation/source/input_spec/process_kernels/mpcs/multiple_domain.rst.in b/docs/documentation/source/input_spec/process_kernels/mpcs/multiple_domain.rst.in new file mode 100644 index 000000000..190ef26f8 --- /dev/null +++ b/docs/documentation/source/input_spec/process_kernels/mpcs/multiple_domain.rst.in @@ -0,0 +1,40 @@ +Multiple Domain MPCs +==================== + +Additionally, MPCs are used to couple across multiple physical +domains. This includes for integrated surface-subsurface +implementations, multiple media, for subgrid models, and other novel +models across domain sets. + +Integrated Hydrology +-------------------- +{ mpc_coupled_water } + +Operator Split Integrated Hydrology +----------------------------------- +{ mpc_coupled_water_split_flux } + +Integrated Thermal Hydrology +---------------------------- +{ mpc_permafrost } + +Operator Split Integrated Thermal Hydrology +------------------------------------------- +{ mpc_permafrost_split_flux } + +Integrated Hydrology with Dual Media +------------------------------------ +{ mpc_coupled_dualmedia_water } + +Integrated Transport +-------------------- +{ mpc_coupled_transport } + +Integrated Reactive Transport +----------------------------- +{ mpc_coupled_reactivetransport } + + + + + diff --git a/docs/documentation/source/input_spec/process_kernels/mpcs/physical.rst.in b/docs/documentation/source/input_spec/process_kernels/mpcs/physical.rst.in deleted file mode 100644 index 5876dacb9..000000000 --- a/docs/documentation/source/input_spec/process_kernels/mpcs/physical.rst.in +++ /dev/null @@ -1,30 +0,0 @@ -Physical MPCs -=============== - -Coupling is an art, and often requires special off-diagonal work for -globally implicit coupling, and fancy games can be played with domains -to couple across domain interfaces both implicitly and sequentially. -Physical MPCs derive from default MPCs to provide special -implementations of some methods. - -Coupled Water MPC ------------------ -{ mpc_coupled_water } - -Coupled Cells MPC ------------------ -{ mpc_coupled_cells } - -Subsurface MPC --------------- -{ mpc_subsurface } - -Surface MPC --------------- -{ mpc_surface } - -Permafrost MPC --------------- -{ mpc_permafrost } - - diff --git a/docs/documentation/source/input_spec/process_kernels/mpcs/tightly_coupled.rst.in b/docs/documentation/source/input_spec/process_kernels/mpcs/tightly_coupled.rst.in new file mode 100644 index 000000000..916b33646 --- /dev/null +++ b/docs/documentation/source/input_spec/process_kernels/mpcs/tightly_coupled.rst.in @@ -0,0 +1,28 @@ +Tightly Coupled MPCs +==================== + +Coupling is an art, and often requires special off-diagonal work for +globally implicit coupling on a single domain. For instance, phase +change results in tight coupling of flow and energy equations; +off-block-diagonal entries in the preconditioner are entered through a +special-purpose coupler. + +Coupled Cells MPC +----------------- +{ mpc_coupled_cells } + +Subsurface Flow & Energy +------------------------ +{ mpc_subsurface } + +Surface Flow & Energy +--------------------- +{ mpc_surface } + +Reactive Transport +------------------ +{ mpc_reactivetransport } + +Flow & Transport +---------------- +{ mpc_flow_transport } diff --git a/docs/documentation/source/input_spec/process_kernels/physical/bgc.rst.in b/docs/documentation/source/input_spec/process_kernels/physical/bgc.rst.in new file mode 100644 index 000000000..f9228d968 --- /dev/null +++ b/docs/documentation/source/input_spec/process_kernels/physical/bgc.rst.in @@ -0,0 +1,16 @@ +Biogeochemistry +--------------- + +To accurately predict watershed ecohydrology, a carbon cycle model is +needed to predict transpiration. By simulating a carbon cycle, we are +able to predict the rate of photosynthesis as a function of space and +time, and photosynthesis governs root water uptake. Currently only +one big-leaf model is available, but ongoing work is wrapping a +generalized Common/Colorado Land Model based on that developed within +the ParFlow team, and another ongoing project is working on wrapping +kernels from E3SM's Land Model. + +Biogeochemistry -- Monolithic Version +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +{ bgc_simple } + diff --git a/docs/documentation/source/input_spec/process_kernels/physical/deformation.rst.in b/docs/documentation/source/input_spec/process_kernels/physical/deformation.rst.in new file mode 100644 index 000000000..871737fba --- /dev/null +++ b/docs/documentation/source/input_spec/process_kernels/physical/deformation.rst.in @@ -0,0 +1,18 @@ + +Deformation +------------- + +The unstructured mesh framework we use provides the opportunity to +include deformation of the mesh. This deformation can be done in two +ways -- either node coordinate changes are provided, or volumetric +changes are provided, and the code attempts to iterate toward a global +coordinate change that satisfies these volumetric changes. The latter +can be somewhat fragile for large deformation, but it does allow +simple deformation such as small, somewhat uniform subsidence. The +volumetric deformation PK below does this based on a volumetric change +given by loss of bulk ice. + +Volumetric Deformation +^^^^^^^^^^^^^^^^^^^^^^ +{ volumetric_deformation } + diff --git a/docs/documentation/source/input_spec/process_kernels/physical/energy.rst.in b/docs/documentation/source/input_spec/process_kernels/physical/energy.rst.in index 26f5ac6b0..da80946c2 100644 --- a/docs/documentation/source/input_spec/process_kernels/physical/energy.rst.in +++ b/docs/documentation/source/input_spec/process_kernels/physical/energy.rst.in @@ -10,15 +10,15 @@ Energy Base PK ^^^^^^^^^^^^^^ { energy_base } -Two-Phase subsurface Energy PK -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Two-Phase Energy PK +^^^^^^^^^^^^^^^^^^^ { energy_two_phase } -Three-Phase subsurface Energy PK -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Three-Phase Energy PK +^^^^^^^^^^^^^^^^^^^^^ { energy_three_phase } -Overland energy with Ice +Overland Energy with Ice ^^^^^^^^^^^^^^^^^^^^^^^^ { energy_surface_ice } diff --git a/docs/documentation/source/input_spec/process_kernels/physical/flow.rst.in b/docs/documentation/source/input_spec/process_kernels/physical/flow.rst.in index 77735569e..015b079e3 100644 --- a/docs/documentation/source/input_spec/process_kernels/physical/flow.rst.in +++ b/docs/documentation/source/input_spec/process_kernels/physical/flow.rst.in @@ -4,15 +4,14 @@ Flow PKs Flow PKs describe the conservation of mass of water as it flows both above and below-ground. Subsurface flow PKs are based on 3D Richards equation, which describes variably saturated flow in porous media. -Minor variations to this include the incorporation of freeze-thaw -processes. Surface flow PKs are based on a diffusion wave equation -and Manning's model for sheet flow. Variations to this also include -the incorporation of freeze-thaw processes. Finally we include in -flow a "snow distribution" algorithm which takes as input -precipitation and applies it based on the existing surface level -(elevation + water + snowpack), thereby "filling in" low-lying areas -preferentially. This makes for more accurate snowpacks at fine -scales. +Variations on this include the incorporation of freeze-thaw processes. +Surface flow PKs are based on a diffusion wave equation and Manning's +model for sheet flow. Variations on this also include the +incorporation of freeze-thaw processes. Finally we include in flow a +"snow distribution" algorithm which takes as input precipitation and +applies it based on the existing surface level (elevation + water + +snowpack), thereby "filling in" low-lying areas preferentially. This +makes for more accurate snowpacks at fine scales. Richards PK ^^^^^^^^^^^ diff --git a/docs/documentation/source/input_spec/process_kernels/physical/index.rst b/docs/documentation/source/input_spec/process_kernels/physical/index.rst index 93fe51cb9..0c25a9b0e 100644 --- a/docs/documentation/source/input_spec/process_kernels/physical/index.rst +++ b/docs/documentation/source/input_spec/process_kernels/physical/index.rst @@ -9,3 +9,5 @@ Physical PKs are the physical capability implemented within ATS. transport energy seb + bgc + deformation diff --git a/docs/documentation/source/input_spec/process_kernels/physical/physical.rst.in b/docs/documentation/source/input_spec/process_kernels/physical/physical.rst.in deleted file mode 100644 index bdd1f5c3e..000000000 --- a/docs/documentation/source/input_spec/process_kernels/physical/physical.rst.in +++ /dev/null @@ -1,144 +0,0 @@ -Physical PKs -============ -Physical PKs are the physical capability implemented within ATS. - -Flow PKs --------- - -Flow PKs describe the conservation of mass of water as it flows both -above and below-ground. Subsurface flow PKs are based on 3D Richards -equation, which describes variably saturated flow in porous media. -Minor variations to this include the incorporation of freeze-thaw -processes. Surface flow PKs are based on a diffusion wave equation -and Manning's model for sheet flow. Variations to this also include -the incorporation of freeze-thaw processes. Finally we include in -flow a "snow distribution" algorithm which takes as input -precipitation and applies it based on the existing surface level -(elevation + water + snowpack), thereby "filling in" low-lying areas -preferentially. This makes for more accurate snowpacks at fine -scales. - -Richards PK -^^^^^^^^^^^ -{ richards } - -Permafrost Flow PK -^^^^^^^^^^^^^^^^^^ -{ permafrost } - -Overland Flow PK -^^^^^^^^^^^^^^^^ -{ overland_pressure } - -Overland Flow with Ice -^^^^^^^^^^^^^^^^^^^^^^ -{ icy_overland } - -Snow Distribution PK -^^^^^^^^^^^^^^^^^^^^ -{ snow_distribution } - - -Transport PK ------------- - -The Transport PK describes the conservation of mass of components transported -with water as it flows. The transport PK is based on the advection-diffusion -equation, applies to one or more components that are dissolved in the aqueous -phase, and is currently used in both surface and subsurface compartments. -The key difference between surface and subsurface transport is in capturing -the volume of water. In the subsurface, the volume of water is set by the -porosity and saturation of the porous medium, while in the surface it is set -by the ponded depth. - -{transport_ats} - -Energy PKs ------------ - -Energy PKs describe the conservation of energy as it is advected and -diffuses both above and below-ground. Both surface and subsurface -energy equations are based on a simple advection-diffusion equation, -and include variants with and without freeze-thaw processes. - -Energy Base PK -^^^^^^^^^^^^^^ -{ energy_base } - -Two-Phase subsurface Energy PK -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -{ energy_two_phase } - -Three-Phase subsurface Energy PK -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -{ energy_three_phase } - -Overland energy with Ice -^^^^^^^^^^^^^^^^^^^^^^^^ -{ energy_surface_ice } - - - -Surface Energy Balance PKs ------------------------------- - -Integrated hydrology is not much use without significant process -complexity in source terms coming from the ecohydrologic environment. -These include straightforward sources, like precipitation, but also -more complicated ones such as evaporation and transpiration. - -These terms are almost always tied up in a surface energy balance -- -evaporation and transpiration are driven by vapor pressure gradients -between the atmosphere and the surface (either snow, ponded water, -soil, or leaf). Solving a surface energy balance often requires -providing a bunch of terms, including radiated energy, conducted -energy, latent and sensible heat models, etc. - -ATS currently has several approaches to calculating these -- see -`ats-demos `_ examples on -ecohydrology for a more in-depth discussion. - -Balance Equation -^^^^^^^^^^^^^^^^ -{ surface_balance_base } - - -Snow Balance Equation -^^^^^^^^^^^^^^^^^^^^^ -{ surface_balance_implicit_subgrid } - -Biogeochemistry ---------------- - -To accurately predict watershed ecohydrology, a carbon cycle model is -needed to predict transpiration. By simulating a carbon cycle, we are -able to predict the rate of photosynthesis as a function of space and -time, and photosynthesis governs root water uptake. Currently only -one big-leaf model is available, but ongoing work is wrapping a -generalized Common/Colorado Land Model based on that developed within -the ParFlow team, and another ongoing project is working on wrapping -kernels from E3SM's Land Model. - -Biogeochemistry -- Monolithic Version -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -{ bgc_simple } - - - -Deformation -------------- - -The unstructured mesh framework we use provides the opportunity to -include deformation of the mesh. This deformation can be done in two -ways -- either node coordinate changes are provided, or volumetric -changes are provided, and the code attempts to iterate toward a global -coordinate change that satisfies these volumetric changes. The latter -can be somewhat fragile for large deformation, but it does allow -simple deformation such as small, somewhat uniform subsidence. The -volumetric deformation PK below does this based on a volumetric change -given by loss of bulk ice. - -Volumetric Deformation -^^^^^^^^^^^^^^^^^^^^^^ -{ volumetric_deformation } - diff --git a/docs/documentation/source/input_spec/process_kernels/physical/seb.rst.in b/docs/documentation/source/input_spec/process_kernels/physical/seb.rst.in index 7bcf065f0..6b00801ad 100644 --- a/docs/documentation/source/input_spec/process_kernels/physical/seb.rst.in +++ b/docs/documentation/source/input_spec/process_kernels/physical/seb.rst.in @@ -26,38 +26,5 @@ Snow Balance Equation ^^^^^^^^^^^^^^^^^^^^^ { surface_balance_implicit_subgrid } -Biogeochemistry ---------------- - -To accurately predict watershed ecohydrology, a carbon cycle model is -needed to predict transpiration. By simulating a carbon cycle, we are -able to predict the rate of photosynthesis as a function of space and -time, and photosynthesis governs root water uptake. Currently only -one big-leaf model is available, but ongoing work is wrapping a -generalized Common/Colorado Land Model based on that developed within -the ParFlow team, and another ongoing project is working on wrapping -kernels from E3SM's Land Model. - -Biogeochemistry -- Monolithic Version -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -{ bgc_simple } - - - -Deformation -------------- - -The unstructured mesh framework we use provides the opportunity to -include deformation of the mesh. This deformation can be done in two -ways -- either node coordinate changes are provided, or volumetric -changes are provided, and the code attempts to iterate toward a global -coordinate change that satisfies these volumetric changes. The latter -can be somewhat fragile for large deformation, but it does allow -simple deformation such as small, somewhat uniform subsidence. The -volumetric deformation PK below does this based on a volumetric change -given by loss of bulk ice. - -Volumetric Deformation -^^^^^^^^^^^^^^^^^^^^^^ -{ volumetric_deformation } + diff --git a/docs/documentation/source/input_spec/process_kernels/physical/transport.rst.in b/docs/documentation/source/input_spec/process_kernels/physical/transport.rst.in index a1af15e75..f597a614e 100644 --- a/docs/documentation/source/input_spec/process_kernels/physical/transport.rst.in +++ b/docs/documentation/source/input_spec/process_kernels/physical/transport.rst.in @@ -1,14 +1,37 @@ -Transport PK ------------- - -The Transport PK describes the conservation of mass of components transported -with water as it flows. The transport PK is based on the advection-diffusion -equation, applies to one or more components that are dissolved in the aqueous -phase, and is currently used in both surface and subsurface compartments. -The key difference between surface and subsurface transport is in capturing -the volume of water. In the subsurface, the volume of water is set by the -porosity and saturation of the porous medium, while in the surface it is set -by the ponded depth. - -{transport_ats} +Geochemical Transport +--------------------- + +Geochemical transport capabilities are implemented in a few different PKs. + +Transport +^^^^^^^^^ + +{ transport_ats } + + +Chemistry +^^^^^^^^^ + +Reactive transport is done by coupling a :ref:`Transport` PK with +chemistry using some variation on a :ref:`Reactive Transport` MPC. +Currently, ATS only implements chemistry through `Alquimia +`_, which calls out to either +`PFloTran `_ or `Crunch +`_ for reaction support. + +{ Alquimia_PK } + +Salinity Transport +^^^^^^^^^^^^^^^^^^ + +Salinity transport is not itself a PK, but may be implemented as a +variation on Transport_ by supplying equations of state that are a +function of the concentration of salt. Examples of this are provided +in the regression tests and demos. + + +Sediment Transport +^^^^^^^^^^^^^^^^^^ + +{ sediment_transport_pk } diff --git a/docs/documentation/source/input_spec/region.rst.in b/docs/documentation/source/input_spec/region.rst.in index f2c431d47..61b48cea0 100644 --- a/docs/documentation/source/input_spec/region.rst.in +++ b/docs/documentation/source/input_spec/region.rst.in @@ -1,55 +1,65 @@ Region ###### -{ Region } - -.. contents:: **Region Types** - :local: - +{ RegionFactory } All === { RegionAll } -Box -=== -{ RegionBox } +Boundary +======== +{ RegionBoundary } + +Point +===== +{ RegionPoint } + +Line Segment +============ +{ RegionLineSegment } Plane ===== { RegionPlane } +Polygon +======= +{ RegionPolygon} + +Box +=== +{ RegionBox } + +Box Volume Fractions +==================== +{ RegionBoxVolumeFractions } + +Cylinder +======== +{ RegionCylinder } + +Half Space +========== +{ RegionHalfSpace } + +Level Set +========= +{ RegionLevelSet } + Labeled Set =========== { RegionLabeledSet } -Function Color +Enumerated Set ============== -{ RegionFunctionColor } +{ RegionEnumerated } -Point -===== -{ RegionPoint } +Color Function +============== +{ RegionFunctionColor } Logical ======= { RegionLogical } -Polygon -======= -{ RegionPolygon} - -Enumerated -========== -{ RegionEnumerated } - -Boundary -======== -{ RegionBoundary } - -Box Volume Fractions -==================== -{ RegionBoxVolumeFractions } -Line Segment -============ -{ RegionLineSegment } diff --git a/docs/documentation/source/input_spec/state/conserved.rst.in b/docs/documentation/source/input_spec/state/conserved.rst.in index dfca2bbcb..d8c2109a5 100644 --- a/docs/documentation/source/input_spec/state/conserved.rst.in +++ b/docs/documentation/source/input_spec/state/conserved.rst.in @@ -34,28 +34,28 @@ Surface water content Snow or canopy water content ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Most other water contents can be formed as `Multiplicative`_ +Most other water contents can be formed as :ref:`Multiplicative` evaluators. See below for a few examples: Multiplicative evalutator for `snow-water_content`: .. code-block:: xml - - - - - + + + + + Multiplicative evaluator for `canopy-water_content`: .. code-block:: xml - - - - - + + + + + Richards energy ^^^^^^^^^^^^^^^ diff --git a/docs/documentation/source/input_spec/state/engineered_water.rst.in b/docs/documentation/source/input_spec/state/engineered_water.rst.in new file mode 100644 index 000000000..384d4c5a4 --- /dev/null +++ b/docs/documentation/source/input_spec/state/engineered_water.rst.in @@ -0,0 +1,32 @@ +Engineered Water Models +------------------------ + +Gate Structure +^^^^^^^^^^^^^^^ + +{ surface_gate_structure_evaluator } + +Pump System +^^^^^^^^^^^^ + +{ surface_pump_system_evaluator } + +Culverts +^^^^^^^^^ + +{ surface_culvert_evaluator } + +Impervious Interception +^^^^^^^^^^^^^^^^^^^^^^^^ + +{ impervious_interception_evaluator } + +Tile Drains +^^^^^^^^^^^^^^^^^^^^^^^^ + +{ distributed_tiles_evaluator } + +{ surface_distributed_tiles_evaluator } + + + diff --git a/docs/documentation/source/input_spec/state/eos.rst.in b/docs/documentation/source/input_spec/state/eos.rst.in index b99e6785c..e0b909674 100644 --- a/docs/documentation/source/input_spec/state/eos.rst.in +++ b/docs/documentation/source/input_spec/state/eos.rst.in @@ -5,21 +5,12 @@ The density of water can be specified in many ways, depending upon phase and problem of interest. Options are available from the simplest (constant value) to functions of just temperature, temperature and pressure, and temperature/pressure/concentration -(e.g. salinity). +(e.g. salinity). We call these Equations of State (EOS). Note that density includes both molar and mass-based values. Most density evaluators can provide either, or do provide both, the difference being simply a factor of the molecular mass of water. -Finally, nearly all (except the constant value) equations of state use -a common set of models which accept all of temperature, pressure, and -concentration. Many of these models ignore one or the other, so it -should be preferred (but is not necessary) to choose the right model -for a given evaluator. Choosing a model that uses fewer of -these than the evaluator provides is valid, but it is inefficient. -Choosing a model that uses more than the evaluator provides will -result in an error. - Constant Value ^^^^^^^^^^^^^^ diff --git a/docs/documentation/source/input_spec/state/index.rst.in b/docs/documentation/source/input_spec/state/index.rst.in index 28393ebf1..d118c8958 100644 --- a/docs/documentation/source/input_spec/state/index.rst.in +++ b/docs/documentation/source/input_spec/state/index.rst.in @@ -1,49 +1,12 @@ + State ##### { State } -State consists of two sublists, one for evaluators and the other for -atomic constants. The latter is currently called `"initial -conditions`", which is a terrible name which must be fixed. - -Evaluators are individual terms used to build up a PK or MPCs. Each -term represents a variable in the equation, and can consist of primary -variables (those that are solved for by a PK solver), independent -variables (those that have no dependent variables but are provided by -the user as data), and secondary variables (those that are functions -of other variables). Note that all three may be variable in space -and/or time. - -Example: - -.. code-block:: xml - - - - ... - - - ... - - - - .. toctree:: :caption: List of Evaluators - :maxdepth: 1 + :maxdepth: 2 primary independent secondary - conserved - subsurface_flow - surface_flow - thermo - eos - seb - snow - canopy - bgc - multiscale - geometric - generic diff --git a/docs/documentation/source/input_spec/state/primary.rst.in b/docs/documentation/source/input_spec/state/primary.rst.in index 83d413cc1..5393fba0f 100644 --- a/docs/documentation/source/input_spec/state/primary.rst.in +++ b/docs/documentation/source/input_spec/state/primary.rst.in @@ -1,3 +1,7 @@ Primary Variables ----------------- { EvaluatorPrimary } + +Aliased Variables +----------------- +{ EvaluatorAlias } diff --git a/docs/documentation/source/input_spec/state/seb.rst.in b/docs/documentation/source/input_spec/state/seb.rst.in index f04225414..5368554ae 100644 --- a/docs/documentation/source/input_spec/state/seb.rst.in +++ b/docs/documentation/source/input_spec/state/seb.rst.in @@ -1,4 +1,4 @@ -Surface energy balance evaluators +Surface Energy Balance Evaluators --------------------------------- Evaluators used to solve the fluxes to and from the atmosphere and @@ -62,10 +62,18 @@ Plant Wilting Point ~~~~~~~~~~~~~~~~~~~ { plant_wilting_factor_evaluator } -Soil Resistance -^^^^^^^^^^^^^^^ +Evaporation Downregulation +~~~~~~~~~~~~~~~~~~~~~~~~~~ { evaporation_downregulation_evaluator } +Soil Resistance, Sakagucki & Zeng +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{ soil_resistance_sakagucki_zeng_evaluator } + +Soil Resistance, Sellers +~~~~~~~~~~~~~~~~~~~~~~~~ +{ soil_resistance_sellers_evaluator } + Radiation Balance Terms ^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,14 +93,12 @@ Canopy Radiation Balance ~~~~~~~~~~~~~~~~~~~~~~~~ { canopy_radiation_evaluator } -Surface Albedo -~~~~~~~~~~~~~~ - -Note that albedo is also a multiple subgrid component model, like -surface balance. - +Surface Albedo, Two Components +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { albedo_twocomponent_evaluator } +Surface Albedo, Two Components +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { albedo_threecomponent_evaluator } Incident Shortwave Radiation diff --git a/docs/documentation/source/input_spec/state/secondary.rst.in b/docs/documentation/source/input_spec/state/secondary.rst.in deleted file mode 100644 index 4ece4b8a7..000000000 --- a/docs/documentation/source/input_spec/state/secondary.rst.in +++ /dev/null @@ -1,44 +0,0 @@ -Secondary Variables -------------------- - -All other evaluators are secondary variable evaluators, and these are -grouped by physics concept or process type. - -Secondary variables, by definition, define functions that evaluate one -or more variables as a function of one or more variables. Therefore -all secondary evaluators provide at least one "Key," which is the -variable(s) computed, and at least one "Dependency." - -If the evaluator computes one and only one key, that key is provided -by the name of the parameter list in the `"evalutors`" list of State_. -If more than one Key is computed, then the second must either be -guessed by the code (for instance if the provided key is -"saturation_liquid", it is likely that the other key is -"saturation_gas") or provided by the user. If more than one key is -computed, all of the keys computed can be specified exactly via the -input spec. Keys are provided in one of two parameters: - -* `"my variable key`" ``[string]`` Specifically name the variable used as "my variable" - -* `"my variable key suffix`" ``[string]`` Name a suffix, and the - variable is given by DOMAIN-SUFFIX, where the DOMAIN is given by the - prefix in the evaluator list's name. This is particularly useful - for collections of enumerated PKs, e.g. columnar PKs, where the - DOMAIN might be computed on the fly based on a column ID. - -Dependencies use the same approach -- each dependency variable name -may include a default, and looks for a "key" and "key suffix" as -potential options. - -As an example, a saturation evaluator may depend on pressure, and may -detail all of its names via something like: - -.. code-block:: xml - - - - - - - - diff --git a/docs/documentation/source/input_spec/state/sediment_transport.rst.in b/docs/documentation/source/input_spec/state/sediment_transport.rst.in new file mode 100644 index 000000000..83937f39c --- /dev/null +++ b/docs/documentation/source/input_spec/state/sediment_transport.rst.in @@ -0,0 +1,22 @@ +Sediment Transport +------------------ + +Most of the below are rates of suspension / fallout used in sediment +transport. The biomass evaluator lets the others be a function of +biomass. + +Biomass +^^^^^^^ +{ biomass_evaluator } + +Organic Matter +^^^^^^^^^^^^^^ +{ organic_matter_evaluator } + +Erosion +^^^^^^^ +{ erosion_evaluator } + +Settlement +^^^^^^^^^^ +{ settlement_evaluator } diff --git a/docs/documentation/source/input_spec/state/subsurface_flow.rst.in b/docs/documentation/source/input_spec/state/subsurface_flow.rst.in index 11437a642..985a23ba5 100644 --- a/docs/documentation/source/input_spec/state/subsurface_flow.rst.in +++ b/docs/documentation/source/input_spec/state/subsurface_flow.rst.in @@ -1,4 +1,4 @@ -Subsurface flow evaluators +Subsurface Flow Evaluators -------------------------- Assorted evaluators used for subsurface flow processes, @@ -16,59 +16,91 @@ Capillary pressure Capillary pressure of liquid on ice ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ { pc_ice_evaluator } +{ pc_ice_water } + +Water Retention and Relative Permeability Models +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +WRM Evaluator +~~~~~~~~~~~~~ -Water Retention Model and Relative Permeability -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ { wrm_evaluator } -{ wrm_partition } + +Relative Permeability Evaluator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + { rel_perm_evaluator } +**WRM and Relative Permeability Models** + Van Genuchten Model ~~~~~~~~~~~~~~~~~~~ + { wrm_van_genuchten } +Brooks-Corey Model +~~~~~~~~~~~~~~~~~~~ + +{ wrm_brooks_corey } + Linear Model ~~~~~~~~~~~~~~~~~~~ + { wrm_linear_system } -Water Retention Model for Freeze-Thaw -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Water Retention and Relative Permeability Models for Freeze-Thaw +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +WRM Permafrost Evaluator +~~~~~~~~~~~~~~~~~~~~~~~~ { wrm_permafrost_evaluator } -Original Implicit model -~~~~~~~~~~~~~~~~~~~~~~~ +**WRM Permafrost Models** + +Original Implicit WRM +~~~~~~~~~~~~~~~~~~~~~ { wrm_implicit_permafrost_model } -Freezing point depression model -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Freezing Point Depression WRM +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { wrm_fpd_permafrost_model } -Freezing point depression, smoothed model -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Freezing Point Depression, Smoothed WRM +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { wrm_fpd_smoothed_permafrost_model } -Interfrost model -~~~~~~~~~~~~~~~~ +Interfrost WRM +~~~~~~~~~~~~~~ { wrm_interfrost_permafrost_model } -Sutra-ICE model -~~~~~~~~~~~~~~~ +Sutra-ICE WRM +~~~~~~~~~~~~~ { wrm_sutra_permafrost_model } -Compressible porosity +Relative Permeability, Freezing Brooks-Corey Evaluator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{ rel_perm_frzBC_evaluator } + +Relative Permeability, Sutra-ICE Evaluator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{ rel_perm_sutraice_evaluator } + + +Compressible Porosity ^^^^^^^^^^^^^^^^^^^^^ -{ compressible_porosity_evaluator } -Standard model +Standard Model ~~~~~~~~~~~~~~ +{ compressible_porosity_evaluator } { compressible_porosity_model } -Exponential model +Exponential Model ~~~~~~~~~~~~~~~~~ +{ compressible_porosity_leijnse_evaluator } { compressible_porosity_leijnse_model } -Viscosity of water +Viscosity of Water ^^^^^^^^^^^^^^^^^^ Two main viscosity models are commonly used -- a constant and one diff --git a/docs/documentation/source/input_spec/state/surface_flow.rst.in b/docs/documentation/source/input_spec/state/surface_flow.rst.in index 528a87ab7..ee05b731a 100644 --- a/docs/documentation/source/input_spec/state/surface_flow.rst.in +++ b/docs/documentation/source/input_spec/state/surface_flow.rst.in @@ -1,30 +1,22 @@ -Surface flow evaluators +Surface Flow Evaluators ----------------------- -Assorted evaluators used for surface flow, including potential -surfaces, Manning's conductivity, and their frozen equivalents. +Evaluators are used in surface flow for things like ponded depth, +Manning's conductivity, and their frozen equivalents. -Like the subsurface flow evaluators, many of these evaluators show up -in nearly all ATS simulations. For real examples, see `ats-demos -`_ - - -Ponded Depth or Water Height -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Ponded Depth +^^^^^^^^^^^^ { height_evaluator } -{ height_model } Ponded Depth, Frozen ^^^^^^^^^^^^^^^^^^^^ { icy_height_evaluator } -{ icy_height_model } -Effective, or Smoothed Height -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Smoothed Ponded Depth +^^^^^^^^^^^^^^^^^^^^^ { effective_height_evaluator } -{ effective_height_model } -Unfrozen fraction +Unfrozen Fraction ^^^^^^^^^^^^^^^^^ { unfrozen_fraction_evaluator } { unfrozen_fraction_model } @@ -33,19 +25,26 @@ Unfrozen Flowing Depth ^^^^^^^^^^^^^^^^^^^^^^ { unfrozen_effective_depth_evaluator } -SurfacePotential -^^^^^^^^^^^^^^^^^^^ -{ pres_elev_evaluator } - -Overland Conductivity, sheet flow +Overland Conductivity, Sheet Flow ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. _`Overland Conductivity Evaluator`: { overland_conductivity_evaluator } { manning_conductivity_model } -Overland Conductivity, litter resistance -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Manning Coefficient +^^^^^^^^^^^^^^^^^^^ + +The Manning coefficient is most commonly just a piecewise-constant +function (defined by land cover type or stream order). In the most +common case, it is therefore an :ref:`Independent Variable From +Function`. However, there are cases where it is useful to define it +as a function of a dynamic litter layer: + { manning_coefficient_litter_evaluator } -{ manning_coefficient_litter_model } + +**Manning n Models** + +{ manning_coefficient_litter_constant_model } +{ manning_coefficient_litter_variable_model } diff --git a/docs/documentation/source/input_spec/state/thermo.rst.in b/docs/documentation/source/input_spec/state/thermo.rst.in index e42561812..b7c2165fe 100644 --- a/docs/documentation/source/input_spec/state/thermo.rst.in +++ b/docs/documentation/source/input_spec/state/thermo.rst.in @@ -25,7 +25,7 @@ Enthalpy ~~~~~~~~ { enthalpy_evaluator } -Thermal Conductivity, two phases +Thermal Conductivity, Two Phases ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ { thermal_conductivity_twophase_evaluator } @@ -37,7 +37,7 @@ Peters-Lidard Model ~~~~~~~~~~~~~~~~~~~ { thermal_conductivity_twophase_peterslidard } -Thermal Conductivity, three phases +Thermal Conductivity, Three Phases ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ { thermal_conductivity_threephase_evaluator } diff --git a/docs/documentation/source/input_spec/state/transport.rst.in b/docs/documentation/source/input_spec/state/transport.rst.in new file mode 100644 index 000000000..649df2ca0 --- /dev/null +++ b/docs/documentation/source/input_spec/state/transport.rst.in @@ -0,0 +1,25 @@ +Transport evaluators +-------------------- + +Only dispersivity requires an evaluator unique to transport. + +Mechanical Dispersion Model Evaluator +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +{ EvaluatorMDM } + +Isotropic Dispersion +~~~~~~~~~~~~~~~~~~~~~~ +{ MDM_Isotropic } + +Bear's Dispersion Model +~~~~~~~~~~~~~~~~~~~~~~~ +{ MDM_Bear } + +Burnett-Frind Dispersion Model +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{ MDM_BurnettFrind } + +Lichtner-Kelkar-Robinson Dispersion Model +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{ MDM_LichtnerKelkarRobinson } diff --git a/docs/documentation/source/input_spec/symbol_table.org b/docs/documentation/source/input_spec/symbol_table.org index b03786457..689a6527d 100644 --- a/docs/documentation/source/input_spec/symbol_table.org +++ b/docs/documentation/source/input_spec/symbol_table.org @@ -1,104 +1,118 @@ #+OPTIONS: ^:nil -| Variable Root Name | Symbol | Description | Units | Process | -|------------------------------------------+----------------------+----------------------------------------------------------------------------------+-----------------------------------------------------+---------| -| coordinate, centroid | $x$, $y$, $z$ | spatial coordinates | $[m]$ | | -| time | $t$ | time variable | $[s]$ | | -| cell_volume | $\vert V \vert$, $V$ | volume (if 3D) or area (if 2D) of a discrete element | $[m^3]$ or $[m^2]$ | | -| gravity | $g$ | gravitational acceleration vector | $[m s^{-2}]$ | | -| canopy-drainage | $D$ | flux of water dripping from the canopy to the ground below | $[m s^-1]$ | canopy | -| canopy-throughfall_drainage_{rain,snow} | | source of {rain,snow} to the respective layer, throughfall + drainage | $[m s^-1]$ | canopy | -| canopy-evaporation | $E_{can}$ | evaporative flux of stored water from the leaf surface | $[m s^-1]$ | canopy | -| canopy-fracwet | $f_{wet}$ | fraction of the canopy leaf area that is covered in water | $[-]$ | canopy | -| canopy-water_content | $\Theta_{can}$ | extensive water content on the leaf surface$^5$ | $[mol]$ | canopy | -| canopy-water_equivalent | | effective thickness of water (per unit surface or leaf area???) | $[m]$ | canopy | -| canopy-water_source | | sum of all sources and sinks of water to the leaf surface | $[mol m^2 s^-1]$ | canopy | -| canopy-water_source_meters | | sum of all sources and sinks of water to the leaf surface | $[m s^-1]$ | canopy | -| canopy-interception | $I_{can}$ | flux of water to the canopy as intercepted rain or snow | $[m s^-1]$ | canopy | -| canopy-leaf_area_index | $LAI$ | leaf area per unit surface area | $[-]$ | canopy | -| canopy-potential_transpiration | $T_{pot}$ | potential transpiration, unlimited by water availability | $[m s^-1]$ | canopy | -| canopy-potential_transpiration_mols | $T_{pot}$ | potential transpiration, unlimited by water availability | $[mol m^-2 s^-1]$ | canopy | -| canopy-temperature | $T_{can}$ | leaf temperature, used in longwave radiation out calculation | $[K]$ | canopy | -| {canopy,snow,surface}-radiation_balance | | net energy balance including radiation and conduction (Priestley-Taylor's R - G) | surface | surface | -| snow-depth | $h_{snow}$ | thickness of the snowpack | $[m]$ | snow | -| snow-age | | average age of the snowpack | $[day]$ | snow | -| snow-density | $\rho_{snow}$ | Mass density of the snow | $[kg m^-3]$ | snow | -| snow-melt | $M$ | Snow melt rate (SWE) | $[m SWE s^-1]$ | snow | -| snow-precipitation | $P_{snow}$ | precipitation of snow, in snow-water-equivalent (SWE) | $[m \mathop{\mathrm{SWE}} s^{-1}]$ | snow | -| snow-evaporation | $E_{snow}$ | evaporation of snow, in snow-water-equivalent (SWE) | $[m \mathop{\mathrm{SWE}} s^{-1}]$ | snow | -| snow-source_sink | $Q_{snow}$ | extensive sum of all sources and sinks of water as snow | $[mol s^{-1}]$ ?? | snow | -| snow-water_source | $Q_{snow}$ | sum of all sources and sinks of water as snow | $[mol m^-2 s^{-1}]$ ?? | snow | -| snow-water_source_meters | $Q_{snow}$ | sum of all sources and sinks of water as snow | $[m s^{-1}]$ ?? | snow | -| snow-source | | sum of all sources of water as snow, excluding sinks | $[m s^{-1}]$ | snow | -| snow-death_rate | | If all snow disappears in a timestep, the effective rate of snow loss. | $[m SWE s^-1]$ | snow | -| snow-water_equivalent | $SWE$ | equivalent "ponded_depth" if one melted the snow | $[m]$ | snow | -| snow-water_content | $\Theta_{snow}$ | extensive water content in snow$^5$ | $[mol]$ | snow | -| snow-temperature | $T_{snow}$ | temperature of the snowpack | $[K]$ | snow | -| surface-ponded_depth | $h$ | ponded depth, or the water head over the surface | $[m]$ | flow | -| surface-unfrozen_effective_depth | $\eta h$ | portion of ponded depth that is unfrozen | $[m]$ | flow | -| surface-unfrozen_fraction | $\eta$ | fraction of water on the surface that is liquid (vs ice) | $[-]$ | energy | -| surface-albedo | $\alpha$ | area-weighted albedo of the surface, as seen by the canopy/atmosphere | $[-]$ | surface | -| surface-albedos.{bare,water,snow} | $\alpha$ | albedo of a given media | $[-]$ | surface | -| surface-emissivities.{bare,water,snow} | $\epsilon$ | emissivity (equivalently absorptivity) of a given media | $[-]$ | surface | -| surface-area_fractions.{bare,water,snow} | $a$ | fraction of the ground surface of a given media | $[-]$ | surface | -| surface-incoming_longwave_radiation | $Q^e_{SW}$ | longwave radiation from the atmosphere | $[W m^-2]$ | surface | -| surface-incoming_shortwave_radiation | $Q^e_{SW}$ | shortwave radiation from the atmosphere | $[W m^-2]$ | surface | -| surface-incident_shortwave_radiation | $Q^e_{SWin}$ | shortwave radiation incident on a surface (of a given slope/aspect) | $[W m^-2]$ | surface | -| surface-qE_conducted | $Q^e_{c}$ | energy conducted to the ground surface | $[W m^-2]$ | surface | -| surface-qE_lw_out | $Q^e_{LWout}$ | longwave energy radiated away from the surface | $[W m^-2]$ | surface | -| surface-qE_sensible_heat | $Q^e_{h}$ | sensible heat flux to the atmosphere | $[W m^-2]$ | surface | -| surface-qE_latent_heat | $Q^e_{E}$ | latent heat flux to the atmosphere | $[W m^-2]$ | surface | -| surface-qE_snowmelt | $Q^e_{snow}$ | latent heat released via snowmelt | $[W m^-2]$ | surface | -| surface-transpiration | $T$ | actual transpiration, integrated vertically and limited by water availability | $[m s^-1]$ | flow | -| surface-total_evapotranspiration | $ET$ | total evaporation (canopy, snow, and bare ground) plus transpiration | $[m s^-1]$ | flow | -| surface-capillary_pressure_plant | $pc_{can}$ | capillary pressure in the plant stem at the ground surface | $[Pa]$ | flow | -| surface-overland_conductivity | $k$ | coefficient for the diffusion wave equation | $[...]$ | flow | -| surface-manning_coefficient | $m_n$ | coefficient in Manning's equation, a measure of surface roughness | $[...]$ | flow | -| surface-precipitation_rain | $P_{r}$ | precipitation of rain | $[m s^{-1}]$ | surface | -| surface-air_temperature | $T_{air}$ | temperature of the air at the ground surface | $[K]$ | surface | -| surface-vapor_pressure_air | $vp_{air}$ | partial pressure of water vapor in the atmosphere | $[Pa]$ | surface | -| surface-wind_speed | ${v}_{air}$ | magnitude of the wind speed | $[m s^-1]$ | surface | -| surface-water_source | $Q_s$ | extensive sum of all sources and sinks of water as liquid (surface) | $[\mathop{\mathrm{mol}} s^{-1}]$ | flow | -| surface-elevation | $z$ | elevation | $[m]$ | | -| surface-aspect | $\psi$ | aspect, clockwise relative to North, in [0,360) | $[degrees]$ | surface | -| surface-slope_magnitude | $\vert S \vert$ | 1 - dot product of the surface's normal with the vertical | $[-]$ | flow | -| surface-water_flux | $\mathbf{q_s}$ | surface flux vector | $[\mathop{\mathrm{mol}} s^{-1}]$ | flow | -| surface-velocity.{1,2}$^4$ | $\mathbf{V_s}$ | surface water velocity vector | $[m s^{-1}]$ | flow | -| surface-evaporative_flux | $E$ | water sink due to evaporation | $[m s^{-1}]$ | flow | -| surface-evaporation | $E$ | water sink due to evaporation | $[m s^{-1}]$ | flow | -| surface-soil_resistance | $r_{soil}$ | resistance of soil to water vapor transport, used in evaporation downregulation | $[-]$ | flow | -| surface-subsurface_flux | $\mathbf{q_{ss}}$ | infiltration, the flux of water into the ground | $[\mathop{\mathrm{mol}} s^{-1}]$ | flow | -| surface-subsurface_energy_flux | $\mathbf{q^e_{ss}}$ | diffusive flux of energy into the ground | $[\mathop{\mathrm{MJ}} s^{-1}]$ | energy | -| surface-advected_energy_flux | $\mathbf{eq_s}$ | extensive energy flux due to advection (face-based) | $[\mathop{\mathrm{MJ}} s^{-1}]$ | energy | -| surface-diffusive_energy_flux | $\mathbf{q_s^e}$ | extensive energy flux due to diffusion (face-based) | $[\mathop{\mathrm{MJ}} s^{-1}]$ | energy | -| surface-water_content | $\Theta_s$ | extensive water content (liquid or ice, but not snow) of a cell$^5$ | $[\mathop{\mathrm{mol}}]$ | flow | -| surface-temperature | $T_s$ | temperature of ponded water or the ground surface | $[K]$ | energy | -| surface-source_molar_density | $n_{source}$ | molar density of all water sources (surface) | $[\mathop{\mathrm{mol}} m^{-3}]$ | flow | -| transpiration | $T$ | actual transpiration, vertically distributed to the subsurface | $[mol m^-3 s^-1]$ | flow | -| root_fraction | $f_r$ | fraction of all roots in this soil layer (vertically sums to 1) | $[-]$ | flow | -| permeability | $K$ | absolute permeability | $[m^2]$ | flow | -| relative_permeability$^1$ | $k_r$ | relative **conductivity**, $\frac{n}{\mu} k$ | see note | flow | -| molar_density_{liquid,gas,ice} | $n_{\{l,g,i\}}$ | molar density of a given phase | $[\mathop{\mathrm{mol}} m^{-3}]$ | | -| mass_density_{liquid,gas,ice} | $\rho_{\{l,g,i\}}$ | mass density of a phase | $[\mathop{\mathrm{kg}} m^{-3}]$ | | -| density_rock | $\rho_{rock}$ | mass density of the medium | $[\mathop{\mathrm{kg}} m^{-3}]$ | | -| pressure | $p$ | pressure of the liquid phase | $[\mathop{\mathrm{Pa}}]$ | flow | -| water_source | $Q$ | extensive sum of all sources and sinks of water as liquid (subsurface) | $[\mathop{\mathrm{mol}} s^{-1}]$ | flow | -| source_molar_density | $n_{source}$ | molar density of all water sources (subsurface) | $[\mathop{\mathrm{mol}} m^{-3}]$ | flow | -| saturation_{liquid,gas,ice} | $s_{\{l,g,i\}}$ | saturation of a given phase | $[-]$ | flow | -| capillary_pressure_{A}_{B} | $p_c^{A-B}$ | capillary pressure of phase A over phase B | $[Pa]$ | flow | -| viscosity_liquid | $\nu$ | dynamic viscosity of water | $[\mathop{\mathrm{Pa}} s]$ | flow | -| base_porosity | $\phi_0$ | porosity of the undeformed medium | $[-]$ | flow | -| porosity | $\phi$ | porosity of the medium, including any compressibility/specific storage | $[-]$ | flow | -| water_flux | $\mathbf{q}$ | extensive water flux (face-based) | $[\mathop{\mathrm{mol}} s^{-1}]$ | flow | -| darcy_velocity.{1,2,3}$^4$ | $\mathbf{V}$ | subsurface water velocity vector | $[m s^{-1}]$ | flow | -| water_content | $\Theta$ | extensive water content (liquid, ice, or vapor) of a cell$^5$ | $[\mathop{\mathrm{mol}}]$ | flow | -| temperature | $T$ | temperature | $[K]$ | energy | -| thermal_conductivity | $\kappa$ | thermal conductivity of the grid cell | $[\mathop{\mathrm{MW}} m^{-1} K^{-1}]$ | energy | -| total_energy_source$^2$ | $Q^e$ | extensive$^3$ sum of all sources and sinks of energy | $[\mathop{\mathrm{MJ}} s^{-1}]$ | energy | -| advected_energy_flux | $\mathbf{eq}$ | extensive energy flux due to advection (face-based) | $[\mathop{\mathrm{MJ}} s^{-1}]$ | energy | -| diffusive_energy_flux | $\mathbf{q^e}$ | extensive energy flux due to diffusion (face-based) | $[\mathop{\mathrm{MJ}} s^{-1}]$ | energy | -| internal_energy_{liquid,gas,ice,rock} | $u_X$ | specific internal energy of a given phase/medium | $[\mathop{\mathrm{MJ}} \mathop{\mathrm{mol}}^{-1}]$ | energy | -| energy | $E$ | extensive energy of a cell$^5$ | $[\mathop{\mathrm{MJ}}]$ | energy | -| enthalpy | $e$ | specific$^3$ enthalpy | $[\mathop{\mathrm{MJ}} \mathop{\mathrm{mol}}^{-1}]$ | energy | -| | | | | | +| Variable Root Name | Symbol | Description | Units | Process | +|------------------------------------------+----------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------+-----------| +| coordinate, centroid | $x$, $y$, $z$ | spatial coordinates | $[m]$ | | +| time | $t$ | time variable | $[s]$ | | +| cell_volume | $\vert V \vert$, $V$ | volume (if 3D) or area (if 2D) of a discrete element | $[m^3]$ or $[m^2]$ | | +| gravity | $g$ | gravitational acceleration vector | $[m \, s^{-2}]$ | | +| canopy-drainage | $D$ | flux of water dripping from the canopy to the ground below | $[m \, s^{-1}]$ | canopy | +| canopy-throughfall_drainage_{rain,snow} | | source of {rain,snow} to the respective layer, throughfall + drainage | $[m \, s^{-1}]$ | canopy | +| canopy-evaporation | $E_{can}$ | evaporative flux of stored water from the leaf surface | $[m \, s^{-1}]$ | canopy | +| canopy-fracwet | $f_{wet}$ | fraction of the canopy leaf area that is covered in water | $[-]$ | canopy | +| canopy-water_content | $\Theta_{can}$ | $^5$ extensive water content on the leaf surface | $[\mathop{\mathrm{mol}}] ^8$ | canopy | +| canopy-water_equivalent | | effective thickness of water (per unit surface or leaf area???) | $[m]$ | canopy | +| canopy-water_source | | sum of all sources and sinks of water to the leaf surface | $[\mathop{\mathrm{mol}} \, m^2 \, s^{-1}]$ | canopy | +| canopy-water_source_meters | | sum of all sources and sinks of water to the leaf surface | $[m \, s^{-1}]$ | canopy | +| canopy-interception | $I_{can}$ | flux of water to the canopy as intercepted rain or snow | $[m \, s^{-1}]$ | canopy | +| canopy-leaf_area_index | $LAI$ | leaf area per unit surface area | $[-]$ | canopy | +| canopy-potential_transpiration | $T_{pot}$ | potential transpiration, unlimited by water availability | $[m \, s^{-1}]$ | canopy | +| canopy-potential_transpiration_mols | $T_{pot}$ | potential transpiration, unlimited by water availability | $[\mathop{\mathrm{mol}} \, m^{-2} \, s^{-1}]$ | canopy | +| canopy-temperature | $T_{can}$ | leaf temperature, used in longwave radiation out calculation | $[K]$ | canopy | +| {canopy,snow,surface}-radiation_balance | | net energy balance including radiation and conduction (Priestley-Taylor's R - G) | | surface | +| snow-depth | $h_{snow}$ | thickness of the snowpack | $[m]$ | snow | +| snow-age | | average age of the snowpack | $[day]$ | snow | +| snow-density | $\rho_{snow}$ | Mass density of the snow | $[kg \, m^-3]$ | snow | +| snow-melt | $M$ | Snow melt rate (SWE) | $[m \mathop{\mathrm{SWE}} s^{-1}]$ | snow | +| snow-precipitation | $P_{snow}$ | precipitation of snow, in snow-water-equivalent (SWE) | $[m \mathop{\mathrm{SWE}} \, s^{-1}]$ | snow | +| snow-evaporation | $E_{snow}$ | evaporation of snow, in snow-water-equivalent (SWE) | $[m \mathop{\mathrm{SWE}} \, s^{-1}]$ | snow | +| snow-source_sink | $Q_{snow}$ | extensive sum of all sources and sinks of water as snow | $[\mathop{\mathrm{mol}} \, s^{-1}]$ ?? | snow | +| snow-water_source | $Q_{snow}$ | sum of all sources and sinks of water as snow | $[\mathop{\mathrm{mol}} \, m^{-2} s^{-1}]$ ?? | snow | +| snow-water_source_meters | $Q_{snow}$ | sum of all sources and sinks of water as snow | $[m \, s^{-1}]$ ?? | snow | +| snow-source | | sum of all sources of water as snow, excluding sinks | $[m \, s^{-1}]$ | snow | +| snow-death_rate | | If all snow disappears in a timestep, the effective rate of snow loss. | $[m \mathop{\mathrm{SWE}} s^{-1}]$ | snow | +| snow-water_equivalent | $SWE$ | equivalent "ponded_depth" if one melted the snow | $[m]$ | snow | +| snow-water_content | $\Theta_{snow}$ | $^5$ extensive water content in snow | $[\mathop{\mathrm{mol}}] ^8$ | snow | +| snow-temperature | $T_{snow}$ | temperature of the snowpack | $[K]$ | snow | +| surface-ponded_depth | $h$ | ponded depth, or the water head over the surface | $[m]$ | flow | +| surface-unfrozen_effective_depth | $\eta h$ | portion of ponded depth that is unfrozen | $[m]$ | flow | +| surface-unfrozen_fraction | $\eta$ | fraction of water on the surface that is liquid (vs ice) | $[-]$ | energy | +| surface-albedo | $\alpha$ | area-weighted albedo of the surface, as seen by the canopy/atmosphere | $[-]$ | surface | +| surface-albedos.{bare,water,snow} | $\alpha$ | albedo of a given media | $[-]$ | surface | +| surface-emissivities.{bare,water,snow} | $\epsilon$ | emissivity (equivalently absorptivity) of a given media | $[-]$ | surface | +| surface-area_fractions.{bare,water,snow} | $a$ | fraction of the ground surface of a given media | $[-]$ | surface | +| surface-incoming_longwave_radiation | $Q^e_{SW}$ | longwave radiation from the atmosphere | $[W \, m^{-2}]$ | surface | +| surface-incoming_shortwave_radiation | $Q^e_{SW}$ | shortwave radiation from the atmosphere | $[W \, m^{-2}]$ | surface | +| surface-incident_shortwave_radiation | $Q^e_{SWin}$ | shortwave radiation incident on a surface (of a given slope/aspect) | $[W \, m^{-2}]$ | surface | +| surface-qE_conducted | $Q^e_{c}$ | energy conducted to the ground surface | $[W \, m^{-2}]$ | surface | +| surface-qE_lw_out | $Q^e_{LWout}$ | longwave energy radiated away from the surface | $[W \, m^{-2}]$ | surface | +| surface-qE_sensible_heat | $Q^e_{h}$ | sensible heat flux to the atmosphere | $[W \, m^{-2}]$ | surface | +| surface-qE_latent_heat | $Q^e_{E}$ | latent heat flux to the atmosphere | $[W \, m^{-2}]$ | surface | +| surface-qE_snowmelt | $Q^e_{snow}$ | latent heat released via snowmelt | $[W \, m^{-2}]$ | surface | +| surface-transpiration | $T$ | actual transpiration, integrated vertically and limited by water availability | $[m \, s^{-1}]$ | flow | +| surface-total_evapotranspiration | $ET$ | total evaporation (canopy, snow, and bare ground) plus transpiration | $[m \, s^{-1}]$ | flow | +| surface-capillary_pressure_plant | $pc_{can}$ | capillary pressure in the plant stem at the ground surface | $[Pa]$ | flow | +| surface-overland_conductivity | $k$ | coefficient for the diffusion wave equation | $[...]$ | flow | +| surface-manning_coefficient | $m_n$ | coefficient in Manning's equation, a measure of surface roughness | $[...]$ | flow | +| surface-precipitation_rain | $P_{r}$ | precipitation of rain | $[m \, s^{-1}]$ | surface | +| surface-air_temperature | $T_{air}$ | temperature of the air at the ground surface | $[K]$ | surface | +| surface-vapor_pressure_air | $vp_{air}$ | partial pressure of water vapor in the atmosphere | $[Pa]$ | surface | +| surface-wind_speed | ${v}_{air}$ | magnitude of the wind speed | $[m \, s^{-1}]$ | surface | +| surface-water_source | $Q_s$ | extensive sum of all sources and sinks of water as liquid (surface) | $[\mathop{\mathrm{mol}} \, s^{-1}]$ | flow | +| surface-elevation | $z$ | elevation | $[m]$ | | +| surface-aspect | $\psi$ | aspect, clockwise relative to North, in [0,360) | $[degrees]$ | surface | +| surface-slope_magnitude | $\vert S \vert$ | 1 - dot product of the surface's normal with the vertical | $[-]$ | flow | +| surface-water_flux | $\mathbf{q_s}$ | surface flux vector | $[\mathop{\mathrm{mol}} \, s^{-1}]$ | flow | +| surface-velocity.{1,2} $^4$ | $\mathbf{V_s}$ | surface water velocity vector | $[m \, s^{-1}]$ | flow | +| surface-evaporative_flux | $E$ | water sink due to evaporation | $[m \, s^{-1}]$ | flow | +| surface-evaporation | $E$ | water sink due to evaporation | $[m \, s^{-1}]$ | flow | +| surface-soil_resistance | $r_{soil}$ | resistance of soil to water vapor transport, used in evaporation downregulation | $[-]$ | flow | +| surface-subsurface_flux | $\mathbf{q_{ss}}$ | infiltration, the flux of water into the ground | $[\mathop{\mathrm{mol}} \, s^{-1}]$ | flow | +| surface-subsurface_energy_flux | $\mathbf{q^e_{ss}}$ | diffusive flux of energy into the ground | $[\mathop{\mathrm{MJ}} \, s^{-1}]$ | energy | +| surface-advected_energy_flux | $\mathbf{eq_s}$ | extensive energy flux due to advection (face-based) | $[\mathop{\mathrm{MJ}} \, s^{-1}]$ | energy | +| surface-diffusive_energy_flux | $\mathbf{q_s^e}$ | extensive energy flux due to diffusion (face-based) | $[\mathop{\mathrm{MJ}} \, s^{-1}]$ | energy | +| surface-water_content | $\Theta_s$ | $^5$ extensive water content (liquid or ice, but not snow) of a cell | $[\mathop{\mathrm{mol}}]$ | flow | +| surface-temperature | $T_s$ | temperature of ponded water or the ground surface | $[K]$ | energy | +| surface-source_molar_density | $n_{source}$ | molar density of all water sources (surface) | $[\mathop{\mathrm{mol}} \, m^{-3}]$ | flow | +| transpiration | $T$ | actual transpiration, vertically distributed to the subsurface | $[\mathop{\mathrm{mol}} \, m^-3 \, s^{-1}]$ | flow | +| root_fraction | $f_r$ | fraction of all roots in this soil layer (vertically sums to 1) | $[-]$ | flow | +| permeability | $K$ | absolute permeability | $[m^2]$ | flow | +| relative_permeability $^1$ | $k_r$ | relative **conductivity**, $\frac{n}{\mu} k$ | see note | flow | +| molar_density_{liquid,gas,ice} $^7$ | $n_{\{l,g,i\}}$ | molar density of a given phase | $[\mathop{\mathrm{mol}} \, m^{-3}]$ | | +| mass_density_{liquid,gas,ice} | $\rho_{\{l,g,i\}}$ | mass density of a phase | $[\mathop{\mathrm{kg}} \, m^{-3}]$ | | +| density_rock | $\rho_{rock}$ | mass density of the medium | $[\mathop{\mathrm{kg}} \, m^{-3}]$ | | +| pressure | $p$ | pressure of the liquid phase | $[\mathop{\mathrm{Pa}}]$ | flow | +| water_source | $Q$ | extensive sum of all sources and sinks of water as liquid (subsurface) | $[\mathop{\mathrm{mol}} \, s^{-1}]$ | flow | +| source_molar_density | $n_{source}$ | molar density of all water sources (subsurface) | $[\mathop{\mathrm{mol}} \, m^{-3}]$ | flow | +| saturation_{liquid,gas,ice} | $s_{\{l,g,i\}}$ | saturation of a given phase | $[-]$ | flow | +| capillary_pressure_{A}_{B} | $p_c^{A-B}$ | capillary pressure of phase A over phase B | $[Pa]$ | flow | +| viscosity_liquid | $\nu$ | dynamic viscosity of water | $[\mathop{\mathrm{Pa}} \, s]$ | flow | +| base_porosity | $\phi_0$ | porosity of the undeformed medium | $[-]$ | flow | +| porosity | $\phi$ | porosity of the medium, including any compressibility/specific storage | $[-]$ | flow | +| water_flux | $\mathbf{q}$ | extensive water flux (face-based) | $[\mathop{\mathrm{mol}} \, s^{-1}]$ | flow | +| darcy_velocity.{1,2,3} $^4$ | $\mathbf{V}$ | subsurface water velocity vector | $[m \, s^{-1}]$ | flow | +| water_content | $\Theta$ | $^5$ extensive water content (liquid, ice, or vapor) of a cell | $[\mathop{\mathrm{mol}}] ^8$ | flow | +| temperature | $T$ | temperature | $[K]$ | energy | +| thermal_conductivity | $\kappa$ | thermal conductivity of the grid cell | $[\mathop{\mathrm{MW}} \, m^{-1} \, K^{-1}]$ | energy | +| total_energy_source $^2$ | $Q^e$ | $^3$ extensive sum of all sources and sinks of energy | $[\mathop{\mathrm{MJ}} \, s^{-1}]$ | energy | +| advected_energy_flux | $\mathbf{eq}$ | extensive energy flux due to advection (face-based) | $[\mathop{\mathrm{MJ}} \, s^{-1}]$ | energy | +| diffusive_energy_flux | $\mathbf{q^e}$ | extensive energy flux due to diffusion (face-based) | $[\mathop{\mathrm{MJ}} \, s^{-1}]$ | energy | +| internal_energy_{liquid,gas,ice,rock} | $u_X$ | $^6$ specific internal energy of a given phase/medium | $[\mathop{\mathrm{MJ}} \, \mathop{\mathrm{mol}}^{-1}]$ | energy | +| energy | $E$ | $^5$ extensive energy of a cell | $[\mathop{\mathrm{MJ}}]$ | energy | +| enthalpy | $e$ | $^6$ specific enthalpy | $[\mathop{\mathrm{MJ}} \, \mathop{\mathrm{mol}}^{-1}]$ | energy | +| mole_ratio | $\xi^C$ | ratio of mols of C to mols of H2O, typically in the liquid phase | $[\mathop{\mathrm{mol C}} \, \mathop{\mathrm{mol H2O}}^{-1}] ^9$ | transport | +| total_component_concentration | $C$ | concentration of a component C in liquid water | $[\mathop{\mathrm{mol C}} \, L^{-1} | chemistry | +| mineral_volume_fractions | | mineral volume fractions for solid phase reactions | $[-]$ | chemistry | +| mineral_specific_surface_area | | specific surface area of solid phase | $[m^2 \mathop{\mathrm{(surface area)}} m^-3]$ | chemistry | +| mineral_rate_constant | | reaction rate constants for solid phase | ?? | chemistry | +| surface_site_density | | density of sites for surface complexation ?? | ?? | chemistry | +| total_sorbed | C^{sorb} | concentration of sorbed C | $[\mathop{\mathrm{mol C}} \, L^{-1}]$ | chemistry | +| isotherm_kd | | isotherm k | ?? | chemistry | +| isotherm_freundlich_n | | Freundlich's n for isotherms | ?? | chemistry | +| isotherm_langmuir_b | | Langmuir's b for isotherms | ?? | chemistry | +| first_order_decay_rate_constant | k_{C1,C2} | decay rate constant for first order reactions from C1 to C2 | ?? | chemistry | +| cation_exchange_capacity | CEC | cation exchange capacity | ?? | chemistry | +| aux_data | | auxiliary data needed by the geochemical engine | n/a | chemistry | + + diff --git a/docs/documentation/source/input_spec/symbol_table.rst b/docs/documentation/source/input_spec/symbol_table.rst index 41bc92cb2..049a78941 100644 --- a/docs/documentation/source/input_spec/symbol_table.rst +++ b/docs/documentation/source/input_spec/symbol_table.rst @@ -1,204 +1,227 @@ .. table:: - :class: datatable - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | Variable Root Name | Symbol | Description | Units | Process | - +===========================================+==================================+==================================================================================+===========================================================+=========+ - | coordinate, centroid | :math:`x`, :math:`y`, :math:`z` | spatial coordinates | :math:`[m]` | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | time | :math:`t` | time variable | :math:`[s]` | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | cell\_volume | :math:`\vert V \vert`, :math:`V` | volume (if 3D) or area (if 2D) of a discrete element | :math:`[m^3]` or :math:`[m^2]` | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | gravity | :math:`g` | gravitational acceleration vector | :math:`[m s^{-2}]` | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-drainage | :math:`D` | flux of water dripping from the canopy to the ground below | :math:`[m s^-1]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-throughfall\_drainage\_{rain,snow} | \ | source of {rain,snow} to the respective layer, throughfall + drainage | :math:`[m s^-1]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-evaporation | :math:`E_{can}` | evaporative flux of stored water from the leaf surface | :math:`[m s^-1]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-fracwet | :math:`f_{wet}` | fraction of the canopy leaf area that is covered in water | :math:`[-]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-water\_content | :math:`\Theta_{can}` | extensive water content on the leaf surface:math:`^5` | :math:`[mol]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-water\_equivalent | \ | effective thickness of water (per unit surface or leaf area???) | :math:`[m]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-water\_source | \ | sum of all sources and sinks of water to the leaf surface | :math:`[mol m^2 s^-1]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-water\_source\_meters | \ | sum of all sources and sinks of water to the leaf surface | :math:`[m s^-1]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-interception | :math:`I_{can}` | flux of water to the canopy as intercepted rain or snow | :math:`[m s^-1]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-leaf\_area\_index | :math:`LAI` | leaf area per unit surface area | :math:`[-]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-potential\_transpiration | :math:`T_{pot}` | potential transpiration, unlimited by water availability | :math:`[m s^-1]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-potential\_transpiration\_mols | :math:`T_{pot}` | potential transpiration, unlimited by water availability | :math:`[mol m^-2 s^-1]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | canopy-temperature | :math:`T_{can}` | leaf temperature, used in longwave radiation out calculation | :math:`[K]` | canopy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | {canopy,snow,surface}-radiation\_balance | \ | net energy balance including radiation and conduction (Priestley-Taylor's R - G) | surface | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-depth | :math:`h_{snow}` | thickness of the snowpack | :math:`[m]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-age | \ | average age of the snowpack | :math:`[day]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-density | :math:`\rho_{snow}` | Mass density of the snow | :math:`[kg m^-3]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-melt | :math:`M` | Snow melt rate (SWE) | :math:`[m SWE s^-1]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-precipitation | :math:`P_{snow}` | precipitation of snow, in snow-water-equivalent (SWE) | :math:`[m \mathop{\mathrm{SWE}} s^{-1}]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-evaporation | :math:`E_{snow}` | evaporation of snow, in snow-water-equivalent (SWE) | :math:`[m \mathop{\mathrm{SWE}} s^{-1}]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-source\_sink | :math:`Q_{snow}` | extensive sum of all sources and sinks of water as snow | :math:`[mol s^{-1}]` ?? | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-water\_source | :math:`Q_{snow}` | sum of all sources and sinks of water as snow | :math:`[mol m^-2 s^{-1}]` ?? | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-water\_source\_meters | :math:`Q_{snow}` | sum of all sources and sinks of water as snow | :math:`[m s^{-1}]` ?? | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-source | \ | sum of all sources of water as snow, excluding sinks | :math:`[m s^{-1}]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-death\_rate | \ | If all snow disappears in a timestep, the effective rate of snow loss. | :math:`[m SWE s^-1]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-water\_equivalent | :math:`SWE` | equivalent "ponded\_depth" if one melted the snow | :math:`[m]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-water\_content | :math:`\Theta_{snow}` | extensive water content in snow:math:`^5` | :math:`[mol]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | snow-temperature | :math:`T_{snow}` | temperature of the snowpack | :math:`[K]` | snow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-ponded\_depth | :math:`h` | ponded depth, or the water head over the surface | :math:`[m]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-unfrozen\_effective\_depth | :math:`\eta h` | portion of ponded depth that is unfrozen | :math:`[m]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-unfrozen\_fraction | :math:`\eta` | fraction of water on the surface that is liquid (vs ice) | :math:`[-]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-albedo | :math:`\alpha` | area-weighted albedo of the surface, as seen by the canopy/atmosphere | :math:`[-]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-albedos.{bare,water,snow} | :math:`\alpha` | albedo of a given media | :math:`[-]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-emissivities.{bare,water,snow} | :math:`\epsilon` | emissivity (equivalently absorptivity) of a given media | :math:`[-]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-area\_fractions.{bare,water,snow} | :math:`a` | fraction of the ground surface of a given media | :math:`[-]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-incoming\_longwave\_radiation | :math:`Q^e_{SW}` | longwave radiation from the atmosphere | :math:`[W m^-2]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-incoming\_shortwave\_radiation | :math:`Q^e_{SW}` | shortwave radiation from the atmosphere | :math:`[W m^-2]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-incident\_shortwave\_radiation | :math:`Q^e_{SWin}` | shortwave radiation incident on a surface (of a given slope/aspect) | :math:`[W m^-2]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-qE\_conducted | :math:`Q^e_{c}` | energy conducted to the ground surface | :math:`[W m^-2]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-qE\_lw\_out | :math:`Q^e_{LWout}` | longwave energy radiated away from the surface | :math:`[W m^-2]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-qE\_sensible\_heat | :math:`Q^e_{h}` | sensible heat flux to the atmosphere | :math:`[W m^-2]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-qE\_latent\_heat | :math:`Q^e_{E}` | latent heat flux to the atmosphere | :math:`[W m^-2]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-qE\_snowmelt | :math:`Q^e_{snow}` | latent heat released via snowmelt | :math:`[W m^-2]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-transpiration | :math:`T` | actual transpiration, integrated vertically and limited by water availability | :math:`[m s^-1]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-total\_evapotranspiration | :math:`ET` | total evaporation (canopy, snow, and bare ground) plus transpiration | :math:`[m s^-1]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-capillary\_pressure\_plant | :math:`pc_{can}` | capillary pressure in the plant stem at the ground surface | :math:`[Pa]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-overland\_conductivity | :math:`k` | coefficient for the diffusion wave equation | :math:`[...]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-manning\_coefficient | :math:`m_n` | coefficient in Manning's equation, a measure of surface roughness | :math:`[...]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-precipitation\_rain | :math:`P_{r}` | precipitation of rain | :math:`[m s^{-1}]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-air\_temperature | :math:`T_{air}` | temperature of the air at the ground surface | :math:`[K]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-vapor\_pressure\_air | :math:`vp_{air}` | partial pressure of water vapor in the atmosphere | :math:`[Pa]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-wind\_speed | :math:`{v}_{air}` | magnitude of the wind speed | :math:`[m s^-1]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-water\_source | :math:`Q_s` | extensive sum of all sources and sinks of water as liquid (surface) | :math:`[\mathop{\mathrm{mol}} s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-elevation | :math:`z` | elevation | :math:`[m]` | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-aspect | :math:`\psi` | aspect, clockwise relative to North, in [0,360) | :math:`[degrees]` | surface | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-slope\_magnitude | :math:`\vert S \vert` | 1 - dot product of the surface's normal with the vertical | :math:`[-]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-water\_flux | :math:`\mathbf{q_s}` | surface flux vector | :math:`[\mathop{\mathrm{mol}} s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-velocity.{1,2}:math:`^4` | :math:`\mathbf{V_s}` | surface water velocity vector | :math:`[m s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-evaporative\_flux | :math:`E` | water sink due to evaporation | :math:`[m s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-evaporation | :math:`E` | water sink due to evaporation | :math:`[m s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-soil\_resistance | :math:`r_{soil}` | resistance of soil to water vapor transport, used in evaporation downregulation | :math:`[-]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-subsurface\_flux | :math:`\mathbf{q_{ss}}` | infiltration, the flux of water into the ground | :math:`[\mathop{\mathrm{mol}} s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-subsurface\_energy\_flux | :math:`\mathbf{q^e_{ss}}` | diffusive flux of energy into the ground | :math:`[\mathop{\mathrm{MJ}} s^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-advected\_energy\_flux | :math:`\mathbf{eq_s}` | extensive energy flux due to advection (face-based) | :math:`[\mathop{\mathrm{MJ}} s^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-diffusive\_energy\_flux | :math:`\mathbf{q_s^e}` | extensive energy flux due to diffusion (face-based) | :math:`[\mathop{\mathrm{MJ}} s^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-water\_content | :math:`\Theta_s` | extensive water content (liquid or ice, but not snow) of a cell:math:`^5` | :math:`[\mathop{\mathrm{mol}}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-temperature | :math:`T_s` | temperature of ponded water or the ground surface | :math:`[K]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | surface-source\_molar\_density | :math:`n_{source}` | molar density of all water sources (surface) | :math:`[\mathop{\mathrm{mol}} m^{-3}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | transpiration | :math:`T` | actual transpiration, vertically distributed to the subsurface | :math:`[mol m^-3 s^-1]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | root\_fraction | :math:`f_r` | fraction of all roots in this soil layer (vertically sums to 1) | :math:`[-]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | permeability | :math:`K` | absolute permeability | :math:`[m^2]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | relative\_permeability:math:`^1` | :math:`k_r` | relative ****conductivity****, :math:`\frac{n}{\mu} k` | see note | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | molar\_density\_{liquid,gas,ice} | :math:`n_{\{l,g,i\}}` | molar density of a given phase | :math:`[\mathop{\mathrm{mol}} m^{-3}]` | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | mass\_density\_{liquid,gas,ice} | :math:`\rho_{\{l,g,i\}}` | mass density of a phase | :math:`[\mathop{\mathrm{kg}} m^{-3}]` | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | density\_rock | :math:`\rho_{rock}` | mass density of the medium | :math:`[\mathop{\mathrm{kg}} m^{-3}]` | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | pressure | :math:`p` | pressure of the liquid phase | :math:`[\mathop{\mathrm{Pa}}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | water\_source | :math:`Q` | extensive sum of all sources and sinks of water as liquid (subsurface) | :math:`[\mathop{\mathrm{mol}} s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | source\_molar\_density | :math:`n_{source}` | molar density of all water sources (subsurface) | :math:`[\mathop{\mathrm{mol}} m^{-3}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | saturation\_{liquid,gas,ice} | :math:`s_{\{l,g,i\}}` | saturation of a given phase | :math:`[-]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | capillary\_pressure\_{A}\_{B} | :math:`p_c^{A-B}` | capillary pressure of phase A over phase B | :math:`[Pa]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | viscosity\_liquid | :math:`\nu` | dynamic viscosity of water | :math:`[\mathop{\mathrm{Pa}} s]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | base\_porosity | :math:`\phi_0` | porosity of the undeformed medium | :math:`[-]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | porosity | :math:`\phi` | porosity of the medium, including any compressibility/specific storage | :math:`[-]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | water\_flux | :math:`\mathbf{q}` | extensive water flux (face-based) | :math:`[\mathop{\mathrm{mol}} s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | darcy\_velocity.{1,2,3}:math:`^4` | :math:`\mathbf{V}` | subsurface water velocity vector | :math:`[m s^{-1}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | water\_content | :math:`\Theta` | extensive water content (liquid, ice, or vapor) of a cell:math:`^5` | :math:`[\mathop{\mathrm{mol}}]` | flow | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | temperature | :math:`T` | temperature | :math:`[K]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | thermal\_conductivity | :math:`\kappa` | thermal conductivity of the grid cell | :math:`[\mathop{\mathrm{MW}} m^{-1} K^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | total\_energy\_source:math:`^2` | :math:`Q^e` | extensive:math:`^3` sum of all sources and sinks of energy | :math:`[\mathop{\mathrm{MJ}} s^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | advected\_energy\_flux | :math:`\mathbf{eq}` | extensive energy flux due to advection (face-based) | :math:`[\mathop{\mathrm{MJ}} s^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | diffusive\_energy\_flux | :math:`\mathbf{q^e}` | extensive energy flux due to diffusion (face-based) | :math:`[\mathop{\mathrm{MJ}} s^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | internal\_energy\_{liquid,gas,ice,rock} | :math:`u_X` | specific internal energy of a given phase/medium | :math:`[\mathop{\mathrm{MJ}} \mathop{\mathrm{mol}}^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | energy | :math:`E` | extensive energy of a cell:math:`^5` | :math:`[\mathop{\mathrm{MJ}}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | enthalpy | :math:`e` | specific:math:`^3` enthalpy | :math:`[\mathop{\mathrm{MJ}} \mathop{\mathrm{mol}}^{-1}]` | energy | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ - | \ | \ | \ | \ | \ | - +-------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+-----------------------------------------------------------+---------+ + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | Variable Root Name | Symbol | Description | Units | Process | + +=============================================+==================================+==================================================================================+========================================================================+===========+ + | coordinate, centroid | :math:`x`, :math:`y`, :math:`z` | spatial coordinates | :math:`[m]` | \ | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | time | :math:`t` | time variable | :math:`[s]` | \ | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | cell\_volume | :math:`\vert V \vert`, :math:`V` | volume (if 3D) or area (if 2D) of a discrete element | :math:`[m^3]` or :math:`[m^2]` | \ | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | gravity | :math:`g` | gravitational acceleration vector | :math:`[m \, s^{-2}]` | \ | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-drainage | :math:`D` | flux of water dripping from the canopy to the ground below | :math:`[m \, s^{-1}]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-throughfall\_drainage\_{rain,snow} | \ | source of {rain,snow} to the respective layer, throughfall + drainage | :math:`[m \, s^{-1}]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-evaporation | :math:`E_{can}` | evaporative flux of stored water from the leaf surface | :math:`[m \, s^{-1}]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-fracwet | :math:`f_{wet}` | fraction of the canopy leaf area that is covered in water | :math:`[-]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-water\_content | :math:`\Theta_{can}` | :math:`^5` extensive water content on the leaf surface | :math:`[\mathop{\mathrm{mol}}] ^8` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-water\_equivalent | \ | effective thickness of water (per unit surface or leaf area???) | :math:`[m]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-water\_source | \ | sum of all sources and sinks of water to the leaf surface | :math:`[\mathop{\mathrm{mol}} \, m^2 \, s^{-1}]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-water\_source\_meters | \ | sum of all sources and sinks of water to the leaf surface | :math:`[m \, s^{-1}]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-interception | :math:`I_{can}` | flux of water to the canopy as intercepted rain or snow | :math:`[m \, s^{-1}]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-leaf\_area\_index | :math:`LAI` | leaf area per unit surface area | :math:`[-]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-potential\_transpiration | :math:`T_{pot}` | potential transpiration, unlimited by water availability | :math:`[m \, s^{-1}]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-potential\_transpiration\_mols | :math:`T_{pot}` | potential transpiration, unlimited by water availability | :math:`[\mathop{\mathrm{mol}} \, m^{-2} \, s^{-1}]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | canopy-temperature | :math:`T_{can}` | leaf temperature, used in longwave radiation out calculation | :math:`[K]` | canopy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | {canopy,snow,surface}-radiation\_balance | \ | net energy balance including radiation and conduction (Priestley-Taylor's R - G) | \ | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-depth | :math:`h_{snow}` | thickness of the snowpack | :math:`[m]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-age | \ | average age of the snowpack | :math:`[day]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-density | :math:`\rho_{snow}` | Mass density of the snow | :math:`[kg \, m^-3]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-melt | :math:`M` | Snow melt rate (SWE) | :math:`[m \mathop{\mathrm{SWE}} s^{-1}]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-precipitation | :math:`P_{snow}` | precipitation of snow, in snow-water-equivalent (SWE) | :math:`[m \mathop{\mathrm{SWE}} \, s^{-1}]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-evaporation | :math:`E_{snow}` | evaporation of snow, in snow-water-equivalent (SWE) | :math:`[m \mathop{\mathrm{SWE}} \, s^{-1}]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-source\_sink | :math:`Q_{snow}` | extensive sum of all sources and sinks of water as snow | :math:`[\mathop{\mathrm{mol}} \, s^{-1}]` ?? | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-water\_source | :math:`Q_{snow}` | sum of all sources and sinks of water as snow | :math:`[\mathop{\mathrm{mol}} \, m^{-2} s^{-1}]` ?? | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-water\_source\_meters | :math:`Q_{snow}` | sum of all sources and sinks of water as snow | :math:`[m \, s^{-1}]` ?? | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-source | \ | sum of all sources of water as snow, excluding sinks | :math:`[m \, s^{-1}]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-death\_rate | \ | If all snow disappears in a timestep, the effective rate of snow loss. | :math:`[m \mathop{\mathrm{SWE}} s^{-1}]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-water\_equivalent | :math:`SWE` | equivalent "ponded\_depth" if one melted the snow | :math:`[m]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-water\_content | :math:`\Theta_{snow}` | :math:`^5` extensive water content in snow | :math:`[\mathop{\mathrm{mol}}] ^8` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | snow-temperature | :math:`T_{snow}` | temperature of the snowpack | :math:`[K]` | snow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-ponded\_depth | :math:`h` | ponded depth, or the water head over the surface | :math:`[m]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-unfrozen\_effective\_depth | :math:`\eta h` | portion of ponded depth that is unfrozen | :math:`[m]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-unfrozen\_fraction | :math:`\eta` | fraction of water on the surface that is liquid (vs ice) | :math:`[-]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-albedo | :math:`\alpha` | area-weighted albedo of the surface, as seen by the canopy/atmosphere | :math:`[-]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-albedos.{bare,water,snow} | :math:`\alpha` | albedo of a given media | :math:`[-]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-emissivities.{bare,water,snow} | :math:`\epsilon` | emissivity (equivalently absorptivity) of a given media | :math:`[-]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-area\_fractions.{bare,water,snow} | :math:`a` | fraction of the ground surface of a given media | :math:`[-]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-incoming\_longwave\_radiation | :math:`Q^e_{SW}` | longwave radiation from the atmosphere | :math:`[W \, m^{-2}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-incoming\_shortwave\_radiation | :math:`Q^e_{SW}` | shortwave radiation from the atmosphere | :math:`[W \, m^{-2}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-incident\_shortwave\_radiation | :math:`Q^e_{SWin}` | shortwave radiation incident on a surface (of a given slope/aspect) | :math:`[W \, m^{-2}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-qE\_conducted | :math:`Q^e_{c}` | energy conducted to the ground surface | :math:`[W \, m^{-2}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-qE\_lw\_out | :math:`Q^e_{LWout}` | longwave energy radiated away from the surface | :math:`[W \, m^{-2}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-qE\_sensible\_heat | :math:`Q^e_{h}` | sensible heat flux to the atmosphere | :math:`[W \, m^{-2}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-qE\_latent\_heat | :math:`Q^e_{E}` | latent heat flux to the atmosphere | :math:`[W \, m^{-2}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-qE\_snowmelt | :math:`Q^e_{snow}` | latent heat released via snowmelt | :math:`[W \, m^{-2}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-transpiration | :math:`T` | actual transpiration, integrated vertically and limited by water availability | :math:`[m \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-total\_evapotranspiration | :math:`ET` | total evaporation (canopy, snow, and bare ground) plus transpiration | :math:`[m \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-capillary\_pressure\_plant | :math:`pc_{can}` | capillary pressure in the plant stem at the ground surface | :math:`[Pa]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-overland\_conductivity | :math:`k` | coefficient for the diffusion wave equation | :math:`[...]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-manning\_coefficient | :math:`m_n` | coefficient in Manning's equation, a measure of surface roughness | :math:`[...]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-precipitation\_rain | :math:`P_{r}` | precipitation of rain | :math:`[m \, s^{-1}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-air\_temperature | :math:`T_{air}` | temperature of the air at the ground surface | :math:`[K]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-vapor\_pressure\_air | :math:`vp_{air}` | partial pressure of water vapor in the atmosphere | :math:`[Pa]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-wind\_speed | :math:`{v}_{air}` | magnitude of the wind speed | :math:`[m \, s^{-1}]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-water\_source | :math:`Q_s` | extensive sum of all sources and sinks of water as liquid (surface) | :math:`[\mathop{\mathrm{mol}} \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-elevation | :math:`z` | elevation | :math:`[m]` | \ | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-aspect | :math:`\psi` | aspect, clockwise relative to North, in [0,360) | :math:`[degrees]` | surface | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-slope\_magnitude | :math:`\vert S \vert` | 1 - dot product of the surface's normal with the vertical | :math:`[-]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-water\_flux | :math:`\mathbf{q_s}` | surface flux vector | :math:`[\mathop{\mathrm{mol}} \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-velocity.{1,2} :math:`^4` | :math:`\mathbf{V_s}` | surface water velocity vector | :math:`[m \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-evaporative\_flux | :math:`E` | water sink due to evaporation | :math:`[m \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-evaporation | :math:`E` | water sink due to evaporation | :math:`[m \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-soil\_resistance | :math:`r_{soil}` | resistance of soil to water vapor transport, used in evaporation downregulation | :math:`[-]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-subsurface\_flux | :math:`\mathbf{q_{ss}}` | infiltration, the flux of water into the ground | :math:`[\mathop{\mathrm{mol}} \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-subsurface\_energy\_flux | :math:`\mathbf{q^e_{ss}}` | diffusive flux of energy into the ground | :math:`[\mathop{\mathrm{MJ}} \, s^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-advected\_energy\_flux | :math:`\mathbf{eq_s}` | extensive energy flux due to advection (face-based) | :math:`[\mathop{\mathrm{MJ}} \, s^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-diffusive\_energy\_flux | :math:`\mathbf{q_s^e}` | extensive energy flux due to diffusion (face-based) | :math:`[\mathop{\mathrm{MJ}} \, s^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-water\_content | :math:`\Theta_s` | :math:`^5` extensive water content (liquid or ice, but not snow) of a cell | :math:`[\mathop{\mathrm{mol}}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-temperature | :math:`T_s` | temperature of ponded water or the ground surface | :math:`[K]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface-source\_molar\_density | :math:`n_{source}` | molar density of all water sources (surface) | :math:`[\mathop{\mathrm{mol}} \, m^{-3}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | transpiration | :math:`T` | actual transpiration, vertically distributed to the subsurface | :math:`[\mathop{\mathrm{mol}} \, m^-3 \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | root\_fraction | :math:`f_r` | fraction of all roots in this soil layer (vertically sums to 1) | :math:`[-]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | permeability | :math:`K` | absolute permeability | :math:`[m^2]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | relative\_permeability :math:`^1` | :math:`k_r` | relative ****conductivity****, :math:`\frac{n}{\mu} k` | see note | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | molar\_density\_{liquid,gas,ice} :math:`^7` | :math:`n_{\{l,g,i\}}` | molar density of a given phase | :math:`[\mathop{\mathrm{mol}} \, m^{-3}]` | \ | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | mass\_density\_{liquid,gas,ice} | :math:`\rho_{\{l,g,i\}}` | mass density of a phase | :math:`[\mathop{\mathrm{kg}} \, m^{-3}]` | \ | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | density\_rock | :math:`\rho_{rock}` | mass density of the medium | :math:`[\mathop{\mathrm{kg}} \, m^{-3}]` | \ | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | pressure | :math:`p` | pressure of the liquid phase | :math:`[\mathop{\mathrm{Pa}}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | water\_source | :math:`Q` | extensive sum of all sources and sinks of water as liquid (subsurface) | :math:`[\mathop{\mathrm{mol}} \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | source\_molar\_density | :math:`n_{source}` | molar density of all water sources (subsurface) | :math:`[\mathop{\mathrm{mol}} \, m^{-3}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | saturation\_{liquid,gas,ice} | :math:`s_{\{l,g,i\}}` | saturation of a given phase | :math:`[-]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | capillary\_pressure\_{A}\_{B} | :math:`p_c^{A-B}` | capillary pressure of phase A over phase B | :math:`[Pa]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | viscosity\_liquid | :math:`\nu` | dynamic viscosity of water | :math:`[\mathop{\mathrm{Pa}} \, s]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | base\_porosity | :math:`\phi_0` | porosity of the undeformed medium | :math:`[-]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | porosity | :math:`\phi` | porosity of the medium, including any compressibility/specific storage | :math:`[-]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | water\_flux | :math:`\mathbf{q}` | extensive water flux (face-based) | :math:`[\mathop{\mathrm{mol}} \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | darcy\_velocity.{1,2,3} :math:`^4` | :math:`\mathbf{V}` | subsurface water velocity vector | :math:`[m \, s^{-1}]` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | water\_content | :math:`\Theta` | :math:`^5` extensive water content (liquid, ice, or vapor) of a cell | :math:`[\mathop{\mathrm{mol}}] ^8` | flow | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | temperature | :math:`T` | temperature | :math:`[K]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | thermal\_conductivity | :math:`\kappa` | thermal conductivity of the grid cell | :math:`[\mathop{\mathrm{MW}} \, m^{-1} \, K^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | total\_energy\_source :math:`^2` | :math:`Q^e` | :math:`^3` extensive sum of all sources and sinks of energy | :math:`[\mathop{\mathrm{MJ}} \, s^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | advected\_energy\_flux | :math:`\mathbf{eq}` | extensive energy flux due to advection (face-based) | :math:`[\mathop{\mathrm{MJ}} \, s^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | diffusive\_energy\_flux | :math:`\mathbf{q^e}` | extensive energy flux due to diffusion (face-based) | :math:`[\mathop{\mathrm{MJ}} \, s^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | internal\_energy\_{liquid,gas,ice,rock} | :math:`u_X` | :math:`^6` specific internal energy of a given phase/medium | :math:`[\mathop{\mathrm{MJ}} \, \mathop{\mathrm{mol}}^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | energy | :math:`E` | :math:`^5` extensive energy of a cell | :math:`[\mathop{\mathrm{MJ}}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | enthalpy | :math:`e` | :math:`^6` specific enthalpy | :math:`[\mathop{\mathrm{MJ}} \, \mathop{\mathrm{mol}}^{-1}]` | energy | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | mole\_ratio | :math:`\xi^C` | ratio of mols of C to mols of H2O, typically in the liquid phase | :math:`[\mathop{\mathrm{mol C}} \, \mathop{\mathrm{mol H2O}}^{-1}] ^9` | transport | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | total\_component\_concentration | :math:`C` | concentration of a component C in liquid water | $[\mathop{\mathrm{mol C}} \\, L^{-1} | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | mineral\_volume\_fractions | \ | mineral volume fractions for solid phase reactions | :math:`[-]` | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | mineral\_specific\_surface\_area | \ | specific surface area of solid phase | :math:`[m^2 \mathop{\mathrm{(surface area)}} m^-3]` | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | mineral\_rate\_constant | \ | reaction rate constants for solid phase | ?? | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | surface\_site\_density | \ | density of sites for surface complexation ?? | ?? | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | total\_sorbed | C^{sorb} | concentration of sorbed C | :math:`[\mathop{\mathrm{mol C}} \, L^{-1}]` | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | isotherm\_kd | \ | isotherm k | ?? | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | isotherm\_freundlich\_n | \ | Freundlich's n for isotherms | ?? | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | isotherm\_langmuir\_b | \ | Langmuir's b for isotherms | ?? | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | first\_order\_decay\_rate\_constant | k\_{C1,C2} | decay rate constant for first order reactions from C1 to C2 | ?? | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | cation\_exchange\_capacity | CEC | cation exchange capacity | ?? | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ + | aux\_data | \ | auxiliary data needed by the geochemical engine | n/a | chemistry | + +---------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+------------------------------------------------------------------------+-----------+ diff --git a/docs/documentation/source/input_spec/symbol_table_notes.rst b/docs/documentation/source/input_spec/symbol_table_notes.rst index 84a6cc89e..ee2fb57e6 100644 --- a/docs/documentation/source/input_spec/symbol_table_notes.rst +++ b/docs/documentation/source/input_spec/symbol_table_notes.rst @@ -10,13 +10,13 @@ averaged to faces, while the absolute permeability may be a tensor. We therefore store the first three terms together, but incorrectly call this "relative_permeability." Furthermore, - because K is order :math:`10^{\{-10 \dash -15\}}`, but + because K is order :math:`10^{\{-10 -- -15\}}`, but :math:`\frac{{n}}{{\mu}}` is order :math:`10^7`, we are multiplying a very small number by a very large number, a classic problem in numerics. Therefore, we typically rescale both, moving 7 orders of magnitude off of the scalar and putting them on the tensor. As a result, the units of this variable are - something like: :math:`[mol m^-3 Pa^-1 s^-1 10^7]`, and typical + something like: [mol m^-3 Pa^-1 s^-1 10^7]`, and typical values range from 0 to ~6. Note that the rescaling factor is NOT stored on the absolute permeability, so permeability is in the typical units :math:`[m^2]`. @@ -31,4 +31,9 @@ 6. We use the word "specific" to mean a quantity that is per unit extent, e.g. specific enthalpy is per unit mol of water, or specific leaf area is per unit dry mass. - + 7. This is somewhat of a misnomer -- molar density is a property of + a component in a phase. These are the molar density of H2O in a + given phase, not total mols in a given phase. Perhaps a better + name would be molar_density_water_as_liquid. + 8. Note that, unless otherwise specified, [mol] always means mols of water. + 9. [mol C] implies mols of an arbitrary component C. diff --git a/src/constitutive_relations/column_integrators/ColumnSumEvaluator.cc b/src/constitutive_relations/column_integrators/ColumnSumEvaluator.cc index 360203651..acac33aa2 100644 --- a/src/constitutive_relations/column_integrators/ColumnSumEvaluator.cc +++ b/src/constitutive_relations/column_integrators/ColumnSumEvaluator.cc @@ -86,8 +86,12 @@ IntegratorColumnSum::scan(AmanziMesh::Entity_ID col, AmanziGeometry::Point& p) { double contrib = (*integrand_)[0][c]; - if (volume_average_ || volume_factor_) { contrib *= (*cv_)[0][c]; } - if (divide_by_density_) { contrib /= (*dens_)[0][c]; } + if (volume_average_ || volume_factor_) { + contrib *= (*cv_)[0][c]; + } + if (divide_by_density_) { + contrib /= (*dens_)[0][c]; + } p[0] += contrib; if (volume_average_) p[1] += (*cv_)[0][c]; diff --git a/src/constitutive_relations/column_integrators/ColumnSumEvaluator.hh b/src/constitutive_relations/column_integrators/ColumnSumEvaluator.hh index cc06b8c44..d7e151769 100644 --- a/src/constitutive_relations/column_integrators/ColumnSumEvaluator.hh +++ b/src/constitutive_relations/column_integrators/ColumnSumEvaluator.hh @@ -16,8 +16,8 @@ divide by surface cell area) and density (useful for the most common use case of summing fluxes onto the surface and converting to m/s instead of mol/m^2/s). -.. _column-sum-evaluator-spec: -.. admonition:: column-sum-evaluator-spec +.. _evaluator-column-sum-spec: +.. admonition:: evaluator-column-sum-spec * `"include volume factor`" ``[bool]`` **true** In summing, multiply the summand subsurface cell volume, then divide the sum by the surface cell diff --git a/src/constitutive_relations/column_integrators/EvaluatorColumnIntegrator.hh b/src/constitutive_relations/column_integrators/EvaluatorColumnIntegrator.hh index a515e5e66..382b53f39 100644 --- a/src/constitutive_relations/column_integrators/EvaluatorColumnIntegrator.hh +++ b/src/constitutive_relations/column_integrators/EvaluatorColumnIntegrator.hh @@ -26,7 +26,7 @@ Clients should provide a struct functor that does the actual work, and returns namespace Amanzi { namespace Relations { -template +template class EvaluatorColumnIntegrator : public EvaluatorSecondaryMonotypeCV { public: explicit EvaluatorColumnIntegrator(Teuchos::ParameterList& plist); @@ -34,8 +34,9 @@ class EvaluatorColumnIntegrator : public EvaluatorSecondaryMonotypeCV { Teuchos::RCP Clone() const override; // Disables derivatives - virtual bool - IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override; + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override; protected: // Implements custom EC to use dependencies from subsurface for surface @@ -55,7 +56,7 @@ class EvaluatorColumnIntegrator : public EvaluatorSecondaryMonotypeCV { }; -template +template EvaluatorColumnIntegrator::EvaluatorColumnIntegrator( Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(plist) @@ -65,7 +66,7 @@ EvaluatorColumnIntegrator::EvaluatorColumnIntegrator( } -template +template Teuchos::RCP EvaluatorColumnIntegrator::Clone() const { @@ -75,7 +76,7 @@ EvaluatorColumnIntegrator::Clone() const // Implements custom EC to use dependencies from subsurface for surface // vector. -template +template void EvaluatorColumnIntegrator::EnsureCompatibility_ToDeps_(State& S) { @@ -99,7 +100,7 @@ EvaluatorColumnIntegrator::EnsureCompatibility_ToDeps_(State // Disables derivatives -template +template bool EvaluatorColumnIntegrator::IsDifferentiableWRT(const State& S, const Key& wrt_key, @@ -110,7 +111,7 @@ EvaluatorColumnIntegrator::IsDifferentiableWRT(const State& // Required methods from EvaluatorSecondaryMonotypeCV -template +template void EvaluatorColumnIntegrator::Evaluate_( const State& S, @@ -140,16 +141,14 @@ EvaluatorColumnIntegrator::Evaluate_( // val[1] is typically e.g. cell volume, but can be 0 to indicate no // denominator. Coefficient provides a hook for column-wide multiples // (e.g. 1/surface area). - if (val[1] > 0.) - res[0][col] = integrator.coefficient(col) * val[0] / val[1]; - else - res[0][col] = integrator.coefficient(col) * val[0]; + if (val[1] > 0.) res[0][col] = integrator.coefficient(col) * val[0] / val[1]; + else res[0][col] = integrator.coefficient(col) * val[0]; } } // Required methods from EvaluatorSecondaryMonotypeCV -template +template void EvaluatorColumnIntegrator::EvaluatePartialDerivative_( const State& S, diff --git a/src/constitutive_relations/column_integrators/PerchedWaterTableColumnIntegrator.hh b/src/constitutive_relations/column_integrators/PerchedWaterTableColumnIntegrator.hh index 3a94ddf30..2407597d4 100644 --- a/src/constitutive_relations/column_integrators/PerchedWaterTableColumnIntegrator.hh +++ b/src/constitutive_relations/column_integrators/PerchedWaterTableColumnIntegrator.hh @@ -4,7 +4,7 @@ The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. - Authors: Bo Gao (gaob@ornl.gov) + Authors: Bo Gao (gaob@ornl.gov) Ethan Coon (coonet@ornl.gov) */ @@ -23,7 +23,7 @@ This is an evaluator for calculating perched water table depth. namespace Amanzi { namespace Relations { -template +template class PerchedWaterTableColumnIntegrator : public EvaluatorColumnIntegrator { public: using EvaluatorColumnIntegrator::EvaluatorColumnIntegrator; @@ -33,16 +33,17 @@ class PerchedWaterTableColumnIntegrator : public EvaluatorColumnIntegrator& result) override; - + using EvaluatorColumnIntegrator::plist_; using EvaluatorColumnIntegrator::dependencies_; private: - static Utils::RegisteredFactory> reg_; + static Utils::RegisteredFactory> + reg_; }; -template +template Teuchos::RCP PerchedWaterTableColumnIntegrator::Clone() const { @@ -51,7 +52,7 @@ PerchedWaterTableColumnIntegrator::Clone() const // Required methods from EvaluatorColumnIntegrator -template +template void PerchedWaterTableColumnIntegrator::Evaluate_( const State& S, @@ -73,31 +74,32 @@ PerchedWaterTableColumnIntegrator::Evaluate_( // requested or the column is complete AmanziGeometry::Point val(0., 0., NAN); auto col_cell = mesh->columns.getCells(col); - double h_top = mesh->getCellCentroid(col_cell[0])[2] - + mesh->getCellVolume(col_cell[0]) * integrator.coefficient(col) / 2; + double h_top = mesh->getCellCentroid(col_cell[0])[2] + + mesh->getCellVolume(col_cell[0]) * integrator.coefficient(col) / 2; double h_end, h_half0, h_half1; h_end = mesh->getCellCentroid(col_cell[col_cell.size() - 1])[2]; // default at bottom centroid h_half0 = mesh->getCellVolume(col_cell[0]) * integrator.coefficient(col) / 2 * (-1); h_half1 = mesh->getCellVolume(col_cell[col_cell.size() - 1]) * integrator.coefficient(col) / 2; - for (int i = 0; i != col_cell.size(); ++i) { // loop from top down looking for the first saturated cell + for (int i = 0; i != col_cell.size(); + ++i) { // loop from top down looking for the first saturated cell bool completed = integrator.scan(col, col_cell[i], val); if (completed) { - h_end = mesh->getCellCentroid(col_cell[i])[2]; // the first saturated cell centroid from top down + h_end = + mesh->getCellCentroid(col_cell[i])[2]; // the first saturated cell centroid from top down break; } } - // Use val[2] to track centroid, and val[1], val[0] to track cell pressure - // or volume determined by using interpolation or not. + // Use val[2] to track centroid, and val[1], val[0] to track cell pressure + // or volume determined by using interpolation or not. if (std::isnan(val[2])) { // completed at first loop cell res[0][col] = h_top - h_end + h_half0; - } else if (val[2] == h_end) { // fail to find satisfied cell util end of loop + } else if (val[2] == h_end) { // fail to find satisfied cell util end of loop res[0][col] = h_top - val[2] + h_half1; } else { if (plist_.template get("interpolate depth from pressure")) { - res[0][col] = (val[2] - h_end) * (101325. - val[0]) / (val[1] - val[0]) - + (h_top - val[2]); + res[0][col] = (val[2] - h_end) * (101325. - val[0]) / (val[1] - val[0]) + (h_top - val[2]); } else { res[0][col] = integrator.coefficient(col) * val[0]; } diff --git a/src/constitutive_relations/column_integrators/WaterTableColumnIntegrator.hh b/src/constitutive_relations/column_integrators/WaterTableColumnIntegrator.hh index 1813be73c..da9334888 100644 --- a/src/constitutive_relations/column_integrators/WaterTableColumnIntegrator.hh +++ b/src/constitutive_relations/column_integrators/WaterTableColumnIntegrator.hh @@ -4,7 +4,7 @@ The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. - Authors: Bo Gao (gaob@ornl.gov) + Authors: Bo Gao (gaob@ornl.gov) Ethan Coon (coonet@ornl.gov) */ @@ -23,7 +23,7 @@ This is an evaluator for calculating water table depth. namespace Amanzi { namespace Relations { -template +template class WaterTableColumnIntegrator : public EvaluatorColumnIntegrator { public: using EvaluatorColumnIntegrator::EvaluatorColumnIntegrator; @@ -41,7 +41,7 @@ class WaterTableColumnIntegrator : public EvaluatorColumnIntegrator +template Teuchos::RCP WaterTableColumnIntegrator::Clone() const { @@ -50,7 +50,7 @@ WaterTableColumnIntegrator::Clone() const // Required methods from EvaluatorColumnIntegrator -template +template void WaterTableColumnIntegrator::Evaluate_( const State& S, @@ -72,32 +72,34 @@ WaterTableColumnIntegrator::Evaluate_( // requested or the column is complete AmanziGeometry::Point val(0., 0., NAN); auto col_cell = mesh->columns.getCells(col); - double h_top = mesh->getCellCentroid(col_cell[0])[2] - + mesh->getCellVolume(col_cell[0]) * integrator.coefficient(col) / 2; - double h_bot = mesh->getCellCentroid(col_cell[col_cell.size() - 1])[2] - - mesh->getCellVolume(col_cell[col_cell.size() - 1]) * integrator.coefficient(col) / 2; + double h_top = mesh->getCellCentroid(col_cell[0])[2] + + mesh->getCellVolume(col_cell[0]) * integrator.coefficient(col) / 2; + double h_bot = + mesh->getCellCentroid(col_cell[col_cell.size() - 1])[2] - + mesh->getCellVolume(col_cell[col_cell.size() - 1]) * integrator.coefficient(col) / 2; double h_end, h_half0, h_half1; h_end = mesh->getCellCentroid(col_cell[0])[2]; // default at top centroid h_half0 = mesh->getCellVolume(col_cell[col_cell.size() - 1]) * integrator.coefficient(col) / 2; h_half1 = mesh->getCellVolume(col_cell[0]) * integrator.coefficient(col) / 2 * (-1); - for (int i = col_cell.size() - 1; i >= 0; --i) { // loop from bottom up looking for the 1st unsaturated cell + for (int i = col_cell.size() - 1; i >= 0; + --i) { // loop from bottom up looking for the 1st unsaturated cell bool completed = integrator.scan(col, col_cell[i], val); if (completed) { - h_end = mesh->getCellCentroid(col_cell[i])[2]; // the first unsaturated cell centroid from bottom up + h_end = mesh->getCellCentroid( + col_cell[i])[2]; // the first unsaturated cell centroid from bottom up break; } } - // Use val[2] to track centroid, and val[1], val[0] to track cell pressure - // or volume determined by using interpolation or not. + // Use val[2] to track centroid, and val[1], val[0] to track cell pressure + // or volume determined by using interpolation or not. if (std::isnan(val[2])) { // completed at first loop cell res[0][col] = h_top - h_end + h_half0; - } else if (val[2] == h_end) { // fail to find satisfied cell util end of loop + } else if (val[2] == h_end) { // fail to find satisfied cell util end of loop res[0][col] = h_top - val[2] + h_half1; } else { if (plist_.template get("interpolate depth from pressure")) { - res[0][col] = (val[2] - h_end) * (101325. - val[0]) / (val[1] - val[0]) - + (h_top - val[2]); + res[0][col] = (val[2] - h_end) * (101325. - val[0]) / (val[1] - val[0]) + (h_top - val[2]); } else { res[0][col] = h_top - h_bot - integrator.coefficient(col) * val[0]; } diff --git a/src/constitutive_relations/column_integrators/activelayer_average_temp_evaluator.hh b/src/constitutive_relations/column_integrators/activelayer_average_temp_evaluator.hh index 359303824..569a43781 100644 --- a/src/constitutive_relations/column_integrators/activelayer_average_temp_evaluator.hh +++ b/src/constitutive_relations/column_integrators/activelayer_average_temp_evaluator.hh @@ -12,8 +12,8 @@ Evaluator name: `"active layer average temperature`" -.. _activelayer-average_temp-evaluator-spec -.. admonition:: activelayer-average_temp-evaluator-spec +.. _activelayer-average_evaluator-temp-spec +.. admonition:: activelayer-average_evaluator-temp-spec * `"transition width [K]`" ``[double]`` **0.2** diff --git a/src/constitutive_relations/column_integrators/column_integrators_reg.hh b/src/constitutive_relations/column_integrators/column_integrators_reg.hh index 2789a285b..5793b5263 100644 --- a/src/constitutive_relations/column_integrators/column_integrators_reg.hh +++ b/src/constitutive_relations/column_integrators/column_integrators_reg.hh @@ -18,18 +18,18 @@ namespace Amanzi { namespace Relations { // registry of method -template <> -Utils::RegisteredFactory - ColumnSumEvaluator::reg_("column sum evaluator"); -template <> +template<> +Utils::RegisteredFactory ColumnSumEvaluator::reg_( + "column sum evaluator"); +template<> Utils::RegisteredFactory ActiveLayerAverageTempEvaluator::reg_("active layer average temperature"); -template <> +template<> Utils::RegisteredFactory ThawDepthEvaluator::reg_("thaw depth"); -template <> -Utils::RegisteredFactory - WaterTableDepthEvaluator::reg_("water table depth"); -template <> +template<> +Utils::RegisteredFactory WaterTableDepthEvaluator::reg_( + "water table depth"); +template<> Utils::RegisteredFactory PerchedWaterTableDepthEvaluator::reg_("perched water table depth"); diff --git a/src/constitutive_relations/column_integrators/perched_water_table_depth_evaluator.cc b/src/constitutive_relations/column_integrators/perched_water_table_depth_evaluator.cc index 36b1305af..0ad630721 100644 --- a/src/constitutive_relations/column_integrators/perched_water_table_depth_evaluator.cc +++ b/src/constitutive_relations/column_integrators/perched_water_table_depth_evaluator.cc @@ -14,7 +14,8 @@ namespace Amanzi { namespace Relations { -ParserPerchedWaterTableDepth::ParserPerchedWaterTableDepth(Teuchos::ParameterList& plist, const KeyTag& key_tag) +ParserPerchedWaterTableDepth::ParserPerchedWaterTableDepth(Teuchos::ParameterList& plist, + const KeyTag& key_tag) { Key domain = Keys::getDomain(key_tag.first); Tag tag = key_tag.second; @@ -34,9 +35,11 @@ ParserPerchedWaterTableDepth::ParserPerchedWaterTableDepth(Teuchos::ParameterLis } -IntegratorPerchedWaterTableDepth::IntegratorPerchedWaterTableDepth(Teuchos::ParameterList& plist, - std::vector& deps, - const AmanziMesh::Mesh* mesh) : mesh_(mesh) +IntegratorPerchedWaterTableDepth::IntegratorPerchedWaterTableDepth( + Teuchos::ParameterList& plist, + std::vector& deps, + const AmanziMesh::Mesh* mesh) + : mesh_(mesh) { AMANZI_ASSERT(deps.size() == 4); sat_ = deps[0]; diff --git a/src/constitutive_relations/column_integrators/perched_water_table_depth_evaluator.hh b/src/constitutive_relations/column_integrators/perched_water_table_depth_evaluator.hh index ac1a24917..4d28ca4a7 100644 --- a/src/constitutive_relations/column_integrators/perched_water_table_depth_evaluator.hh +++ b/src/constitutive_relations/column_integrators/perched_water_table_depth_evaluator.hh @@ -17,9 +17,9 @@ Computes the depth to the perched water table. .. admonition:: perched-water-table-depth-spec * `"interpolate depth from pressure`" ``[bool]`` **false** Default to calculate - perched water table depth by locating the bottom face of the last continuously - unsaturated cell from top downward. If true, use the height and pressure at the - centroids of the last continuously unsaturated cell and its adjacent saturated + perched water table depth by locating the bottom face of the last continuously + unsaturated cell from top downward. If true, use the height and pressure at the + centroids of the last continuously unsaturated cell and its adjacent saturated cell to determine the perched water table depth through interpolation. KEYS: @@ -49,8 +49,8 @@ struct ParserPerchedWaterTableDepth { class IntegratorPerchedWaterTableDepth { public: IntegratorPerchedWaterTableDepth(Teuchos::ParameterList& plist, - std::vector& deps, - const AmanziMesh::Mesh* mesh); + std::vector& deps, + const AmanziMesh::Mesh* mesh); int scan(AmanziMesh::Entity_ID col, AmanziMesh::Entity_ID c, AmanziGeometry::Point& p); double coefficient(AmanziMesh::Entity_ID col); diff --git a/src/constitutive_relations/column_integrators/water_table_depth_evaluator.cc b/src/constitutive_relations/column_integrators/water_table_depth_evaluator.cc index c11ba4041..657fe1155 100644 --- a/src/constitutive_relations/column_integrators/water_table_depth_evaluator.cc +++ b/src/constitutive_relations/column_integrators/water_table_depth_evaluator.cc @@ -36,7 +36,8 @@ ParserWaterTableDepth::ParserWaterTableDepth(Teuchos::ParameterList& plist, cons IntegratorWaterTableDepth::IntegratorWaterTableDepth(Teuchos::ParameterList& plist, std::vector& deps, - const AmanziMesh::Mesh* mesh) : mesh_(mesh) + const AmanziMesh::Mesh* mesh) + : mesh_(mesh) { AMANZI_ASSERT(deps.size() == 4); sat_ = deps[0]; @@ -57,8 +58,8 @@ IntegratorWaterTableDepth::scan(AmanziMesh::Entity_ID col, p[0] = (*pres_)[0][c]; // last saturated cell pressure } else { p[0] += (*cv_)[0][c]; // cumulative saturated cell volume - } - return false; + } + return false; } if (is_interp_) { p[1] = (*pres_)[0][c]; // first unsaturated cell pressure diff --git a/src/constitutive_relations/column_integrators/water_table_depth_evaluator.hh b/src/constitutive_relations/column_integrators/water_table_depth_evaluator.hh index 2bf12aef1..d8626953f 100644 --- a/src/constitutive_relations/column_integrators/water_table_depth_evaluator.hh +++ b/src/constitutive_relations/column_integrators/water_table_depth_evaluator.hh @@ -17,9 +17,9 @@ Computes the depth to the water table. .. admonition:: water-table-depth-spec * `"interpolate depth from pressure`" ``[bool]`` **false** Default to calculate - water table depth by locating the top face of the last continuously saturated - cell from bottom upward. If true, use the height and pressure at the centroids - of the last continuously saturated cell and its adjacent unsaturated cell to + water table depth by locating the top face of the last continuously saturated + cell from bottom upward. If true, use the height and pressure at the centroids + of the last continuously saturated cell and its adjacent unsaturated cell to determine the water table depth through interpolation. KEYS: diff --git a/src/constitutive_relations/eos/carbon_decomposition_rate_evaluator.cc b/src/constitutive_relations/eos/carbon_decomposition_rate_evaluator.cc index ae9b70ad3..50d990982 100644 --- a/src/constitutive_relations/eos/carbon_decomposition_rate_evaluator.cc +++ b/src/constitutive_relations/eos/carbon_decomposition_rate_evaluator.cc @@ -24,7 +24,7 @@ CarbonDecomposeRateEvaluator::CarbonDecomposeRateEvaluator(Teuchos::ParameterLis { Tag tag = my_keys_.front().second; domain_ = Keys::getDomain(my_keys_.front().first); // column, domain - domain_surf_ = Keys::readDomainHint(plist, domain_, "subsurface", "surface"); + domain_surf_ = Keys::readDomainHint(plist, domain_, "subsurface", "surface"); temp_key_ = Keys::readKey(plist, domain_, "temperature", "temperature"); dependencies_.insert(KeyTag{ temp_key_, tag }); @@ -71,7 +71,8 @@ CarbonDecomposeRateEvaluator::Evaluate_(const State& S, const std::vector& params) = 0; virtual double DMassDensityDT(std::vector& params) { return 0.; } virtual double DMassDensityDp(std::vector& params) { return 0.; } - virtual double DMassDensityDC(std::vector& params) { return 0.; } + virtual double DMassDensityDMoleFraction(std::vector& params) { return 0.; } virtual double MolarDensity(std::vector& params) = 0; virtual double DMolarDensityDT(std::vector& params) { return 0.; } virtual double DMolarDensityDp(std::vector& params) { return 0.; } - virtual double DMolarDensityDC(std::vector& params) { return 0.; } + virtual double DMolarDensityDMoleFraction(std::vector& params) { return 0.; } // If molar mass is constant, we can take some shortcuts if we need both // molar and mass densities. MolarMass() is undefined if @@ -43,7 +43,7 @@ class EOS { virtual double MolarMass() = 0; virtual bool IsTemperature() = 0; virtual bool IsPressure() = 0; - virtual bool IsConcentration() = 0; + virtual bool IsMoleFraction() = 0; }; } // namespace Relations diff --git a/src/constitutive_relations/eos/eos_constant.cc b/src/constitutive_relations/eos/eos_constant.cc index f8d0fc4d9..61fe52dec 100644 --- a/src/constitutive_relations/eos/eos_constant.cc +++ b/src/constitutive_relations/eos/eos_constant.cc @@ -21,7 +21,8 @@ namespace Amanzi { namespace Relations { -EOSConstant::EOSConstant(Teuchos::ParameterList& eos_plist) : eos_plist_(eos_plist) +EOSConstant::EOSConstant(Teuchos::ParameterList& eos_plist) + : eos_plist_(eos_plist) { InitializeFromPlist_(); }; diff --git a/src/constitutive_relations/eos/eos_constant.hh b/src/constitutive_relations/eos/eos_constant.hh index 60c41e7e5..10c07a013 100644 --- a/src/constitutive_relations/eos/eos_constant.hh +++ b/src/constitutive_relations/eos/eos_constant.hh @@ -6,14 +6,39 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - ATS +A constant molar and mass density of water, independent of temperature or +concentration, but related to each other by a molar mass of water. + +Note, users should prefer to use `"independent variable constant`" to this. + +`"EOS type`" = `"constant`" + +.. _eos-constant-spec: +.. admonition:: eos-constant-spec + + ONE OF + + * `"molar mass [kg mol^-1]`" ``[double]`` **0.0180153** + + OR + + * `"molar mass [g mol^-1]`" ``[double]`` **18.0153** + + END + + ONE OF + + * `"density [mol m^-3]`" ``[double]`` molar density of water + + OR + + * `"density [kg m^-3]`" ``[double]`` mass density of water + + END - Simple EOS for constant density. - Defaults to reasonable values for water. - http://software.lanl.gov/ats/trac */ @@ -39,11 +64,11 @@ class EOSConstant : public EOSConstantMolarMass { virtual double DMolarDensityDp(std::vector& params) override { return 0.; } - virtual double DMolarDensityDC(std::vector& params) override { return 0.; } + virtual double DMolarDensityDMoleFraction(std::vector& params) override { return 0.; } virtual bool IsTemperature() override { return false; } virtual bool IsPressure() override { return false; } - virtual bool IsConcentration() override { return false; } + virtual bool IsMoleFraction() override { return false; } private: virtual void InitializeFromPlist_(); diff --git a/src/constitutive_relations/eos/eos_constant_molar_mass.hh b/src/constitutive_relations/eos/eos_constant_molar_mass.hh index b3b417b71..e87702fdb 100644 --- a/src/constitutive_relations/eos/eos_constant_molar_mass.hh +++ b/src/constitutive_relations/eos/eos_constant_molar_mass.hh @@ -27,8 +27,12 @@ namespace Relations { class EOSConstantMolarMass : public EOS { public: - EOSConstantMolarMass() : M_(0.0) {} - explicit EOSConstantMolarMass(double M) : M_(M) {} + EOSConstantMolarMass() + : M_(0.0) + {} + explicit EOSConstantMolarMass(double M) + : M_(M) + {} virtual double MolarDensity(std::vector& params) { return MassDensity(params) / M_; } @@ -42,9 +46,9 @@ class EOSConstantMolarMass : public EOS { return DMassDensityDp(params) / M_; } - virtual double DMolarDensityDC(std::vector& params) + virtual double DMolarDensityDMoleFraction(std::vector& params) { - return DMassDensityDC(params) / M_; + return DMassDensityDMoleFraction(params) / M_; } virtual double MassDensity(std::vector& params) { return MolarDensity(params) * M_; } @@ -59,9 +63,9 @@ class EOSConstantMolarMass : public EOS { return DMolarDensityDp(params) * M_; } - virtual double DMassDensityDC(std::vector& params) + virtual double DMassDensityDMoleFraction(std::vector& params) { - return DMolarDensityDC(params) * M_; + return DMolarDensityDMoleFraction(params) * M_; } virtual bool IsConstantMolarMass() { return true; } diff --git a/src/constitutive_relations/eos/eos_evaluator.cc b/src/constitutive_relations/eos/eos_evaluator.cc index e35c0fb88..96e00de78 100644 --- a/src/constitutive_relations/eos/eos_evaluator.cc +++ b/src/constitutive_relations/eos/eos_evaluator.cc @@ -112,13 +112,13 @@ EOSEvaluator::ParsePlistConc_() Tag tag = my_keys_.front().second; // -- concentration - conc_key_ = - Keys::readKeyTag(plist_, domain_name, "concentration", "total_component_concentration", tag); + conc_key_ = Keys::readKeyTag(plist_, domain_name, "mole fraction", "mole_fraction", tag); dependencies_.insert(conc_key_); } -EOSEvaluator::EOSEvaluator(Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(plist) +EOSEvaluator::EOSEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) { ParsePlistKeys_(); @@ -126,9 +126,9 @@ EOSEvaluator::EOSEvaluator(Teuchos::ParameterList& plist) : EvaluatorSecondaryMo EOSFactory eos_fac; eos_ = eos_fac.createEOS(plist_.sublist("EOS parameters")); - if (eos_->IsConcentration()) ParsePlistConc_(); - if (eos_->IsTemperature()) ParsePlistTemp_(); - if (eos_->IsPressure()) ParsePlistPres_(); + if (eos_->IsMoleFraction() ) ParsePlistConc_(); + if (eos_->IsTemperature() ) ParsePlistTemp_(); + if (eos_->IsPressure() ) ParsePlistPres_(); // -- logging if (vo_.os_OK(Teuchos::VERB_EXTREME)) { @@ -157,7 +157,7 @@ EOSEvaluator::Evaluate_(const State& S, const std::vector& res // Pull dependencies out of state. auto tag = my_keys_.front().second; - if (eos_->IsConcentration()) + if (eos_->IsMoleFraction()) dep_cv.emplace_back(S.GetPtr(conc_key_.first, conc_key_.second).get()); if (eos_->IsTemperature()) dep_cv.emplace_back(S.GetPtr(temp_key_.first, temp_key_.second).get()); @@ -177,7 +177,7 @@ EOSEvaluator::Evaluate_(const State& S, const std::vector& res if (molar_dens != nullptr) { // evaluate MolarDensity() - for (CompositeVector::name_iterator comp = molar_dens->begin(); comp != molar_dens->end(); + for (CompositeVector::name_iterator comp = molar_dens->begin() ; comp != molar_dens->end(); ++comp) { for (int k = 0; k < num_dep; k++) { dep_vec[k] = dep_cv[k]->ViewComponent(*comp, false).get(); @@ -186,7 +186,9 @@ EOSEvaluator::Evaluate_(const State& S, const std::vector& res auto& dens_v = *(molar_dens->ViewComponent(*comp, false)); int count = dens_v.MyLength(); for (int id = 0; id != count; ++id) { - for (int k = 0; k < num_dep; k++) { eos_params[k] = (*dep_vec[k])[0][id]; } + for (int k = 0; k < num_dep; k++) { + eos_params[k] = (*dep_vec[k])[0][id]; + } dens_v[0][id] = eos_->MolarDensity(eos_params); AMANZI_ASSERT(dens_v[0][id] > 0); } @@ -194,7 +196,7 @@ EOSEvaluator::Evaluate_(const State& S, const std::vector& res } if (mass_dens != nullptr) { - for (CompositeVector::name_iterator comp = mass_dens->begin(); comp != mass_dens->end(); + for (CompositeVector::name_iterator comp = mass_dens->begin() ; comp != mass_dens->end(); ++comp) { if (mode_ == EOS_MODE_BOTH && eos_->IsConstantMolarMass() && molar_dens->HasComponent(*comp)) { @@ -249,7 +251,7 @@ EOSEvaluator::EvaluatePartialDerivative_(const State& S, // Pull dependencies out of state. auto tag = my_keys_.front().second; - if (eos_->IsConcentration()) + if (eos_->IsMoleFraction()) dep_cv.emplace_back(S.GetPtr(conc_key_.first, conc_key_.second).get()); if (eos_->IsTemperature()) dep_cv.emplace_back(S.GetPtr(temp_key_.first, temp_key_.second).get()); @@ -269,7 +271,7 @@ EOSEvaluator::EvaluatePartialDerivative_(const State& S, if (molar_dens != nullptr) { // evaluate MolarDensity() - for (CompositeVector::name_iterator comp = molar_dens->begin(); comp != molar_dens->end(); + for (CompositeVector::name_iterator comp = molar_dens->begin() ; comp != molar_dens->end(); ++comp) { for (int k = 0; k < num_dep; k++) { dep_vec[k] = dep_cv[k]->ViewComponent(*comp, false).get(); @@ -280,17 +282,23 @@ EOSEvaluator::EvaluatePartialDerivative_(const State& S, if (wrt == conc_key_) { for (int id = 0; id != count; ++id) { - for (int k = 0; k < num_dep; k++) { eos_params[k] = (*dep_vec[k])[0][id]; } - dens_v[0][id] = eos_->DMolarDensityDC(eos_params); + for (int k = 0; k < num_dep; k++) { + eos_params[k] = (*dep_vec[k])[0][id]; + } + dens_v[0][id] = eos_->DMolarDensityDMoleFraction(eos_params); } } else if (wrt == pres_key_) { for (int id = 0; id != count; ++id) { - for (int k = 0; k < num_dep; k++) { eos_params[k] = (*dep_vec[k])[0][id]; } + for (int k = 0; k < num_dep; k++) { + eos_params[k] = (*dep_vec[k])[0][id]; + } dens_v[0][id] = eos_->DMolarDensityDp(eos_params); } } else if (wrt == temp_key_) { for (int id = 0; id != count; ++id) { - for (int k = 0; k < num_dep; k++) { eos_params[k] = (*dep_vec[k])[0][id]; } + for (int k = 0; k < num_dep; k++) { + eos_params[k] = (*dep_vec[k])[0][id]; + } dens_v[0][id] = eos_->DMolarDensityDT(eos_params); } } else { @@ -300,7 +308,7 @@ EOSEvaluator::EvaluatePartialDerivative_(const State& S, } if (mass_dens != nullptr) { - for (CompositeVector::name_iterator comp = mass_dens->begin(); comp != mass_dens->end(); + for (CompositeVector::name_iterator comp = mass_dens->begin() ; comp != mass_dens->end(); ++comp) { if (mode_ == EOS_MODE_BOTH && eos_->IsConstantMolarMass() && molar_dens->HasComponent(*comp)) { @@ -320,7 +328,7 @@ EOSEvaluator::EvaluatePartialDerivative_(const State& S, if (wrt == conc_key_) { for (int id = 0; id != count; ++id) { for (int k = 0; k < num_dep; k++) eos_params[k] = (*dep_vec[k])[0][id]; - dens_v[0][id] = eos_->DMassDensityDC(eos_params); + dens_v[0][id] = eos_->DMassDensityDMoleFraction(eos_params); } } else if (wrt == pres_key_) { for (int id = 0; id != count; ++id) { diff --git a/src/constitutive_relations/eos/eos_evaluator.hh b/src/constitutive_relations/eos/eos_evaluator.hh index 37c19a43d..a6b640a41 100644 --- a/src/constitutive_relations/eos/eos_evaluator.hh +++ b/src/constitutive_relations/eos/eos_evaluator.hh @@ -6,8 +6,32 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! + +This evaluates an EOS as a function of temperature, pressure, and/or mole +ratio/concentration. + +.. _evaluator-eos-spec: +.. admonition:: evaluator-eos-spec + + * `"EOS parameters`" ``[eos-typedinline-spec]`` + + KEYS: + + - `"molar density`" Note that molar density is [mol H2O m^-3]. This is a + _component_ quantity. + - `"mass density`" Note that mass density is [kg m^-3]. This is a _phase_ + quantity. + + DEPENDENCIES: + + - `"temperature`" + - `"pressure`" + - `"mole fraction`" + +*/ + -//! EOSEvaluator is the interface between state/data and the model, an EOS. #ifndef AMANZI_RELATIONS_EOS_EVALUATOR_HH_ #define AMANZI_RELATIONS_EOS_EVALUATOR_HH_ diff --git a/src/constitutive_relations/eos/eos_ice.cc b/src/constitutive_relations/eos/eos_ice.cc index 9b67ac9df..065b212d5 100644 --- a/src/constitutive_relations/eos/eos_ice.cc +++ b/src/constitutive_relations/eos/eos_ice.cc @@ -76,10 +76,10 @@ EOSIce::DMassDensityDp(std::vector& params) void EOSIce::InitializeFromPlist_() { - if (eos_plist_.isParameter("Molar mass of ice [kg/mol]")) { - M_ = eos_plist_.get("Molar mass of ice [kg/mol]"); + if (eos_plist_.isParameter("molar mass [kg mol^-1]")) { + M_ = eos_plist_.get("molar mass [kg mol^-1]"); } else { - M_ = eos_plist_.get("Molar mass of ice [g/mol]", 18.0153) * 1e-3; + M_ = eos_plist_.get("molar mass [g mol^-1]", 18.0153) * 1e-3; } }; diff --git a/src/constitutive_relations/eos/eos_ice.hh b/src/constitutive_relations/eos/eos_ice.hh index 2bed3de38..fad16e0f1 100644 --- a/src/constitutive_relations/eos/eos_ice.hh +++ b/src/constitutive_relations/eos/eos_ice.hh @@ -6,14 +6,25 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - ATS +A molar and mass density of solid water, empirically fit to data as a function +of both pressure and temperature. + +`"EOS type`" = `"ice`" + +.. _eos-ice-spec: +.. admonition:: eos-ice-spec + + ONE OF + + * `"molar mass [kg mol^-1]`" ``[double]`` **0.0180153** :math:`M` above + + OR - EOS for liquid ice. See the permafrost physical properties notes for - references and documentation of this EOS at: + * `"molar mass [g mol^-1]`" ``[double]`` **18.0153** - http://software.lanl.gov/ats/trac + END */ @@ -36,11 +47,11 @@ class EOSIce : public EOSConstantMolarMass { virtual double MassDensity(std::vector& params) override; virtual double DMassDensityDT(std::vector& params) override; virtual double DMassDensityDp(std::vector& params) override; - virtual double DMassDensityDC(std::vector& params) override { return 0; } + virtual double DMassDensityDMoleFraction(std::vector& params) override { return 0; } virtual bool IsTemperature() override { return true; } virtual bool IsPressure() override { return true; } - virtual bool IsConcentration() override { return false; } + virtual bool IsMoleFraction() override { return false; } private: virtual void InitializeFromPlist_(); diff --git a/src/constitutive_relations/eos/eos_ideal_gas.cc b/src/constitutive_relations/eos/eos_ideal_gas.cc index 15de6be7b..dd31eccbd 100644 --- a/src/constitutive_relations/eos/eos_ideal_gas.cc +++ b/src/constitutive_relations/eos/eos_ideal_gas.cc @@ -19,7 +19,8 @@ namespace Amanzi { namespace Relations { -EOSIdealGas::EOSIdealGas(Teuchos::ParameterList& eos_plist) : eos_plist_(eos_plist) +EOSIdealGas::EOSIdealGas(Teuchos::ParameterList& eos_plist) + : eos_plist_(eos_plist) { InitializeFromPlist_(); }; @@ -53,12 +54,12 @@ EOSIdealGas::DMolarDensityDp(std::vector& params) void EOSIdealGas::InitializeFromPlist_() { - R_ = eos_plist_.get("Ideal gas constant [J/mol-K]", 8.3144621); + R_ = eos_plist_.get("ideal gas constant [J mol^-1 K^-1]", 8.3144621); - if (eos_plist_.isParameter("Molar mass of gas [kg/mol]")) { - M_ = eos_plist_.get("Molar mass of gas [kg/mol]"); + if (eos_plist_.isParameter("molar mass of gas [kg mol^-1]")) { + M_ = eos_plist_.get("molar mass of gas [kg mol^-1]"); } else { - M_ = eos_plist_.get("Molar mass of gas [g/mol]", 28.956) * 1e-3; + M_ = eos_plist_.get("molar mass of gas [g mol^-1]", 28.956) * 1e-3; } }; diff --git a/src/constitutive_relations/eos/eos_ideal_gas.hh b/src/constitutive_relations/eos/eos_ideal_gas.hh index cb6028461..a08e66ab8 100644 --- a/src/constitutive_relations/eos/eos_ideal_gas.hh +++ b/src/constitutive_relations/eos/eos_ideal_gas.hh @@ -6,11 +6,28 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - ATS +Implements the ideal gas EOS, which computes n as a function of p and T. +Default properties are that of air. + +`"EOS type`" = `"ideal gas`" + +.. _eos-ideal-gas-spec: +.. admonition:: eos-ideal-gas-spec + + * `"ideal gas constant [J mol^-1 K^-1]`" ``[double]`` **8.3144621** + + ONE OF + + * `"molar mass of gas [kg mol^-1]`" ``[double]`` **0.028956** + + OR + + * `"molar mass of gas [g mol^-1]`" ``[double]`` **28.956** + + END - EOS for an ideal gas. */ @@ -33,11 +50,11 @@ class EOSIdealGas : public EOSConstantMolarMass { virtual double MolarDensity(std::vector& params) override; virtual double DMolarDensityDT(std::vector& params) override; virtual double DMolarDensityDp(std::vector& params) override; - virtual double DMolarDensityDC(std::vector& params) override { return 0.; } + virtual double DMolarDensityDMoleFraction(std::vector& params) override { return 0.; } virtual bool IsTemperature() override { return true; } virtual bool IsPressure() override { return true; } - virtual bool IsConcentration() override { return false; } + virtual bool IsMoleFraction() override { return false; } protected: virtual void InitializeFromPlist_(); diff --git a/src/constitutive_relations/eos/eos_linear.cc b/src/constitutive_relations/eos/eos_linear.cc index 5b26d9b10..e6012ab5f 100644 --- a/src/constitutive_relations/eos/eos_linear.cc +++ b/src/constitutive_relations/eos/eos_linear.cc @@ -21,7 +21,8 @@ namespace Amanzi { namespace Relations { -EOSLinear::EOSLinear(Teuchos::ParameterList& eos_plist) : eos_plist_(eos_plist) +EOSLinear::EOSLinear(Teuchos::ParameterList& eos_plist) + : eos_plist_(eos_plist) { InitializeFromPlist_(); }; @@ -30,19 +31,19 @@ void EOSLinear::InitializeFromPlist_() { // defaults to water - if (eos_plist_.isParameter("molar mass [kg/mol]")) { - M_ = eos_plist_.get("molar mass [kg/mol]"); + if (eos_plist_.isParameter("molar mass [kg mol^-1]")) { + M_ = eos_plist_.get("molar mass [kg mol^-1]"); } else { - M_ = eos_plist_.get("molar mass [g/mol]", 18.0153) * 1.e-3; + M_ = eos_plist_.get("molar mass [g mol^-1]", 18.0153) * 1.e-3; } - if (eos_plist_.isParameter("density [mol/m^3]")) { - rho_ = eos_plist_.get("density [mol/m^3]") * M_; + if (eos_plist_.isParameter("density [mol m^-3]")) { + rho_ = eos_plist_.get("density [mol m^-3]") * M_; } else { - rho_ = eos_plist_.get("density [kg/m^3]"); + rho_ = eos_plist_.get("density [kg m^-3]"); } - beta_ = eos_plist_.get("compressibility [1/Pa]"); + beta_ = eos_plist_.get("compressibility [Pa^-1]"); }; } // namespace Relations diff --git a/src/constitutive_relations/eos/eos_linear.hh b/src/constitutive_relations/eos/eos_linear.hh index f553cf804..53a12023a 100644 --- a/src/constitutive_relations/eos/eos_linear.hh +++ b/src/constitutive_relations/eos/eos_linear.hh @@ -8,11 +8,40 @@ */ /* - ATS - Simple EOS for compressibility with pressure. +A molar and mass density of water that are linear in pressure. - http://software.lanl.gov/ats/trac +.. math:: + + n &= n_0 + \beta (p - p_{atm}) + \rho &= M n + +`"EOS type`" = `"linear`" + +.. _eos-linear-spec: +.. admonition:: eos-linear-spec + + ONE OF + + * `"molar mass [kg mol^-1]`" ``[double]`` **0.0180153** :math:`M` above + + OR + + * `"molar mass [g mol^-1]`" ``[double]`` **18.0153** + + END + + ONE OF + + * `"density [mol m^-3]`" ``[double]`` molar density of water, :math:`n_0` above + + OR + + * `"density [kg m^-3]`" ``[double]`` mass density of water + + END + + * `"compressibility [Pa^-1]`" ``[double]`` :math:`\beta` above. */ @@ -41,11 +70,11 @@ class EOSLinear : public EOSConstantMolarMass { return params[0] > 101325. ? rho_ * beta_ : 0.; } virtual double DMassDensityDT(std::vector& params) override { return 0.; } - virtual double DMassDensityDC(std::vector& params) override { return 0.; } + virtual double DMassDensityDMoleFraction(std::vector& params) override { return 0.; } virtual bool IsTemperature() override { return false; } virtual bool IsPressure() override { return true; } - virtual bool IsConcentration() override { return false; } + virtual bool IsMoleFraction() override { return false; } private: virtual void InitializeFromPlist_(); diff --git a/src/constitutive_relations/eos/eos_reg.hh b/src/constitutive_relations/eos/eos_reg.hh index 3e20af476..c18171e04 100644 --- a/src/constitutive_relations/eos/eos_reg.hh +++ b/src/constitutive_relations/eos/eos_reg.hh @@ -38,16 +38,16 @@ Utils::RegisteredFactory EOS_SW::factory_("salt water"); Utils::RegisteredFactory EOSVaporInGas::factory_("vapor in gas"); Utils::RegisteredFactory EOSWater::factory_("liquid water"); -Utils::RegisteredFactory - MolarFractionGasEvaluator::factory_("molar fraction gas"); -Utils::RegisteredFactory - VaporPressureWater::factory_("water vapor over water/ice"); +Utils::RegisteredFactory MolarFractionGasEvaluator::factory_( + "molar fraction gas"); +Utils::RegisteredFactory VaporPressureWater::factory_( + "water vapor over water/ice"); Utils::RegisteredFactory ViscosityEvaluator::factory_("viscosity"); -Utils::RegisteredFactory - ViscosityConstant::factory_("constant"); -Utils::RegisteredFactory - ViscosityWater::factory_("liquid water"); +Utils::RegisteredFactory ViscosityConstant::factory_( + "constant"); +Utils::RegisteredFactory ViscosityWater::factory_( + "liquid water"); Utils::RegisteredFactory CarbonDecomposeRateEvaluator::reg_("carbon decomposition rate"); diff --git a/src/constitutive_relations/eos/eos_sw.cc b/src/constitutive_relations/eos/eos_sw.cc index edec614cb..8becbc2b3 100644 --- a/src/constitutive_relations/eos/eos_sw.cc +++ b/src/constitutive_relations/eos/eos_sw.cc @@ -22,7 +22,8 @@ namespace Amanzi { namespace Relations { -EOS_SW::EOS_SW(Teuchos::ParameterList& eos_plist) : eos_plist_(eos_plist) +EOS_SW::EOS_SW(Teuchos::ParameterList& eos_plist) + : eos_plist_(eos_plist) { InitializeFromPlist_(); } @@ -35,7 +36,7 @@ EOS_SW::MassDensity(std::vector& params) }; double -EOS_SW::DMassDensityDC(std::vector& params) +EOS_SW::DMassDensityDMoleFraction(std::vector& params) { return E_; }; @@ -48,11 +49,12 @@ EOS_SW::MolarDensity(std::vector& params) }; double -EOS_SW::DMolarDensityDC(std::vector& params) +EOS_SW::DMolarDensityDMoleFraction(std::vector& params) { double C = params[0]; double b = (M_water_ * (1 - C) + M_salt_ * C); - return (DMassDensityDC(params) * b - MassDensity(params) * (M_salt_ - M_water_)) / (b * b); + return (DMassDensityDMoleFraction(params) * b - MassDensity(params) * (M_salt_ - M_water_)) / + (b * b); }; diff --git a/src/constitutive_relations/eos/eos_sw.hh b/src/constitutive_relations/eos/eos_sw.hh index 0bd23d650..dec9131ba 100644 --- a/src/constitutive_relations/eos/eos_sw.hh +++ b/src/constitutive_relations/eos/eos_sw.hh @@ -26,18 +26,18 @@ namespace Relations { class EOS_SW : public EOS { public: explicit EOS_SW(Teuchos::ParameterList& eos_plist); - virtual ~EOS_SW(){}; + virtual ~EOS_SW() {}; // Virtual methods that form the EOS virtual double MassDensity(std::vector& params) override; - virtual double DMassDensityDC(std::vector& params) override; + virtual double DMassDensityDMoleFraction(std::vector& params) override; virtual double MolarDensity(std::vector& params) override; - virtual double DMolarDensityDC(std::vector& params) override; + virtual double DMolarDensityDMoleFraction(std::vector& params) override; virtual bool IsTemperature() override { return false; } virtual bool IsPressure() override { return false; } - virtual bool IsConcentration() override { return true; } + virtual bool IsMoleFraction() override { return true; } // If molar mass is constant, we can take some shortcuts if we need both // molar and mass densities. MolarMass() is undefined if diff --git a/src/constitutive_relations/eos/eos_vapor_in_gas.cc b/src/constitutive_relations/eos/eos_vapor_in_gas.cc index 09516bd5c..4ddf9f180 100644 --- a/src/constitutive_relations/eos/eos_vapor_in_gas.cc +++ b/src/constitutive_relations/eos/eos_vapor_in_gas.cc @@ -7,20 +7,14 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -/* - ATS - - EOS for an ideal gas (does not implement viscosity at this point!) - -*/ - #include "eos_factory.hh" #include "eos_vapor_in_gas.hh" namespace Amanzi { namespace Relations { -EOSVaporInGas::EOSVaporInGas(Teuchos::ParameterList& eos_plist) : eos_plist_(eos_plist) +EOSVaporInGas::EOSVaporInGas(Teuchos::ParameterList& eos_plist) + : eos_plist_(eos_plist) { InitializeFromPlist_(); } diff --git a/src/constitutive_relations/eos/eos_vapor_in_gas.hh b/src/constitutive_relations/eos/eos_vapor_in_gas.hh index b5fff9848..bab3f89ce 100644 --- a/src/constitutive_relations/eos/eos_vapor_in_gas.hh +++ b/src/constitutive_relations/eos/eos_vapor_in_gas.hh @@ -6,14 +6,18 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - ATS +A molar and mass density of gas including water vapor. This wraps another EOS +for providing molar density, but removes mass density functions as they are not +valid for this use case. Typically this wraps the ideal gas law EOS. + +`"EOS type`" = `"vapor in gas`" + +.. _eos-vapor-in-gas-spec: +.. admonition:: eos-vapor-in-gas-spec - EOS for a combination of air and vapor pressure. Mass density is not - available, not because it can't be calculated, but because it depends upon - omega. It's not really needed, and if it were, would not fit the EOS - interface without serious work. + * `"gas EOS parameters`" ``[eos-typedinline-spec]`` */ @@ -47,7 +51,7 @@ class EOSVaporInGas : public EOS { AMANZI_ASSERT(0); return 0.0; } - double DMassDensityDC(std::vector& params) override + double DMassDensityDMoleFraction(std::vector& params) override { AMANZI_ASSERT(0); return 0.0; @@ -56,11 +60,11 @@ class EOSVaporInGas : public EOS { double MolarDensity(std::vector& params) override; double DMolarDensityDT(std::vector& params) override; double DMolarDensityDp(std::vector& params) override; - double DMolarDensityDC(std::vector& params) override { return 0.; } + double DMolarDensityDMoleFraction(std::vector& params) override { return 0.; } virtual bool IsTemperature() override { return gas_eos_->IsTemperature(); } virtual bool IsPressure() override { return gas_eos_->IsPressure(); } - virtual bool IsConcentration() override { return gas_eos_->IsConcentration(); } + virtual bool IsMoleFraction() override { return gas_eos_->IsMoleFraction(); } bool IsConstantMolarMass() override { return false; } double MolarMass() override diff --git a/src/constitutive_relations/eos/eos_water.cc b/src/constitutive_relations/eos/eos_water.cc index c6bee7ad0..57770e441 100644 --- a/src/constitutive_relations/eos/eos_water.cc +++ b/src/constitutive_relations/eos/eos_water.cc @@ -7,16 +7,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -/* - ATS - - EOS for liquid water. See the permafrost physical properties notes for - references and documentation of this EOS at: - - http://software.lanl.gov/ats/trac - -*/ - #include "eos_water.hh" namespace Amanzi { @@ -25,15 +15,20 @@ namespace Relations { EOSWater::EOSWater(Teuchos::ParameterList& eos_plist) : EOSConstantMolarMass(0.0180153), eos_plist_(eos_plist), - ka_(999.915), kb_(0.0416516), kc_(-0.0100836), kd_(0.000206355), kT0_(273.15), - kalpha_(5.0e-10), - kp0_(1.0e5){}; + kp0_(1.0e5) +{ + if (eos_plist_.isParameter("molar mass [kg mol^-1]")) { + M_ = eos_plist_.get("molar mass [kg mol^-1]"); + } else { + M_ = eos_plist_.get("molar mass [g mol^-1]", 18.0153) * 1e-3; + } +}; double diff --git a/src/constitutive_relations/eos/eos_water.hh b/src/constitutive_relations/eos/eos_water.hh index ab347171c..f7e2d8cca 100644 --- a/src/constitutive_relations/eos/eos_water.hh +++ b/src/constitutive_relations/eos/eos_water.hh @@ -6,14 +6,25 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - ATS +A molar and mass density of liquid water, empirically fit to data as a function +of both pressure and temperature. + +`"EOS type`" = `"liquid water`" + +.. _eos-liquid-water-spec: +.. admonition:: eos-liquid-water-spec + + ONE OF + + * `"molar mass [kg mol^-1]`" ``[double]`` **0.0180153** + + OR - EOS for liquid water. See the permafrost physical properties notes for - references and documentation of this EOS at: + * `"molar mass [g mol^-1]`" ``[double]`` **18.0153** - http://software.lanl.gov/ats/trac + END */ @@ -36,9 +47,9 @@ class EOSWater : public EOSConstantMolarMass { virtual double MassDensity(std::vector& params) override; virtual double DMassDensityDT(std::vector& params) override; virtual double DMassDensityDp(std::vector& params) override; - virtual double DMassDensityDC(std::vector& params) override { return 0; } + virtual double DMassDensityDMoleFraction(std::vector& params) override { return 0; } - virtual bool IsConcentration() override { return false; } + virtual bool IsMoleFraction() override { return false; } virtual bool IsTemperature() override { return true; } virtual bool IsPressure() override { return true; } diff --git a/src/constitutive_relations/eos/molar_fraction_gas_evaluator_reg.hh b/src/constitutive_relations/eos/molar_fraction_gas_evaluator_reg.hh index e3ce14b94..2d77422db 100644 --- a/src/constitutive_relations/eos/molar_fraction_gas_evaluator_reg.hh +++ b/src/constitutive_relations/eos/molar_fraction_gas_evaluator_reg.hh @@ -19,8 +19,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - MolarFractionGasEvaluator::factory_("molar fraction gas"); +Utils::RegisteredFactory MolarFractionGasEvaluator::factory_( + "molar fraction gas"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/eos/vapor_pressure_relation.hh b/src/constitutive_relations/eos/vapor_pressure_relation.hh index 0d737e6e3..66b491907 100644 --- a/src/constitutive_relations/eos/vapor_pressure_relation.hh +++ b/src/constitutive_relations/eos/vapor_pressure_relation.hh @@ -22,7 +22,7 @@ namespace Relations { class VaporPressureRelation { public: - virtual ~VaporPressureRelation(){}; + virtual ~VaporPressureRelation() {}; virtual double SaturatedVaporPressure(double T) = 0; virtual double DSaturatedVaporPressureDT(double T) = 0; diff --git a/src/constitutive_relations/eos/vapor_pressure_water_reg.hh b/src/constitutive_relations/eos/vapor_pressure_water_reg.hh index 8411e9af6..eeddaf1d4 100644 --- a/src/constitutive_relations/eos/vapor_pressure_water_reg.hh +++ b/src/constitutive_relations/eos/vapor_pressure_water_reg.hh @@ -22,8 +22,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - VaporPressureWater::factory_("water vapor over water/ice"); +Utils::RegisteredFactory VaporPressureWater::factory_( + "water vapor over water/ice"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/eos/viscosity_constant.cc b/src/constitutive_relations/eos/viscosity_constant.cc index cdde0afab..d0ad4f6e8 100644 --- a/src/constitutive_relations/eos/viscosity_constant.cc +++ b/src/constitutive_relations/eos/viscosity_constant.cc @@ -21,7 +21,8 @@ namespace Amanzi { namespace Relations { -ViscosityConstant::ViscosityConstant(Teuchos::ParameterList& visc_plist) : visc_plist_(visc_plist) +ViscosityConstant::ViscosityConstant(Teuchos::ParameterList& visc_plist) + : visc_plist_(visc_plist) { InitializeFromPlist_(); }; diff --git a/src/constitutive_relations/eos/viscosity_constant_reg.hh b/src/constitutive_relations/eos/viscosity_constant_reg.hh index a90a6c465..b33d1b49e 100644 --- a/src/constitutive_relations/eos/viscosity_constant_reg.hh +++ b/src/constitutive_relations/eos/viscosity_constant_reg.hh @@ -22,8 +22,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - ViscosityConstant::factory_("constant"); +Utils::RegisteredFactory ViscosityConstant::factory_( + "constant"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/eos/viscosity_evaluator.cc b/src/constitutive_relations/eos/viscosity_evaluator.cc index 35a8db3a2..877fad547 100644 --- a/src/constitutive_relations/eos/viscosity_evaluator.cc +++ b/src/constitutive_relations/eos/viscosity_evaluator.cc @@ -82,7 +82,9 @@ ViscosityEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& result_v = *(result[0]->ViewComponent(*comp, false)); int count = result[0]->size(*comp); - for (int id = 0; id != count; ++id) { result_v[0][id] = visc_->DViscosityDT(temp_v[0][id]); } + for (int id = 0; id != count; ++id) { + result_v[0][id] = visc_->DViscosityDT(temp_v[0][id]); + } } } diff --git a/src/constitutive_relations/eos/viscosity_evaluator.hh b/src/constitutive_relations/eos/viscosity_evaluator.hh index 898eb00bb..d0111f850 100644 --- a/src/constitutive_relations/eos/viscosity_evaluator.hh +++ b/src/constitutive_relations/eos/viscosity_evaluator.hh @@ -12,10 +12,12 @@ A non-isothermal viscosity model intended for use within a range of temperatures from well below freezing to ~100C. -.. _viscosity-evaluator-spec: -.. admonition:: viscosity-evaluator-spec +`"evaluator type`" = `"viscosity`" - * `"viscosity model parameters`" ``[viscosity-typedinline-spec-list]`` +.. _evaluator-viscosity-spec: +.. admonition:: evaluator-viscosity-spec + + * `"viscosity model parameters`" ``[viscosity-typedinline-spec]`` KEYS: diff --git a/src/constitutive_relations/eos/viscosity_relation.hh b/src/constitutive_relations/eos/viscosity_relation.hh index 4a43b91fd..370806543 100644 --- a/src/constitutive_relations/eos/viscosity_relation.hh +++ b/src/constitutive_relations/eos/viscosity_relation.hh @@ -8,7 +8,7 @@ */ /* - Basic interface of a Viscosity. + Basic interface of a Viscosity Relation. */ @@ -21,7 +21,7 @@ namespace Relations { // Equation of State model class ViscosityRelation { public: - virtual ~ViscosityRelation(){}; + virtual ~ViscosityRelation() {}; // Virtual methods that form the Viscosity virtual double Viscosity(double T) = 0; diff --git a/src/constitutive_relations/eos/viscosity_relation_factory.cc b/src/constitutive_relations/eos/viscosity_relation_factory.cc index 2402cd551..819ae2ff9 100644 --- a/src/constitutive_relations/eos/viscosity_relation_factory.cc +++ b/src/constitutive_relations/eos/viscosity_relation_factory.cc @@ -7,13 +7,6 @@ Authors: Ethan Coon */ -/* ------------------------------------------------------------------------- - - ATS - - Self-registering factory for Viscosity implementations. - ------------------------------------------------------------------------- */ - #include #include "viscosity_relation_factory.hh" @@ -24,7 +17,7 @@ namespace Relations { Teuchos::RCP ViscosityRelationFactory::createViscosity(Teuchos::ParameterList& plist) { - std::string visc_typename = plist.get("viscosity relation type"); + std::string visc_typename = plist.get("viscosity type"); return Teuchos::rcp(CreateInstance(visc_typename, plist)); }; diff --git a/src/constitutive_relations/eos/viscosity_water.cc b/src/constitutive_relations/eos/viscosity_water.cc index 75e08d242..ec963a08b 100644 --- a/src/constitutive_relations/eos/viscosity_water.cc +++ b/src/constitutive_relations/eos/viscosity_water.cc @@ -7,16 +7,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -/* - ATS - - EOS for liquid water. See the permafrost physical properties notes for - references and documentation of this EOS at: - - http://software.lanl.gov/ats/trac - -*/ - #include "errors.hh" #include "viscosity_water.hh" @@ -30,7 +20,7 @@ ViscosityWater::ViscosityWater(Teuchos::ParameterList& eos_plist) kcv1_(0.00585), kbv2_(1.3272), kcv2_(-0.001053), - kT1_(293.15){}; + kT1_(293.15) {}; double @@ -54,6 +44,7 @@ ViscosityWater::Viscosity(double T) return visc; }; + double ViscosityWater::DViscosityDT(double T) { diff --git a/src/constitutive_relations/eos/viscosity_water.hh b/src/constitutive_relations/eos/viscosity_water.hh index 1e8ac8d39..5d6d0b883 100644 --- a/src/constitutive_relations/eos/viscosity_water.hh +++ b/src/constitutive_relations/eos/viscosity_water.hh @@ -12,9 +12,7 @@ A constitutive relation for the viscosity of water as a function of temperature in K, given as an empirical series expansion fit to data. -Used by setting - -`"viscosity relation type`" = `"liquid water`" +`"viscosity type`" = `"liquid water`" .. _viscosity-water-spec: .. admonition:: viscosity-water-spec diff --git a/src/constitutive_relations/eos/viscosity_water_reg.hh b/src/constitutive_relations/eos/viscosity_water_reg.hh index c0a6afc2d..3a65b232d 100644 --- a/src/constitutive_relations/eos/viscosity_water_reg.hh +++ b/src/constitutive_relations/eos/viscosity_water_reg.hh @@ -24,8 +24,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - ViscosityWater::factory_("liquid water"); +Utils::RegisteredFactory ViscosityWater::factory_( + "liquid water"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/generic_evaluators/AdditiveEvaluator.cc b/src/constitutive_relations/generic_evaluators/AdditiveEvaluator.cc index 99dccd5ea..a3e742fa4 100644 --- a/src/constitutive_relations/generic_evaluators/AdditiveEvaluator.cc +++ b/src/constitutive_relations/generic_evaluators/AdditiveEvaluator.cc @@ -66,7 +66,7 @@ AdditiveEvaluator::Evaluate_(const State& S, const std::vector if (positive_) { for (const auto& name : *result[0]) { auto& res = *result[0]->ViewComponent(name, false); - for (int i = 0; i != res.MyLength(); ++i) res[0][i] = std::max(res[0][i], 0.); + for (int i = 0; i != res.MyLength() ; ++i) res[0][i] = std::max(res[0][i], 0.); } } } @@ -85,7 +85,9 @@ AdditiveEvaluator::EvaluatePartialDerivative_(const State& S, auto& res = *result[0]->ViewComponent(name, false); const auto& value_v = *value.ViewComponent(name, false); for (int i = 0; i != res.MyLength(); ++i) { - if (value_v[0][i] == 0.0) { res[0][i] = 0.; } + if (value_v[0][i] == 0.0) { + res[0][i] = 0.; + } } } } diff --git a/src/constitutive_relations/generic_evaluators/AdditiveEvaluator.hh b/src/constitutive_relations/generic_evaluators/AdditiveEvaluator.hh index bb874a62d..92e2e408f 100644 --- a/src/constitutive_relations/generic_evaluators/AdditiveEvaluator.hh +++ b/src/constitutive_relations/generic_evaluators/AdditiveEvaluator.hh @@ -10,8 +10,8 @@ //! A generic evaluator for summing a collection of fields. /*! -.. _additive-evaluator-spec: -.. admonition:: additive-evaluator-spec +.. _evaluator-additive-spec: +.. admonition:: evaluator-additive-spec * `"constant shift`" ``[double]`` **0** A constant value to add to the sum. * `"enforce positivity`" ``[bool]`` **false** If true, max the result with 0. diff --git a/src/constitutive_relations/generic_evaluators/AdditiveEvaluator_reg.hh b/src/constitutive_relations/generic_evaluators/AdditiveEvaluator_reg.hh index 9f37b4f65..0490bb95b 100644 --- a/src/constitutive_relations/generic_evaluators/AdditiveEvaluator_reg.hh +++ b/src/constitutive_relations/generic_evaluators/AdditiveEvaluator_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - AdditiveEvaluator::factory_("additive evaluator"); +Utils::RegisteredFactory AdditiveEvaluator::factory_( + "additive evaluator"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/generic_evaluators/ExtractionEvaluator_reg.hh b/src/constitutive_relations/generic_evaluators/ExtractionEvaluator_reg.hh index 472f7f41b..b11d22dd9 100644 --- a/src/constitutive_relations/generic_evaluators/ExtractionEvaluator_reg.hh +++ b/src/constitutive_relations/generic_evaluators/ExtractionEvaluator_reg.hh @@ -20,8 +20,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - ExtractionEvaluator::reg_("extraction evaluator"); +Utils::RegisteredFactory ExtractionEvaluator::reg_( + "extraction evaluator"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/generic_evaluators/InitialTimeEvaluator.hh b/src/constitutive_relations/generic_evaluators/InitialTimeEvaluator.hh index a8bb32b77..bbddaa135 100644 --- a/src/constitutive_relations/generic_evaluators/InitialTimeEvaluator.hh +++ b/src/constitutive_relations/generic_evaluators/InitialTimeEvaluator.hh @@ -12,8 +12,8 @@ Stores the value of a field at the initial time. Note this must be checkpointed because it can never be reconstructed. -.. _initial-time-evaluator-spec: -.. admonition:: initial-time-evaluator-spec +.. _evaluator-initial-time-spec: +.. admonition:: evaluator-initial-time-spec * `"initial time`" ``[double]`` **0** Time value to save, in units as below. * `"initial time units`" ``[string]`` **s** Units of initial time above. diff --git a/src/constitutive_relations/generic_evaluators/InitialTimeEvaluator_reg.hh b/src/constitutive_relations/generic_evaluators/InitialTimeEvaluator_reg.hh index 9bfe18287..1f86b6dd2 100644 --- a/src/constitutive_relations/generic_evaluators/InitialTimeEvaluator_reg.hh +++ b/src/constitutive_relations/generic_evaluators/InitialTimeEvaluator_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - InitialTimeEvaluator::reg_("initial value"); +Utils::RegisteredFactory InitialTimeEvaluator::reg_( + "initial value"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/generic_evaluators/MultiplicativeEvaluator.cc b/src/constitutive_relations/generic_evaluators/MultiplicativeEvaluator.cc index 35534a5aa..6952f074c 100644 --- a/src/constitutive_relations/generic_evaluators/MultiplicativeEvaluator.cc +++ b/src/constitutive_relations/generic_evaluators/MultiplicativeEvaluator.cc @@ -71,7 +71,9 @@ MultiplicativeEvaluator::Evaluate_(const State& S, const std::vector - MultiplicativeEvaluator::factory_("multiplicative evaluator"); +Utils::RegisteredFactory MultiplicativeEvaluator::factory_( + "multiplicative evaluator"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/generic_evaluators/ReciprocalEvaluator.cc b/src/constitutive_relations/generic_evaluators/ReciprocalEvaluator.cc index 602101554..43701ce58 100644 --- a/src/constitutive_relations/generic_evaluators/ReciprocalEvaluator.cc +++ b/src/constitutive_relations/generic_evaluators/ReciprocalEvaluator.cc @@ -54,10 +54,8 @@ ReciprocalEvaluator::Evaluate_(const State& S, const std::vectorfirst == reciprocal_key_) - key_tag_numer++; - else - key_tag_denom++; + if (key_tag_numer->first == reciprocal_key_) key_tag_numer++; + else key_tag_denom++; const auto& numer = S.Get(key_tag_numer->first, key_tag_numer->second); const auto& denom = S.Get(key_tag_denom->first, key_tag_denom->second); @@ -72,7 +70,9 @@ ReciprocalEvaluator::Evaluate_(const State& S, const std::vectorViewComponent(comp, false); - for (int c = 0; c != res_c.MyLength(); ++c) { res_c[0][c] = std::max(res_c[0][c], 0.); } + for (int c = 0; c != res_c.MyLength(); ++c) { + res_c[0][c] = std::max(res_c[0][c], 0.); + } } } } @@ -87,10 +87,8 @@ ReciprocalEvaluator::EvaluatePartialDerivative_(const State& S, auto key_tag_numer = dependencies_.begin(); auto key_tag_denom = dependencies_.begin(); - if (key_tag_numer->first == reciprocal_key_) - key_tag_numer++; - else - key_tag_denom++; + if (key_tag_numer->first == reciprocal_key_) key_tag_numer++; + else key_tag_denom++; if (wrt_key == key_tag_denom->first) { const auto& numer = S.Get(key_tag_numer->first, key_tag_numer->second); @@ -110,7 +108,7 @@ ReciprocalEvaluator::EvaluatePartialDerivative_(const State& S, for (const auto& comp : *result[0]) { Epetra_MultiVector& res_c = *result[0]->ViewComponent(comp, false); const Epetra_MultiVector& denom_c = *denom.ViewComponent(comp, false); - for (int c = 0; c != res_c.MyLength(); ++c) res_c[0][c] = -coef_ / denom_c[0][c]; + for (int c = 0; c != res_c.MyLength() ; ++c) res_c[0][c] = -coef_ / denom_c[0][c]; } } } diff --git a/src/constitutive_relations/generic_evaluators/ReciprocalEvaluator_reg.hh b/src/constitutive_relations/generic_evaluators/ReciprocalEvaluator_reg.hh index b4f8ea515..c64a00092 100644 --- a/src/constitutive_relations/generic_evaluators/ReciprocalEvaluator_reg.hh +++ b/src/constitutive_relations/generic_evaluators/ReciprocalEvaluator_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - ReciprocalEvaluator::factory_("reciprocal evaluator"); +Utils::RegisteredFactory ReciprocalEvaluator::factory_( + "reciprocal evaluator"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator.cc b/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator.cc index 0db532695..e21dbc126 100644 --- a/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator.cc +++ b/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator.cc @@ -64,7 +64,7 @@ SubgridAggregateEvaluator::EnsureEvaluators(State& S) { if (dependencies_.size() == 0) { auto ds = S.GetDomainSet(source_domain_); - Tag dep_tag = Keys::readTag(plist_, my_keys_.front().second); + Tag dep_tag = Keys::readTag(plist_, "dependency", my_keys_.front().second); if (ds->getReferencingParent() == Teuchos::null) { Errors::Message msg; msg << "SubgridAggregateEvaluator: DomainSet \"" << source_domain_ diff --git a/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator.hh b/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator.hh index 9d4fc5598..8175fcc87 100644 --- a/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator.hh +++ b/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator.hh @@ -10,8 +10,8 @@ //! SubgridAggregateEvaluator restricts a field to the subgrid version of the same field. /*! -.. _subgrid-aggregate-evaluator-spec: -.. admonition:: subgrid-aggregate-evaluator-spec +.. _evaluator-subgrid-aggregate-spec: +.. admonition:: evaluator-subgrid-aggregate-spec * `"source domain name`" ``[string]`` Domain name of the source mesh. diff --git a/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator_reg.hh b/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator_reg.hh index 8655c3feb..15f2598c9 100644 --- a/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator_reg.hh +++ b/src/constitutive_relations/generic_evaluators/SubgridAggregateEvaluator_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - SubgridAggregateEvaluator::factory_("subgrid aggregate evaluator"); +Utils::RegisteredFactory SubgridAggregateEvaluator::factory_( + "subgrid aggregate evaluator"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/generic_evaluators/SubgridDisaggregateEvaluator.hh b/src/constitutive_relations/generic_evaluators/SubgridDisaggregateEvaluator.hh index 520ba7851..2c6ad3217 100644 --- a/src/constitutive_relations/generic_evaluators/SubgridDisaggregateEvaluator.hh +++ b/src/constitutive_relations/generic_evaluators/SubgridDisaggregateEvaluator.hh @@ -13,8 +13,8 @@ Note that this evaluator fills exactly one subdomain in a domain set -- there will be N evaluators each filling one subdomain. -.. _subgrid-disaggregate-evaluator-spec: -.. admonition:: subgrid-disaggregate-evaluator-spec +.. _evaluator-subgrid-disaggregate-spec: +.. admonition:: evaluator-subgrid-disaggregate-spec * `"source domain name`" ``[string]`` Domain name of the source mesh. diff --git a/src/constitutive_relations/generic_evaluators/TimeMaxEvaluator.cc b/src/constitutive_relations/generic_evaluators/TimeMaxEvaluator.cc index 0037eff2e..cf5d43671 100644 --- a/src/constitutive_relations/generic_evaluators/TimeMaxEvaluator.cc +++ b/src/constitutive_relations/generic_evaluators/TimeMaxEvaluator.cc @@ -57,7 +57,9 @@ TimeMaxEvaluator::Evaluate_(const State& S, const std::vector& .ViewComponent("cell", false); if (operator_ == "max") { - for (int c = 0; c != res.MyLength(); ++c) { res[0][c] = std::max(res[0][c], dep[0][c]); } + for (int c = 0; c != res.MyLength(); ++c) { + res[0][c] = std::max(res[0][c], dep[0][c]); + } } } diff --git a/src/constitutive_relations/generic_evaluators/TimeMaxEvaluator.hh b/src/constitutive_relations/generic_evaluators/TimeMaxEvaluator.hh index 43f9d99ae..75a310a82 100644 --- a/src/constitutive_relations/generic_evaluators/TimeMaxEvaluator.hh +++ b/src/constitutive_relations/generic_evaluators/TimeMaxEvaluator.hh @@ -11,8 +11,8 @@ Computes a maximum (or minimum) of a field, over time in a pointwise way. -.. _time-max-evaluator-spec: -.. admonition:: time-max-evaluator-spec +.. _evaluator-time-max-spec: +.. admonition:: evaluator-time-max-spec * `"operator`" ``[string]`` **max** One of max or min. diff --git a/src/constitutive_relations/surface_subsurface_fluxes/overland_source_from_subsurface_flux_evaluator.cc b/src/constitutive_relations/surface_subsurface_fluxes/overland_source_from_subsurface_flux_evaluator.cc index 005a8491b..02cc1938b 100644 --- a/src/constitutive_relations/surface_subsurface_fluxes/overland_source_from_subsurface_flux_evaluator.cc +++ b/src/constitutive_relations/surface_subsurface_fluxes/overland_source_from_subsurface_flux_evaluator.cc @@ -105,7 +105,9 @@ void OverlandSourceFromSubsurfaceFluxEvaluator::Evaluate_(const State& S, const std::vector& result) { - if (face_and_dirs_ == Teuchos::null) { IdentifyFaceAndDirection_(S); } + if (face_and_dirs_ == Teuchos::null) { + IdentifyFaceAndDirection_(S); + } auto tag = my_keys_.front().second; Teuchos::RCP subsurface = S.GetMesh(domain_sub_); diff --git a/src/constitutive_relations/surface_subsurface_fluxes/surface_top_cells_evaluator_reg.hh b/src/constitutive_relations/surface_subsurface_fluxes/surface_top_cells_evaluator_reg.hh index 829a6e814..24fb3cdd0 100644 --- a/src/constitutive_relations/surface_subsurface_fluxes/surface_top_cells_evaluator_reg.hh +++ b/src/constitutive_relations/surface_subsurface_fluxes/surface_top_cells_evaluator_reg.hh @@ -19,8 +19,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - SurfaceTopCellsEvaluator::reg_("surface from top cell evaluator"); +Utils::RegisteredFactory SurfaceTopCellsEvaluator::reg_( + "surface from top cell evaluator"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/surface_subsurface_fluxes/top_cells_surface_evaluator_reg.hh b/src/constitutive_relations/surface_subsurface_fluxes/top_cells_surface_evaluator_reg.hh index 838905581..1c031acf2 100644 --- a/src/constitutive_relations/surface_subsurface_fluxes/top_cells_surface_evaluator_reg.hh +++ b/src/constitutive_relations/surface_subsurface_fluxes/top_cells_surface_evaluator_reg.hh @@ -19,8 +19,8 @@ namespace Amanzi { namespace Relations { // registry of method -Utils::RegisteredFactory - TopCellsSurfaceEvaluator::reg_("top cell from surface evaluator"); +Utils::RegisteredFactory TopCellsSurfaceEvaluator::reg_( + "top cell from surface evaluator"); } // namespace Relations } // namespace Amanzi diff --git a/src/constitutive_relations/surface_subsurface_fluxes/volumetric_darcy_flux_evaluator.cc b/src/constitutive_relations/surface_subsurface_fluxes/volumetric_darcy_flux_evaluator.cc index ac27f4801..8e2be068f 100644 --- a/src/constitutive_relations/surface_subsurface_fluxes/volumetric_darcy_flux_evaluator.cc +++ b/src/constitutive_relations/surface_subsurface_fluxes/volumetric_darcy_flux_evaluator.cc @@ -69,12 +69,10 @@ Volumetric_FluxEvaluator::Evaluate_(const State& S, const std::vector 0) - res_v[0][f] = darcy_flux[0][f] / n_liq; - else - res_v[0][f] = 0.; + if (n_liq > 0) res_v[0][f] = darcy_flux[0][f] / n_liq; + else res_v[0][f] = 0.; } } diff --git a/src/constitutive_relations/surface_subsurface_fluxes/volumetric_darcy_flux_evaluator_reg.hh b/src/constitutive_relations/surface_subsurface_fluxes/volumetric_darcy_flux_evaluator_reg.hh index 19812ecf8..4a4b672ba 100644 --- a/src/constitutive_relations/surface_subsurface_fluxes/volumetric_darcy_flux_evaluator_reg.hh +++ b/src/constitutive_relations/surface_subsurface_fluxes/volumetric_darcy_flux_evaluator_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Relations { -Utils::RegisteredFactory - Volumetric_FluxEvaluator::fac_("volumetric darcy flux"); +Utils::RegisteredFactory Volumetric_FluxEvaluator::fac_( + "volumetric darcy flux"); } // namespace Relations } // namespace Amanzi diff --git a/src/executables/ats_driver.cc b/src/executables/ats_driver.cc index 8a89c1440..498569c18 100644 --- a/src/executables/ats_driver.cc +++ b/src/executables/ats_driver.cc @@ -36,7 +36,7 @@ #include "TreeVector.hh" #include "PK_Factory.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "exceptions.hh" #include "errors.hh" diff --git a/src/executables/ats_driver.hh b/src/executables/ats_driver.hh index ef499dfaf..1872f987f 100644 --- a/src/executables/ats_driver.hh +++ b/src/executables/ats_driver.hh @@ -21,14 +21,14 @@ called `"main`". That list contains the following required elements: .. _main-spec: .. admonition:: main-spec - * `"cycle driver`" ``[coordinator-spec]`` See below. - * `"mesh`" ``[mesh-typed-spec-list]`` A list of Mesh_ objects. - * `"regions`" ``[region-typedinline-spec-list]`` A list of Region_ objects. - * `"visualization`" ``[visualization-spec-list]`` A list of Visualization_ objects. - * `"observations`" ``[observation-spec-list]`` An list of Observation_ objects. - * `"checkpoint`" ``[checkpoint-spec]`` A Checkpoint_ spec. - * `"PKs`" ``[pk-typedinline-spec-list]`` A list of `Process Kernels`_. - * `"state`" ``[state-spec]`` A State_ spec. + * `"cycle driver`" ``[coordinator-spec]`` See below. + * `"mesh`" ``[mesh-typed-spec-list]`` A list of :doc:`mesh` objects. + * `"regions`" ``[region-typedinline-spec-list]`` A list of :doc:`region` objects. + * `"visualization`" ``[visualization-spec-list]`` A list of :ref:`Visualization` objects. + * `"observations`" ``[observation-spec-list]`` An list of :ref:`Observations` objects. + * `"checkpoint`" ``[checkpoint-spec]`` A :ref:`Checkpoint` spec. + * `"PKs`" ``[pk-typedinline-spec-list]`` A list of :ref:`Process Kernels`. + * `"state`" ``[state-spec]`` A :ref:`State` spec. Coordinator @@ -40,40 +40,41 @@ simulation, including starting and ending times and restart options. .. _coordinator-spec: .. admonition:: coordinator-spec - * `"start time`" ``[double]`` **0.** Specifies the start of time in model time. - * `"start time units`" ``[string]`` **"s"** One of "s", "d", or "yr" + * `"start time`" ``[double]`` **0.** Specifies the start of time in model time. + * `"start time units`" ``[string]`` **"s"** One of "s", "d", or "yr" - ONE OF + ONE OF - * `"end time`" ``[double]`` Specifies the end of the simulation in model time. - * `"end time units`" ``[string]`` **"s"** One of `"s`", `"d`", or `"yr`" + * `"end time`" ``[double]`` Specifies the end of the simulation in model time. + * `"end time units`" ``[string]`` **"s"** One of `"s`", `"d`", or `"yr`" - OR + OR - * `"end cycle`" ``[int]`` **optional** If provided, specifies the end of the - simulation in timestep cycles. + * `"end cycle`" ``[int]`` **optional** If provided, specifies the end of the + simulation in timestep cycles. - END + END - * `"subcycled timestep`" ``[bool]`` **false** If true, this coordinator creates - a third State object to store intermediate solutions, allowing for failed - steps. - * `"restart from checkpoint file`" ``[string]`` **optional** If provided, - specifies a path to the checkpoint file to continue a stopped simulation. - * `"wallclock duration [hrs]`" ``[double]`` **optional** After this time, the - simulation will checkpoint and end. - * `"required times`" ``[io-event-spec]`` **optional** An IOEvent_ spec that - sets a collection of times/cycles at which the simulation is guaranteed to - hit exactly. This is useful for situations such as where data is provided at - a regular interval, and interpolation error related to that data is to be - minimized. - * `"PK tree`" ``[pk-typed-spec-list]`` List of length one, the top level - PK_ spec. + * `"subcycled timestep`" ``[bool]`` **false** If true, this coordinator creates + a third State object to store intermediate solutions, allowing for failed + steps. + * `"restart from checkpoint file`" ``[string]`` **optional** If provided, + specifies a path to the checkpoint file to continue a stopped simulation. + * `"wallclock duration [hrs]`" ``[double]`` **optional** After this time, the + simulation will checkpoint and end. + + * `"required times`" ``[io-event-spec]`` **optional** An + :doc:`/input_spec/io/ioevent` spec that sets a collection of times/cycles + at which the simulation is guaranteed to hit exactly. This is useful for + situations such as where data is provided at a regular interval, and + interpolation error related to that data is to be minimized. + * `"PK tree`" ``[pk-typed-spec-list]`` List of length one, the top level + :doc:`/input_spec/process_kernels/index` spec. Note: Either `"end cycle`" or `"end time`" are required, and if both are present, the simulation will stop with whichever arrives first. An `"end cycle`" is commonly used to ensure that, in the case -of a timestep crash, we do not continue on forever spewing output. +of a timestep crash, we do not continue the simulation indefinitely. Example: diff --git a/src/executables/ats_mesh_factory.cc b/src/executables/ats_mesh_factory.cc index dbfcb6d77..0d75ac64f 100644 --- a/src/executables/ats_mesh_factory.cc +++ b/src/executables/ats_mesh_factory.cc @@ -150,7 +150,9 @@ createMeshLogical(const std::string& mesh_name, mesh = factory.createLogical(mesh_logical_plist); } - if (mesh != Teuchos::null) { checkVerifyMesh(*mesh_plist, mesh); } + if (mesh != Teuchos::null) { + checkVerifyMesh(*mesh_plist, mesh); + } bool deformable = mesh_plist->get("deformable mesh", false); S.RegisterMesh(mesh_name, mesh, deformable); @@ -518,7 +520,7 @@ createDomainSetIndexed(const std::string& mesh_name_pristine, Teuchos::RCP reference_mesh = Teuchos::null; if (is_reference_mesh) { reference_parent_name = ds_list->get("referencing parent domain"); - if (S.HasMesh(reference_parent_name)) reference_mesh = S.GetMesh(reference_parent_name); + if (S.HasMesh(reference_parent_name) ) reference_mesh = S.GetMesh(reference_parent_name); } else { reference_parent_name = "NONE"; } @@ -659,7 +661,7 @@ createDomainSetRegions(const std::string& mesh_name_pristine, Teuchos::RCP reference_mesh = Teuchos::null; if (is_reference_mesh) { reference_parent_name = ds_list->get("referencing parent domain"); - if (S.HasMesh(reference_parent_name)) reference_mesh = S.GetMesh(reference_parent_name); + if (S.HasMesh(reference_parent_name) ) reference_mesh = S.GetMesh(reference_parent_name); } else { reference_parent_name = "NONE"; } @@ -855,7 +857,9 @@ createMeshes(const Teuchos::RCP& global_list, void setDefaultParameters(Teuchos::ParameterList& plist, const Amanzi::VerboseObject& vo) { - if (!plist.isParameter("partitioner")) { plist.set("partitioner", "zoltan_rcb"); } + if (!plist.isParameter("partitioner")) { + plist.set("partitioner", "zoltan_rcb"); + } if (!plist.isSublist("verbose object")) { plist.sublist("verbose object").set("verbosity level", vo.getVerbLevelString()); } diff --git a/src/executables/ats_mesh_factory.hh b/src/executables/ats_mesh_factory.hh index 72a6bb8bb..bfcade9c0 100644 --- a/src/executables/ats_mesh_factory.hh +++ b/src/executables/ats_mesh_factory.hh @@ -70,14 +70,17 @@ Generated mesh are by definition structured, with uniform dx, dy, and dz. Such a mesh is specified by a bounding box high and low coordinate, and a list of number of cells in each direction. -Specified by `"mesh type`" of `"generate mesh`". +`"mesh type`" = `"generate mesh`". .. _mesh-generate-mesh-spec: .. admonition:: mesh-generate-mesh-spec - * `"domain low coordinate`" ``[Array(double)]`` Location of low corner of domain - * `"domain high coordinate`" ``[Array(double)]`` Location of high corner of domain - * `"number of cells`" ``[Array(int)]`` the number of uniform cells in each coordinate direction + * `"domain low coordinate`" ``[Array(double)]`` Location of low corner of + domain + * `"domain high coordinate`" ``[Array(double)]`` Location of high corner of + domain + * `"number of cells`" ``[Array(int)]`` the number of uniform cells in each + coordinate direction Example: @@ -108,7 +111,7 @@ generated with a Nemesis tool and named as filename.par.N.r where N is the number of processors and r is the rank. When running in parallel and the suffix is .exo, the code will partition automatically the serial file. -Specified by `"mesh type`" of `"read mesh file`". +`"mesh type`" = `"read mesh file`". .. _mesh-read-mesh-file-spec: .. admonition:: mesh-read-mesh-file-spec @@ -143,7 +146,7 @@ unstructured mesh. This is an active research and development area, and is used most frequently for river networks, root networks, and crack networks. -Specified by `"mesh type`" of `"logical`". +`"mesh type`" = `"logical`". .. todo:: WIP: add spec! @@ -165,7 +168,7 @@ projected in the z-direction. No checks for holes are performed. Surface meshes may similarly be audited to make sure they are reasonable for computation. -Specified by `"mesh type`" of `"surface`". +`"mesh type`" = `"surface`". .. _mesh-surface-spec: .. admonition:: mesh-surface-spec @@ -174,11 +177,11 @@ Specified by `"mesh type`" of `"surface`". ONE OF - * `"surface sideset name`" ``[string]`` The Region_ name containing all surface faces. + * `"surface sideset name`" ``[string]`` The :doc:`region` name containing all surface faces. OR - * `"surface sideset names`" ``[Array(string)]`` A list of Region_ names containing the surface faces. + * `"surface sideset names`" ``[Array(string)]`` A list of :doc:`region` names containing the surface faces. END @@ -220,7 +223,7 @@ is preserved, so all local entities in this mesh have parents whose entities are local on the parent mesh, so that no communication is ever done when passing info between an parent mesh and an extracted mesh. -Specified by `"mesh type`" of `"extracted`". +`"mesh type`" = `"extracted`". .. _mesh-extracted-spec: .. admonition:: mesh-extracted-spec @@ -244,7 +247,7 @@ Specified by `"mesh type`" of `"extracted`". of this mesh is the same as the parent mesh. If true, the communicator of this mesh is the subset of the parent mesh comm that has entries on the surface. - + Aliased Mesh ============ @@ -255,7 +258,7 @@ instance, one might find it useful to define both a "surface water" and a "surface" domain would point to the "surface" mesh, and the "snow" domain would be an "aliased" domain whose target is the "surface" mesh. -Specified by `"mesh type`" of `"aliased`". +`"mesh type`" = `"aliased`". .. _mesh-aliased-spec: .. admonition:: mesh-aliased-spec @@ -276,7 +279,7 @@ local ID of an entity (in the case of `"domain set indexed`") or a region name (in the case of `"domain set regions`"). -Indexed domain set meshes are specified by `"mesh type`" of `"domain set indexed`". +`"mesh type`" = `"domain set indexed`". .. _mesh-domain-set-indexed-spec: .. admonition:: mesh-domain-set-indexed-spec @@ -291,7 +294,7 @@ Indexed domain set meshes are specified by `"mesh type`" of `"domain set indexed surface. Note, additionally, there must be a sublist of the name of the domain set, -which itself is a `"mesh-typed-spec`"_, but may be missing some info +which itself is a :doc:`mesh-typed-spec `, but may be missing some info (e.g. `"entity LID`") that is filled in by this index. Example: @@ -315,7 +318,7 @@ Example: -Region-based domain set meshes are specified by `"mesh type`" of `"domain set regions`". +`"mesh type`" = `"domain set regions`". .. _mesh-domain-set-regions-spec: .. admonition:: mesh-domain-set-regions-spec @@ -330,7 +333,7 @@ Region-based domain set meshes are specified by `"mesh type`" of `"domain set re surface. Note, additionally, there must be a sublist of the name of the domain set, -which itself is a `"mesh-typed-spec`"_, but may be missing some info +which itself is a :doc:`mesh-typed-spec `, but may be missing some info (e.g. `"region`") that is filled in by this domain set. Example: the below example shows how to extract two subdomains, making them @@ -365,7 +368,7 @@ Column Meshes `Domain Set Meshes`_, which generate a column mesh spec for every face of a set. -Specified by `"mesh type`" of `"column`". +`"mesh type`" = `"column`". .. _mesh-column-spec: .. admonition:: mesh-column-spec @@ -405,7 +408,7 @@ Column Surface Meshes `Domain Set Meshes`_, which generate a column surface mesh spec for every face of a set. -Specified by `"mesh type`" of `"column surface`". +`"mesh type`" = `"column surface`". .. _mesh-column-surface-spec: .. admonition:: mesh-column-surface-spec @@ -434,101 +437,96 @@ namespace Mesh { // // Helper function // -bool -checkVerifyMesh(Teuchos::ParameterList& mesh_plist, - Teuchos::RCP mesh); +bool checkVerifyMesh(Teuchos::ParameterList& mesh_plist, + Teuchos::RCP mesh); // // Create mesh for each type // -Teuchos::RCP -createMeshFromFile(const std::string& mesh_name, - const Teuchos::RCP& mesh_plist, - const Amanzi::Comm_ptr_type& comm, - const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -Teuchos::RCP -createMeshGenerated(const std::string& mesh_name, - const Teuchos::RCP& mesh_plist, - const Amanzi::Comm_ptr_type& comm, - const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -Teuchos::RCP -createMeshLogical(const std::string& mesh_name, - const Teuchos::RCP& mesh_plist, +Teuchos::RCP createMeshFromFile( + const std::string& mesh_name, + const Teuchos::RCP& mesh_plist, + const Amanzi::Comm_ptr_type& comm, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +Teuchos::RCP createMeshGenerated( + const std::string& mesh_name, + const Teuchos::RCP& mesh_plist, + const Amanzi::Comm_ptr_type& comm, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +Teuchos::RCP createMeshLogical( + const std::string& mesh_name, + const Teuchos::RCP& mesh_plist, + const Amanzi::Comm_ptr_type& comm, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +Teuchos::RCP createMeshAliased( + const std::string& mesh_name, + const Teuchos::RCP& mesh_plist, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +Teuchos::RCP createMeshSurface( + const std::string& mesh_name, + const Teuchos::RCP& mesh_plist, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +Teuchos::RCP createMeshExtracted( + const std::string& mesh_name, + const Teuchos::RCP& mesh_plist, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + + +Teuchos::RCP createMeshColumn( + const std::string& mesh_name, + const Teuchos::RCP& mesh_plist, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +Teuchos::RCP createMeshColumnSurface( + const std::string& mesh_name, + const Teuchos::RCP& mesh_plist, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +void createDomainSetIndexed(const std::string& mesh_name_pristine, + const Teuchos::RCP& mesh_plist, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +void createDomainSetRegions(const std::string& mesh_name_pristine, + const Teuchos::RCP& mesh_plist, + const Teuchos::RCP& gm, + Amanzi::State& S, + Amanzi::VerboseObject& vo); + +Teuchos::RCP createMesh( + const Teuchos::RCP& plist, + const Amanzi::Comm_ptr_type& comm, + const Teuchos::RCP& gm, + Amanzi::State& s, + Amanzi::VerboseObject& vo); + +void createMeshes(const Teuchos::RCP& plist, const Amanzi::Comm_ptr_type& comm, const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -Teuchos::RCP -createMeshAliased(const std::string& mesh_name, - const Teuchos::RCP& mesh_plist, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -Teuchos::RCP -createMeshSurface(const std::string& mesh_name, - const Teuchos::RCP& mesh_plist, - const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -Teuchos::RCP -createMeshExtracted(const std::string& mesh_name, - const Teuchos::RCP& mesh_plist, - const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - - -Teuchos::RCP -createMeshColumn(const std::string& mesh_name, - const Teuchos::RCP& mesh_plist, - const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -Teuchos::RCP -createMeshColumnSurface(const std::string& mesh_name, - const Teuchos::RCP& mesh_plist, - const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -void -createDomainSetIndexed(const std::string& mesh_name_pristine, - const Teuchos::RCP& mesh_plist, - const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -void -createDomainSetRegions(const std::string& mesh_name_pristine, - const Teuchos::RCP& mesh_plist, - const Teuchos::RCP& gm, - Amanzi::State& S, - Amanzi::VerboseObject& vo); - -Teuchos::RCP -createMesh(const Teuchos::RCP& plist, - const Amanzi::Comm_ptr_type& comm, - const Teuchos::RCP& gm, - Amanzi::State& s, - Amanzi::VerboseObject& vo); - -void -createMeshes(const Teuchos::RCP& plist, - const Amanzi::Comm_ptr_type& comm, - const Teuchos::RCP& gm, - Amanzi::State& s); - -void -setDefaultParameters(Teuchos::ParameterList& plist, const Amanzi::VerboseObject& vo); + Amanzi::State& s); + +void setDefaultParameters(Teuchos::ParameterList& plist, const Amanzi::VerboseObject& vo); } // namespace Mesh } // namespace ATS diff --git a/src/executables/ats_registration_files.hh b/src/executables/ats_registration_files.hh index a0c440c88..6d348689f 100644 --- a/src/executables/ats_registration_files.hh +++ b/src/executables/ats_registration_files.hh @@ -23,7 +23,7 @@ //#include "ats_sediment_transport_registration.hh" #include "models_transport_reg.hh" #ifdef ALQUIMIA_ENABLED -# include "pks_chemistry_reg.hh" +#include "pks_chemistry_reg.hh" #endif #ifdef ECOSIM_ENABLED # include "ats_ecosim_registration.hh" diff --git a/src/executables/coordinator.cc b/src/executables/coordinator.cc index 9b771d060..b2023c8e6 100644 --- a/src/executables/coordinator.cc +++ b/src/executables/coordinator.cc @@ -50,7 +50,7 @@ actual work. #include "PK.hh" #include "TreeVector.hh" #include "PK_Factory.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "ats_mesh_factory.hh" @@ -172,12 +172,12 @@ Coordinator::Coordinator(const Teuchos::RCP& plist, } // writes cellcentroids in global ordering - if (plist_->sublist("mesh").sublist(mesh->first).isSublist("mesh info")){ + if (plist_->sublist("mesh").sublist(mesh->first).isSublist("mesh info")) { auto& mesh_info_list = plist_->sublist("mesh").sublist(mesh->first).sublist("mesh info"); Teuchos::RCP mesh_info = Teuchos::rcp(new Amanzi::MeshInfo(mesh_info_list, *S_)); mesh_info->WriteMeshCentroids(mesh->first, *(mesh->second.first)); - } + } } @@ -252,7 +252,8 @@ Coordinator::Coordinator(const Teuchos::RCP& plist, } // create the timestep manager, register assorted timestep control events - tsm_ = Teuchos::rcp(new Amanzi::Utils::TimeStepManager(coordinator_list_->sublist("timestep manager"))); + tsm_ = Teuchos::rcp( + new Amanzi::Utils::TimeStepManager(coordinator_list_->sublist("timestep manager"))); checkpoint_->RegisterWithTimeStepManager(*tsm_); for (const auto& obs : observations_) obs->RegisterWithTimeStepManager(*tsm_); for (const auto& vis : visualization_) vis->RegisterWithTimeStepManager(*tsm_); @@ -311,8 +312,9 @@ Coordinator::initialize() // - get the time prior to initializing anything else if (restart_) { double t_restart = Amanzi::ReadCheckpointInitialTime(comm_, restart_filename_); - S_->set_time(Amanzi::Tags::CURRENT, t_restart); - S_->set_time(Amanzi::Tags::NEXT, t_restart); + for (const auto& record : S_->GetRecordSet("time")) { + S_->set_time(record.first, t_restart); + } t0_ = t_restart; } @@ -354,7 +356,6 @@ Coordinator::initialize() } // Final checks. - //S_->CheckNotEvaluatedFieldsInitialized(); S_->InitializeEvaluators(); S_->InitializeFieldCopies(); S_->CheckAllFieldsInitialized(); @@ -395,11 +396,11 @@ rss_usage() defined(__MACH__)) struct rusage usage; getrusage(RUSAGE_SELF, &usage); -# if (defined(__APPLE__) || defined(__MACH__)) +#if (defined(__APPLE__) || defined(__MACH__)) return static_cast(usage.ru_maxrss) / 1024.0 / 1024.0; -# else +#else return static_cast(usage.ru_maxrss) / 1024.0; -# endif +#endif #else return 0.0; #endif @@ -424,7 +425,9 @@ Coordinator::report_memory() double mem = rss_usage(); double percell(mem); - if (local_ncells > 0) { percell = mem / local_ncells; } + if (local_ncells > 0) { + percell = mem / local_ncells; + } double max_percell(0.0); double min_percell(0.0); @@ -534,7 +537,9 @@ Coordinator::get_dt(bool after_fail) } // cap the max step size - if (dt > max_dt_) { dt = max_dt_; } + if (dt > max_dt_) { + dt = max_dt_; + } // ask the step manager if this step is ok dt = tsm_->TimeStep(S_->get_time(Amanzi::Tags::NEXT), dt, after_fail); @@ -613,13 +618,19 @@ Coordinator::visualize(bool force) double time = S_->get_time(); if (!dump) { - for (const auto& vis : visualization_) { dump |= vis->DumpRequested(cycle, time); } + for (const auto& vis : visualization_) { + dump |= vis->DumpRequested(cycle, time); + } } - if (dump) { pk_->CalculateDiagnostics(Amanzi::Tags::NEXT); } + if (dump) { + pk_->CalculateDiagnostics(Amanzi::Tags::NEXT); + } for (const auto& vis : visualization_) { - if (force || vis->DumpRequested(cycle, time)) { WriteVis(*vis, *S_); } + if (force || vis->DumpRequested(cycle, time)) { + WriteVis(*vis, *S_); + } } return dump; } diff --git a/src/executables/elm_ats_api/Indexer.hh b/src/executables/elm_ats_api/Indexer.hh index f7be7d43c..ceadde70d 100644 --- a/src/executables/elm_ats_api/Indexer.hh +++ b/src/executables/elm_ats_api/Indexer.hh @@ -13,19 +13,13 @@ namespace ATS { namespace Utils { -enum class Indexer_kind { - SCALAR = 0, - ELM, - ATS -}; +enum class Indexer_kind { SCALAR = 0, ELM, ATS }; -enum class Domain_kind { - SURF, - SUBSURF -}; +enum class Domain_kind { SURF, SUBSURF }; -template struct Indexer; +template +struct Indexer; // // Indexer for scalars. @@ -33,14 +27,21 @@ template struct Indexer; template struct Indexer { template - typename std::enable_if::type - get(T const * const& val, const int col, const int cic) const { return *val_; } + typename std::enable_if::type get(T const* const& val, + const int col, + const int cic) const + { + return *val_; + } template - typename std::enable_if::type - get(T const * const& val, const int i) const { return *val_; } + typename std::enable_if::type get(T const* const& val, + const int i) const + { + return *val_; + } -private: + private: T* val_; }; @@ -50,21 +51,24 @@ private: // template struct Indexer { - - Indexer(int ncells_per_col=-1) - : ncells_per_col_(ncells_per_col) {} + Indexer(int ncells_per_col = -1) + : ncells_per_col_(ncells_per_col) + {} // for use by subsurface template - typename std::enable_if::type - get(T * const& val, const int col, const int cic) const { + typename std::enable_if::type get(T* const& val, + const int col, + const int cic) const + { return val[col * ncells_per_col_ + cic]; } // for use by surface template - typename std::enable_if::type - get(T * const& val, const int i) const { + typename std::enable_if::type get(T* const& val, + const int i) const + { return val[i]; } @@ -78,21 +82,24 @@ struct Indexer { // template struct Indexer { - Indexer(const Amanzi::AmanziMesh::Mesh& mesh) - : mesh_(mesh) {} + : mesh_(mesh) + {} // for use by subsurface template - typename std::enable_if::type - get(T * const& val, const int col, const int cic) const { + typename std::enable_if::type get(T* const& val, + const int col, + const int cic) const + { return val[mesh_.cells_of_column(col)[cic]]; } // for use by surface template - typename std::enable_if::type - get(T * const& val, const int i) const { + typename std::enable_if::type get(T* const& val, + const int i) const + { return val[i]; } @@ -101,8 +108,5 @@ struct Indexer { }; - - - } // namespace Utils } // namespace ATS diff --git a/src/executables/elm_ats_api/elm_ats_api.cc b/src/executables/elm_ats_api/elm_ats_api.cc index c2bebe3d7..b113e24f1 100644 --- a/src/executables/elm_ats_api/elm_ats_api.cc +++ b/src/executables/elm_ats_api/elm_ats_api.cc @@ -13,144 +13,157 @@ #include "elm_ats_api.h" #ifdef __cplusplus -extern "C"{ -#endif - -// allocate, call constructor and cast ptr to opaque ELM_ATSDriver_ptr -ELM_ATSDriver_ptr ats_create(MPI_Fint *f_comm, const char *input_filename) -{ - return reinterpret_cast(ATS::createELM_ATSDriver(f_comm, input_filename)); -} - -// reinterpret as elm_ats_driver and delete (calls destructor) -void ats_delete(ELM_ATSDriver_ptr ats) -{ - auto ats_ptr = reinterpret_cast(ats); - ats_ptr->finalize(); - delete ats_ptr; -} - -// call driver advance() -void ats_advance(ELM_ATSDriver_ptr ats, - double const * const dt, - bool const * const checkpoint, - bool const * const visualize) -{ - reinterpret_cast(ats)->advance(*dt, *checkpoint, *visualize); -} - -// call driver advance_test() -void ats_advance_test(ELM_ATSDriver_ptr ats) -{ - reinterpret_cast(ats)->advance_test(); -} - -void ats_get_mesh_info(ELM_ATSDriver_ptr ats, - int * const ncols_local, - int * const ncols_global, - double * const lat, - double * const lon, - double * const elev, - double * const surf_area, - int * const pft, - int * const nlevgrnd, - double * const depth) -{ - reinterpret_cast(ats)->get_mesh_info(*ncols_local, *ncols_global, - lat, lon, elev, surf_area, pft, *nlevgrnd, depth); -} - - -// call driver setup() -void ats_setup(ELM_ATSDriver_ptr ats) -{ - reinterpret_cast(ats)->setup(); -} -// call driver initialize() -void ats_initialize(ELM_ATSDriver_ptr ats, - double const * const t, - double const * const patm, - double const * const soilp) -{ - reinterpret_cast(ats)->initialize(*t, patm, soilp); +namespace { + // did ATS initialize kokkos? + bool ats_kokkos_init = false; } - -void ats_set_soil_hydrologic_parameters(ELM_ATSDriver_ptr ats, - double const * const base_porosity, - double const * const hydraulic_conductivity, - double const * const clapp_horn_b, - double const * const clapp_horn_smpsat, - double const * const clapp_horn_sr) +extern "C" { - reinterpret_cast(ats) - ->set_soil_hydrologic_parameters(base_porosity, hydraulic_conductivity, - clapp_horn_b, clapp_horn_smpsat, clapp_horn_sr); -} - - -void ats_set_veg_parameters(ELM_ATSDriver_ptr ats, - double const * const mafic_potential_full_turgor, - double const * const mafic_potential_wilt_point) -{ - reinterpret_cast(ats) - ->set_veg_parameters(mafic_potential_full_turgor, mafic_potential_wilt_point); -} - - -void ats_set_soil_hydrologic_properties(ELM_ATSDriver_ptr ats, - double const * const effective_porosity) -{ - reinterpret_cast(ats) - ->set_soil_hydrologic_properties(effective_porosity); -} - - -// set veg properties, non-constant in time -void ats_set_veg_properties(ELM_ATSDriver_ptr ats, - double const * const rooting_fraction) -{ - reinterpret_cast(ats) - ->set_veg_properties(rooting_fraction); -} - - -// call driver set_sources() -void ats_set_sources(ELM_ATSDriver_ptr ats, - double const * const surface_infiltration, - double const * const surface_evaporation, - double const * const subsurface_transpiration) -{ - reinterpret_cast(ats) - ->set_potential_sources(surface_infiltration, surface_evaporation, subsurface_transpiration); -} - - -void ats_get_waterstate(ELM_ATSDriver_ptr ats, - double * const surface_ponded_depth, - double * const water_table_depth, - double * const soil_pressure, - double * const soil_psi, - double * const sat_liq, - double * const sat_ice) -{ - reinterpret_cast(ats) - ->get_waterstate(surface_ponded_depth, water_table_depth, soil_pressure, soil_psi, sat_liq, sat_ice); -} - +#endif -void ats_get_water_fluxes(ELM_ATSDriver_ptr ats, - double * const soil_infiltration, - double * const evaporation, - double * const transpiration, - double * net_subsurface_fluxes, - double * net_runon) -{ - reinterpret_cast(ats) - ->get_water_fluxes(soil_infiltration, evaporation, transpiration, - net_subsurface_fluxes, net_runon); -} + // allocate, call constructor and cast ptr to opaque ELM_ATSDriver_ptr + ELM_ATSDriver_ptr ats_create(MPI_Fint* f_comm, const char* input_filename) + { + // Initialize Kokkos if ELM hasn't already (for near future, it won't) + if (!Kokkos::is_initialized()) { + Kokkos::initialize(); + ats_kokkos_init = true; + } + return reinterpret_cast(ATS::createELM_ATSDriver(f_comm, input_filename)); + } + + // reinterpret as elm_ats_driver and delete (calls destructor) + void ats_delete(ELM_ATSDriver_ptr ats) + { + auto ats_ptr = reinterpret_cast(ats); + ats_ptr->finalize(); + delete ats_ptr; + + // If ATS initialized Kokkos, then finalize it here + if (ats_kokkos_init && Kokkos::is_initialized()) { + Kokkos::finalize(); + ats_kokkos_init = false; + } + } + + // call driver advance() + void ats_advance(ELM_ATSDriver_ptr ats, + double const* const dt, + bool const* const checkpoint, + bool const* const visualize) + { + reinterpret_cast(ats)->advance(*dt, *checkpoint, *visualize); + } + + // call driver advance_test() + void ats_advance_test(ELM_ATSDriver_ptr ats) + { + reinterpret_cast(ats)->advance_test(); + } + + void ats_get_mesh_info(ELM_ATSDriver_ptr ats, + int* const ncols_local, + int* const ncols_global, + double* const lat, + double* const lon, + double* const elev, + double* const surf_area, + int* const pft, + int* const nlevgrnd, + double* const depth) + { + reinterpret_cast(ats)->get_mesh_info( + *ncols_local, *ncols_global, lat, lon, elev, surf_area, pft, *nlevgrnd, depth); + } + + + // call driver setup() + void ats_setup(ELM_ATSDriver_ptr ats) + { + reinterpret_cast(ats)->setup(); + } + + // call driver initialize() + void ats_initialize(ELM_ATSDriver_ptr ats, + double const* const t, + double const* const patm, + double const* const soilp) + { + reinterpret_cast(ats)->initialize(*t, patm, soilp); + } + + + void ats_set_soil_hydrologic_parameters(ELM_ATSDriver_ptr ats, + double const* const base_porosity, + double const* const hydraulic_conductivity, + double const* const clapp_horn_b, + double const* const clapp_horn_smpsat, + double const* const clapp_horn_sr) + { + reinterpret_cast(ats)->set_soil_hydrologic_parameters( + base_porosity, hydraulic_conductivity, clapp_horn_b, clapp_horn_smpsat, clapp_horn_sr); + } + + + void ats_set_veg_parameters(ELM_ATSDriver_ptr ats, + double const* const mafic_potential_full_turgor, + double const* const mafic_potential_wilt_point) + { + reinterpret_cast(ats)->set_veg_parameters(mafic_potential_full_turgor, + mafic_potential_wilt_point); + } + + + void ats_set_soil_hydrologic_properties(ELM_ATSDriver_ptr ats, + double const* const effective_porosity) + { + reinterpret_cast(ats)->set_soil_hydrologic_properties(effective_porosity); + } + + + // set veg properties, non-constant in time + void ats_set_veg_properties(ELM_ATSDriver_ptr ats, double const* const rooting_fraction) + { + reinterpret_cast(ats)->set_veg_properties(rooting_fraction); + } + + + // call driver set_sources() + void ats_set_sources(ELM_ATSDriver_ptr ats, + double const* const surface_infiltration, + double const* const surface_evaporation, + double const* const subsurface_transpiration) + { + reinterpret_cast(ats)->set_potential_sources( + surface_infiltration, surface_evaporation, subsurface_transpiration); + } + + + void ats_get_waterstate(ELM_ATSDriver_ptr ats, + double* const surface_ponded_depth, + double* const water_table_depth, + double* const soil_pressure, + double* const soil_psi, + double* const sat_liq, + double* const sat_ice) + { + reinterpret_cast(ats)->get_waterstate( + surface_ponded_depth, water_table_depth, soil_pressure, soil_psi, sat_liq, sat_ice); + } + + + void ats_get_water_fluxes(ELM_ATSDriver_ptr ats, + double* const soil_infiltration, + double* const evaporation, + double* const transpiration, + double* net_subsurface_fluxes, + double* net_runon) + { + reinterpret_cast(ats)->get_water_fluxes( + soil_infiltration, evaporation, transpiration, net_subsurface_fluxes, net_runon); + } #ifdef __cplusplus } diff --git a/src/executables/elm_ats_api/elm_ats_driver.cc b/src/executables/elm_ats_api/elm_ats_driver.cc index 92336f32b..00d3b73de 100644 --- a/src/executables/elm_ats_api/elm_ats_driver.cc +++ b/src/executables/elm_ats_api/elm_ats_driver.cc @@ -21,13 +21,14 @@ #include "CompositeVector.hh" #include "IO.hh" #include "UnstructuredObservations.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "elm_ats_driver.hh" namespace ATS { ELM_ATSDriver* -createELM_ATSDriver(MPI_Fint *f_comm, const char *infile, int npfts) { +createELM_ATSDriver(MPI_Fint* f_comm, const char* infile, int npfts) +{ // -- create communicator & get process rank //auto comm = getDefaultComm(); auto c_comm = MPI_Comm_f2c(*f_comm); @@ -41,8 +42,7 @@ createELM_ATSDriver(MPI_Fint *f_comm, const char *infile, int npfts) { // check validity of input file name if (input_filename.empty()) { - if (rank == 0) - std::cerr << "ERROR: no input file provided" << std::endl; + if (rank == 0) std::cerr << "ERROR: no input file provided" << std::endl; } else if (!std::filesystem::exists(input_filename)) { if (rank == 0) std::cerr << "ERROR: input file \"" << input_filename << "\" does not exist." << std::endl; @@ -73,7 +73,7 @@ ELM_ATSDriver::ELM_ATSDriver(const Teuchos::RCP& plist, domain_subsurf_ = Keys::readDomain(*plist_, "domain", "domain"); domain_surf_ = Keys::readDomainHint(*plist_, domain_subsurf_, "subsurface", "surface"); - // meshes + // meshes mesh_subsurf_ = S_->GetMesh(domain_subsurf_); mesh_surf_ = S_->GetMesh(domain_surf_); @@ -87,36 +87,54 @@ ELM_ATSDriver::ELM_ATSDriver(const Teuchos::RCP& plist, poro_key_ = Keys::readKey(*plist_, domain_subsurf_, "porosity", "porosity"); perm_key_ = Keys::readKey(*plist_, domain_subsurf_, "permeability", "permeability"); ch_b_key_ = Keys::readKey(*plist_, domain_subsurf_, "Clapp and Hornberger b", "clapp_horn_b"); - ch_smpsat_key_ = Keys::readKey(*plist_, domain_subsurf_, "Clapp and Hornberger soil mafic potential at saturation", "clapp_horn_smpsat"); - ch_sr_key_ = Keys::readKey(*plist_, domain_subsurf_, "Clapp and Hornberger residual saturation", "clapp_horn_sr"); + ch_smpsat_key_ = Keys::readKey(*plist_, + domain_subsurf_, + "Clapp and Hornberger soil mafic potential at saturation", + "clapp_horn_smpsat"); + ch_sr_key_ = Keys::readKey( + *plist_, domain_subsurf_, "Clapp and Hornberger residual saturation", "clapp_horn_sr"); // potential sources - root_frac_key_ = Keys::readKey(*plist_, domain_subsurf_, "rooting depth fraction", "rooting_depth_fraction"); - pot_infilt_key_ = Keys::readKey(*plist_, domain_surf_, "potential infiltration mps", "potential_infiltration_mps"); // inputs onto surface (rain, snowmelt) - pot_evap_key_ = Keys::readKey(*plist_, domain_surf_, "potential evaporation mps", "potential_evaporation_mps"); - pot_trans_key_ = Keys::readKey(*plist_, domain_surf_, "potential transpiration mps", "potential_transpiration_mps"); + root_frac_key_ = + Keys::readKey(*plist_, domain_subsurf_, "rooting depth fraction", "rooting_depth_fraction"); + pot_infilt_key_ = + Keys::readKey(*plist_, + domain_surf_, + "potential infiltration mps", + "potential_infiltration_mps"); // inputs onto surface (rain, snowmelt) + pot_evap_key_ = + Keys::readKey(*plist_, domain_surf_, "potential evaporation mps", "potential_evaporation_mps"); + pot_trans_key_ = Keys::readKey( + *plist_, domain_surf_, "potential transpiration mps", "potential_transpiration_mps"); // water state pd_key_ = Keys::readKey(*plist_, domain_surf_, "ponded depth", "ponded_depth"); wtd_key_ = Keys::readKey(*plist_, domain_surf_, "water table depth", "water_table_depth"); pres_key_ = Keys::readKey(*plist_, domain_subsurf_, "pressure", "pressure"); wc_key_ = Keys::readKey(*plist_, domain_subsurf_, "conserved", "water_content"); - pc_key_ = Keys::readKey(*plist_, domain_subsurf_, "capillary_pressure_gas_liq", "capillary_pressure_gas_liq"); + pc_key_ = Keys::readKey( + *plist_, domain_subsurf_, "capillary_pressure_gas_liq", "capillary_pressure_gas_liq"); sat_key_ = Keys::readKey(*plist_, domain_subsurf_, "saturation", "saturation_liquid"); // water fluxes - infilt_key_ = Keys::readKey(*plist_, domain_surf_, "surface-subsurface flux", "surface_subsurface_flux"); + infilt_key_ = + Keys::readKey(*plist_, domain_surf_, "surface-subsurface flux", "surface_subsurface_flux"); evap_key_ = Keys::readKey(*plist_, domain_surf_, "evaporation", "evaporation"); trans_key_ = Keys::readKey(*plist_, domain_subsurf_, "transpiration", "transpiration"); // keys for fields used to convert ELM units to ATS units - surf_mol_dens_key_ = Keys::readKey(*plist_, domain_surf_, "surface molar density", "molar_density_liquid"); - surf_mass_dens_key_ = Keys::readKey(*plist_, domain_surf_, "surface mass density", "mass_density_liquid"); - subsurf_mol_dens_key_ = Keys::readKey(*plist_, domain_subsurf_, "molar density", "molar_density_liquid"); - subsurf_mass_dens_key_ = Keys::readKey(*plist_, domain_subsurf_, "mass density", "mass_density_liquid"); + surf_mol_dens_key_ = + Keys::readKey(*plist_, domain_surf_, "surface molar density", "molar_density_liquid"); + surf_mass_dens_key_ = + Keys::readKey(*plist_, domain_surf_, "surface mass density", "mass_density_liquid"); + subsurf_mol_dens_key_ = + Keys::readKey(*plist_, domain_subsurf_, "molar density", "molar_density_liquid"); + subsurf_mass_dens_key_ = + Keys::readKey(*plist_, domain_subsurf_, "mass density", "mass_density_liquid"); // need to put into observations or explicitly update if value other than 0.0 is desired - total_trans_key_ = Keys::readKey(*plist_, domain_surf_, "total transpiration", "total_transpiration"); + total_trans_key_ = + Keys::readKey(*plist_, domain_surf_, "total transpiration", "total_transpiration"); // cell vol keys surf_cv_key_ = Keys::getKey(domain_surf_, "cell_volume"); @@ -137,7 +155,7 @@ ELM_ATSDriver::ELM_ATSDriver(const Teuchos::RCP& plist, // subsurface auto col_zero = mesh_subsurf_->columns.getCells(0); ncells_per_col_ = col_zero.size(); - for (int col=0; col!=ncolumns_; ++col) + for (int col = 0; col != ncolumns_; ++col) AMANZI_ASSERT(mesh_subsurf_->columns.getCells(col).size() == ncells_per_col_); } @@ -146,99 +164,127 @@ void ELM_ATSDriver::setup() { // potential fluxes (ELM -> ATS) - requireAtNext(pot_infilt_key_, Amanzi::Tags::NEXT, *S_, pot_infilt_key_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(pot_evap_key_, Amanzi::Tags::NEXT, *S_, pot_evap_key_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(pot_trans_key_, Amanzi::Tags::NEXT, *S_, pot_trans_key_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(pot_infilt_key_, Amanzi::Tags::NEXT, *S_, pot_infilt_key_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(pot_evap_key_, Amanzi::Tags::NEXT, *S_, pot_evap_key_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(pot_trans_key_, Amanzi::Tags::NEXT, *S_, pot_trans_key_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); // subsurface properties - requireAtNext(base_poro_key_, Amanzi::Tags::NEXT, *S_, base_poro_key_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(perm_key_, Amanzi::Tags::NEXT, *S_, perm_key_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(base_poro_key_, Amanzi::Tags::NEXT, *S_, base_poro_key_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(perm_key_, Amanzi::Tags::NEXT, *S_, perm_key_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); // dynamic subsurface properties - requireAtNext(root_frac_key_, Amanzi::Tags::NEXT, *S_, root_frac_key_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(poro_key_, Amanzi::Tags::NEXT, *S_) // use base_porosity from elm and ATS model for compressibility - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(root_frac_key_, Amanzi::Tags::NEXT, *S_, root_frac_key_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(poro_key_, + Amanzi::Tags::NEXT, + *S_) // use base_porosity from elm and ATS model for compressibility + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); // Clapp and Hornberger water retention params (ELM -> ATS) - requireAtNext(ch_b_key_, Amanzi::Tags::NEXT, *S_, ch_b_key_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(ch_smpsat_key_, Amanzi::Tags::NEXT, *S_, ch_smpsat_key_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(ch_sr_key_, Amanzi::Tags::NEXT, *S_, ch_sr_key_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(ch_b_key_, Amanzi::Tags::NEXT, *S_, ch_b_key_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(ch_smpsat_key_, Amanzi::Tags::NEXT, *S_, ch_smpsat_key_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(ch_sr_key_, Amanzi::Tags::NEXT, *S_, ch_sr_key_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); // per-column ATS water state (ATS -> ELM) - requireAtNext(pd_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(wtd_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(pd_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(wtd_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); // per cell ATS water state - requireAtNext(pc_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(sat_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(pc_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(sat_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); // mesh data - // requireAtNext(lat_key_, Amanzi::Tags::NEXT, *S_) + // requireEvaluatorAtNext(lat_key_, Amanzi::Tags::NEXT, *S_) // .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - // requireAtNext(lon_key_, Amanzi::Tags::NEXT, *S_) + // requireEvaluatorAtNext(lon_key_, Amanzi::Tags::NEXT, *S_) // .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - // requireAtNext(elev_key_, Amanzi::Tags::NEXT, *S_) + // requireEvaluatorAtNext(elev_key_, Amanzi::Tags::NEXT, *S_) // .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(surf_cv_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(cv_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(surf_cv_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(cv_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); // may not be necessary? any PK that utilizes this should already have density - requireAtNext(surf_mol_dens_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(surf_mass_dens_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(subsurf_mol_dens_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(subsurf_mass_dens_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - - requireAtNext(total_trans_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(wc_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - - requireAtNext(evap_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(trans_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); - - requireAtNext(infilt_key_, Amanzi::Tags::NEXT, *S_) - .SetMesh(mesh_surf_)->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtNext(pres_key_, Amanzi::Tags::NEXT, *S_, "flow") - .SetMesh(mesh_subsurf_)->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(surf_mol_dens_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(surf_mass_dens_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(subsurf_mol_dens_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(subsurf_mass_dens_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireEvaluatorAtNext(total_trans_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(wc_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireEvaluatorAtNext(evap_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(trans_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireEvaluatorAtNext(infilt_key_, Amanzi::Tags::NEXT, *S_) + .SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(pres_key_, Amanzi::Tags::NEXT, *S_, "flow") + .SetMesh(mesh_subsurf_) + ->AddComponent("cell", AmanziMesh::CELL, 1); Coordinator::setup(); } - // // dz & depth are currently ignored -- presumed identical between ATS & ELM // -void ELM_ATSDriver::get_mesh_info(int& ncols_local, - int& ncols_global, - double * const lat, - double * const lon, - double * const elev, - double * const surface_area, - int * const pft, - int& nlevgrnd, - double * const depth) +void +ELM_ATSDriver::get_mesh_info(int& ncols_local, + int& ncols_global, + double* const lat, + double* const lon, + double* const elev, + double* const surface_area, + int* const pft, + int& nlevgrnd, + double* const depth) { ncols_local = ncolumns_; ncols_global = mesh_surf_->getMap(AmanziMesh::Entity_kind::CELL, false).NumGlobalElements(); @@ -250,32 +296,34 @@ void ELM_ATSDriver::get_mesh_info(int& ncols_local, // NOTE: figure out how to map from ATS LC types to ELM PFT... --etc // hard-coded veg type for now... - for (int i=0; i!=ncolumns_; ++i) pft[i] = 1; + for (int i = 0; i != ncolumns_; ++i) pft[i] = 1; nlevgrnd = ncells_per_col_; const auto& cells_in_col = mesh_subsurf_->columns.getCells(0); double ldepth = 0.; double top_face_z = mesh_subsurf_->getFaceCentroid(mesh_subsurf_->columns.getFaces(0)[0])[2]; - for (int i=0; i!=ncells_per_col_; ++i) { - double bottom_face_z = mesh_subsurf_->getFaceCentroid(mesh_subsurf_->columns.getFaces(0)[i+1])[2]; + for (int i = 0; i != ncells_per_col_; ++i) { + double bottom_face_z = + mesh_subsurf_->getFaceCentroid(mesh_subsurf_->columns.getFaces(0)[i + 1])[2]; double dz = top_face_z - bottom_face_z; - ldepth += dz/2.; + ldepth += dz / 2.; depth[i] = ldepth; top_face_z = bottom_face_z; - ldepth += dz/2.; + ldepth += dz / 2.; } // hard-coded Toledo OH for now... - for (int i=0; i!=ncolumns_; ++i) { + for (int i = 0; i != ncolumns_; ++i) { lat[i] = 41.65; lon[i] = -83.54; } } -void ELM_ATSDriver::initialize(double t, - double const * const elm_water_content, - double const * const elm_pressure) +void +ELM_ATSDriver::initialize(double t, + double const* const elm_water_content, + double const* const elm_pressure) { // Assign start time to ATS t0_ = t; @@ -302,7 +350,8 @@ void ELM_ATSDriver::initialize(double t, } // use incoming water content to initialize pressure field -void ELM_ATSDriver::init_pressure_from_wc_(double const * const elm_water_content) +void +ELM_ATSDriver::init_pressure_from_wc_(double const* const elm_water_content) { // gravity, atmospheric pressure, and liquid water density // hardwired for now @@ -313,20 +362,20 @@ void ELM_ATSDriver::init_pressure_from_wc_(double const * const elm_water_conten // evaluators S_->GetEvaluator(subsurf_mass_dens_key_, Amanzi::Tags::NEXT).Update(*S_, subsurf_mass_dens_key_); const auto& mass_d = *S_->Get(subsurf_mass_dens_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + .ViewComponent("cell", false); S_->GetEvaluator(poro_key_, Amanzi::Tags::NEXT).Update(*S_, poro_key_); - const auto& por = *S_->Get(poro_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& por = + *S_->Get(poro_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); S_->GetEvaluator(cv_key_, Amanzi::Tags::NEXT).Update(*S_, cv_key_); - const auto& volume = *S_->Get(cv_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& volume = + *S_->Get(cv_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); S_->GetEvaluator(surf_cv_key_, Amanzi::Tags::NEXT).Update(*S_, surf_cv_key_); - const auto& area = *S_->Get(surf_cv_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& area = + *S_->Get(surf_cv_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); // writable to pressure - auto& pres = *S_->GetW(pres_key_, Amanzi::Tags::NEXT, "flow") - .ViewComponent("cell", false); + auto& pres = + *S_->GetW(pres_key_, Amanzi::Tags::NEXT, "flow").ViewComponent("cell", false); // WRM model auto& wrm_eval = S_->GetEvaluator(sat_key_, Amanzi::Tags::NEXT); @@ -339,11 +388,11 @@ void ELM_ATSDriver::init_pressure_from_wc_(double const * const elm_water_conten // initialize pressure field from ELM water content // per-column hydrostatic pressure in areas of continuous total saturation // unsaturated areas are considered to be in contact with atmosphere - for (int i=0; i!=ncolumns_; ++i) { + for (int i = 0; i != ncolumns_; ++i) { const auto& cells_of_col = mesh_subsurf_->columns.getCells(i); int top_sat_idx = -1; double sat_depth = 0.0; - for (int j=0; j!=ncells_per_col_; ++j) { + for (int j = 0; j != ncells_per_col_; ++j) { // convert ELM water content (kg/m2] to saturation of pore space (0 to 1) [-] // VWC = elm_wc * 1/dz * 1/porosity * 1/mass density // [-] = [kg/m2] * [m^-1] * [-] * [m3/kg] @@ -359,7 +408,7 @@ void ELM_ATSDriver::init_pressure_from_wc_(double const * const elm_water_conten sat_depth = 0.0; } sat_depth += dz; - pres[0][cells_of_col[j]] = p_atm + rho * g * (sat_depth - dz/2); + pres[0][cells_of_col[j]] = p_atm + rho * g * (sat_depth - dz / 2); } } } @@ -375,12 +424,13 @@ void ELM_ATSDriver::init_pressure_from_wc_(double const * const elm_water_conten } -void ELM_ATSDriver::advance(double dt, bool do_chkp, bool do_vis) +void +ELM_ATSDriver::advance(double dt, bool do_chkp, bool do_vis) { double dt_subcycle = dt; double t_end = S_->get_time() + dt_subcycle; - bool fail{false}; + bool fail{ false }; while (S_->get_time() < t_end && dt_subcycle > 0.0) { S_->Assign("dt", Amanzi::Tags::DEFAULT, "dt", dt_subcycle); S_->advance_time(Amanzi::Tags::NEXT, dt_subcycle); @@ -428,7 +478,8 @@ void ELM_ATSDriver::advance(double dt, bool do_chkp, bool do_vis) // simulates external timeloop with dt coming from calling model -void ELM_ATSDriver::advance_test() +void +ELM_ATSDriver::advance_test() { while (S_->get_time() < t1_) { // use dt from ATS for testing @@ -438,7 +489,8 @@ void ELM_ATSDriver::advance_test() } } -void ELM_ATSDriver::finalize() +void +ELM_ATSDriver::finalize() { WriteStateStatistics(*S_, *vo_); report_memory(); @@ -447,11 +499,12 @@ void ELM_ATSDriver::finalize() } -void ELM_ATSDriver::set_soil_hydrologic_parameters(double const * const base_porosity, - double const * const hydraulic_conductivity, - double const * const clapp_horn_b, - double const * const clapp_horn_smpsat, - double const * const clapp_horn_sr) +void +ELM_ATSDriver::set_soil_hydrologic_parameters(double const* const base_porosity, + double const* const hydraulic_conductivity, + double const* const clapp_horn_b, + double const* const clapp_horn_smpsat, + double const* const clapp_horn_sr) { // convert Ksat to perm via rho * g / visc using default rho and visc values. copyToSub_(hydraulic_conductivity, perm_key_); @@ -471,29 +524,32 @@ void ELM_ATSDriver::set_soil_hydrologic_parameters(double const * const base_por } -void ELM_ATSDriver::set_veg_parameters(double const * const mafic_potential_full_turgor, - double const * const mafic_potential_wilt_point) +void +ELM_ATSDriver::set_veg_parameters(double const* const mafic_potential_full_turgor, + double const* const mafic_potential_wilt_point) { // pass for now! FIXME --etc } -void ELM_ATSDriver::set_soil_hydrologic_properties(double const * const effective_porosity) +void +ELM_ATSDriver::set_soil_hydrologic_properties(double const* const effective_porosity) { // this isn't well defined -- pass for now --etc } -void ELM_ATSDriver::set_veg_properties(double const * const rooting_fraction) +void +ELM_ATSDriver::set_veg_properties(double const* const rooting_fraction) { copyToSub_(rooting_fraction, root_frac_key_); } void -ELM_ATSDriver::set_potential_sources(double const * const elm_surface_input, - double const * const elm_evaporation, - double const * const elm_transpiration) +ELM_ATSDriver::set_potential_sources(double const* const elm_surface_input, + double const* const elm_evaporation, + double const* const elm_transpiration) { // ELM's infiltration, evaporation, and transpiration are in units of mm s^-1 // ATS units are in mol m^-2 s^-1 @@ -502,24 +558,24 @@ ELM_ATSDriver::set_potential_sources(double const * const elm_surface_input, // or // mm / s * m/mm * mol/m3 = mol m^-2 s^-1 auto& in = *S_->GetW(pot_infilt_key_, Amanzi::Tags::NEXT, pot_infilt_key_) - .ViewComponent("cell", false); + .ViewComponent("cell", false); auto& ev = *S_->GetW(pot_evap_key_, Amanzi::Tags::NEXT, pot_evap_key_) - .ViewComponent("cell", false); + .ViewComponent("cell", false); auto& tr = *S_->GetW(pot_trans_key_, Amanzi::Tags::NEXT, pot_trans_key_) - .ViewComponent("cell", false); + .ViewComponent("cell", false); AMANZI_ASSERT(in.MyLength() == ncolumns_); AMANZI_ASSERT(ev.MyLength() == ncolumns_); AMANZI_ASSERT(tr.MyLength() == ncolumns_); S_->GetEvaluator(surf_mol_dens_key_, Amanzi::Tags::NEXT).Update(*S_, surf_mol_dens_key_); - const auto& surf_d = *S_->Get(surf_mol_dens_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& surf_d = + *S_->Get(surf_mol_dens_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); - for (int i=0; i!=ncolumns_; ++i) { + for (int i = 0; i != ncolumns_; ++i) { const double factor = 0.001 * surf_d[0][i]; in[0][i] = elm_surface_input[i] * factor; - ev[0][i] = elm_evaporation[i] * factor; - tr[0][i] = elm_transpiration[i] * factor; + ev[0][i] = elm_evaporation[i] * factor; + tr[0][i] = elm_transpiration[i] * factor; } changedEvaluatorPrimary(pot_infilt_key_, Amanzi::Tags::NEXT, *S_); @@ -529,32 +585,33 @@ ELM_ATSDriver::set_potential_sources(double const * const elm_surface_input, void -ELM_ATSDriver::get_waterstate(double * const ponded_depth, - double * const wt_depth, - double * const soil_water_potential, - double * const matric_potential, - double * const sat_liq, - double * const sat_ice) // remove? +ELM_ATSDriver::get_waterstate(double* const ponded_depth, + double* const wt_depth, + double* const soil_water_potential, + double* const matric_potential, + double* const sat_liq, + double* const sat_ice) // remove? { // convert saturation into [kg/m2] from [-] S_->GetEvaluator(sat_key_, Amanzi::Tags::NEXT).Update(*S_, sat_key_); - const auto& satl = *S_->Get(sat_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& satl = + *S_->Get(sat_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); S_->GetEvaluator(poro_key_, Amanzi::Tags::NEXT).Update(*S_, poro_key_); - const auto& por = *S_->Get(poro_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& por = + *S_->Get(poro_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); S_->GetEvaluator(subsurf_mass_dens_key_, Amanzi::Tags::NEXT).Update(*S_, subsurf_mass_dens_key_); const auto& dens = *S_->Get(subsurf_mass_dens_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + .ViewComponent("cell", false); // TODO look into ELM effective porosity, ATS ice density, ice saturation - for (int i=0; i!=ncolumns_; ++i) { + for (int i = 0; i != ncolumns_; ++i) { const auto faces = mesh_subsurf_->columns.getFaces(i); const auto cells = mesh_subsurf_->columns.getCells(i); - for (int j=0; j!=ncells_per_col_; ++j) { - const double dz = mesh_subsurf_->getFaceCentroid(faces[j])[2] - mesh_subsurf_->getFaceCentroid(faces[j + 1])[2]; + for (int j = 0; j != ncells_per_col_; ++j) { + const double dz = mesh_subsurf_->getFaceCentroid(faces[j])[2] - + mesh_subsurf_->getFaceCentroid(faces[j + 1])[2]; sat_liq[j * ncolumns_ + i] = satl[0][cells[j]] * por[0][cells[j]] * dens[0][cells[j]] * dz; } } @@ -562,10 +619,9 @@ ELM_ATSDriver::get_waterstate(double * const ponded_depth, // Ponded depth // convert ATS m to mm S_->GetEvaluator(pd_key_, Amanzi::Tags::NEXT).Update(*S_, "ELM"); - const auto& pd = *S_->Get(pd_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); - for (int i=0; i!=ncolumns_; ++i) - ponded_depth[i] = pd[0][i] * 1000.0; + const auto& pd = + *S_->Get(pd_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); + for (int i = 0; i != ncolumns_; ++i) ponded_depth[i] = pd[0][i] * 1000.0; // water table depth S_->GetEvaluator(wtd_key_, Amanzi::Tags::NEXT).Update(*S_, "ELM"); @@ -573,34 +629,34 @@ ELM_ATSDriver::get_waterstate(double * const ponded_depth, // Soil matric potential // convert ATS Pa to -mmH2O -// int z_index = mesh_subsurf_->space_dimension() - 1; -// const auto& gravity = S_->Get("gravity", Amanzi::Tags::DEFAULT); -// const double g_inv = 1.0 / gravity[z_index]; // should be -9.80665 m s^-2 -// -// S_->GetEvaluator(pres_key_, Amanzi::Tags::NEXT).Update(*S_, pres_key_); -// const auto& pres = *S_->Get(pres_key_, Amanzi::Tags::NEXT) -// .ViewComponent("cell", false); -// -// S_->GetEvaluator(pc_key_, Amanzi::Tags::NEXT).Update(*S_, "ELM"); -// const auto& pc = *S_->Get(pc_key_, Amanzi::Tags::NEXT) -// .ViewComponent("cell", false); -// -// for (int i=0; i!=ncolumns_; ++i) { -// const auto& cells = mesh_subsurf_->columns.getCells(i); -// for (int j=0; j!=ncells_per_col_; ++j) { -// matric_potential[j * ncolumns_ + i] = pc[0][cells[j]] * g_inv; -// soil_water_potential[j * ncolumns_ + i] = 0.101325 - 1.e-6 * pres[0][cells[j]]; -// } -// } + // int z_index = mesh_subsurf_->space_dimension() - 1; + // const auto& gravity = S_->Get("gravity", Amanzi::Tags::DEFAULT); + // const double g_inv = 1.0 / gravity[z_index]; // should be -9.80665 m s^-2 + // + // S_->GetEvaluator(pres_key_, Amanzi::Tags::NEXT).Update(*S_, pres_key_); + // const auto& pres = *S_->Get(pres_key_, Amanzi::Tags::NEXT) + // .ViewComponent("cell", false); + // + // S_->GetEvaluator(pc_key_, Amanzi::Tags::NEXT).Update(*S_, "ELM"); + // const auto& pc = *S_->Get(pc_key_, Amanzi::Tags::NEXT) + // .ViewComponent("cell", false); + // + // for (int i=0; i!=ncolumns_; ++i) { + // const auto& cells = mesh_subsurf_->columns.getCells(i); + // for (int j=0; j!=ncells_per_col_; ++j) { + // matric_potential[j * ncolumns_ + i] = pc[0][cells[j]] * g_inv; + // soil_water_potential[j * ncolumns_ + i] = 0.101325 - 1.e-6 * pres[0][cells[j]]; + // } + // } } void -ELM_ATSDriver::get_water_fluxes(double * const surf_subsurf_flx, - double * const evaporation, - double * const transpiration, - double * const net_subsurface_fluxes, - double * const net_runon) +ELM_ATSDriver::get_water_fluxes(double* const surf_subsurf_flx, + double* const evaporation, + double* const transpiration, + double* const net_subsurface_fluxes, + double* const net_runon) { // Convert and send ATS fluxes to ELM @@ -611,20 +667,20 @@ ELM_ATSDriver::get_water_fluxes(double * const surf_subsurf_flx, // Surface fluxes S_->GetEvaluator(infilt_key_, Amanzi::Tags::NEXT).Update(*S_, infilt_key_); - const auto& infilt = *S_->Get(infilt_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& infilt = + *S_->Get(infilt_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); S_->GetEvaluator(evap_key_, Amanzi::Tags::NEXT).Update(*S_, evap_key_); - const auto& evap = *S_->Get(evap_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& evap = + *S_->Get(evap_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); S_->GetEvaluator(surf_mol_dens_key_, Amanzi::Tags::NEXT).Update(*S_, surf_mol_dens_key_); - const auto& surfdens = *S_->Get(surf_mol_dens_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& surfdens = + *S_->Get(surf_mol_dens_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); // convert mol/m2/s to mmH2O/s for ELM - // mol/m2/s * m3/mol = m/s * mm/m = mm/s - for (int i=0; i!=ncolumns_; ++i) { + // mol/m2/s * m3/mol = m/s * mm/m = mm/s + for (int i = 0; i != ncolumns_; ++i) { const double mm_per_mol = 1000.0 / surfdens[0][i]; surf_subsurf_flx[i] = infilt[0][i] * mm_per_mol; evaporation[i] = evap[0][i] * mm_per_mol; @@ -632,20 +688,21 @@ ELM_ATSDriver::get_water_fluxes(double * const surf_subsurf_flx, // Subsurface flux S_->GetEvaluator(trans_key_, Amanzi::Tags::NEXT).Update(*S_, "ELM"); - const auto& trans = *S_->Get(trans_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& trans = + *S_->Get(trans_key_, Amanzi::Tags::NEXT).ViewComponent("cell", false); S_->GetEvaluator(subsurf_mol_dens_key_, Amanzi::Tags::NEXT).Update(*S_, subsurf_mol_dens_key_); const auto& subsurfdens = *S_->Get(subsurf_mol_dens_key_, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + .ViewComponent("cell", false); // convert mol/m3/s to mmH2O/s by integrating over dz - NO? // treat the same as surface fluxes? - for (int i=0; i!=ncolumns_; ++i) { + for (int i = 0; i != ncolumns_; ++i) { const auto& faces = mesh_subsurf_->columns.getFaces(i); const auto& cells = mesh_subsurf_->columns.getCells(i); - for (int j=0; j!=ncells_per_col_; ++j) { - double dz = mesh_subsurf_->getFaceCentroid(faces[j])[2] - mesh_subsurf_->getFaceCentroid(faces[j + 1])[2]; + for (int j = 0; j != ncells_per_col_; ++j) { + double dz = mesh_subsurf_->getFaceCentroid(faces[j])[2] - + mesh_subsurf_->getFaceCentroid(faces[j + 1])[2]; AMANZI_ASSERT(dz > 0.); const double factor = dz * 1000.0 / subsurfdens[0][cells[j]]; transpiration[j * ncolumns_ + i] = trans[0][cells[j]] * factor; @@ -655,7 +712,8 @@ ELM_ATSDriver::get_water_fluxes(double * const surf_subsurf_flx, } -void ELM_ATSDriver::initZero_(const Key& key) +void +ELM_ATSDriver::initZero_(const Key& key) { auto& vec = S_->GetW(key, Amanzi::Tags::NEXT, key); vec.PutScalar(0.); @@ -663,15 +721,16 @@ void ELM_ATSDriver::initZero_(const Key& key) } -void ELM_ATSDriver::copyToSurf_(double const * const in, const Key& key, Key owner) +void +ELM_ATSDriver::copyToSurf_(double const* const in, const Key& key, Key owner) { - if (owner.empty()) owner = key; + if (owner.empty() ) owner = key; // surf maps directly into columns - auto& vec = *S_->GetW(key, Amanzi::Tags::NEXT, owner) - .ViewComponent("cell", false); + auto& vec = + *S_->GetW(key, Amanzi::Tags::NEXT, owner).ViewComponent("cell", false); AMANZI_ASSERT(vec.MyLength() == ncolumns_); - for (int i=0; i!=ncolumns_; ++i) vec[0][i] = in[i]; + for (int i = 0; i != ncolumns_; ++i) vec[0][i] = in[i]; changedEvaluatorPrimary(key, Amanzi::Tags::NEXT, *S_); } @@ -681,15 +740,16 @@ void ELM_ATSDriver::copyToSurf_(double const * const in, const Key& key, Key own // ELM data is defined as var(col,lev), meaning that, due to Fortran ordering, // the column is fasted varying, not the grid cell. // -void ELM_ATSDriver::copyToSub_(double const * const in, const Key& key, Key owner) +void +ELM_ATSDriver::copyToSub_(double const* const in, const Key& key, Key owner) { - if (owner.empty()) owner = key; - auto& vec = *S_->GetW(key, Amanzi::Tags::NEXT, owner) - .ViewComponent("cell", false); + if (owner.empty() ) owner = key; + auto& vec = + *S_->GetW(key, Amanzi::Tags::NEXT, owner).ViewComponent("cell", false); - for (int i=0; i!=ncolumns_; ++i) { + for (int i = 0; i != ncolumns_; ++i) { const auto& cells = mesh_subsurf_->columns.getCells(i); - for (int j=0; j!=ncells_per_col_; ++j) { + for (int j = 0; j != ncells_per_col_; ++j) { vec[0][cells[j]] = in[j * ncolumns_ + i]; } } @@ -698,13 +758,13 @@ void ELM_ATSDriver::copyToSub_(double const * const in, const Key& key, Key owne } -void ELM_ATSDriver::copyFromSurf_(double * const out, const Key& key) const +void +ELM_ATSDriver::copyFromSurf_(double* const out, const Key& key) const { S_->GetEvaluator(key, Amanzi::Tags::NEXT).Update(*S_, "ELM"); - const auto& vec = *S_->Get(key, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& vec = *S_->Get(key, Amanzi::Tags::NEXT).ViewComponent("cell", false); - for (int i=0; i!=ncolumns_; ++i) out[i] = vec[0][i]; + for (int i = 0; i != ncolumns_; ++i) out[i] = vec[0][i]; } @@ -712,15 +772,15 @@ void ELM_ATSDriver::copyFromSurf_(double * const out, const Key& key) const // ELM data is defined as var(col,lev), meaning that, due to Fortran ordering, // the column is fasted varying, not the grid cell. // -void ELM_ATSDriver::copyFromSub_(double * const out, const Key& key) const +void +ELM_ATSDriver::copyFromSub_(double* const out, const Key& key) const { S_->GetEvaluator(key, Amanzi::Tags::NEXT).Update(*S_, "ELM"); - const auto& vec = *S_->Get(key, Amanzi::Tags::NEXT) - .ViewComponent("cell", false); + const auto& vec = *S_->Get(key, Amanzi::Tags::NEXT).ViewComponent("cell", false); - for (int i=0; i!=ncolumns_; ++i) { + for (int i = 0; i != ncolumns_; ++i) { const auto cells = mesh_subsurf_->columns.getCells(i); - for (int j=0; j!=ncells_per_col_; ++j) { + for (int j = 0; j != ncells_per_col_; ++j) { out[j * ncolumns_ + i] = vec[0][cells[j]]; } } diff --git a/src/executables/elm_ats_api/elm_ats_driver.hh b/src/executables/elm_ats_api/elm_ats_driver.hh index 0affad254..910f45ef2 100644 --- a/src/executables/elm_ats_api/elm_ats_driver.hh +++ b/src/executables/elm_ats_api/elm_ats_driver.hh @@ -45,9 +45,7 @@ namespace ATS { using namespace Amanzi; class ELM_ATSDriver : public Coordinator { - -public: - + public: ELM_ATSDriver(const Teuchos::RCP& plist, const Teuchos::RCP& wallclock_timer, const Teuchos::RCP>& teuchos_comm, @@ -60,53 +58,51 @@ public: void get_mesh_info(int& ncols_local, int& ncols_global, - double * const lat, - double * const lon, - double * const elev, - double * const surf_area, - int * const pft, + double* const lat, + double* const lon, + double* const elev, + double* const surf_area, + int* const pft, int& nlevgrnd, - double * const depth); + double* const depth); void setup(); - void initialize(double t, - double const * const p_atm, - double const * const pressure); - - void set_soil_hydrologic_parameters(double const * const base_porosity, - double const * const hydraulic_conductivity, - double const * const clapp_horn_b, - double const * const clapp_horn_smpsat, - double const * const clapp_horn_sr); - void set_veg_parameters(double const * const mafic_potential_full_turgor, - double const * const mafic_potential_wilt_point); - void set_soil_hydrologic_properties(double const * const effective_porosity); - void set_veg_properties(double const * const rooting_fraction); - void set_potential_sources(double const * const elm_surface_input, - double const * const elm_evaporation, - double const * const elm_transpiration); - - void get_waterstate(double * const surface_ponded_depth, - double * const water_table_depth, - double * const soil_pressure, - double * const soil_psi, - double * const sat_liq, - double * const sat_ice); - - void get_water_fluxes(double * const soil_infiltration, - double * const evaporation, - double * const transpiration, - double * const net_subsurface_fluxes, - double * const net_runon); + void initialize(double t, double const* const p_atm, double const* const pressure); + + void set_soil_hydrologic_parameters(double const* const base_porosity, + double const* const hydraulic_conductivity, + double const* const clapp_horn_b, + double const* const clapp_horn_smpsat, + double const* const clapp_horn_sr); + void set_veg_parameters(double const* const mafic_potential_full_turgor, + double const* const mafic_potential_wilt_point); + void set_soil_hydrologic_properties(double const* const effective_porosity); + void set_veg_properties(double const* const rooting_fraction); + void set_potential_sources(double const* const elm_surface_input, + double const* const elm_evaporation, + double const* const elm_transpiration); + + void get_waterstate(double* const surface_ponded_depth, + double* const water_table_depth, + double* const soil_pressure, + double* const soil_psi, + double* const sat_liq, + double* const sat_ice); + + void get_water_fluxes(double* const soil_infiltration, + double* const evaporation, + double* const transpiration, + double* const net_subsurface_fluxes, + double* const net_runon); private: - void init_pressure_from_wc_(double const * const elm_water_content); + void init_pressure_from_wc_(double const* const elm_water_content); - void copyToSurf_(double const * const in, const Key& key, Key owner=""); - void copyToSub_(double const * const in, const Key& key, Key owner=""); - void copyFromSurf_(double * const out, const Key& key) const; - void copyFromSub_(double * const out, const Key& key) const; + void copyToSurf_(double const* const in, const Key& key, Key owner = ""); + void copyToSub_(double const* const in, const Key& key, Key owner = ""); + void copyFromSurf_(double* const out, const Key& key) const; + void copyFromSub_(double* const out, const Key& key) const; void initZero_(const Key& key); @@ -154,18 +150,12 @@ public: Key subsurf_mass_dens_key_; Key surf_cv_key_; Key cv_key_; - }; // // Nonmember constructor/factory reads file, converts comm to the right type. // -ELM_ATSDriver* -createELM_ATSDriver(MPI_Fint *f_comm, const char *infile, int npfts=17); +ELM_ATSDriver* createELM_ATSDriver(MPI_Fint* f_comm, const char* infile, int npfts = 17); } // namespace ATS - - - - diff --git a/src/executables/elm_ats_api/test/elm_ats_test.cc b/src/executables/elm_ats_api/test/elm_ats_test.cc index 776591149..e02790aa3 100644 --- a/src/executables/elm_ats_api/test/elm_ats_test.cc +++ b/src/executables/elm_ats_api/test/elm_ats_test.cc @@ -1,4 +1,3 @@ - #include #include @@ -29,25 +28,26 @@ #include "elm_ats_driver.hh" #include "elm_ats_api.h" -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - #ifdef AMANZI_USE_FENV // feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); feraiseexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); #endif - Teuchos::GlobalMPISession mpiSession(&argc,&argv,0); + Teuchos::GlobalMPISession mpiSession(&argc, &argv, 0); int rank = mpiSession.getRank(); std::string input_filename; - if ((argc >= 2) && (argv[argc-1][0] != '-')) { - input_filename = std::string(argv[argc-1]); + if ((argc >= 2) && (argv[argc - 1][0] != '-')) { + input_filename = std::string(argv[argc - 1]); argc--; } Teuchos::CommandLineProcessor clp; - clp.setDocString("Run ATS simulations for ecosystem hydrology.\n\nStandard usage: ats input.xml\n"); + clp.setDocString( + "Run ATS simulations for ecosystem hydrology.\n\nStandard usage: ats input.xml\n"); std::string opt_input_filename = ""; clp.setOption("xml_file", &opt_input_filename, "XML input file"); @@ -56,10 +56,13 @@ int main(int argc, char *argv[]) clp.setOption("version", "no_version", &version, "Print version number and exit."); bool print_version(false); - clp.setOption("print_version", "no_print_version", &print_version, "Print full version info and exit."); + clp.setOption( + "print_version", "no_print_version", &print_version, "Print full version info and exit."); std::string verbosity; - clp.setOption("verbosity", &verbosity, "Default verbosity level: \"none\", \"low\", \"medium\", \"high\", \"extreme\"."); + clp.setOption("verbosity", + &verbosity, + "Default verbosity level: \"none\", \"low\", \"medium\", \"high\", \"extreme\"."); clp.throwExceptions(false); clp.recogniseAllOptions(true); @@ -102,7 +105,8 @@ int main(int argc, char *argv[]) MPI_Fint comm = 0; // test driver directly - auto driver = std::unique_ptr(ATS::createELM_ATSDriver(&comm, input_filename.data())); + auto driver = + std::unique_ptr(ATS::createELM_ATSDriver(&comm, input_filename.data())); driver->setup(); //driver->get_mesh_info(ncols_local, ncols_global, lat.data(), lon.data(), elev.data(), surf_area_m2.data(), pft_i.data(), ncells_per_col, depth.data()); driver->initialize(); diff --git a/src/executables/main.cc b/src/executables/main.cc index 31019ddb5..6f521ab49 100644 --- a/src/executables/main.cc +++ b/src/executables/main.cc @@ -36,6 +36,8 @@ // registration files #include "ats_registration_files.hh" +#include "PK_Factory.hh" +#include "Evaluator_Factory.hh" int main(int argc, char* argv[]) @@ -80,6 +82,13 @@ main(int argc, char* argv[]) std::string writing_rank; clp.setOption("write_on_rank", &writing_rank, "Rank on which to write VerboseObjects"); + bool list_evals(false); + clp.setOption( + "list_evaluators", "no_list_evaluators", &list_evals, "List available evaluators and exit."); + + bool list_pks(false); + clp.setOption("list_pks", "no_list_pks", &list_pks, "List available PKs and MPCs and exit."); + clp.throwExceptions(false); clp.recogniseAllOptions(true); @@ -97,7 +106,9 @@ main(int argc, char* argv[]) #define STR(s) #s // check for version info request if (version) { - if (rank == 0) { std::cout << "ATS version " << XSTR(ATS_VERSION) << std::endl; } + if (rank == 0) { + std::cout << "ATS version " << XSTR(ATS_VERSION) << std::endl; + } Kokkos::finalize(); return 0; } @@ -116,6 +127,25 @@ main(int argc, char* argv[]) return 0; } + if (list_evals) { + if (rank == 0) { + Amanzi::Evaluator_Factory fac; + std::cout << "Evaluators: "; // no endline is intentional! + fac.WriteChoices(std::cout); + } + Kokkos::finalize(); + return 0; + } + if (list_pks) { + if (rank == 0) { + Amanzi::PKFactory fac; + std::cout << "PKs and MPCs: "; // no endline is intentional! + fac.WriteChoices(std::cout); + } + Kokkos::finalize(); + return 0; + } + // parse the verbosity level Teuchos::EVerbosityLevel opt_level; if (verbosity.empty()) { @@ -188,7 +218,8 @@ main(int argc, char* argv[]) // -- parse input file Teuchos::RCP plist; - if (Amanzi::Keys::ends_with(input_filename, ".yaml") || Amanzi::Keys::ends_with(input_filename, ".YAML")) { + if (Amanzi::Keys::ends_with(input_filename, ".yaml") || + Amanzi::Keys::ends_with(input_filename, ".YAML")) { plist = Teuchos::YAMLParameterList::parseYamlFile(input_filename); } else { plist = Teuchos::getParametersFromXmlFile(input_filename); @@ -200,7 +231,7 @@ main(int argc, char* argv[]) Teuchos::readVerboseObjectSublist(&*plist, &fos, &verbosity_from_list); if (verbosity_from_list != Teuchos::VERB_DEFAULT) Amanzi::VerboseObject::global_default_level = verbosity_from_list; - if (!verbosity.empty()) Amanzi::VerboseObject::global_default_level = opt_level; + if (!verbosity.empty() ) Amanzi::VerboseObject::global_default_level = opt_level; if (Amanzi::VerboseObject::global_default_level != Teuchos::VERB_NONE && (rank == 0)) { std::cout @@ -221,10 +252,14 @@ main(int argc, char* argv[]) try { ret = driver.run(); } catch (std::string& s) { - if (rank == 0) { std::cerr << "ERROR:" << std::endl << s << std::endl; } + if (rank == 0) { + std::cerr << "ERROR:" << std::endl << s << std::endl; + } return 1; } catch (int& ierr) { - if (rank == 0) { std::cerr << "ERROR: unknown error code " << ierr << std::endl; } + if (rank == 0) { + std::cerr << "ERROR: unknown error code " << ierr << std::endl; + } return ierr; } } diff --git a/src/executables/test/executable_coupled_water1.xml b/src/executables/test/executable_coupled_water1.xml index 4a9d2c1e0..99deb0ff0 100644 --- a/src/executables/test/executable_coupled_water1.xml +++ b/src/executables/test/executable_coupled_water1.xml @@ -29,7 +29,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -141,9 +141,11 @@ - + + + @@ -176,8 +178,10 @@ - + + + @@ -194,7 +198,7 @@ - + @@ -240,7 +244,7 @@ - + @@ -270,7 +274,7 @@ - + @@ -318,7 +322,7 @@ - + @@ -363,13 +367,14 @@ - + - + + @@ -392,13 +397,13 @@ - + - + @@ -417,7 +422,7 @@ - + @@ -427,19 +432,19 @@ - + - + - + - + diff --git a/src/executables/test/executable_coupled_water2.xml b/src/executables/test/executable_coupled_water2.xml index 3a0553d37..51df67d7c 100644 --- a/src/executables/test/executable_coupled_water2.xml +++ b/src/executables/test/executable_coupled_water2.xml @@ -29,7 +29,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -142,9 +142,11 @@ - + + + @@ -177,8 +179,10 @@ - + + + @@ -195,7 +199,7 @@ - + @@ -232,7 +236,7 @@ - + @@ -243,7 +247,7 @@ - + @@ -273,7 +277,7 @@ - + @@ -321,7 +325,7 @@ - + @@ -366,13 +370,14 @@ - + - + + @@ -395,13 +400,13 @@ - + - + @@ -420,7 +425,7 @@ - + @@ -430,19 +435,19 @@ - + - + - + - + diff --git a/src/executables/test/executable_coupled_water3.xml b/src/executables/test/executable_coupled_water3.xml index f6373638e..5b2d8aa0b 100644 --- a/src/executables/test/executable_coupled_water3.xml +++ b/src/executables/test/executable_coupled_water3.xml @@ -29,7 +29,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -141,9 +141,11 @@ - + + + @@ -176,8 +178,10 @@ - + + + @@ -194,7 +198,7 @@ - + @@ -231,7 +235,7 @@ - + @@ -242,7 +246,7 @@ - + @@ -272,7 +276,7 @@ - + @@ -320,7 +324,7 @@ - + @@ -365,13 +369,14 @@ - + - + + @@ -394,13 +399,13 @@ - + - + @@ -419,7 +424,7 @@ - + @@ -429,19 +434,19 @@ - + - + - + - + diff --git a/src/executables/test/executable_mesh_factory.cc b/src/executables/test/executable_mesh_factory.cc index 430e38127..11bfaf2b5 100644 --- a/src/executables/test/executable_mesh_factory.cc +++ b/src/executables/test/executable_mesh_factory.cc @@ -174,7 +174,9 @@ SUITE(ATS_MESH_FACTORY) Epetra_MultiVector vec(S->GetMesh("domain")->getMap(AmanziMesh::Entity_kind::CELL, false), 1); vec.PutScalar(-1); - for (const auto& subdomain : *ds) { ds->doImport(subdomain, *subdomain_vecs[subdomain], vec); } + for (const auto& subdomain : *ds) { + ds->doImport(subdomain, *subdomain_vecs[subdomain], vec); + } double result; vec.MinValue(&result); @@ -371,7 +373,9 @@ SUITE(ATS_MESH_FACTORY) ds->doImport(subdomain, vec_l, vec2); // fill via column - for (const auto& c : S->GetMesh("domain")->columns.getCells(col)) { vec1[0][c] = index; } + for (const auto& c : S->GetMesh("domain")->columns.getCells(col)) { + vec1[0][c] = index; + } col++; } diff --git a/src/operators/advection/advection_donor_upwind.cc b/src/operators/advection/advection_donor_upwind.cc index 4fb677dd2..f486e8df5 100644 --- a/src/operators/advection/advection_donor_upwind.cc +++ b/src/operators/advection/advection_donor_upwind.cc @@ -39,12 +39,11 @@ AdvectionDonorUpwind::set_flux(const Teuchos::RCP& flux) }; -void -AdvectionDonorUpwind::Apply(const Teuchos::RCP& bc_flux, - bool include_bc_fluxes){ +void AdvectionDonorUpwind::Apply(const Teuchos::RCP& bc_flux, + bool include_bc_fluxes){ // Part 1: Collect fluxes in faces - { field_->ScatterMasterToGhosted("cell"); // communicate the cells + { field_ -> ScatterMasterToGhosted("cell"); // communicate the cells const Epetra_MultiVector& field_c = *field_->ViewComponent("cell", true); Epetra_MultiVector& field_f = *field_->ViewComponent("face", true); @@ -56,7 +55,9 @@ for (unsigned int f = 0; f != nfaces_ghosted; ++f) { // loop over master and sla int c1 = (*upwind_cell_)[f]; if (c1 >= 0) { double u = std::abs(flux[0][f]); - for (unsigned int i = 0; i != num_dofs_; ++i) { field_f[i][f] = u * field_c[i][c1]; } + for (unsigned int i = 0; i != num_dofs_; ++i) { + field_f[i][f] = u * field_c[i][c1]; + } } } } // namespace Operators @@ -76,11 +77,15 @@ for (unsigned int f = 0; f != nfaces_ghosted; ++f) { // loop over master and sla int c2 = (*downwind_cell_)[f]; if (c1 >= 0 && c1 < ncells_owned) { - for (int i = 0; i != num_dofs_; ++i) { field_c[i][c1] -= field_f[i][f]; } + for (int i = 0; i != num_dofs_; ++i) { + field_c[i][c1] -= field_f[i][f]; + } } if (c2 >= 0 && c2 < ncells_owned) { - for (int i = 0; i != num_dofs_; ++i) { field_c[i][c2] += field_f[i][f]; } + for (int i = 0; i != num_dofs_; ++i) { + field_c[i][c2] += field_f[i][f]; + } } } } diff --git a/src/operators/advection/advection_donor_upwind.hh b/src/operators/advection/advection_donor_upwind.hh index bde147f33..74ef30444 100644 --- a/src/operators/advection/advection_donor_upwind.hh +++ b/src/operators/advection/advection_donor_upwind.hh @@ -34,8 +34,8 @@ class AdvectionDonorUpwind : public Advection { const Teuchos::RCP mesh); virtual void set_flux(const Teuchos::RCP& flux); - virtual void - Apply(const Teuchos::RCP& bc_flux, bool include_bc_fluxes = true); + virtual void Apply(const Teuchos::RCP& bc_flux, + bool include_bc_fluxes = true); private: void IdentifyUpwindCells_(); diff --git a/src/operators/advection/advection_factory.hh b/src/operators/advection/advection_factory.hh index 99bb1a964..178755d2f 100644 --- a/src/operators/advection/advection_factory.hh +++ b/src/operators/advection/advection_factory.hh @@ -28,8 +28,8 @@ namespace Operators { class AdvectionFactory { public: - Teuchos::RCP - create(Teuchos::ParameterList& advect_plist, const Teuchos::RCP mesh); + Teuchos::RCP create(Teuchos::ParameterList& advect_plist, + const Teuchos::RCP mesh); }; } // namespace Operators diff --git a/src/operators/deformation/MatrixVolumetricDeformation.cc b/src/operators/deformation/MatrixVolumetricDeformation.cc index 3ae4bdab5..4a14aec0c 100644 --- a/src/operators/deformation/MatrixVolumetricDeformation.cc +++ b/src/operators/deformation/MatrixVolumetricDeformation.cc @@ -95,7 +95,8 @@ MatrixVolumetricDeformation::ApplyRHS( Epetra_MultiVector& rhs_n = *x_node->ViewComponent("node", false); unsigned int nnodes_owned = mesh_->getNumEntities(AmanziMesh::Entity_kind::NODE, AmanziMesh::Parallel_kind::OWNED); - for (AmanziMesh::Entity_ID_List::const_iterator n = fixed_nodes->begin(); n != fixed_nodes->end(); + for (AmanziMesh::Entity_ID_List::const_iterator n = fixed_nodes->begin() + ; n != fixed_nodes->end(); ++n) { if (*n < nnodes_owned) rhs_n[0][*n] = 0; } @@ -352,7 +353,8 @@ MatrixVolumetricDeformation::Assemble( std::cout << "MIN VAL OP (PRE) = " << min << std::endl; // -- Fix the bottom nodes, they may not move - for (AmanziMesh::Entity_ID_List::const_iterator n = fixed_nodes->begin(); n != fixed_nodes->end(); + for (AmanziMesh::Entity_ID_List::const_iterator n = fixed_nodes->begin() + ; n != fixed_nodes->end(); ++n) { // extract the row if (*n < nnodes) { @@ -396,8 +398,7 @@ MatrixVolumetricDeformation::Assemble( } -void -MatrixVolumetricDeformation::set_inverse_parameters(){}; +void MatrixVolumetricDeformation::set_inverse_parameters() {}; } // namespace Operators } // namespace Amanzi diff --git a/src/operators/deformation/Matrix_PreconditionerDelegate.cc b/src/operators/deformation/Matrix_PreconditionerDelegate.cc index 8efd08216..426b349db 100644 --- a/src/operators/deformation/Matrix_PreconditionerDelegate.cc +++ b/src/operators/deformation/Matrix_PreconditionerDelegate.cc @@ -44,7 +44,7 @@ void Matrix_PreconditionerDelegate::InitializePreconditioner() { if (prec_method_ == TRILINOS_ML) { - if (ml_prec_->IsPreconditionerComputed()) ml_prec_->DestroyPreconditioner(); + if (ml_prec_->IsPreconditionerComputed() ) ml_prec_->DestroyPreconditioner(); ml_prec_->SetParameterList(solver_plist_); ml_prec_->ComputePreconditioner(); diff --git a/src/operators/divgrad/MatrixMFD.cc b/src/operators/divgrad/MatrixMFD.cc index 269c60916..8e4928ed1 100644 --- a/src/operators/divgrad/MatrixMFD.cc +++ b/src/operators/divgrad/MatrixMFD.cc @@ -154,7 +154,9 @@ MatrixMFD::CreateMFDmassMatrices(const Teuchos::PtrgetNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::OWNED); - if (Mff_cells_.size() != ncells) { Mff_cells_.resize(static_cast(ncells)); } + if (Mff_cells_.size() != ncells) { + Mff_cells_.resize(static_cast(ncells)); + } int ok; nokay_ = npassed_ = 0; @@ -171,7 +173,9 @@ MatrixMFD::CreateMFDmassMatrices(const Teuchos::Ptr& int ncells = mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::OWNED); - if (Aff_cells_.size() != ncells) { Aff_cells_.resize(static_cast(ncells)); } - if (Afc_cells_.size() != ncells) { Afc_cells_.resize(static_cast(ncells)); } - if (Acf_cells_.size() != ncells) { Acf_cells_.resize(static_cast(ncells)); } + if (Aff_cells_.size() != ncells) { + Aff_cells_.resize(static_cast(ncells)); + } + if (Afc_cells_.size() != ncells) { + Afc_cells_.resize(static_cast(ncells)); + } + if (Acf_cells_.size() != ncells) { + Acf_cells_.resize(static_cast(ncells)); + } if (Acc_cells_.size() != ncells) { Acc_cells_.resize(static_cast(ncells)); Acc_ = Teuchos::rcp( @@ -258,13 +267,17 @@ MatrixMFD::CreateMFDstiffnessMatrices(const Teuchos::Ptr& if (Krel == Teuchos::null || (!Krel->HasComponent("cell") && !Krel->HasComponent("face"))) { for (int n = 0; n != nfaces; ++n) { - for (int m = 0; m != nfaces; ++m) { Bff(m, n) = Mff(m, n); } + for (int m = 0; m != nfaces; ++m) { + Bff(m, n) = Mff(m, n); + } } } else if (Krel->HasComponent("cell") && !Krel->HasComponent("face")) { const Epetra_MultiVector& Krel_c = *Krel->ViewComponent("cell", false); for (int n = 0; n != nfaces; ++n) { - for (int m = 0; m != nfaces; ++m) { Bff(m, n) = Mff(m, n) * Krel_c[0][c]; } + for (int m = 0; m != nfaces; ++m) { + Bff(m, n) = Mff(m, n) * Krel_c[0][c]; + } } } else if (!Krel->HasComponent("cell") && Krel->HasComponent("face")) { const Epetra_MultiVector& Krel_f = *Krel->ViewComponent("face", true); @@ -273,7 +286,9 @@ MatrixMFD::CreateMFDstiffnessMatrices(const Teuchos::Ptr& for (int m = 0; m != nfaces; ++m) { AmanziMesh::Entity_ID f = faces[m]; - for (int n = 0; n != nfaces; ++n) { Bff(m, n) = Mff(m, n) * Krel_f[0][f]; } + for (int n = 0; n != nfaces; ++n) { + Bff(m, n) = Mff(m, n) * Krel_f[0][f]; + } } } else if (Krel->HasComponent("cell") && Krel->HasComponent("face")) { const Epetra_MultiVector& Krel_f = *Krel->ViewComponent("face", true); @@ -283,7 +298,9 @@ MatrixMFD::CreateMFDstiffnessMatrices(const Teuchos::Ptr& for (int m = 0; m != nfaces; ++m) { AmanziMesh::Entity_ID f = faces[m]; - for (int n = 0; n != nfaces; ++n) { Bff(m, n) = Mff(m, n) * Krel_c[0][c] * Krel_f[0][f]; } + for (int n = 0; n != nfaces; ++n) { + Bff(m, n) = Mff(m, n) * Krel_c[0][c] * Krel_f[0][f]; + } } } @@ -318,8 +335,12 @@ MatrixMFD::CreateMFDrhsVectors() { int ncells = mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::OWNED); - if (Ff_cells_.size() != ncells) { Ff_cells_.resize(static_cast(ncells)); } - if (Fc_cells_.size() != ncells) { Fc_cells_.resize(static_cast(ncells)); } + if (Ff_cells_.size() != ncells) { + Ff_cells_.resize(static_cast(ncells)); + } + if (Fc_cells_.size() != ncells) { + Fc_cells_.resize(static_cast(ncells)); + } for (int c = 0; c != ncells; ++c) { int nfaces = mesh_->getCellNumFaces(c); @@ -441,7 +462,9 @@ MatrixMFD::FillMatrixGraphs_(const Teuchos::Ptr cf_graph, faces = mesh_->getCellFaces(c); int nfaces = faces.size(); - for (int n = 0; n != nfaces; ++n) { faces_GID[n] = fmap_wghost.GID(faces[n]); } + for (int n = 0; n != nfaces; ++n) { + faces_GID[n] = fmap_wghost.GID(faces[n]); + } cf_graph->InsertMyIndices(c, nfaces, &(faces[0])); ff_graph->InsertGlobalIndices(nfaces, faces_GID, nfaces, faces_GID); } @@ -514,7 +537,9 @@ MatrixMFD::Apply(const CompositeVector& X, CompositeVector& Y) const int nfaces = faces.size(); Teuchos::SerialDenseVector v(nfaces), av(nfaces); - for (int n = 0; n < nfaces; n++) { v(n) = Xf[0][faces[n]]; } + for (int n = 0; n < nfaces; n++) { + v(n) = Xf[0][faces[n]]; + } av.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, Aff[c], v, 0.0); @@ -680,7 +705,9 @@ MatrixMFD::DeriveFlux(const CompositeVector& solution, int f = faces[n]; if (f < nfaces_owned && !done[f]) { double s = 0.0; - for (int m = 0; m != nfaces; ++m) { s += Aff_cells_[c](n, m) * dp[m]; } + for (int m = 0; m != nfaces; ++m) { + s += Aff_cells_[c](n, m) * dp[m]; + } flux_v[0][f] = s * dirs[n]; done[f] = true; @@ -689,7 +716,9 @@ MatrixMFD::DeriveFlux(const CompositeVector& solution, } // ensure post-condition - we got them all - for (int f = 0; f != nfaces_owned; ++f) { ASSERT(done[f]); } + for (int f = 0; f != nfaces_owned; ++f) { + ASSERT(done[f]); + } } @@ -828,7 +857,9 @@ MatrixMFD::UpdateConsistentCellCorrection(const CompositeVector& u, Epetra_MultiVector& Pu_c = *Pu->ViewComponent("cell", false); Pu_c.Update(1.0, *u.ViewComponent("cell", false), -1.0); - for (int c = 0; c != Pu_c.MyLength(); ++c) { Pu_c[0][c] /= Acc_cells_[c]; } + for (int c = 0; c != Pu_c.MyLength(); ++c) { + Pu_c[0][c] /= Acc_cells_[c]; + } } @@ -841,16 +872,24 @@ MatrixMFD::Add2MFDstiffnessMatrices(std::vector* Acc_ptr, int ncells = mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::OWNED); if (Acc_ptr) { - for (int c = 0; c != ncells; ++c) { Acc_cells_[c] += (*Acc_ptr)[c]; } + for (int c = 0; c != ncells; ++c) { + Acc_cells_[c] += (*Acc_ptr)[c]; + } } if (Afc_ptr) { - for (int c = 0; c != ncells; ++c) { Afc_cells_[c] += Afc_ptr->at(c); } + for (int c = 0; c != ncells; ++c) { + Afc_cells_[c] += Afc_ptr->at(c); + } } if (Acf_ptr) { - for (int c = 0; c != ncells; ++c) { Acf_cells_[c] += Acf_ptr->at(c); } + for (int c = 0; c != ncells; ++c) { + Acf_cells_[c] += Acf_ptr->at(c); + } } if (Aff_ptr) { - for (int c = 0; c != ncells; ++c) { Aff_cells_[c] += Aff_ptr->at(c); } + for (int c = 0; c != ncells; ++c) { + Aff_cells_[c] += Aff_ptr->at(c); + } } } @@ -899,7 +938,9 @@ MatrixMFD::ApplyAcf_(const Epetra_MultiVector& X, Epetra_MultiVector& Y, double faces = mesh_->getCellFaces(c); int nfaces = faces.size(); - for (int n = 0; n < nfaces; n++) { Y[0][c] += Acf[c][n] * X[0][faces[n]]; } + for (int n = 0; n < nfaces; n++) { + Y[0][c] += Acf[c][n] * X[0][faces[n]]; + } } return 0; } @@ -954,7 +995,9 @@ MatrixMFD::ApplyAfc_(const Epetra_MultiVector& X, Epetra_MultiVector& Y, double int nfaces = faces.size(); double tmp = X[0][c]; - for (int n = 0; n < nfaces; n++) { Y[0][faces[n]] += Afc[c][n] * tmp; } + for (int n = 0; n < nfaces; n++) { + Y[0][faces[n]] += Afc[c][n] * tmp; + } } return 0; } @@ -1016,7 +1059,9 @@ MatrixMFD::AssembleAff_() const faces = mesh_->getCellFaces(c); int nfaces = faces.size(); - for (int n = 0; n != nfaces; ++n) { gid[n] = fmap_wghost.GID(faces[n]); } + for (int n = 0; n != nfaces; ++n) { + gid[n] = fmap_wghost.GID(faces[n]); + } Aff_->SumIntoGlobalValues(nfaces, gid, Aff_cells_[c].values()); } diff --git a/src/operators/divgrad/MatrixMFD_Coupled_Surf.cc b/src/operators/divgrad/MatrixMFD_Coupled_Surf.cc index b7c2ae9a1..bc3915b56 100644 --- a/src/operators/divgrad/MatrixMFD_Coupled_Surf.cc +++ b/src/operators/divgrad/MatrixMFD_Coupled_Surf.cc @@ -189,7 +189,9 @@ MatrixMFD_Coupled_Surf::AssembleSchur_() const // ensure consistency of the sparsity structure, this can likely be // removed eventually. ASSERT(entriesA == entriesB); - for (int m = 0; m != entriesA; ++m) { ASSERT(indicesA[m] == indicesB[m]); } + for (int m = 0; m != entriesA; ++m) { + ASSERT(indicesA[m] == indicesB[m]); + } // Convert local cell numbers to domain's local face numbers AmanziMesh::Entity_ID frow = surface_mesh_->getEntityParent(AmanziMesh::Entity_kind::CELL, sc); @@ -297,7 +299,9 @@ MatrixMFD_Coupled_Surf::AssembleAff_() const // ensure consistency of the sparsity structure, this can likely be // removed eventually. ASSERT(entriesA == entriesB); - for (int m = 0; m != entriesA; ++m) { ASSERT(indicesA[m] == indicesB[m]); } + for (int m = 0; m != entriesA; ++m) { + ASSERT(indicesA[m] == indicesB[m]); + } // Convert local cell numbers to domain's local face numbers AmanziMesh::Entity_ID frow = surface_mesh_->getEntityParent(AmanziMesh::Entity_kind::CELL, sc); diff --git a/src/operators/upwinding/UpwindFluxFactory.hh b/src/operators/upwinding/UpwindFluxFactory.hh index a56ab55b7..8284100f0 100644 --- a/src/operators/upwinding/UpwindFluxFactory.hh +++ b/src/operators/upwinding/UpwindFluxFactory.hh @@ -22,12 +22,11 @@ namespace Amanzi { namespace Operators { namespace UpwindFactory { -Teuchos::RCP -Create(Teuchos::ParameterList& oplist, - State& S, - const std::string& pkname, - const Tag& tag, - const Key& flux_key); +Teuchos::RCP Create(Teuchos::ParameterList& oplist, + State& S, + const std::string& pkname, + const Tag& tag, + const Key& flux_key); } // namespace UpwindFactory } // namespace Operators diff --git a/src/operators/upwinding/upwind_arithmetic_mean.cc b/src/operators/upwinding/upwind_arithmetic_mean.cc index 28a4eb8a4..ad0e1c984 100644 --- a/src/operators/upwinding/upwind_arithmetic_mean.cc +++ b/src/operators/upwinding/upwind_arithmetic_mean.cc @@ -56,7 +56,9 @@ UpwindArithmeticMean::CalculateCoefficientsOnFaces(const CompositeVector& cell_c // initialize the face coefficients face_coef.ViewComponent(face_component, true)->PutScalar(0.0); - if (face_coef.HasComponent("cell")) { face_coef.ViewComponent("cell", true)->PutScalar(1.0); } + if (face_coef.HasComponent("cell")) { + face_coef.ViewComponent("cell", true)->PutScalar(1.0); + } // Note that by scattering, and then looping over all Parallel_kind::ALL cells, we // end up getting the correct upwind values in all faces (owned or @@ -85,7 +87,9 @@ UpwindArithmeticMean::CalculateCoefficientsOnFaces(const CompositeVector& cell_c mesh->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::OWNED); for (unsigned int f = 0; f != f_owned; ++f) { auto cells = mesh->getFaceCells(f); - if (cells.size() == 1) { face_coef_f[0][f] *= 2.; } + if (cells.size() == 1) { + face_coef_f[0][f] *= 2.; + } } }; diff --git a/src/operators/upwinding/upwind_cell_centered.cc b/src/operators/upwinding/upwind_cell_centered.cc index 310aaeb3d..19d510957 100644 --- a/src/operators/upwinding/upwind_cell_centered.cc +++ b/src/operators/upwinding/upwind_cell_centered.cc @@ -35,7 +35,9 @@ UpwindCellCentered::Update(const CompositeVector& cells, const Teuchos::Ptr& db) const { *faces.ViewComponent("cell") = *cells.ViewComponent("cell"); - if (faces.HasComponent("face")) { faces.ViewComponent("face", true)->PutScalar(1.0); } + if (faces.HasComponent("face")) { + faces.ViewComponent("face", true)->PutScalar(1.0); + } }; diff --git a/src/operators/upwinding/upwind_elevation_stabilized.cc b/src/operators/upwinding/upwind_elevation_stabilized.cc index 2cbf21157..d4108370b 100644 --- a/src/operators/upwinding/upwind_elevation_stabilized.cc +++ b/src/operators/upwinding/upwind_elevation_stabilized.cc @@ -74,7 +74,9 @@ UpwindElevationStabilized::CalculateCoefficientsOnFaces(const CompositeVector& s Teuchos::RCP mesh = face_coef.Mesh(); // initialize the face coefficients - if (face_coef.HasComponent("cell")) { face_coef.ViewComponent("cell", true)->PutScalar(1.0); } + if (face_coef.HasComponent("cell")) { + face_coef.ViewComponent("cell", true)->PutScalar(1.0); + } // communicate needed ghost values slope.ScatterMasterToGhosted("cell"); diff --git a/src/operators/upwinding/upwind_flux_fo_cont.cc b/src/operators/upwinding/upwind_flux_fo_cont.cc index 2099bac56..0dfe54b6c 100644 --- a/src/operators/upwinding/upwind_flux_fo_cont.cc +++ b/src/operators/upwinding/upwind_flux_fo_cont.cc @@ -40,7 +40,7 @@ UpwindFluxFOCont::UpwindFluxFOCont(const std::string& pkname, manning_coef_(manning_coef), elevation_(elevation), slope_regularization_(slope_regularization), - manning_exp_(manning_exp){}; + manning_exp_(manning_exp) {}; void @@ -69,7 +69,9 @@ UpwindFluxFOCont::CalculateCoefficientsOnFaces(const CompositeVector& cell_coef, Teuchos::RCP mesh = face_coef.Mesh(); // initialize the face coefficients - if (face_coef.HasComponent("cell")) { face_coef.ViewComponent("cell", true)->PutScalar(1.0); } + if (face_coef.HasComponent("cell")) { + face_coef.ViewComponent("cell", true)->PutScalar(1.0); + } // communicate needed ghost values cell_coef.ScatterMasterToGhosted("cell"); @@ -164,12 +166,9 @@ UpwindFluxFOCont::CalculateCoefficientsOnFaces(const CompositeVector& cell_coef, double pdf = 0.0; // Determine the coefficient - if (dw == -1) - pdf = pds[1]; - else if (uw == -1) - pdf = pds[0]; - else - pdf = pds[0] + elevation_v[0][uw] - std::max(elevation_v[0][uw], elevation_v[0][dw]); + if (dw == -1) pdf = pds[1]; + else if (uw == -1) pdf = pds[0]; + else pdf = pds[0] + elevation_v[0][uw] - std::max(elevation_v[0][uw], elevation_v[0][dw]); double exponent = manning_exp_ + 1.0; coef_faces[0][f] = std::pow(std::max(pdf, 0.), exponent) / denominator; diff --git a/src/operators/upwinding/upwind_flux_harmonic_mean.cc b/src/operators/upwinding/upwind_flux_harmonic_mean.cc index ae9977fe5..795974897 100644 --- a/src/operators/upwinding/upwind_flux_harmonic_mean.cc +++ b/src/operators/upwinding/upwind_flux_harmonic_mean.cc @@ -53,7 +53,9 @@ UpwindFluxHarmonicMean::CalculateCoefficientsOnFaces(const CompositeVector& cell Teuchos::RCP mesh = face_coef.Mesh(); // initialize the face coefficients - if (face_coef.HasComponent("cell")) { face_coef.ViewComponent("cell", true)->PutScalar(1.0); } + if (face_coef.HasComponent("cell")) { + face_coef.ViewComponent("cell", true)->PutScalar(1.0); + } // communicate needed ghost values cell_coef.ScatterMasterToGhosted("cell"); @@ -132,10 +134,8 @@ UpwindFluxHarmonicMean::CalculateCoefficientsOnFaces(const CompositeVector& cell double amean_order_of_supression = 15.0; // Determine the coefficient - if (dw == -1) - coef_faces[0][f] = coefs[1]; - else if (uw == -1) - coef_faces[0][f] = coefs[0]; + if (dw == -1) coef_faces[0][f] = coefs[1]; + else if (uw == -1) coef_faces[0][f] = coefs[0]; else { double dist[2]; dist[0] = AmanziGeometry::norm(mesh->getFaceCentroid(f) - mesh->getCellCentroid(uw)); @@ -170,8 +170,7 @@ UpwindFluxHarmonicMean::CalculateCoefficientsOnFaces(const CompositeVector& cell double param = std::abs(flux_v[0][f]) / flow_eps; double alt_coef_face = hmean + amean * amean_scaling[1]; coef_faces[0][f] = param * coef_face + (1 - param) * alt_coef_face; - } else - coef_faces[0][f] = coef_face; + } else coef_faces[0][f] = coef_face; } } }; diff --git a/src/operators/upwinding/upwind_flux_split_denominator.cc b/src/operators/upwinding/upwind_flux_split_denominator.cc index 00d5fa767..306aed894 100644 --- a/src/operators/upwinding/upwind_flux_split_denominator.cc +++ b/src/operators/upwinding/upwind_flux_split_denominator.cc @@ -67,7 +67,9 @@ UpwindFluxSplitDenominator::CalculateCoefficientsOnFaces(const CompositeVector& Teuchos::RCP mesh = face_coef.Mesh(); // initialize the face coefficients - if (face_coef.HasComponent("cell")) { face_coef.ViewComponent("cell", true)->PutScalar(1.0); } + if (face_coef.HasComponent("cell")) { + face_coef.ViewComponent("cell", true)->PutScalar(1.0); + } // communicate needed ghost values cell_coef.ScatterMasterToGhosted("cell"); diff --git a/src/operators/upwinding/upwind_gravity_flux.cc b/src/operators/upwinding/upwind_gravity_flux.cc index 39e2a075f..5e3653ee1 100644 --- a/src/operators/upwinding/upwind_gravity_flux.cc +++ b/src/operators/upwinding/upwind_gravity_flux.cc @@ -14,7 +14,7 @@ // faces. // ----------------------------------------------------------------------------- -#include "Tensor.hh" +#include "TensorVector.hh" #include "CompositeVector.hh" #include "State.hh" #include "upwind_gravity_flux.hh" @@ -24,8 +24,8 @@ namespace Operators { UpwindGravityFlux::UpwindGravityFlux(const std::string& pkname, const Tag& tag, - const Teuchos::RCP> K) - : pkname_(pkname), tag_(tag), K_(K){}; + const Teuchos::RCP& K) + : pkname_(pkname), tag_(tag), K_(K) {}; void UpwindGravityFlux::Update(const CompositeVector& cells, @@ -63,7 +63,9 @@ UpwindGravityFlux::CalculateCoefficientsOnFaces(const CompositeVector& cell_coef // initialize the face coefficients face_coef.ViewComponent(face_component, true)->PutScalar(0.0); - if (face_coef.HasComponent("cell")) { face_coef.ViewComponent("cell", true)->PutScalar(1.0); } + if (face_coef.HasComponent("cell")) { + face_coef.ViewComponent("cell", true)->PutScalar(1.0); + } // Note that by scattering, and then looping over all Parallel_kind::ALL cells, we // end up getting the correct upwind values in all faces (owned or diff --git a/src/operators/upwinding/upwind_gravity_flux.hh b/src/operators/upwinding/upwind_gravity_flux.hh index a4b216c62..6cd54939d 100644 --- a/src/operators/upwinding/upwind_gravity_flux.hh +++ b/src/operators/upwinding/upwind_gravity_flux.hh @@ -17,8 +17,7 @@ #ifndef AMANZI_UPWINDING_GRAVITYFLUX_SCHEME_ #define AMANZI_UPWINDING_GRAVITYFLUX_SCHEME_ -#include "Epetra_Vector.h" -#include "Tensor.hh" +#include "TensorVector.hh" #include "upwinding.hh" @@ -33,7 +32,7 @@ class UpwindGravityFlux : public Upwinding { public: UpwindGravityFlux(const std::string& pkname, const Tag& tag, - const Teuchos::RCP> K); + const Teuchos::RCP& K); virtual void Update(const CompositeVector& cells, CompositeVector& faces, @@ -58,7 +57,7 @@ class UpwindGravityFlux : public Upwinding { private: std::string pkname_; Tag tag_; - Teuchos::RCP> K_; + Teuchos::RCP K_; }; } // namespace Operators diff --git a/src/operators/upwinding/upwind_potential_difference.cc b/src/operators/upwinding/upwind_potential_difference.cc index 2b7f5e815..2f4cc593b 100644 --- a/src/operators/upwinding/upwind_potential_difference.cc +++ b/src/operators/upwinding/upwind_potential_difference.cc @@ -29,7 +29,9 @@ UpwindPotentialDifference::UpwindPotentialDifference(const std::string& pkname, const std::string& overlap) : pkname_(pkname), tag_(tag), potential_(potential), overlap_(overlap) { - if (overlap_ == std::string("")) { overlap_ = potential_; } + if (overlap_ == std::string("")) { + overlap_ = potential_; + } }; @@ -54,7 +56,9 @@ UpwindPotentialDifference::CalculateCoefficientsOnFaces(const CompositeVector& c AMANZI_ASSERT(cell_coef.Ghosted()); // initialize the cell coefficients - if (face_coef.HasComponent("cell")) { face_coef.ViewComponent("cell", true)->PutScalar(1.0); } + if (face_coef.HasComponent("cell")) { + face_coef.ViewComponent("cell", true)->PutScalar(1.0); + } Teuchos::RCP mesh = face_coef.Mesh(); std::vector dirs; @@ -69,7 +73,7 @@ UpwindPotentialDifference::CalculateCoefficientsOnFaces(const CompositeVector& c const Epetra_MultiVector& overlap_c = *overlap.ViewComponent("cell", true); const Epetra_MultiVector& potential_c = *potential.ViewComponent("cell", true); Teuchos::RCP potential_f; - if (potential.HasComponent("face")) potential_f = potential.ViewComponent("face", false); + if (potential.HasComponent("face") ) potential_f = potential.ViewComponent("face", false); const Epetra_MultiVector& cell_coef_c = *cell_coef.ViewComponent("cell", true); int nfaces = face_coef.size("face", false); @@ -91,7 +95,9 @@ UpwindPotentialDifference::CalculateCoefficientsOnFaces(const CompositeVector& c double ol1 = std::max(0., overlap_c[0][cells[1]]); double flow_eps = 0.0; - if ((ol0 > 0) || (ol1 > 0)) { flow_eps = (ol0 * ol1) / (ol0 + ol1); } + if ((ol0 > 0) || (ol1 > 0)) { + flow_eps = (ol0 * ol1) / (ol0 + ol1); + } flow_eps = std::max(flow_eps, eps); // Determine the coefficient. @@ -190,7 +196,9 @@ UpwindPotentialDifference::UpdateDerivatives( double ol1 = std::max(0., overlap_c[0][cells[1]]); double flow_eps = 0.0; - if ((ol0 > 0) || (ol1 > 0)) { flow_eps = (ol0 * ol1) / (ol0 + ol1); } + if ((ol0 > 0) || (ol1 > 0)) { + flow_eps = (ol0 * ol1) / (ol0 + ol1); + } flow_eps = std::max(flow_eps, eps); // Determine the coefficient. diff --git a/src/operators/upwinding/upwind_total_flux.cc b/src/operators/upwinding/upwind_total_flux.cc index 3fba19c81..576f43723 100644 --- a/src/operators/upwinding/upwind_total_flux.cc +++ b/src/operators/upwinding/upwind_total_flux.cc @@ -29,7 +29,7 @@ UpwindTotalFlux::UpwindTotalFlux(const std::string& pkname, const Tag& tag, const std::string& flux, double flux_eps) - : pkname_(pkname), tag_(tag), flux_(flux), flux_eps_(flux_eps){}; + : pkname_(pkname), tag_(tag), flux_(flux), flux_eps_(flux_eps) {}; void @@ -66,7 +66,9 @@ UpwindTotalFlux::CalculateCoefficientsOnFaces(const CompositeVector& cell_coef, Teuchos::RCP mesh = face_coef.Mesh(); // initialize the face coefficients - if (face_coef.HasComponent("cell")) { face_coef.ViewComponent("cell", true)->PutScalar(1.0); } + if (face_coef.HasComponent("cell")) { + face_coef.ViewComponent("cell", true)->PutScalar(1.0); + } // communicate needed ghost values cell_coef.ScatterMasterToGhosted(cell_component); diff --git a/src/pks/CMakeLists.txt b/src/pks/CMakeLists.txt index 8c1b2dfe4..99421a746 100644 --- a/src/pks/CMakeLists.txt +++ b/src/pks/CMakeLists.txt @@ -8,18 +8,16 @@ include_directories(${GEOCHEM_SOURCE_DIR}) include_directories(${CHEMPK_SOURCE_DIR}) set(ats_pks_src_files - pk_helpers.cc + chem_pk_helpers.cc pk_bdf_default.cc - pk_physical_default.cc pk_physical_bdf_default.cc pk_explicit_default.cc bc_factory.cc ) set(ats_pks_inc_files - pk_helpers.hh + chem_pk_helpers.hh pk_bdf_default.hh - pk_physical_default.hh pk_physical_bdf_default.hh pk_explicit_default.hh pk_physical_explicit_default.hh diff --git a/src/pks/bc_factory.hh b/src/pks/bc_factory.hh index 5cde3b70d..9845a20da 100644 --- a/src/pks/bc_factory.hh +++ b/src/pks/bc_factory.hh @@ -89,14 +89,15 @@ class BCFactory { : mesh_(mesh), plist_(plist) {} - Teuchos::RCP - CreateWithFunction(const std::string& list_name, const std::string& function_name) const; + Teuchos::RCP CreateWithFunction( + const std::string& list_name, + const std::string& function_name) const; - Teuchos::RCP - CreateWithoutFunction(const std::string& list_name) const; + Teuchos::RCP CreateWithoutFunction( + const std::string& list_name) const; - Teuchos::RCP - CreateDynamicFunction(const std::string& list_name) const; + Teuchos::RCP CreateDynamicFunction( + const std::string& list_name) const; bool CheckExplicitFlag(const std::string& list_name); diff --git a/src/pks/biogeochemistry/bgc_simple/PFT.cc b/src/pks/biogeochemistry/bgc_simple/PFT.cc index 01c0383b1..239570d3f 100644 --- a/src/pks/biogeochemistry/bgc_simple/PFT.cc +++ b/src/pks/biogeochemistry/bgc_simple/PFT.cc @@ -22,7 +22,9 @@ namespace Amanzi { namespace BGC { -PFT::PFT(std::string pft_type_, int ncells) : pft_type(pft_type_), BRootSoil(ncells) {} +PFT::PFT(std::string pft_type_, int ncells) + : pft_type(pft_type_), BRootSoil(ncells) +{} PFT::PFT(std::string pft_type_, int ncells, double* brootcells_) : pft_type(pft_type_), BRootSoil(View, brootcells_, ncells) @@ -109,8 +111,12 @@ PFT::Init(double col_area) carbon2biomass = 2; aroot_radius = 0.002; - for (int i = 0; i < 10; i++) { annCBalance[i] = 0; } - for (int c = 0; c != BRootSoil.Length(); ++c) { BRootSoil[c] = 0.; } + for (int i = 0; i < 10; i++) { + annCBalance[i] = 0; + } + for (int c = 0; c != BRootSoil.Length(); ++c) { + BRootSoil[c] = 0.; + } } void @@ -184,7 +190,9 @@ PFT::InitRoots(const Epetra_SerialDenseVector& SoilTArr, totalweights = 1.0; } - for (int c = 0; c != nSoilLayers; ++c) { BRootSoil[c] = BRootSoil[c] / totalweights * Broot; } + for (int c = 0; c != nSoilLayers; ++c) { + BRootSoil[c] = BRootSoil[c] / totalweights * Broot; + } AssertRootBalance_or_die(); return; diff --git a/src/pks/biogeochemistry/bgc_simple/bgc_simple.cc b/src/pks/biogeochemistry/bgc_simple/bgc_simple.cc index 38093452d..70a7efa56 100644 --- a/src/pks/biogeochemistry/bgc_simple/bgc_simple.cc +++ b/src/pks/biogeochemistry/bgc_simple/bgc_simple.cc @@ -20,7 +20,7 @@ ------------------------------------------------------------------------- */ #include "MeshPartition.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "bgc_simple_funcs.hh" #include "bgc_simple.hh" @@ -88,7 +88,7 @@ BGCSimple::Setup() // -- PFTs -- old and new! Teuchos::ParameterList& pft_params = plist_->sublist("pft parameters"); std::vector pft_names; - for (Teuchos::ParameterList::ConstIterator lcv = pft_params.begin(); lcv != pft_params.end(); + for (Teuchos::ParameterList::ConstIterator lcv = pft_params.begin() ; lcv != pft_params.end(); ++lcv) { std::string pft_name = lcv->first; pft_names.push_back(pft_name); @@ -150,23 +150,20 @@ BGCSimple::Setup() ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, num_pools_); // requirements: other primary variables - S_->Require(trans_key_, tag_next_, name_) + requireEvaluatorAtNext(trans_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetGhosted() ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireEvaluatorPrimary(trans_key_, tag_next_, *S_); - S_->Require(shaded_sw_key_, tag_next_, name_) + requireEvaluatorAtNext(shaded_sw_key_, tag_next_, *S_, name_) .SetMesh(mesh_surf_) ->SetGhosted() ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireEvaluatorPrimary(shaded_sw_key_, tag_next_, *S_); - S_->Require(total_lai_key_, tag_next_, name_) + requireEvaluatorAtNext(total_lai_key_, tag_next_, *S_, name_) .SetMesh(mesh_surf_) ->SetGhosted() ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireEvaluatorPrimary(total_lai_key_, tag_next_, *S_); // requirement: diagnostics S_->Require("co2_decomposition", tag_next_, name_) @@ -287,7 +284,9 @@ BGCSimple::Initialize() int num_cols_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); for (int col = 0; col != num_cols_; ++col) { - for (int i = 0; i != bio.NumVectors(); ++i) { pfts_old_[col][i]->Bleaf = bio[i][col]; } + for (int i = 0; i != bio.NumVectors(); ++i) { + pfts_old_[col][i]->Bleaf = bio[i][col]; + } } } } @@ -321,7 +320,9 @@ BGCSimple::Initialize() // ensure all initialization in both PFTs? Not sure this is // necessary -- likely done in initial call to commit-state --etc for (int col = 0; col != num_cols_; ++col) { - for (int i = 0; i != num_pfts_; ++i) { *pfts_[col][i] = *pfts_old_[col][i]; } + for (int i = 0; i != num_pfts_; ++i) { + *pfts_[col][i] = *pfts_old_[col][i]; + } } } @@ -337,7 +338,9 @@ BGCSimple::CommitStep(double told, double tnew, const Tag& tag) int num_cols_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); for (int col = 0; col != num_cols_; ++col) { - for (int i = 0; i != num_pfts_; ++i) { *pfts_old_[col][i] = *pfts_[col][i]; } + for (int i = 0; i != num_pfts_; ++i) { + *pfts_old_[col][i] = *pfts_[col][i]; + } } } @@ -360,7 +363,9 @@ BGCSimple::AdvanceStep(double t_old, double t_new, bool reinit) AmanziMesh::Entity_ID num_cols_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); for (AmanziMesh::Entity_ID col = 0; col != num_cols_; ++col) { - for (int i = 0; i != num_pfts_; ++i) { *pfts_[col][i] = *pfts_old_[col][i]; } + for (int i = 0; i != num_pfts_; ++i) { + *pfts_[col][i] = *pfts_old_[col][i]; + } } // grab the required fields @@ -533,7 +538,9 @@ BGCSimple::FieldToColumn_(AmanziMesh::Entity_ID col, } auto col_iter = mesh_->columns.getCells(col); - for (std::size_t i = 0; i != col_iter.size(); ++i) { (*col_vec)[i] = vec[col_iter[i]]; } + for (std::size_t i = 0; i != col_iter.size(); ++i) { + (*col_vec)[i] = vec[col_iter[i]]; + } } // helper function for pushing field to column @@ -544,7 +551,9 @@ BGCSimple::FieldToColumn_(AmanziMesh::Entity_ID col, int ncol) { auto col_iter = mesh_->columns.getCells(col); - for (std::size_t i = 0; i != col_iter.size(); ++i) { col_vec[i] = vec[col_iter[i]]; } + for (std::size_t i = 0; i != col_iter.size(); ++i) { + col_vec[i] = vec[col_iter[i]]; + } } diff --git a/src/pks/biogeochemistry/bgc_simple/bgc_simple.hh b/src/pks/biogeochemistry/bgc_simple/bgc_simple.hh index 7a499a8ef..fe2409b8f 100644 --- a/src/pks/biogeochemistry/bgc_simple/bgc_simple.hh +++ b/src/pks/biogeochemistry/bgc_simple/bgc_simple.hh @@ -7,73 +7,77 @@ Authors: Ethan Coon (coonet@ornl.gov) Chonggang Xu (cxu@lanl.gov) */ - -//! Above and below-ground carbon cycle model. /*! -This is a multi-leaf layer, big-leaf vegetation model coupled to a Century -model for belowground carbon decomposition. +This PK solves for both above and belowground carbon cycle. It is a multi-leaf +layer, big-leaf vegetation model coupled to a Century model for belowground +carbon decomposition. It leverages a PFT-based structure which allows multiple height-sorted PFTs to coexist on the same grid cells, with the shorter PFTs getting whatever light is -left in the understory. - -The implementation is based on an old, standalone code by Chonggang Xu, and -adapted for ATS. While this is not simple, it is called BGC simple as it is -about the least amount of complexity required to get a reasonable carbon cycle -into ATS. - -Outputs of this include transpiration, a critical sink for hydrology, as it -solves photosynthesis based on water availability. +left in the understory. The implementation is based on a standalone code by +Chonggang Xu, and adapted for ATS. Outputs of this include transpiration, a +critical sink for hydrology, as it solves photosynthesis based on water +availability. -Note this is an "explicit update PK," or effectively a forward Euler timestep +Note this is an "explicit PK," or effectively a forward Euler timestep that is not written in ODE form. Note this works on both the surface (vegetation) and subsurface (decomposition) meshes. **It is required** that the subsurface mesh is a "columnar" mesh, and -that build_columns in the subsurface Mesh_ spec has been supplied. +that build_columns in the subsurface :ref:`Mesh` spec has been supplied. -.. _bgc-simple-spec: -.. admonition:: bgc-simple-spec +`"PK type`" = `"BGC simple`" - * `"initial timestep`" ``[double]`` **1.0** Initial timestep size `[s]` +.. _pk-bgc-simple-spec: +.. admonition:: pk-bgc-simple-spec - * `"number of carbon pools`" ``[int]`` **7** Unclear whether this can actually change? + * `"initial timestep`" ``[double]`` **1.0** Initial timestep size `[s]` - * `"soil carbon parameters`" ``[soil-carbon-spec-list]`` List of soil carbon parameters by soil mesh partition region name. + * `"number of carbon pools`" ``[int]`` **7** Unclear whether this can actually change? - * `"pft parameters`" ``[pft-spec-list]`` List of PFT parameters by PFT name. + * `"soil carbon parameters`" ``[soil-carbon-spec-list]`` List of soil carbon + parameters by soil mesh partition region name. - * `"latitude [degrees]`" ``[double]`` **60** Latitude of the simulation in degrees. Used in radiation balance. + * `"pft parameters`" ``[pft-spec-list]`` List of PFT parameters by PFT name. - * `"wind speed reference height [m]`" ``[double]`` **2.0** Reference height of the wind speed dataset. + * `"latitude [degrees]`" ``[double]`` **60** Latitude of the simulation in + degrees. Used in radiation balance. - * `"cryoturbation mixing coefficient [cm^2/yr]`" ``[double]`` **5.0** Controls diffusion of carbon into the subsurface via cryoturbation. + * `"wind speed reference height [m]`" ``[double]`` **2.0** Reference height + of the wind speed dataset. - * `"leaf biomass initial condition`" ``[initial-conditions-spec]`` Sets the leaf biomass IC. + * `"cryoturbation mixing coefficient [cm^2/yr]`" ``[double]`` **5.0** + Controls diffusion of carbon into the subsurface via cryoturbation. - * `"domain name`" ``[string]`` **domain** + * `"leaf biomass initial condition`" ``[initial-conditions-spec]`` Sets the + leaf biomass IC. - * `"surface domain name`" ``[string]`` **surface** + * `"domain name`" ``[string]`` **domain** - * `"transpiration key`" ``[string]`` **DOMAIN-transpiration** The distributed transpiration flux `[mol s^-1]` + * `"surface domain name`" ``[string]`` **surface** - * `"shaded shortwave radiation key`" ``[string]`` - **SURFACE_DOMAIN-shaded_shortwave_radiation** Shortwave radiation that gets - past the canopy and teo the bare ground for soil evaporation. `[W m^-2]` + * `"transpiration key`" ``[string]`` **DOMAIN-transpiration** The + distributed transpiration flux `[mol s^-1]` - * `"total leaf area index key`" ``[string]`` **SURFACE_DOMAIN-total_leaf_area_index** Total LAI across all PFTs. + * `"shaded shortwave radiation key`" ``[string]`` + **SURFACE_DOMAIN-shaded_shortwave_radiation** Shortwave radiation that + gets past the canopy and teo the bare ground for soil evaporation. + [W m^-2] - EVALUATORS: + * `"total leaf area index key`" ``[string]`` + **SURFACE_DOMAIN-total_leaf_area_index** Total LAI across all PFTs. - - `"temperature`" The soil temperature `[K]` - - `"pressure`" soil mafic potential `[Pa]` - - `"surface-cell_volume`" `[m^2]` - - `"surface-incoming shortwave radiation`" `[W m^-2]` - - `"surface-air_temperature`" `[K]` - - `"surface-vapor_pressure_air`" `[Pa]` - - `"surface-wind_speed`" `[m s^-1]` - - `"surface-co2_concentration`" `[ppm]` + EVALUATORS: + + - `"temperature`" The soil temperature `[K]` + - `"pressure`" soil mafic potential `[Pa]` + - `"surface-cell_volume`" `[m^2]` + - `"surface-incoming shortwave radiation`" `[W m^-2]` + - `"surface-air_temperature`" `[K]` + - `"surface-vapor_pressure_air`" `[Pa]` + - `"surface-wind_speed`" `[m s^-1]` + - `"surface-co2_concentration`" `[ppm]` */ @@ -88,7 +92,7 @@ that build_columns in the subsurface Mesh_ spec has been supplied. #include "TreeVector.hh" #include "PK_Factory.hh" -#include "pk_physical_default.hh" +#include "PK_Physical_Default.hh" #include "SoilCarbonParameters.hh" #include "PFT.hh" @@ -131,8 +135,10 @@ class BGCSimple : public PK_Physical_Default { const Epetra_Vector& vec, Teuchos::Ptr col_vec, bool copy = true); - void - FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, double* col_vec, int ncol); + void FieldToColumn_(AmanziMesh::Entity_ID col, + const Epetra_Vector& vec, + double* col_vec, + int ncol); void ColDepthDz_(AmanziMesh::Entity_ID col, Teuchos::Ptr depth, Teuchos::Ptr dz); diff --git a/src/pks/biogeochemistry/bgc_simple/bgc_simple_funcs.cc b/src/pks/biogeochemistry/bgc_simple/bgc_simple_funcs.cc index daa7af770..f98185d65 100644 --- a/src/pks/biogeochemistry/bgc_simple/bgc_simple_funcs.cc +++ b/src/pks/biogeochemistry/bgc_simple/bgc_simple_funcs.cc @@ -85,7 +85,8 @@ BGCAdvance(double t, //---------------------------------------------------------------------- // loop through the list of PFTs - for (std::vector>::iterator pft_iter = pftarr.begin(); pft_iter != pftarr.end(); + for (std::vector>::iterator pft_iter = pftarr.begin() + ; pft_iter != pftarr.end(); ++pft_iter) { PFT& pft = *(*pft_iter); pft.GPP = 0.0; @@ -111,7 +112,9 @@ BGCAdvance(double t, pft.Bleafmemory = pft.bleafon * pft.leafondays; } - if (pft.leafoffdaysi < pft.leafoffdays) { pft.leafoffdaysi += dt_days; } + if (pft.leafoffdaysi < pft.leafoffdays) { + pft.leafoffdaysi += dt_days; + } } if (pft.leafstatus == 2) { @@ -394,7 +397,9 @@ BGCAdvance(double t, totalNonStoreB / (1.0 / pft.leaf2rootratio + 1.0 + 1.0 / pft.leaf2stemratio); double tarLAI = tarBleaf * pft.SLA / gridarea; - if (tarLAI > pft.maxLAI) { tarBleaf = pft.maxLAI / pft.SLA * gridarea; } + if (tarLAI > pft.maxLAI) { + tarBleaf = pft.maxLAI / pft.SLA * gridarea; + } double tarBroot = tarBleaf / pft.leaf2rootratio; double tarBstem = tarBleaf / pft.leaf2stemratio; double tarBtotal = tarBleaf + tarBstem + tarBroot; @@ -472,21 +477,29 @@ BGCAdvance(double t, HighTLim(SoilTArr[k] - 273.15); double soil_wp = std::max(std::min((SoilWPArr[k] - p_atm) / 1.e6, wp_max), wp_min); double WFactor = std::max((soil_wp - pft.minLeafWP) / (-0.05 - pft.minLeafWP), 0.); - if (SoilDArr[k] >= thawD) { WFactor = 0.0; } + if (SoilDArr[k] >= thawD) { + WFactor = 0.0; + } weightArr[k] = pft.BRootSoil[k] * TFactor * WFactor; totalweights += weightArr[k]; } if (totalweights <= 0.0) { //completely frozen totalweights = pft.Broot; - for (int k = 0; k != ncells; ++k) { weightArr[k] = pft.BRootSoil[k]; } + for (int k = 0; k != ncells; ++k) { + weightArr[k] = pft.BRootSoil[k]; + } } - for (int k = 0; k != ncells; ++k) { weightArr[k] /= totalweights; } + for (int k = 0; k != ncells; ++k) { + weightArr[k] /= totalweights; + } //--------------------------------------- // Check root mass balance double sumWeight = 0.0; - for (int k = 0; k != (ncells - 1); ++k) { sumWeight = sumWeight + weightArr[k]; } + for (int k = 0; k != (ncells - 1); ++k) { + sumWeight = sumWeight + weightArr[k]; + } pft.AssertRootBalance_or_die(); //------------------------------------------------------------- @@ -504,7 +517,9 @@ BGCAdvance(double t, } } else { // grow horizontally - for (int k = 0; k != ncells; ++k) { pft.BRootSoil[k] += grwBroot * weightArr[k]; } + for (int k = 0; k != ncells; ++k) { + pft.BRootSoil[k] += grwBroot * weightArr[k]; + } } pft.Broot = pft.Broot + grwBroot; @@ -595,7 +610,9 @@ BGCAdvance(double t, } // zero out annual variables - for (int i = 0; i != max_leaf_layers; ++i) { pft.annCBalance[i] = 0; } + for (int i = 0; i != max_leaf_layers; ++i) { + pft.annCBalance[i] = 0; + } pft.annNPP = 0.0; } @@ -675,7 +692,9 @@ BGCAdvance(double t, if (std::fmod(t_days, 365.25) > std::fmod(t_days + dt_days, 365.25)) { // year rolled over // annual setup - for (int i = 0; i != max_leaf_layers; ++i) { pft.annCBalance[i] = 0; } + for (int i = 0; i != max_leaf_layers; ++i) { + pft.annCBalance[i] = 0; + } //seed rain pft.Bleaf = pft.seedrainlai * gridarea / pft.SLA; @@ -699,13 +718,14 @@ BGCAdvance(double t, pft.Bstore += pft.Broot / (pft.Bleaf + pft.Bleafmemory) * storagecleaf * pft.storagecroot2sw / pft.storagecleaf2sw; } //end of year check - } //biomass check - } // loop for different PFTs + } //biomass check + } // loop for different PFTs //--------------------------------------------------------------------------------- //calculate shaded radiations for soil double radi = met.qSWin; - for (std::vector>::iterator pft_iter = pftarr.begin(); pft_iter != pftarr.end(); + for (std::vector>::iterator pft_iter = pftarr.begin() + ; pft_iter != pftarr.end(); ++pft_iter) { // std::cout << "wtf: (" << (*pft_iter)->pft_type << ") " << (*pft_iter)->LER << ", " << (*pft_iter)->lai << ", " << radi << std::endl; radi *= std::exp(-(*pft_iter)->LER * (*pft_iter)->lai); @@ -807,17 +827,23 @@ Cryoturbate(double dt, } else { Epetra_SerialDenseVector& C_up = soilcarr[k - 1]->SOM; double dz_up = SoilDArr[k] - SoilDArr[k - 1]; - for (int l = 0; l != npools; ++l) { dC_up[l] = (C[l] - C_up[l]) / dz_up; } + for (int l = 0; l != npools; ++l) { + dC_up[l] = (C[l] - C_up[l]) / dz_up; + } } // dC/dz on the face below if ((k == ncells - 1) || k + 1 >= k_frozen) { // boundary case - for (int l = 0; l != npools; ++l) { dC_dn[l] = 0; } + for (int l = 0; l != npools; ++l) { + dC_dn[l] = 0; + } } else { Epetra_SerialDenseVector& C_dn = soilcarr[k + 1]->SOM; double dz_dn = SoilDArr[k + 1] - SoilDArr[k]; - for (int l = 0; l != npools; ++l) { dC_dn[l] = (C_dn[l] - C[l]) / dz_dn; } + for (int l = 0; l != npools; ++l) { + dC_dn[l] = (C_dn[l] - C[l]) / dz_dn; + } } // dC = dt * D * (dC/dz_below - dC/dz_above) / dz @@ -836,7 +862,9 @@ Cryoturbate(double dt, Epetra_SerialDenseVector& C_k = soilcarr[k]->SOM; Epetra_SerialDenseVector& dC_k = dC[k]; - for (int l = 0; l != npools; ++l) { C_k[l] += dC_k[l]; } + for (int l = 0; l != npools; ++l) { + C_k[l] += dC_k[l]; + } k++; } } diff --git a/src/pks/biogeochemistry/bgc_simple/bgc_simple_funcs.hh b/src/pks/biogeochemistry/bgc_simple/bgc_simple_funcs.hh index 1d04d6bdb..ae4fe7c3c 100644 --- a/src/pks/biogeochemistry/bgc_simple/bgc_simple_funcs.hh +++ b/src/pks/biogeochemistry/bgc_simple/bgc_simple_funcs.hh @@ -29,37 +29,34 @@ Main functions for biogeochemistry on a column. namespace Amanzi { namespace BGC { -void -BGCAdvance(double t, - double dt, - double gridarea, - double cryoturbation_coef, - const MetData& met, - const Epetra_SerialDenseVector& SoilTArr, - const Epetra_SerialDenseVector& SoilArr, - const Epetra_SerialDenseVector& SoilDArr, - const Epetra_SerialDenseVector& SoilThicknessArr, - std::vector>& pftarr, - std::vector>& soilcarr, - Epetra_SerialDenseVector& SoilCO2Arr, - Epetra_SerialDenseVector& TransArr, - double& sw_shaded); +void BGCAdvance(double t, + double dt, + double gridarea, + double cryoturbation_coef, + const MetData& met, + const Epetra_SerialDenseVector& SoilTArr, + const Epetra_SerialDenseVector& SoilArr, + const Epetra_SerialDenseVector& SoilDArr, + const Epetra_SerialDenseVector& SoilThicknessArr, + std::vector>& pftarr, + std::vector>& soilcarr, + Epetra_SerialDenseVector& SoilCO2Arr, + Epetra_SerialDenseVector& TransArr, + double& sw_shaded); -void -Cryoturbate(double dt, - const Epetra_SerialDenseVector& SoilTArr, - const Epetra_SerialDenseVector& SoilDArr, - const Epetra_SerialDenseVector& SoilThicknessArr, - std::vector>& soilcarr, - double diffusion_coef); +void Cryoturbate(double dt, + const Epetra_SerialDenseVector& SoilTArr, + const Epetra_SerialDenseVector& SoilDArr, + const Epetra_SerialDenseVector& SoilThicknessArr, + std::vector>& soilcarr, + double diffusion_coef); -void -Cryoturbate(double dt, - const Epetra_SerialDenseVector& SoilTArr, - const Epetra_SerialDenseVector& SoilDArr, - const Epetra_SerialDenseVector& SoilThicknessArr, - std::vector>& soilcarr, - std::vector& diffusion_coefs); +void Cryoturbate(double dt, + const Epetra_SerialDenseVector& SoilTArr, + const Epetra_SerialDenseVector& SoilDArr, + const Epetra_SerialDenseVector& SoilThicknessArr, + std::vector>& soilcarr, + std::vector& diffusion_coefs); } // namespace BGC diff --git a/src/pks/biogeochemistry/bgc_simple/utils.hh b/src/pks/biogeochemistry/bgc_simple/utils.hh index 17b9d882e..48c03b08d 100644 --- a/src/pks/biogeochemistry/bgc_simple/utils.hh +++ b/src/pks/biogeochemistry/bgc_simple/utils.hh @@ -33,17 +33,14 @@ struct MetData { double lat; }; -double -PermafrostDepth(const Epetra_SerialDenseVector& SoilTArr, - const Epetra_SerialDenseVector& SoilThicknessArr, - double freeze_temp); +double PermafrostDepth(const Epetra_SerialDenseVector& SoilTArr, + const Epetra_SerialDenseVector& SoilThicknessArr, + double freeze_temp); -int -PermafrostDepthIndex(const Epetra_SerialDenseVector& SoilTArr, double freeze_temp); +int PermafrostDepthIndex(const Epetra_SerialDenseVector& SoilTArr, double freeze_temp); // This function calculate the effect of temperature on biological process. -double -TEffectsQ10(double Q10, double T, double refT); +double TEffectsQ10(double Q10, double T, double refT); } // namespace BGC } // namespace Amanzi diff --git a/src/pks/biogeochemistry/bgc_simple/vegetation.hh b/src/pks/biogeochemistry/bgc_simple/vegetation.hh index 282db3244..845b554b0 100644 --- a/src/pks/biogeochemistry/bgc_simple/vegetation.hh +++ b/src/pks/biogeochemistry/bgc_simple/vegetation.hh @@ -25,8 +25,12 @@ class QSat { public: QSat(); - void - operator()(double tleafk, double pressure, double* es, double* esdT, double* qs, double* qsdT); + void operator()(double tleafk, + double pressure, + double* es, + double* esdT, + double* qs, + double* qsdT); private: double a0, a1, a2, a3, a4, a5, a6, a7, a8; @@ -36,51 +40,46 @@ class QSat { }; // Determine time, in minutes of a given day of the year at a given latitude. -double -DayLength(double lat, int doy); +double DayLength(double lat, int doy); // Limit the highest temp? -double -HighTLim(double tleaf); +double HighTLim(double tleaf); //solve the quadratic equation -void -Quadratic(double a, double b, double c, double* r1, double* r2); +void Quadratic(double a, double b, double c, double* r1, double* r2); // This function calculate the net photosynthetic rate based on Farquhar // model, with updated leaf temperature based on energy balances by seperately solve light and RUBISCO-limited carboxylations -void -Photosynthesis(double PARi, - double LUE, - double LER, - double pressure, - double windv, - double tair, - double vp_air, - double CO2a, - double mp, - double Vcmax25, - double* A, - double* tleaf, - double* Resp, - double* ET); +void Photosynthesis(double PARi, + double LUE, + double LER, + double pressure, + double windv, + double tair, + double vp_air, + double CO2a, + double mp, + double Vcmax25, + double* A, + double* tleaf, + double* Resp, + double* ET); //// This function calculate the net photosynthetic rate based on Farquhar // model, with updated leaf temperature based on energy balances by jointly solving light and RUBISCO-limited carboxylations -void -Photosynthesis0(double PARi, - double LUE, - double LER, - double pressure, - double windv, - double tair, - double vp_air, - double CO2a, - double mp, - double Vcmax25, - double* A, - double* tleaf, - double* Resp, - double* ET); +void Photosynthesis0(double PARi, + double LUE, + double LER, + double pressure, + double windv, + double tair, + double vp_air, + double CO2a, + double mp, + double Vcmax25, + double* A, + double* tleaf, + double* Resp, + double* ET); } // namespace BGC diff --git a/src/pks/biogeochemistry/carbon/simple/CarbonSimple.cc b/src/pks/biogeochemistry/carbon/simple/CarbonSimple.cc index 1ee199be4..1b211c5e2 100644 --- a/src/pks/biogeochemistry/carbon/simple/CarbonSimple.cc +++ b/src/pks/biogeochemistry/carbon/simple/CarbonSimple.cc @@ -17,7 +17,7 @@ CarbonSimple::CarbonSimple(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& S, const Teuchos::RCP& solution) : Amanzi::PK(pk_tree, glist, S, solution), - Amanzi::PK_Physical_Explicit_Default(pk_tree, glist, S, solution), + Amanzi::PK_Physical_Default_Explicit_Default(pk_tree, glist, S, solution), is_diffusion_(false), is_source_(false), is_decomp_(false), @@ -42,7 +42,7 @@ CarbonSimple::CarbonSimple(Teuchos::ParameterList& pk_tree, void CarbonSimple::Setup() { - PK_Physical_Explicit_Default::Setup(); + PK_Physical_Default_Explicit_Default::Setup(); // number of carbon pools npools_ = plist_->get("number of carbon pools"); @@ -118,7 +118,9 @@ CarbonSimple::FunctionalTimeDerivative(const double t, const TreeVector& u, Tree const Epetra_MultiVector& cv = *S_->Get(cell_vol_key_, tag_current_).ViewComponent("cell", false); Epetra_MultiVector& dudt_c = *dudt->ViewComponent("cell", false); - for (int c = 0; c != dudt_c.MyLength(); ++c) { dudt_c[0][c] *= cv[0][c]; } + for (int c = 0; c != dudt_c.MyLength(); ++c) { + dudt_c[0][c] *= cv[0][c]; + } } diff --git a/src/pks/biogeochemistry/carbon/simple/CarbonSimple.hh b/src/pks/biogeochemistry/carbon/simple/CarbonSimple.hh index fae7d5595..9ad4fa1ba 100644 --- a/src/pks/biogeochemistry/carbon/simple/CarbonSimple.hh +++ b/src/pks/biogeochemistry/carbon/simple/CarbonSimple.hh @@ -23,7 +23,7 @@ Process kernel for energy equation for Richard's flow. namespace Amanzi { namespace BGC { -class CarbonSimple : public PK_Physical_Explicit_Default { +class CarbonSimple : public PK_Physical_Default_Explicit_Default { public: CarbonSimple(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& glist, @@ -39,15 +39,16 @@ class CarbonSimple : public PK_Physical_Explicit_Default { // virtual void initialize(const State& S); // -- Commit any secondary (dependent) variables. - virtual void CommitStep(double t_old, double t_new, const Tag& tag) override{}; + virtual void CommitStep(double t_old, double t_new, const Tag& tag) override {}; // -- Calculate any diagnostics prior to doing vis virtual void CalculateDiagnostics(const Tag& tag) override; // EnergyBase is a BDFFnBase // computes the non-linear functional f = f(t,u,udot) - virtual void - FunctionalTimeDerivative(const double t, const TreeVector& u, TreeVector& f) override; + virtual void FunctionalTimeDerivative(const double t, + const TreeVector& u, + TreeVector& f) override; protected: virtual void ApplyDiffusion_(const Teuchos::Ptr& g); diff --git a/src/pks/biogeochemistry/constitutive_models/carbon/bioturbation_evaluator.cc b/src/pks/biogeochemistry/constitutive_models/carbon/bioturbation_evaluator.cc index 930a2b2bb..54955b65f 100644 --- a/src/pks/biogeochemistry/constitutive_models/carbon/bioturbation_evaluator.cc +++ b/src/pks/biogeochemistry/constitutive_models/carbon/bioturbation_evaluator.cc @@ -91,7 +91,9 @@ BioturbationEvaluator::Evaluate_(const State& S, const std::vector - BioturbationEvaluator::fac_("bioturbation evaluator"); +Utils::RegisteredFactory BioturbationEvaluator::fac_( + "bioturbation evaluator"); } // namespace BGCRelations } // namespace BGC diff --git a/src/pks/biogeochemistry/constitutive_models/carbon/pool_decomposition_evaluator.hh b/src/pks/biogeochemistry/constitutive_models/carbon/pool_decomposition_evaluator.hh index f07295974..53f9486fe 100644 --- a/src/pks/biogeochemistry/constitutive_models/carbon/pool_decomposition_evaluator.hh +++ b/src/pks/biogeochemistry/constitutive_models/carbon/pool_decomposition_evaluator.hh @@ -29,8 +29,8 @@ class PoolDecompositionEvaluator : public EvaluatorSecondaryMonotypeCV { Teuchos::RCP Clone() const; // Required methods from EvaluatorSecondaryMonotypeCV - virtual void - EvaluateField_(const Teuchos::Ptr& S, const Teuchos::Ptr& result); + virtual void EvaluateField_(const Teuchos::Ptr& S, + const Teuchos::Ptr& result); virtual void EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, Key wrt_key, const Teuchos::Ptr& result); diff --git a/src/pks/biogeochemistry/constitutive_models/carbon/pool_decomposition_evaluator_reg.hh b/src/pks/biogeochemistry/constitutive_models/carbon/pool_decomposition_evaluator_reg.hh index aa749d58e..e34490173 100644 --- a/src/pks/biogeochemistry/constitutive_models/carbon/pool_decomposition_evaluator_reg.hh +++ b/src/pks/biogeochemistry/constitutive_models/carbon/pool_decomposition_evaluator_reg.hh @@ -14,8 +14,8 @@ namespace BGC { namespace BGCRelations { // registry of method -Utils::RegisteredFactory - PoolDecompositionEvaluator::fac_("pool decomposition evaluator"); +Utils::RegisteredFactory PoolDecompositionEvaluator::fac_( + "pool decomposition evaluator"); } // namespace BGCRelations } // namespace BGC diff --git a/src/pks/biogeochemistry/constitutive_models/carbon/pool_transfer_evaluator.hh b/src/pks/biogeochemistry/constitutive_models/carbon/pool_transfer_evaluator.hh index 814e0d6c3..97239ae52 100644 --- a/src/pks/biogeochemistry/constitutive_models/carbon/pool_transfer_evaluator.hh +++ b/src/pks/biogeochemistry/constitutive_models/carbon/pool_transfer_evaluator.hh @@ -34,10 +34,10 @@ class PoolTransferEvaluator : public EvaluatorSecondaryMonotypeCV { // Required methods from EvaluatorSecondaryMonotypeCV virtual void EvaluateField_(const Teuchos::Ptr& S, const std::vector>& results); - virtual void - EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, - Key wrt_key, - const std::vector>& results); + virtual void EvaluateFieldPartialDerivative_( + const Teuchos::Ptr& S, + Key wrt_key, + const std::vector>& results); protected: diff --git a/src/pks/biogeochemistry/fates/fates_pk.cc b/src/pks/biogeochemistry/fates/fates_pk.cc index 73650caed..177043cf5 100644 --- a/src/pks/biogeochemistry/fates/fates_pk.cc +++ b/src/pks/biogeochemistry/fates/fates_pk.cc @@ -402,8 +402,8 @@ FATES_PK::AdvanceStep(double t_old, double t_new, bool reinit) bool run_photo = false; bool run_veg_dym = false; - if (fabs(t_new - (t_photosynthesis_ + dt_photosynthesis_)) < 1e-12 * t_new) run_photo = true; - if (fabs(t_new - (t_site_dym_ + dt_site_dym_)) < 1e-12 * t_new) run_veg_dym = true; + if (fabs(t_new - (t_photosynthesis_ + dt_photosynthesis_) ) < 1e-12 * t_new) run_photo = true; + if (fabs(t_new - (t_site_dym_ + dt_site_dym_) ) < 1e-12 * t_new) run_veg_dym = true; if (run_photo) { @@ -449,7 +449,7 @@ FATES_PK::AdvanceStep(double t_old, double t_new, bool reinit) FieldToColumn_(c, suc_vec, suc_.data() + c * ncells_per_col_, ncells_per_col_); } else { - for (int i = 0; i < suc_.size(); i++) suc_[i] = 0.; // No suction is defined in State; + for (int i = 0; i < suc_.size() ; i++) suc_[i] = 0.; // No suction is defined in State; } } } @@ -615,7 +615,9 @@ FATES_PK::FieldToColumn_(AmanziMesh::Entity_ID col, int ncol) { auto& col_iter = mesh_->columns.getCells(col); - for (std::size_t i = 0; i != col_iter.size(); ++i) { col_vec[i] = vec[col_iter[i]]; } + for (std::size_t i = 0; i != col_iter.size(); ++i) { + col_vec[i] = vec[col_iter[i]]; + } } // helper function for collecting column dz and depth diff --git a/src/pks/biogeochemistry/fates/fates_pk.hh b/src/pks/biogeochemistry/fates/fates_pk.hh index 567e8d330..d8ce2b13b 100644 --- a/src/pks/biogeochemistry/fates/fates_pk.hh +++ b/src/pks/biogeochemistry/fates/fates_pk.hh @@ -11,7 +11,7 @@ #define PK_FATES_HH_ #include "PK_Factory.hh" -#include "pk_physical_default.hh" +#include "PK_Physical_Default.hh" #include "ISO_Fortran_binding.h" #include "Teuchos_ParameterList.hpp" @@ -106,7 +106,7 @@ class FATES_PK : public PK_Physical_Default { // -- Update diagnostics for vis. - virtual void CalculateDiagnostics(const Teuchos::RCP& S){}; + virtual void CalculateDiagnostics(const Teuchos::RCP& S) {}; virtual bool AdvanceStep(double t_old, double t_new, bool reinit); @@ -119,8 +119,10 @@ class FATES_PK : public PK_Physical_Default { virtual void set_dt(double dt) { dt_ = dt; } protected: - void - FieldToColumn_(AmanziMesh::Entity_ID col, const Epetra_Vector& vec, double* col_vec, int ncol); + void FieldToColumn_(AmanziMesh::Entity_ID col, + const Epetra_Vector& vec, + double* col_vec, + int ncol); void ColDepthDz_(AmanziMesh::Entity_ID col, Teuchos::Ptr depth, Teuchos::Ptr dz); diff --git a/src/pks/chem_pk_helpers.cc b/src/pks/chem_pk_helpers.cc new file mode 100644 index 000000000..4bffc45ae --- /dev/null +++ b/src/pks/chem_pk_helpers.cc @@ -0,0 +1,65 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon (ecoon@ornl.gov) +*/ + +#include "Epetra_MultiVector.h" + +#include "Key.hh" +#include "State.hh" +#include "PK_Helpers.hh" +#include "chem_pk_helpers.hh" + +namespace Amanzi { + +// ----------------------------------------------------------------------------- +// Helper functions for working with Amanzi's Chemistry PK +// ----------------------------------------------------------------------------- +void +convertConcentrationToMolFrac(State& S, + const KeyTag& tcc, + const KeyTag& mol_frac, + const KeyTag& mol_dens, + const std::string& passwd) +{ + const Epetra_MultiVector& tcc_c = + *S.Get(tcc.first, tcc.second).ViewComponent("cell", false); + Epetra_MultiVector& mol_frac_c = + *S.GetW(mol_frac.first, mol_frac.second, passwd).ViewComponent("cell", false); + + S.GetEvaluator(mol_dens.first, mol_dens.second).Update(S, passwd); + const Epetra_MultiVector& mol_dens_c = + *S.Get(mol_dens.first, mol_dens.second).ViewComponent("cell", false); + + // convert from mole fraction [mol C / mol H20] to [mol C / L] + int ierr = mol_frac_c.ReciprocalMultiply(1.e3, mol_dens_c, tcc_c, 0.); + AMANZI_ASSERT(!ierr); + changedEvaluatorPrimary(mol_frac.first, mol_frac.second, S); +} + +void +convertMolFracToConcentration(State& S, + const KeyTag& mol_frac, + const KeyTag& tcc, + const KeyTag& mol_dens, + const std::string& passwd) +{ + const Epetra_MultiVector& mol_frac_c = + *S.Get(mol_frac.first, mol_frac.second).ViewComponent("cell", false); + Epetra_MultiVector& tcc_c = + *S.GetW(tcc.first, tcc.second, passwd).ViewComponent("cell", false); + + S.GetEvaluator(mol_dens.first, mol_dens.second).Update(S, passwd); + const Epetra_MultiVector& mol_dens_c = + *S.Get(mol_dens.first, mol_dens.second).ViewComponent("cell", false); + + int ierr = tcc_c.Multiply(1.e-3, mol_dens_c, mol_frac_c, 0.); + AMANZI_ASSERT(!ierr); + changedEvaluatorPrimary(tcc.first, tcc.second, S); +} + +} // namespace Amanzi diff --git a/src/pks/chem_pk_helpers.hh b/src/pks/chem_pk_helpers.hh new file mode 100644 index 000000000..36330093b --- /dev/null +++ b/src/pks/chem_pk_helpers.hh @@ -0,0 +1,36 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon (ecoon@ornl.gov) +*/ + +//! A set of helper functions for doing common things in PKs. +#pragma once + +#include +#include "Key.hh" + +namespace Amanzi { + +class State; + +// ----------------------------------------------------------------------------- +// Helper functions for working with Amanzi's Chemistry PK +// ----------------------------------------------------------------------------- +void convertConcentrationToMolFrac(State& S, + const KeyTag& tcc, + const KeyTag& mol_frac, + const KeyTag& mol_dens, + const std::string& passwd); + + +void convertMolFracToConcentration(State& S, + const KeyTag& mol_frac, + const KeyTag& tcc, + const KeyTag& mol_dens, + const std::string& passwd); + +} // namespace Amanzi diff --git a/src/pks/deform/volumetric_deformation.cc b/src/pks/deform/volumetric_deformation.cc index 2c394501b..037b228d0 100644 --- a/src/pks/deform/volumetric_deformation.cc +++ b/src/pks/deform/volumetric_deformation.cc @@ -11,7 +11,7 @@ //! Subsidence through bulk ice loss and cell volumetric change. #include "CompositeVectorFunctionFactory.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "volumetric_deformation.hh" #define DEBUG 0 @@ -127,7 +127,7 @@ VolumetricDeformation::Setup() } // note this mesh is never deformed in this PK as all movement is vertical - if (S_->HasMesh(domain_surf_)) surf_mesh_ = S_->GetMesh(domain_surf_); + if (S_->HasMesh(domain_surf_) ) surf_mesh_ = S_->GetMesh(domain_surf_); // the 3D variant of the surface mesh does change! if (S_->HasMesh(domain_surf_3d_)) { @@ -161,37 +161,37 @@ VolumetricDeformation::Setup() cv_fac.SetMesh(mesh_)->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); switch (deform_mode_) { - case (DEFORM_MODE_DVDT): { - // Create the deformation function - Teuchos::ParameterList func_plist = plist_->sublist("deformation function"); - std::vector compnames; - deform_func_ = Functions::CreateCompositeVectorFunction(func_plist, cv_fac, compnames); - // note, should check that cells exist in the function? - break; - } + case (DEFORM_MODE_DVDT): { + // Create the deformation function + Teuchos::ParameterList func_plist = plist_->sublist("deformation function"); + std::vector compnames; + deform_func_ = Functions::CreateCompositeVectorFunction(func_plist, cv_fac, compnames); + // note, should check that cells exist in the function? + break; + } - case (DEFORM_MODE_SATURATION, DEFORM_MODE_STRUCTURAL): { - requireAtNext(sat_liq_key_, tag_next_, *S_); - requireAtCurrent(sat_liq_key_, tag_current_, *S_, name_) - .SetMesh(mesh_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtNext(sat_ice_key_, tag_next_, *S_); - requireAtCurrent(sat_ice_key_, tag_current_, *S_, name_) - .SetMesh(mesh_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtNext(sat_gas_key_, tag_next_, *S_); - requireAtCurrent(sat_gas_key_, tag_current_, *S_, name_) - .SetMesh(mesh_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtNext(poro_key_, tag_next_, *S_); - requireAtCurrent(poro_key_, tag_current_, *S_, name_) - .SetMesh(mesh_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - break; - } - default: { - AMANZI_ASSERT(0); - } + case (DEFORM_MODE_SATURATION, DEFORM_MODE_STRUCTURAL): { + requireEvaluatorAtNext(sat_liq_key_, tag_next_, *S_); + requireEvaluatorAtCurrent(sat_liq_key_, tag_current_, *S_, name_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + requireEvaluatorAtNext(sat_ice_key_, tag_next_, *S_); + requireEvaluatorAtCurrent(sat_ice_key_, tag_current_, *S_, name_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + requireEvaluatorAtNext(sat_gas_key_, tag_next_, *S_); + requireEvaluatorAtCurrent(sat_gas_key_, tag_current_, *S_, name_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + requireEvaluatorAtNext(poro_key_, tag_next_, *S_, true); + requireEvaluatorAtCurrent(poro_key_, tag_current_, *S_, name_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + break; + } + default: { + AMANZI_ASSERT(0); + } } // require for cell volume, and make sure the cell volume is deformable! @@ -202,66 +202,66 @@ VolumetricDeformation::Setup() cv_eval_list.set("evaluator type", "deforming cell volume"); cv_eval_list.set("deformation key", key_); } - requireAtNext(cv_key_, tag_next_, *S_) + requireEvaluatorAtNext(cv_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // require a copy at the old tag - requireAtCurrent(cv_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(cv_key_, tag_current_, *S_, name_); // Strategy-specific setup switch (strategy_) { - case (DEFORM_STRATEGY_GLOBAL_OPTIMIZATION): { - // // create the operator - // Teuchos::ParameterList op_plist = plist_->sublist("global solve operator"); - // // def_matrix_ = Teuchos::rcp(new Operators::MatrixVolumetricDeformation(op_plist, mesh_)); - - // // NOTE: this doesn't work because ATS operators are not supported, and - // // this isn't based on Amanzi::Operators::Operator. But this code branch - // // is fairly dead anyway.... --etc - // def_matrix_->set_inverse_parameters(); - - // // create storage for the nodal deformation - // S_->RequireField(Keys::getKey(domain_,"nodal_dz"), name_)->SetMesh(mesh_)->SetGhosted() - // ->SetComponent("node", AmanziMesh::Entity_kind::NODE, 1); - break; - } - - case (DEFORM_STRATEGY_MSTK): { - requireAtCurrent(sat_ice_key_, tag_current_, *S_, name_) - .SetMesh(mesh_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + case (DEFORM_STRATEGY_GLOBAL_OPTIMIZATION): { + // // create the operator + // Teuchos::ParameterList op_plist = plist_->sublist("global solve operator"); + // // def_matrix_ = Teuchos::rcp(new Operators::MatrixVolumetricDeformation(op_plist, mesh_)); + + // // NOTE: this doesn't work because ATS operators are not supported, and + // // this isn't based on Amanzi::Operators::Operator. But this code branch + // // is fairly dead anyway.... --etc + // def_matrix_->set_inverse_parameters(); + + // // create storage for the nodal deformation + // S_->RequireField(Keys::getKey(domain_,"nodal_dz"), name_)->SetMesh(mesh_)->SetGhosted() + // ->SetComponent("node", AmanziMesh::Entity_kind::NODE, 1); + break; + } - requireAtCurrent(poro_key_, tag_current_, *S_, name_) - .SetMesh(mesh_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - break; - } + case (DEFORM_STRATEGY_MSTK): { + requireEvaluatorAtCurrent(sat_ice_key_, tag_current_, *S_, name_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - case (DEFORM_STRATEGY_AVERAGE): { - // Both of these are work space and do not need to be put into State, but - // we do so anyway to allow them to be visualized for debugging (hence at - // tag_next_). + requireEvaluatorAtCurrent(poro_key_, tag_current_, *S_, name_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + break; + } - // create storage for the nodal change in position - // dof 0: the volume-averaged displacement - // dof 1: the simply averaged displacement - // dof 2: count of number of faces contributing to the node change - requireAtNext(nodal_dz_key_, tag_next_, *S_, name_) - .SetMesh(mesh_) - ->SetGhosted() - ->SetComponent("node", AmanziMesh::Entity_kind::NODE, 3); + case (DEFORM_STRATEGY_AVERAGE): { + // Both of these are work space and do not need to be put into State, but + // we do so anyway to allow them to be visualized for debugging (hence at + // tag_next_). + + // create storage for the nodal change in position + // dof 0: the volume-averaged displacement + // dof 1: the simply averaged displacement + // dof 2: count of number of faces contributing to the node change + requireEvaluatorAtNext(nodal_dz_key_, tag_next_, *S_, name_) + .SetMesh(mesh_) + ->SetGhosted() + ->SetComponent("node", AmanziMesh::Entity_kind::NODE, 3); - // create cell-based storage for deformation of the face above the cell - S_->Require(face_above_dz_key_, tag_next_, name_) - .SetMesh(mesh_) - ->SetGhosted() - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - break; - } - default: { - } + // create cell-based storage for deformation of the face above the cell + S_->Require(face_above_dz_key_, tag_next_, name_) + .SetMesh(mesh_) + ->SetGhosted() + ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + break; + } + default: { + } } } @@ -278,25 +278,25 @@ VolumetricDeformation::Initialize() S_->GetRecordW(del_cv_key_, tag_next_, name_).set_initialized(); switch (strategy_) { - case (DEFORM_STRATEGY_GLOBAL_OPTIMIZATION): { - // // initialize the initial displacement to be zero - // S_->GetW(nodal_dz_key_, tag_next_, name_).PutScalar(0.); - // S_->GetRecordW(nodal_dz_key_, tag_next_, name_).set_initialized(); - // break; - } - case (DEFORM_STRATEGY_AVERAGE): { - // initialize the initial displacement to be zero - S_->GetW(nodal_dz_key_, tag_next_, name_).PutScalar(0.); - S_->GetRecordW(nodal_dz_key_, tag_next_, name_).set_initialized(); - S_->GetRecordW(nodal_dz_key_, tag_next_, name_).set_io_vis(false); // cannot vis - S_->GetRecordW(nodal_dz_key_, Tags::NEXT, name_).set_io_vis(false); // cannot vis - S_->GetW(face_above_dz_key_, tag_next_, name_).PutScalar(0.); - S_->GetRecordW(face_above_dz_key_, tag_next_, name_).set_initialized(); - S_->GetRecordW(face_above_dz_key_, tag_next_, name_).set_io_vis(false); // no need - break; - } - default: { - } + case (DEFORM_STRATEGY_GLOBAL_OPTIMIZATION): { + // // initialize the initial displacement to be zero + // S_->GetW(nodal_dz_key_, tag_next_, name_).PutScalar(0.); + // S_->GetRecordW(nodal_dz_key_, tag_next_, name_).set_initialized(); + // break; + } + case (DEFORM_STRATEGY_AVERAGE): { + // initialize the initial displacement to be zero + S_->GetW(nodal_dz_key_, tag_next_, name_).PutScalar(0.); + S_->GetRecordW(nodal_dz_key_, tag_next_, name_).set_initialized(); + S_->GetRecordW(nodal_dz_key_, tag_next_, name_).set_io_vis(false); // cannot vis + S_->GetRecordW(nodal_dz_key_, Tags::NEXT, name_).set_io_vis(false); // cannot vis + S_->GetW(face_above_dz_key_, tag_next_, name_).PutScalar(0.); + S_->GetRecordW(face_above_dz_key_, tag_next_, name_).set_initialized(); + S_->GetRecordW(face_above_dz_key_, tag_next_, name_).set_io_vis(false); // no need + break; + } + default: { + } } // initialize the vertex coordinate to the current mesh @@ -343,126 +343,128 @@ VolumetricDeformation::AdvanceStep(double t_old, double t_new, bool reinit) // Calculate the change in cell volumes switch (deform_mode_) { - case (DEFORM_MODE_DVDT): { - deform_func_->Compute((t_old + t_new) / 2., dcell_vol_vec.ptr()); - dcell_vol_vec->Scale(dt); - break; - } + case (DEFORM_MODE_DVDT): { + deform_func_->Compute((t_old + t_new) / 2., dcell_vol_vec.ptr()); + dcell_vol_vec->Scale(dt); + break; + } - case (DEFORM_MODE_SATURATION): { - if (S_->HasEvaluator(cv_key_, tag_current_)) - S_->GetEvaluator(cv_key_, tag_current_).Update(*S_, name_); - if (S_->HasEvaluator(sat_liq_key_, tag_current_)) - S_->GetEvaluator(sat_liq_key_, tag_current_).Update(*S_, name_); - if (S_->HasEvaluator(sat_gas_key_, tag_current_)) - S_->GetEvaluator(sat_gas_key_, tag_current_).Update(*S_, name_); - if (S_->HasEvaluator(sat_ice_key_, tag_current_)) - S_->GetEvaluator(sat_ice_key_, tag_current_).Update(*S_, name_); - if (S_->HasEvaluator(poro_key_, tag_current_)) - S_->GetEvaluator(poro_key_, tag_current_).Update(*S_, name_); + case (DEFORM_MODE_SATURATION): { + if (S_->HasEvaluator(cv_key_, tag_current_)) + S_->GetEvaluator(cv_key_, tag_current_).Update(*S_, name_); + if (S_->HasEvaluator(sat_liq_key_, tag_current_)) + S_->GetEvaluator(sat_liq_key_, tag_current_).Update(*S_, name_); + if (S_->HasEvaluator(sat_gas_key_, tag_current_)) + S_->GetEvaluator(sat_gas_key_, tag_current_).Update(*S_, name_); + if (S_->HasEvaluator(sat_ice_key_, tag_current_)) + S_->GetEvaluator(sat_ice_key_, tag_current_).Update(*S_, name_); + if (S_->HasEvaluator(poro_key_, tag_current_)) + S_->GetEvaluator(poro_key_, tag_current_).Update(*S_, name_); - const Epetra_MultiVector& cv = - *S_->Get(cv_key_, tag_current_).ViewComponent("cell", true); - const Epetra_MultiVector& s_liq = - *S_->Get(sat_liq_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& s_ice = - *S_->Get(sat_ice_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& s_gas = - *S_->Get(sat_gas_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& poro = - *S_->Get(poro_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& base_poro = - *S_->Get(key_, tag_current_).ViewComponent("cell", false); - - Epetra_MultiVector& dcell_vol_c = *dcell_vol_vec->ViewComponent("cell", false); - int dim = mesh_->getSpaceDimension(); - - auto cells = mesh_->getSetEntities( - deform_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); - - for (auto c : cells) { - double frac = 0.; - - if (s_liq[0][c] > min_S_liq_) { // perform deformation if s_liq > min_S_liq_ - if ((poro[0][c] - base_poro[0][c]) / base_poro[0][c] < - overpressured_limit_) { // perform deformation - // if pressure have been relaxed enough - frac = std::min((base_poro[0][c] - min_porosity_) / (1 - min_porosity_), - deform_scaling_ * ((1 - s_ice[0][c]) - min_S_liq_) * base_poro[0][c]); + const Epetra_MultiVector& cv = + *S_->Get(cv_key_, tag_current_).ViewComponent("cell", true); + const Epetra_MultiVector& s_liq = + *S_->Get(sat_liq_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& s_ice = + *S_->Get(sat_ice_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& s_gas = + *S_->Get(sat_gas_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& poro = + *S_->Get(poro_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& base_poro = + *S_->Get(key_, tag_current_).ViewComponent("cell", false); + + Epetra_MultiVector& dcell_vol_c = *dcell_vol_vec->ViewComponent("cell", false); + int dim = mesh_->getSpaceDimension(); + + auto cells = mesh_->getSetEntities( + deform_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + + for (auto c : cells) { + double frac = 0.; + + if (s_liq[0][c] > min_S_liq_) { // perform deformation if s_liq > min_S_liq_ + if ((poro[0][c] - base_poro[0][c]) / base_poro[0][c] < + overpressured_limit_) { // perform deformation + // if pressure have been relaxed enough + frac = std::min((base_poro[0][c] - min_porosity_) / (1 - min_porosity_), + deform_scaling_ * ((1 - s_ice[0][c]) - min_S_liq_) * base_poro[0][c]); + } } - } - dcell_vol_c[0][c] = -frac * cv[0][c]; + dcell_vol_c[0][c] = -frac * cv[0][c]; #if DEBUG - double soil_mass_vol = cv[0][c] * (1 - base_poro[0][c]); - std::cout << "Cell: " << c << " " << cv[0][c] << " " << dcell_vol_c[0][c] << " frac " << frac - << " poro " << poro[0][c] << " ice " << s_ice[0][c] << " liq " << s_liq[0][c] - << " gas " << s_gas[0][c] << " soil vol " << soil_mass_vol << std::endl; + double soil_mass_vol = cv[0][c] * (1 - base_poro[0][c]); + std::cout << "Cell: " << c << " " << cv[0][c] << " " << dcell_vol_c[0][c] << " frac " + << frac << " poro " << poro[0][c] << " ice " << s_ice[0][c] << " liq " + << s_liq[0][c] << " gas " << s_gas[0][c] << " soil vol " << soil_mass_vol + << std::endl; #endif + } + break; } - break; - } - case (DEFORM_MODE_STRUCTURAL): { - if (S_->HasEvaluator(cv_key_, tag_current_)) - S_->GetEvaluator(cv_key_, tag_current_).Update(*S_, name_); - if (S_->HasEvaluator(sat_liq_key_, tag_current_)) - S_->GetEvaluator(sat_liq_key_, tag_current_).Update(*S_, name_); - if (S_->HasEvaluator(sat_gas_key_, tag_current_)) - S_->GetEvaluator(sat_gas_key_, tag_current_).Update(*S_, name_); - if (S_->HasEvaluator(sat_ice_key_, tag_current_)) - S_->GetEvaluator(sat_ice_key_, tag_current_).Update(*S_, name_); - if (S_->HasEvaluator(poro_key_, tag_current_)) - S_->GetEvaluator(poro_key_, tag_current_).Update(*S_, name_); + case (DEFORM_MODE_STRUCTURAL): { + if (S_->HasEvaluator(cv_key_, tag_current_)) + S_->GetEvaluator(cv_key_, tag_current_).Update(*S_, name_); + if (S_->HasEvaluator(sat_liq_key_, tag_current_)) + S_->GetEvaluator(sat_liq_key_, tag_current_).Update(*S_, name_); + if (S_->HasEvaluator(sat_gas_key_, tag_current_)) + S_->GetEvaluator(sat_gas_key_, tag_current_).Update(*S_, name_); + if (S_->HasEvaluator(sat_ice_key_, tag_current_)) + S_->GetEvaluator(sat_ice_key_, tag_current_).Update(*S_, name_); + if (S_->HasEvaluator(poro_key_, tag_current_)) + S_->GetEvaluator(poro_key_, tag_current_).Update(*S_, name_); - const Epetra_MultiVector& cv = - *S_->Get(cv_key_, tag_current_).ViewComponent("cell", true); - const Epetra_MultiVector& s_liq = - *S_->Get(sat_liq_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& s_ice = - *S_->Get(sat_ice_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& s_gas = - *S_->Get(sat_gas_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& poro = - *S_->Get(poro_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& base_poro = - *S_->Get(key_, tag_current_).ViewComponent("cell", false); - - Epetra_MultiVector& dcell_vol_c = *dcell_vol_vec->ViewComponent("cell", false); - dcell_vol_c.PutScalar(0.); - int dim = mesh_->getSpaceDimension(); - - auto cells = mesh_->getSetEntities( - deform_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); - - double time_factor = dt > time_scale_ ? 1 : dt / time_scale_; - for (auto c : cells) { - double fs = 1 - poro[0][c]; - double fi = poro[0][c] * s_ice[0][c]; - - double frac = 0.; - if (fs + fi < structural_vol_frac_ && // sub-structural... start subsiding - (poro[0][c] - base_poro[0][c]) / base_poro[0][c] < overpressured_limit_) { - // perform deformation if we are not too overpressured - frac = (structural_vol_frac_ - (fs + fi)) * time_factor; - } + const Epetra_MultiVector& cv = + *S_->Get(cv_key_, tag_current_).ViewComponent("cell", true); + const Epetra_MultiVector& s_liq = + *S_->Get(sat_liq_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& s_ice = + *S_->Get(sat_ice_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& s_gas = + *S_->Get(sat_gas_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& poro = + *S_->Get(poro_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& base_poro = + *S_->Get(key_, tag_current_).ViewComponent("cell", false); + + Epetra_MultiVector& dcell_vol_c = *dcell_vol_vec->ViewComponent("cell", false); + dcell_vol_c.PutScalar(0.); + int dim = mesh_->getSpaceDimension(); + + auto cells = mesh_->getSetEntities( + deform_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + + double time_factor = dt > time_scale_ ? 1 : dt / time_scale_; + for (auto c : cells) { + double fs = 1 - poro[0][c]; + double fi = poro[0][c] * s_ice[0][c]; + + double frac = 0.; + if (fs + fi < structural_vol_frac_ && // sub-structural... start subsiding + (poro[0][c] - base_poro[0][c]) / base_poro[0][c] < overpressured_limit_) { + // perform deformation if we are not too overpressured + frac = (structural_vol_frac_ - (fs + fi)) * time_factor; + } - dcell_vol_c[0][c] = -frac * cv[0][c]; + dcell_vol_c[0][c] = -frac * cv[0][c]; - AMANZI_ASSERT(dcell_vol_c[0][c] <= 0); + AMANZI_ASSERT(dcell_vol_c[0][c] <= 0); #if DEBUG - std::cout << "Cell " << c << ": V, dV: " << cv[0][c] << " " << dcell_vol_c[0][c] << std::endl - << " poro_0 " << base_poro[0][c] << " | poro " << poro[0][c] << " | frac " << frac - << " | time factor " << time_factor << std::endl - << " ice " << s_ice[0][c] << " | liq " << s_liq[0][c] << " | gas " << s_gas[0][c] - << std::endl - << " conserved soil vol:" << cv[0][c] * (1 - base_poro[0][c]) << std::endl; + std::cout << "Cell " << c << ": V, dV: " << cv[0][c] << " " << dcell_vol_c[0][c] + << std::endl + << " poro_0 " << base_poro[0][c] << " | poro " << poro[0][c] << " | frac " + << frac << " | time factor " << time_factor << std::endl + << " ice " << s_ice[0][c] << " | liq " << s_liq[0][c] << " | gas " << s_gas[0][c] + << std::endl + << " conserved soil vol:" << cv[0][c] * (1 - base_poro[0][c]) << std::endl; #endif + } + break; } - break; - } - default: - AMANZI_ASSERT(0); + default: + AMANZI_ASSERT(0); } // set up the fixed nodes @@ -482,140 +484,143 @@ VolumetricDeformation::AdvanceStep(double t_old, double t_new, bool reinit) if (dcell_vol_norm > 0.) { // Deform the subsurface mesh switch (strategy_) { - case (DEFORM_STRATEGY_MSTK): { - // collect needed data, ghosted - const Epetra_MultiVector& poro = - *S_->Get(poro_key_, tag_current_).ViewComponent("cell"); - const Epetra_MultiVector& s_ice = - *S_->Get(sat_ice_key_, tag_current_).ViewComponent("cell", false); - const Epetra_MultiVector& cv = - *S_->Get(cv_key_, tag_current_).ViewComponent("cell"); - - // -- dcell vol - const Epetra_MultiVector& dcell_vol_c = *dcell_vol_vec->ViewComponent("cell", true); - - // data needed in vectors - int ncells = - mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); - int nnodes = - mesh_->getNumEntities(AmanziMesh::Entity_kind::NODE, AmanziMesh::Parallel_kind::ALL); - std::vector target_cell_vols(ncells); - std::vector min_cell_vols(ncells); - int dim = mesh_->getSpaceDimension(); - double min_height = std::numeric_limits::max(); + case (DEFORM_STRATEGY_MSTK): { + // collect needed data, ghosted + const Epetra_MultiVector& poro = + *S_->Get(poro_key_, tag_current_).ViewComponent("cell"); + const Epetra_MultiVector& s_ice = + *S_->Get(sat_ice_key_, tag_current_).ViewComponent("cell", false); + const Epetra_MultiVector& cv = + *S_->Get(cv_key_, tag_current_).ViewComponent("cell"); + + // -- dcell vol + const Epetra_MultiVector& dcell_vol_c = *dcell_vol_vec->ViewComponent("cell", true); + + // data needed in vectors + int ncells = + mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); + int nnodes = + mesh_->getNumEntities(AmanziMesh::Entity_kind::NODE, AmanziMesh::Parallel_kind::ALL); + std::vector target_cell_vols(ncells); + std::vector min_cell_vols(ncells); + int dim = mesh_->getSpaceDimension(); + double min_height = std::numeric_limits::max(); - for (int c = 0; c != ncells; ++c) { - target_cell_vols[c] = cv[0][c] + dcell_vol_c[0][c]; - min_cell_vols[c] = ((1 - poro[0][c]) + poro[0][c] * s_ice[0][c]) * cv[0][c]; - // min vol is rock vol + ice + a bit - if (std::abs(cv[0][c] - target_cell_vols[c]) / cv[0][c] > 1e-4) { + for (int c = 0; c != ncells; ++c) { + target_cell_vols[c] = cv[0][c] + dcell_vol_c[0][c]; + min_cell_vols[c] = ((1 - poro[0][c]) + poro[0][c] * s_ice[0][c]) * cv[0][c]; + // min vol is rock vol + ice + a bit + if (std::abs(cv[0][c] - target_cell_vols[c]) / cv[0][c] > 1e-4) { #if DEBUG - std::cout << "Cell " << c << ": " - << "V, V_target, V_min " << cv[0][c] << " " << target_cell_vols[c] << " " - << min_cell_vols[c] << std::endl; + std::cout << "Cell " << c << ": " + << "V, V_target, V_min " << cv[0][c] << " " << target_cell_vols[c] << " " + << min_cell_vols[c] << std::endl; #endif - auto centroid = mesh_->getCellCentroid(c); - min_height = std::min(min_height, centroid[dim - 1]); - AMANZI_ASSERT(min_cell_vols[c] <= target_cell_vols[c]); + auto centroid = mesh_->getCellCentroid(c); + min_height = std::min(min_height, centroid[dim - 1]); + AMANZI_ASSERT(min_cell_vols[c] <= target_cell_vols[c]); - } else { - target_cell_vols[c] = -1.; // disregard these cells + } else { + target_cell_vols[c] = -1.; // disregard these cells + } } - } - - // make a list of nodes below this height to keep fixed position to help MSTK - AmanziMesh::Entity_ID_List below_node_list; - for (unsigned int n = 0; n != nnodes; ++n) { - AmanziGeometry::Point nc(3); - nc = mesh_->getNodeCoordinate(n); - if (nc[dim - 1] < min_height) below_node_list.emplace_back(n); - } - Errors::Message mesg("Volumetric Deformation not implemented in Amanzi"); - Exceptions::amanzi_throw(mesg); - //mesh_nc_->deform(target_cell_vols, min_cell_vols, below_node_list, true); - deformed_this_step_ = true; - break; - } + // make a list of nodes below this height to keep fixed position to help MSTK + AmanziMesh::Entity_ID_List below_node_list; + for (unsigned int n = 0; n != nnodes; ++n) { + AmanziGeometry::Point nc(3); + nc = mesh_->getNodeCoordinate(n); + if (nc[dim - 1] < min_height) below_node_list.emplace_back(n); + } - case (DEFORM_STRATEGY_AVERAGE): { - const Epetra_MultiVector& dcell_vol_c = *dcell_vol_vec->ViewComponent("cell", true); - const Epetra_MultiVector& cv = - *S_->Get(cv_key_, tag_current_).ViewComponent("cell"); + Errors::Message mesg("Volumetric Deformation not implemented in Amanzi"); + Exceptions::amanzi_throw(mesg); + //mesh_nc_->deform(target_cell_vols, min_cell_vols, below_node_list, true); + deformed_this_step_ = true; + break; + } - CompositeVector& nodal_dz_vec = S_->GetW(nodal_dz_key_, tag_next_, name_); - { // context for vector prior to communication - Epetra_MultiVector& nodal_dz = *nodal_dz_vec.ViewComponent("node", "true"); - nodal_dz.PutScalar(0.); - - int ncols = mesh_->columns.num_columns_owned; - int z_index = mesh_->getSpaceDimension() - 1; - for (int col = 0; col != ncols; ++col) { - auto col_cells = mesh_->columns.getCells(col); - auto col_faces = mesh_->columns.getFaces(col); - AMANZI_ASSERT(col_faces.size() == col_cells.size() + 1); - - // iterate up the column accumulating face displacements - double face_displacement = 0.; - for (int ci = col_cells.size() - 1; ci >= 0; --ci) { - int f_below = col_faces[ci + 1]; - int f_above = col_faces[ci]; - - double dz = - mesh_->getFaceCentroid(f_above)[z_index] - mesh_->getFaceCentroid(f_below)[z_index]; - face_displacement += -dz * dcell_vol_c[0][col_cells[ci]] / cv[0][col_cells[ci]]; - - AMANZI_ASSERT(face_displacement >= 0.); + case (DEFORM_STRATEGY_AVERAGE): { + const Epetra_MultiVector& dcell_vol_c = *dcell_vol_vec->ViewComponent("cell", true); + const Epetra_MultiVector& cv = + *S_->Get(cv_key_, tag_current_).ViewComponent("cell"); + + CompositeVector& nodal_dz_vec = S_->GetW(nodal_dz_key_, tag_next_, name_); + { // context for vector prior to communication + Epetra_MultiVector& nodal_dz = *nodal_dz_vec.ViewComponent("node", "true"); + nodal_dz.PutScalar(0.); + + int ncols = mesh_->columns.num_columns_owned; + int z_index = mesh_->getSpaceDimension() - 1; + for (int col = 0; col != ncols; ++col) { + auto col_cells = mesh_->columns.getCells(col); + auto col_faces = mesh_->columns.getFaces(col); + AMANZI_ASSERT(col_faces.size() == col_cells.size() + 1); + + // iterate up the column accumulating face displacements + double face_displacement = 0.; + for (int ci = col_cells.size() - 1; ci >= 0; --ci) { + int f_below = col_faces[ci + 1]; + int f_above = col_faces[ci]; + + double dz = + mesh_->getFaceCentroid(f_above)[z_index] - mesh_->getFaceCentroid(f_below)[z_index]; + face_displacement += -dz * dcell_vol_c[0][col_cells[ci]] / cv[0][col_cells[ci]]; + + AMANZI_ASSERT(face_displacement >= 0.); #if DEBUG - if (face_displacement > 0.) { - std::cout << " Shifting cell " << col_cells[ci] << ", with personal displacement of " - << -dz * dcell_vol_c[0][col_cells[ci]] / cv[0][col_cells[ci]] - << " and frac " << -dcell_vol_c[0][col_cells[ci]] / cv[0][col_cells[ci]] - << std::endl; - } + if (face_displacement > 0.) { + std::cout << " Shifting cell " << col_cells[ci] + << ", with personal displacement of " + << -dz * dcell_vol_c[0][col_cells[ci]] / cv[0][col_cells[ci]] + << " and frac " << -dcell_vol_c[0][col_cells[ci]] / cv[0][col_cells[ci]] + << std::endl; + } #endif - // shove the face changes into the nodal averages - auto nodes = mesh_->getFaceNodes(f_above); - for (auto n : nodes) { - nodal_dz[0][n] += face_displacement; - nodal_dz[1][n] += dz; - nodal_dz[2][n]++; + // shove the face changes into the nodal averages + auto nodes = mesh_->getFaceNodes(f_above); + for (auto n : nodes) { + nodal_dz[0][n] += face_displacement; + nodal_dz[1][n] += dz; + nodal_dz[2][n]++; + } } } } - } - // take the averages - nodal_dz_vec.GatherGhostedToMaster(); - nodal_dz_vec.ScatterMasterToGhosted(); + // take the averages + nodal_dz_vec.GatherGhostedToMaster(); + nodal_dz_vec.ScatterMasterToGhosted(); - Epetra_MultiVector& nodal_dz = *nodal_dz_vec.ViewComponent("node", "true"); - for (int n = 0; n != nodal_dz.MyLength(); ++n) { - if (nodal_dz[2][n] > 0) { - nodal_dz[0][n] /= nodal_dz[2][n]; - nodal_dz[1][n] /= nodal_dz[2][n]; + Epetra_MultiVector& nodal_dz = *nodal_dz_vec.ViewComponent("node", "true"); + for (int n = 0; n != nodal_dz.MyLength(); ++n) { + if (nodal_dz[2][n] > 0) { + nodal_dz[0][n] /= nodal_dz[2][n]; + nodal_dz[1][n] /= nodal_dz[2][n]; + } } - } - // deform the mesh - AmanziMesh::Entity_ID_View node_ids("node_ids", nodal_dz.MyLength()); - AmanziMesh::Point_View new_positions("new_positions", nodal_dz.MyLength()); - for (int n = 0; n != nodal_dz.MyLength(); ++n) { - node_ids[n] = n; - new_positions[n] = mesh_->getNodeCoordinate(n); - AMANZI_ASSERT(nodal_dz[0][n] >= 0.); - new_positions[n][2] -= nodal_dz[0][n]; - } + // deform the mesh + AmanziMesh::Entity_ID_View node_ids("node_ids", nodal_dz.MyLength()); + AmanziMesh::Point_View new_positions("new_positions", nodal_dz.MyLength()); + for (int n = 0; n != nodal_dz.MyLength(); ++n) { + node_ids[n] = n; + new_positions[n] = mesh_->getNodeCoordinate(n); + AMANZI_ASSERT(nodal_dz[0][n] >= 0.); + new_positions[n][2] -= nodal_dz[0][n]; + } - for (auto& p : new_positions) { AMANZI_ASSERT(AmanziGeometry::norm(p) >= 0.); } - AmanziMesh::deform(*mesh_nc_, node_ids, new_positions); - deformed_this_step_ = true; - // INSERT EXTRA CODE TO UNDEFORM THE MESH FOR MIN_VOLS! - break; - } - default: - AMANZI_ASSERT(0); + for (auto& p : new_positions) { + AMANZI_ASSERT(AmanziGeometry::norm(p) >= 0.); + } + AmanziMesh::deform(*mesh_nc_, node_ids, new_positions); + deformed_this_step_ = true; + // INSERT EXTRA CODE TO UNDEFORM THE MESH FOR MIN_VOLS! + break; + } + default: + AMANZI_ASSERT(0); } // now we have to adapt the surface mesh to the new volume mesh @@ -716,7 +721,9 @@ VolumetricDeformation::CommitStep(double t_old, double t_new, const Tag& tag_nex assign(poro_key_, tag_current, tag_next, *S_); } - if (strategy_ == DEFORM_STRATEGY_MSTK) { assign(poro_key_, tag_current, tag_next, *S_); } + if (strategy_ == DEFORM_STRATEGY_MSTK) { + assign(poro_key_, tag_current, tag_next, *S_); + } // lastly, save the new coordinates for checkpointing if (deformed_this_step_) { @@ -735,7 +742,7 @@ void VolumetricDeformation::FailStep(double t_old, double t_new, const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Failing step." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Failing step." << std::endl; if (deformed_this_step_) { copyVectorToMeshCoordinates(S_->Get(vertex_loc_key_, tag), *mesh_nc_); diff --git a/src/pks/deform/volumetric_deformation.hh b/src/pks/deform/volumetric_deformation.hh index 9683de7d0..336b08169 100644 --- a/src/pks/deform/volumetric_deformation.hh +++ b/src/pks/deform/volumetric_deformation.hh @@ -8,16 +8,15 @@ Markus Berndt Daniil Svyatskiy */ - -//! Subsidence through bulk ice loss and cell volumetric change. /*! -This process kernel provides for going from a cell volumetric change to an +This PK implements vertical subsidence through bulk ice loss and cell +volumetric change. It implements going from a cell volumetric change to an updated unstructured mesh, and can be coupled sequentially with flow to solve problems of flow in a subsiding porous media. Note that this PK is slaved to the flow PK. This PK must be advanced first, -and be weakly coupled to the flow PK (or an MPC that advances the flow PK), and +and must be weakly coupled to the flow PK (or an MPC that advances the flow PK), and the timestep of this PK must match that of the flow PK (e.g. do not try to subcyle one or the other). This uses a rather hacky, unconventional use of time tags, where we use saturations and porosities at the NEXT time, but ASSUME @@ -25,8 +24,8 @@ they are actually the values of the CURRENT time. This saves having to stash a copy of these variables at the CURRENT time, which would otherwise not be used. Note that all deformation here is vertical, and we assume that the subsurface -mesh is **perfectly columnar** and that the "build columns" parameter has been -given to the subsurface mesh. See the Mesh_ spec for more. +mesh is **columnar** and that the "build columns" parameter has been +given to the subsurface mesh. See the :ref:`Mesh` spec for more. The process here is governed through two options, the "deformation mode" and the "deformation strategy." @@ -34,7 +33,8 @@ the "deformation strategy." The deformation mode describes how the cell volume change is calculated. There are three options here: -- "prescribed" uses a function to precribe the volume changes as a function of (t,x,y,z). +- "prescribed" uses a function to precribe the volume changes as a function of + (t,x,y,z). - "structural" decreases the cell volume if the porosity is above a prescribed "structurally connected matrix" porosity. Think of this as bulk ice @@ -46,8 +46,6 @@ are three options here: and tries to relax the liquid saturation back toward a value that is consistent with what the thawed soil should be. -.. todo: Move this into an evaluator! - The deformation strategy describes how the cell volume change is turned into node coordinate changes. Three options are available: @@ -73,36 +71,38 @@ node coordinate changes. Three options are available: NOTE: all deformation options are treated EXPLICITLY, and depend only upon values from the old time. -.. _volumetric-deformation-pk-spec: -.. admonition:: volumetric-deformation-pk-spec +`"PK type`" = `"volumetric deformation`" + +.. _pk-volumetric-deformation-spec: +.. admonition:: pk-volumetric-deformation-spec - * `"max timestep [s]`" ``[double]`` **inf** Sets a maximum timestep size. + * `"max timestep [s]`" ``[double]`` **inf** Sets a maximum timestep size. - * `"deformation mode`" ``[string]`` **prescribed** See above for - descriptions. One of: `"prescribed`", `"structural`", or `"saturation`". + * `"deformation mode`" ``[string]`` **prescribed** See above for + descriptions. One of: `"prescribed`", `"structural`", or `"saturation`". - * `"deformation strategy`" ``[string]`` **global optimization** See above - for descriptions. One of `"average`", `"global optimization`", or `"mstk - implementation`" + * `"deformation strategy`" ``[string]`` **global optimization** See above + for descriptions. One of `"average`", `"global optimization`", or `"mstk + implementation`" - * `"domain name`" ``[string]`` **domain** The mesh to deform. + * `"domain name`" ``[string]`` **domain** The mesh to deform. - * `"surface domain name`" ``[string]`` **surface** The surface mesh. + * `"surface domain name`" ``[string]`` **surface** The surface mesh. - * `"deformation function`" ``[function-spec]`` **optional** Only used if - "deformation mode" == "prescribed" + * `"deformation function`" ``[function-spec]`` **optional** Only used if + "deformation mode" == "prescribed" - EVALUATORS: + EVALUATORS: - - `"saturation_ice`" **DOMAIN-saturation_ice** - - `"saturation_liquid`" **DOMAIN-saturation_liquid** - - `"saturation_gas`" **DOMAIN-saturation_gas** - - `"porosity`" **DOMAIN-porosity** - - `"cell volume`" **DOMAIN-cell_volume** + - `"saturation_ice`" **DOMAIN-saturation_ice** + - `"saturation_liquid`" **DOMAIN-saturation_liquid** + - `"saturation_gas`" **DOMAIN-saturation_gas** + - `"porosity`" **DOMAIN-porosity** + - `"cell volume`" **DOMAIN-cell_volume** - INCLUDES: + INCLUDES: - - ``[pk-physical-default-spec]`` + - ``[pk-physical-default-spec]`` */ @@ -115,8 +115,8 @@ values from the old time. #include "PK.hh" #include "PK_Factory.hh" -#include "pk_physical_default.hh" -#include "pk_helpers.hh" +#include "PK_Physical_Default.hh" +#include "PK_Helpers.hh" //#include "MatrixVolumetricDeformation.hh" namespace Amanzi { diff --git a/src/pks/energy/advection_diffusion/advection_diffusion_ti.cc b/src/pks/energy/advection_diffusion/advection_diffusion_ti.cc index 36033d74d..ed2425963 100644 --- a/src/pks/energy/advection_diffusion/advection_diffusion_ti.cc +++ b/src/pks/energy/advection_diffusion/advection_diffusion_ti.cc @@ -72,7 +72,7 @@ AdvectionDiffusion::ApplyPreconditioner(Teuchos::RCP u, if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << "Precon application:" << std::endl; *vo_->os() << " u: " << (*u->Data())("cell", 0); - if (u->Data()->HasComponent("face")) *vo_->os() << " f: " << (*u->Data())("face", 80); + if (u->Data() ->HasComponent("face")) *vo_->os() << " f: " << (*u->Data())("face", 80); *vo_->os() << std::endl; } @@ -80,7 +80,7 @@ AdvectionDiffusion::ApplyPreconditioner(Teuchos::RCP u, if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << " Pu: " << (*Pu->Data())("cell", 0); - if (Pu->Data()->HasComponent("face")) *vo_->os() << " f: " << (*Pu->Data())("face", 80); + if (Pu->Data() ->HasComponent("face")) *vo_->os() << " f: " << (*Pu->Data())("face", 80); *vo_->os() << std::endl; } diff --git a/src/pks/energy/constitutive_relations/energy/interfrost_energy_evaluator_reg.hh b/src/pks/energy/constitutive_relations/energy/interfrost_energy_evaluator_reg.hh index 3a1fd3a15..96a2fe961 100644 --- a/src/pks/energy/constitutive_relations/energy/interfrost_energy_evaluator_reg.hh +++ b/src/pks/energy/constitutive_relations/energy/interfrost_energy_evaluator_reg.hh @@ -12,8 +12,8 @@ namespace Amanzi { namespace Energy { -Utils::RegisteredFactory - InterfrostEnergyEvaluator::reg_("interfrost energy"); +Utils::RegisteredFactory InterfrostEnergyEvaluator::reg_( + "interfrost energy"); } // namespace Energy } // namespace Amanzi diff --git a/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator.cc b/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator.cc index 60904c3cd..138bb958e 100644 --- a/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator.cc +++ b/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator.cc @@ -162,7 +162,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -194,7 +194,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == phi0_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -226,7 +226,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -258,7 +258,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -290,7 +290,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ul_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -322,7 +322,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == sg_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -354,7 +354,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ng_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -386,7 +386,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ug_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -418,7 +418,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == rho_r_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -450,7 +450,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ur_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -482,7 +482,7 @@ LiquidGasEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); diff --git a/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator.hh b/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator.hh index 4e1d94a13..67bcd533e 100644 --- a/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator.hh +++ b/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator.hh @@ -15,15 +15,15 @@ Calculates energy, in [KJ], via the equation: .. math:: E = V * ( \phi (u_l s_l n_l + u_g s_g n_g) + (1-\phi_0) u_r \rho_r ) -Specified with evaluator type: `"liquid+gas energy`" +`"evaluator type`" = `"liquid+gas energy`" Note this equation assumes that porosity is compressible, but is based on the uncompressed rock grain density (not bulk density). This means that porosity is the base, uncompressible value when used with the energy in the grain, but the larger, compressible value when used with the energy in the water. -.. _field-evaluator-type-liquid-gas-energy-spec: -.. admonition:: field-evaluator-type-liquid-gas-energy-spec +.. _evaluator-liquid-gas-energy-spec: +.. admonition:: evaluator-liquid-gas-energy-spec DEPENDENCIES: diff --git a/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator_reg.hh b/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator_reg.hh index 66eb0013d..ca68c7ee4 100644 --- a/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator_reg.hh +++ b/src/pks/energy/constitutive_relations/energy/liquid_gas_energy_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Energy { namespace Relations { -Utils::RegisteredFactory - LiquidGasEnergyEvaluator::reg_("liquid+gas energy"); +Utils::RegisteredFactory LiquidGasEnergyEvaluator::reg_( + "liquid+gas energy"); } // namespace Relations } // namespace Energy diff --git a/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator.cc b/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator.cc index 0ab7ab424..b195c508d 100644 --- a/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator.cc +++ b/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator.cc @@ -180,7 +180,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -212,7 +212,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == phi0_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -244,7 +244,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -276,7 +276,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -308,7 +308,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ul_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -340,7 +340,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == si_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -372,7 +372,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -404,7 +404,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ui_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -436,7 +436,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == rho_r_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -468,7 +468,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ur_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -500,7 +500,7 @@ LiquidIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); diff --git a/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator.hh b/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator.hh index fea795b07..9c0988237 100644 --- a/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator.hh +++ b/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator.hh @@ -15,7 +15,7 @@ Calculates energy, in [KJ], via the equation: .. math:: E = V * ( \phi (u_l s_l n_l + u_i s_i n_i) + (1-\phi_0) u_r \rho_r ) -Specified with evaluator type: `"liquid+ice energy`" +`"evaluator type`" = `"liquid+ice energy`" Note this equation assumes that porosity is compressible, but is based on the uncompressed rock grain density (not bulk density). This means that porosity @@ -24,8 +24,8 @@ the larger, compressible value when used with the energy in the water. Note that this ignores energy in the gas phase. -.. _field-evaluator-type-liquid-ice-energy-spec: -.. admonition:: field-evaluator-type-liquid-ice-energy-spec +.. _evaluator-liquid-ice-energy-spec: +.. admonition:: evaluator-liquid-ice-energy-spec DEPENDENCIES: diff --git a/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator_reg.hh b/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator_reg.hh index 6935bfb7a..8efe0c9cb 100644 --- a/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator_reg.hh +++ b/src/pks/energy/constitutive_relations/energy/liquid_ice_energy_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Energy { namespace Relations { -Utils::RegisteredFactory - LiquidIceEnergyEvaluator::reg_("liquid+ice energy"); +Utils::RegisteredFactory LiquidIceEnergyEvaluator::reg_( + "liquid+ice energy"); } // namespace Relations } // namespace Energy diff --git a/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator.cc b/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator.cc index 923095c21..56b34dea4 100644 --- a/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator.cc +++ b/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator.cc @@ -153,7 +153,7 @@ RichardsEnergyEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -179,7 +179,7 @@ RichardsEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == phi0_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -205,7 +205,7 @@ RichardsEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -231,7 +231,7 @@ RichardsEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -257,7 +257,7 @@ RichardsEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ul_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -283,7 +283,7 @@ RichardsEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == rho_r_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -309,7 +309,7 @@ RichardsEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ur_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -335,7 +335,7 @@ RichardsEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); diff --git a/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator.hh b/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator.hh index 06a269dfb..52def8894 100644 --- a/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator.hh +++ b/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator.hh @@ -15,7 +15,7 @@ Energy associated with a soil and pore-water system, in [KJ] .. math:: E = V * ( \phi u_l s_l n_l + (1-\phi_0) u_r \rho_r ) -Specified with evaluator type: `"richards energy`" +`"evaluator type`" = `"richards energy`" Note this equation assumes that porosity is compressible, but is based on the uncompressed rock grain density (not bulk density). This means that porosity @@ -24,8 +24,8 @@ the larger, compressible value when used with the energy in the water. Note that this ignores energy in the gas phase. -.. _field-evaluator-type-richards-energy-spec: -.. admonition:: field-evaluator-type-richards-energy-spec +.. _evaluator-richards-energy-spec: +.. admonition:: evaluator-richards-energy-spec DEPENDENCIES: diff --git a/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator_reg.hh b/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator_reg.hh index 80c35085a..9a786f29e 100644 --- a/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator_reg.hh +++ b/src/pks/energy/constitutive_relations/energy/richards_energy_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Energy { namespace Relations { -Utils::RegisteredFactory - RichardsEnergyEvaluator::reg_("richards energy"); +Utils::RegisteredFactory RichardsEnergyEvaluator::reg_( + "richards energy"); } // namespace Relations } // namespace Energy diff --git a/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator.cc b/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator.cc index f4e7568f1..8758cb87e 100644 --- a/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator.cc +++ b/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator.cc @@ -124,7 +124,7 @@ SurfaceIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == h_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); const Epetra_MultiVector& eta_v = *eta->ViewComponent(*comp, false); @@ -143,7 +143,7 @@ SurfaceIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == eta_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); const Epetra_MultiVector& eta_v = *eta->ViewComponent(*comp, false); @@ -162,7 +162,7 @@ SurfaceIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); const Epetra_MultiVector& eta_v = *eta->ViewComponent(*comp, false); @@ -181,7 +181,7 @@ SurfaceIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ul_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); const Epetra_MultiVector& eta_v = *eta->ViewComponent(*comp, false); @@ -200,7 +200,7 @@ SurfaceIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); const Epetra_MultiVector& eta_v = *eta->ViewComponent(*comp, false); @@ -219,7 +219,7 @@ SurfaceIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ui_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); const Epetra_MultiVector& eta_v = *eta->ViewComponent(*comp, false); @@ -238,7 +238,7 @@ SurfaceIceEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); const Epetra_MultiVector& eta_v = *eta->ViewComponent(*comp, false); diff --git a/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator.hh b/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator.hh index f8767a19b..da7bdfd42 100644 --- a/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator.hh +++ b/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator.hh @@ -15,10 +15,10 @@ The energy associated with ponded water, in [KJ], given by: .. math:: E = V * ( \eta h u_l n_l + (1 - \eta) h u_i n_i ) -Specified with evaluator type: `"surface ice energy`" +`"evaluator type`" = `"surface ice energy`" -.. _field-evaluator-type-surface-ice-energy-spec: -.. admonition:: field-evaluator-type-surface-ice-energy-spec +.. _evaluator-surface-ice-energy-spec: +.. admonition:: evaluator-surface-ice-energy-spec DEPENDENCIES: diff --git a/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator_reg.hh b/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator_reg.hh index d560aced5..211db3823 100644 --- a/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator_reg.hh +++ b/src/pks/energy/constitutive_relations/energy/surface_ice_energy_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Energy { namespace Relations { -Utils::RegisteredFactory - SurfaceIceEnergyEvaluator::reg_("surface ice energy"); +Utils::RegisteredFactory SurfaceIceEnergyEvaluator::reg_( + "surface ice energy"); } // namespace Relations } // namespace Energy diff --git a/src/pks/energy/constitutive_relations/energy/surface_ice_energy_model.hh b/src/pks/energy/constitutive_relations/energy/surface_ice_energy_model.hh index 9922ecb11..e77692409 100644 --- a/src/pks/energy/constitutive_relations/energy/surface_ice_energy_model.hh +++ b/src/pks/energy/constitutive_relations/energy/surface_ice_energy_model.hh @@ -28,9 +28,13 @@ class SurfaceIceEnergyModel { double Energy(double h, double eta, double nl, double ul, double ni, double ui, double cv) const; - double - DEnergyDPondedDepth(double h, double eta, double nl, double ul, double ni, double ui, double cv) - const; + double DEnergyDPondedDepth(double h, + double eta, + double nl, + double ul, + double ni, + double ui, + double cv) const; double DEnergyDUnfrozenFraction(double h, double eta, double nl, @@ -66,9 +70,13 @@ class SurfaceIceEnergyModel { double ni, double ui, double cv) const; - double - DEnergyDCellVolume(double h, double eta, double nl, double ul, double ni, double ui, double cv) - const; + double DEnergyDCellVolume(double h, + double eta, + double nl, + double ul, + double ni, + double ui, + double cv) const; protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); diff --git a/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator.cc b/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator.cc index 00f9baa7d..1733df6a5 100644 --- a/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator.cc +++ b/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator.cc @@ -186,7 +186,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -224,7 +224,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == phi0_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -262,7 +262,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -300,7 +300,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -338,7 +338,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ul_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -376,7 +376,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == si_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -414,7 +414,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -452,7 +452,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ui_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -490,7 +490,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == sg_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -528,7 +528,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ng_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -566,7 +566,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ug_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -604,7 +604,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == rho_r_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -642,7 +642,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ur_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); @@ -680,7 +680,7 @@ ThreePhaseEnergyEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& phi0_v = *phi0->ViewComponent(*comp, false); diff --git a/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator.hh b/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator.hh index e105c4667..2e16690f9 100644 --- a/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator.hh +++ b/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator.hh @@ -15,15 +15,15 @@ Calculates energy, in [KJ], via the equation: .. math:: E = V * ( \phi (u_l s_l n_l + u_i s_i n_i + u_g s_g n_g) + (1-\phi_0) u_r \rho_r ) -Specified with evaluator type: `"three phase energy`" +`"evaluator type`" = `"three phase energy`" Note this equation assumes that porosity is compressible, but is based on the uncompressed rock grain density (not bulk density). This means that porosity is the base, uncompressible value when used with the energy in the grain, but the larger, compressible value when used with the energy in the water. -.. _field-evaluator-type-three-phase-energy-spec: -.. admonition:: field-evaluator-type-three-phase-energy-spec +.. _evaluator-three-phase-energy-spec: +.. admonition:: evaluator-three-phase-energy-spec DEPENDENCIES: diff --git a/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator_reg.hh b/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator_reg.hh index e1bdac914..788fa3b5d 100644 --- a/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator_reg.hh +++ b/src/pks/energy/constitutive_relations/energy/three_phase_energy_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Energy { namespace Relations { -Utils::RegisteredFactory - ThreePhaseEnergyEvaluator::reg_("three phase energy"); +Utils::RegisteredFactory ThreePhaseEnergyEvaluator::reg_( + "three phase energy"); } // namespace Relations } // namespace Energy diff --git a/src/pks/energy/constitutive_relations/enthalpy/enthalpy_evaluator.cc b/src/pks/energy/constitutive_relations/enthalpy/enthalpy_evaluator.cc index ec3d32f12..8e5bb8346 100644 --- a/src/pks/energy/constitutive_relations/enthalpy/enthalpy_evaluator.cc +++ b/src/pks/energy/constitutive_relations/enthalpy/enthalpy_evaluator.cc @@ -60,7 +60,7 @@ EnthalpyEvaluator::Evaluate_(const State& S, const std::vector Teuchos::RCP pres = S.GetPtr(pres_key_, tag); Teuchos::RCP n_l = S.GetPtr(dens_key_, tag); - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& pres_v = *pres->ViewComponent(*comp, false); const Epetra_MultiVector& nl_v = *n_l->ViewComponent(*comp, false); @@ -91,7 +91,7 @@ EnthalpyEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP n_l = S.GetPtr(dens_key_, tag); - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& nl_v = *n_l->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp, false); @@ -109,7 +109,7 @@ EnthalpyEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP pres = S.GetPtr(pres_key_, tag); Teuchos::RCP n_l = S.GetPtr(dens_key_, tag); - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& nl_v = *n_l->ViewComponent(*comp, false); const Epetra_MultiVector& pres_v = *pres->ViewComponent(*comp, false); diff --git a/src/pks/energy/constitutive_relations/enthalpy/enthalpy_evaluator.hh b/src/pks/energy/constitutive_relations/enthalpy/enthalpy_evaluator.hh index 3d553e9c0..4b09c03d9 100644 --- a/src/pks/energy/constitutive_relations/enthalpy/enthalpy_evaluator.hh +++ b/src/pks/energy/constitutive_relations/enthalpy/enthalpy_evaluator.hh @@ -6,24 +6,18 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -/* ----------------------------------------------------------------------------- -ATS - -Evaluator for enthalpy. ------------------------------------------------------------------------------ */ - /*! -Computes enthalpy [MJ / mol] of as a function of internal energy, pressure, and density. +Computes enthalpy `[MJ mol^-1]` of as a function of internal energy, pressure, and density. .. math:: + e = u + 10^{-6} * \frac{p}{n_l} `"evaluator type`" = `"enthalpy`" -.. _enthalpy-evaluator-spec: -.. admonition:: enthalpy-evaluator-spec +.. _evaluator-enthalpy-spec: +.. admonition:: evaluator-enthalpy-spec * `"include work term`" ``[bool]`` **false** If false, e = u, ignoring the work term. diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_evaluator.cc b/src/pks/energy/constitutive_relations/internal_energy/iem_evaluator.cc index b5eb5b53d..77a77d12d 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_evaluator.cc +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_evaluator.cc @@ -19,7 +19,8 @@ namespace Amanzi { namespace Energy { -IEMEvaluator::IEMEvaluator(Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(plist) +IEMEvaluator::IEMEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) { AMANZI_ASSERT(plist_.isSublist("IEM parameters")); Teuchos::ParameterList sublist = plist_.sublist("IEM parameters"); @@ -68,7 +69,9 @@ IEMEvaluator::Evaluate_(const State& S, const std::vector& res Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp, false); int ncomp = result[0]->size(*comp, false); - for (int i = 0; i != ncomp; ++i) { result_v[0][i] = iem_->InternalEnergy(temp_v[0][i]); } + for (int i = 0; i != ncomp; ++i) { + result_v[0][i] = iem_->InternalEnergy(temp_v[0][i]); + } } } @@ -88,7 +91,9 @@ IEMEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp, false); int ncomp = result[0]->size(*comp, false); - for (int i = 0; i != ncomp; ++i) { result_v[0][i] = iem_->DInternalEnergyDT(temp_v[0][i]); } + for (int i = 0; i != ncomp; ++i) { + result_v[0][i] = iem_->DInternalEnergyDT(temp_v[0][i]); + } } } diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_evaluator.hh b/src/pks/energy/constitutive_relations/internal_energy/iem_evaluator.hh index 6176e3787..64e321459 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_evaluator.hh +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_evaluator.hh @@ -6,22 +6,16 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -/* - The IEM Evaluator simply calls the IEM with the correct arguments. - -*/ - /*! Computes (specific) internal energy of as a function of temperature. `"evaluator type`" = `"iem`" -.. _iem-evaluator-spec: -.. admonition:: iem-evaluator-spec +.. _evaluator-iem-spec: +.. admonition:: evaluator-iem-spec - * `"IEM parameters`" ``[IEM-model-typedinline-spec-list]`` + * `"IEM parameters`" ``[iem-typedinline-spec-list]`` KEYS: diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_factory_reg.hh b/src/pks/energy/constitutive_relations/internal_energy/iem_factory_reg.hh index e22a64234..d2fe8f5a2 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_factory_reg.hh +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_factory_reg.hh @@ -17,6 +17,6 @@ #include "iem_factory.hh" // explicity instantitate the static data of Factory -template <> +template<> Amanzi::Utils::Factory::map_type* Amanzi::Utils::Factory::map_; diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_linear.cc b/src/pks/energy/constitutive_relations/internal_energy/iem_linear.cc index da3184dde..9a80e19d8 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_linear.cc +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_linear.cc @@ -23,7 +23,8 @@ Linear internal energy model -- function of Cv and temperature namespace Amanzi { namespace Energy { -IEMLinear::IEMLinear(Teuchos::ParameterList& plist) : plist_(plist) +IEMLinear::IEMLinear(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_linear.hh b/src/pks/energy/constitutive_relations/internal_energy/iem_linear.hh index 83c12dbe1..35c3c27c5 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_linear.hh +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_linear.hh @@ -18,20 +18,20 @@ Linear internal energy model -- function of Cv and temperature `"IEM type`" = `"linear`" -.. _IEM-model-linear-spec: -.. admonition:: IEM-model-linear-spec +.. _iem-linear-spec: +.. admonition:: iem-linear-spec - * `"reference temperature [K]`" ``[double]`` **273.15** The phase transition point, T_ref above + * `"reference temperature [K]`" ``[double]`` **273.15** The phase transition point, :math:`T_{ref}` above ONE OF - * `"latent heat [J kg^-1]`" ``[double]`` Latent heat of fusion, L_f above - * `"heat capacity [J kg^-1 K^-1]`" ``[double]`` C_v above + * `"latent heat [J kg^-1]`" ``[double]`` Latent heat of fusion, :math:`L_f` above + * `"heat capacity [J kg^-1 K^-1]`" ``[double]`` :math:`C_v` above OR - * `"latent heat [J mol^-1]`" ``[double]`` Latent heat of fusion, L_f above. - * `"heat capacity [J mol^-1 K^-1]`" ``[double]`` C_v above + * `"latent heat [J mol^-1]`" ``[double]`` Latent heat of fusion, :math:`L_f` above. + * `"heat capacity [J mol^-1 K^-1]`" ``[double]`` :math:`C_v` above END diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_quadratic.cc b/src/pks/energy/constitutive_relations/internal_energy/iem_quadratic.cc index 5d4fe66ac..bf9f16c2b 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_quadratic.cc +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_quadratic.cc @@ -22,7 +22,8 @@ Quadratic internal energy model -- function of Cv and temperature namespace Amanzi { namespace Energy { -IEMQuadratic::IEMQuadratic(Teuchos::ParameterList& plist) : plist_(plist) +IEMQuadratic::IEMQuadratic(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_quadratic.hh b/src/pks/energy/constitutive_relations/internal_energy/iem_quadratic.hh index dfd089c5d..754b450e8 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_quadratic.hh +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_quadratic.hh @@ -18,24 +18,27 @@ Quadratic internal energy model -- function of Cv and temperature `"IEM type`" = `"quadratic`" -.. _IEM-model-quadratic-spec: -.. admonition:: IEM-model-quadratic-spec +.. _iem-quadratic-spec: +.. admonition:: iem-quadratic-spec - * `"reference temperature [K]`" ``[double]`` **273.15** The phase transition point, T_ref above. + * `"reference temperature [K]`" ``[double]`` **273.15** The phase transition + point, :math:`T_{ref}` above. - ONE OF + ONE OF - * `"latent heat [J kg^-1]`" ``[double]`` Latent heat of fusion, L_f above - * `"heat capacity [J kg^-1 K^-1]`" ``[double]`` C_v above - * `"quadratic b [J kg^-1 K^-2]`" ``[double]`` b above + * `"latent heat [J kg^-1]`" ``[double]`` Latent heat of fusion, :math:`L_f` + above + * `"heat capacity [J kg^-1 K^-1]`" ``[double]`` :math:`C_v` above + * `"quadratic b [J kg^-1 K^-2]`" ``[double]`` :math:`b` above - OR + OR - * `"latent heat [J mol^-1]`" ``[double]`` Latent heat of fusion, L_f above. - * `"heat capacity [J mol^-1 K^-1]`" ``[double]`` C_v above - * `"quadratic b [J mol^-1 K^-2]`" ``[double]`` b above + * `"latent heat [J mol^-1]`" ``[double]`` Latent heat of fusion, :math:`L_f` + above. + * `"heat capacity [J mol^-1 K^-1]`" ``[double]`` :math:`C_v` above + * `"quadratic b [J mol^-1 K^-2]`" ``[double]`` :math:`b` above - END + END */ diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor.cc b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor.cc index 918f72b48..5226d8b9b 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor.cc +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor.cc @@ -18,7 +18,8 @@ Internal energy model for air and water vapor, relative to water @237.15K namespace Amanzi { namespace Energy { -IEMWaterVapor::IEMWaterVapor(Teuchos::ParameterList& plist) : plist_(plist) +IEMWaterVapor::IEMWaterVapor(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor.hh b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor.hh index c2d54ccd6..f49f97d3b 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor.hh +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor.hh @@ -7,14 +7,21 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Internal energy model for air and water vapor. /*! -.. _iem-water-vapor-model-spec: -.. admonition:: iem-water-vapor-model-spec +Internal energy model for air and water vapor. - * `"latent heat [J mol^-1]`" ``[double]`` Latent heat of vaporization - * `"heat capacity [J mol^-1 K^-1]`" ``[double]`` C_v +.. math:: + + u = (1 + 0.622 \omega) C_v^{air} (T - 273.15) + \omega L_v + +.. _iem-water-vapor-spec: +.. admonition:: iem-water-vapor-spec + + * `"latent heat [J mol^-1]`" ``[double]`` Latent heat of vaporization, + :math:`L_v` + * `"heat capacity [J mol^-1 K^-1]`" ``[double]`` Heat capacity of air, + :math:`C_v^{air}` */ diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator.cc b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator.cc index 8c76d8642..ea9b79caa 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator.cc +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator.cc @@ -90,7 +90,7 @@ IEMWaterVaporEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP mol_frac = S.GetPtr(mol_frac_key_, tag); if (wrt_key == temp_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& temp_v = *temp->ViewComponent(*comp, false); const Epetra_MultiVector& molfrac_v = *mol_frac->ViewComponent(*comp, false); @@ -102,7 +102,7 @@ IEMWaterVaporEvaluator::EvaluatePartialDerivative_(const State& S, } } } else if (wrt_key == mol_frac_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& temp_v = *temp->ViewComponent(*comp, false); const Epetra_MultiVector& molfrac_v = *mol_frac->ViewComponent(*comp, false); diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator.hh b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator.hh index e69f49495..02a7b97b6 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator.hh +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator.hh @@ -19,10 +19,10 @@ fraction of water vapor in the gaseous phase. `"evaluator type`" = `"iem water vapor`" -.. _iem-water-vapor-evaluator-spec: -.. admonition:: iem-water-vapor-evaluator-spec +.. _evaluator-iem-water-vapor-spec: +.. admonition:: evaluator-iem-water-vapor-spec - * `"IEM parameters`" ``[IEM-water-vapor-model-spec]`` + * `"IEM parameters`" ``[iem-water-vapor-spec]`` KEYS: diff --git a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator_reg.hh b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator_reg.hh index ca67fadb9..77084f8a2 100644 --- a/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator_reg.hh +++ b/src/pks/energy/constitutive_relations/internal_energy/iem_water_vapor_evaluator_reg.hh @@ -17,8 +17,8 @@ namespace Amanzi { namespace Energy { -Utils::RegisteredFactory - IEMWaterVaporEvaluator::factory_("iem water vapor"); +Utils::RegisteredFactory IEMWaterVaporEvaluator::factory_( + "iem water vapor"); } // namespace Energy } // namespace Amanzi diff --git a/src/pks/energy/constitutive_relations/source_terms/advected_energy_source_evaluator.cc b/src/pks/energy/constitutive_relations/source_terms/advected_energy_source_evaluator.cc index 0a28eaf51..7ba0a0086 100644 --- a/src/pks/energy/constitutive_relations/source_terms/advected_energy_source_evaluator.cc +++ b/src/pks/energy/constitutive_relations/source_terms/advected_energy_source_evaluator.cc @@ -80,14 +80,18 @@ AdvectedEnergySourceEvaluator::Evaluate_(const State& S, if (source_units_ == SOURCE_UNITS_MOLS_PER_SECOND) { unsigned int ncells = res.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { res[0][c] /= cv[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res[0][c] /= cv[0][c]; + } } if (include_conduction_) { const Epetra_MultiVector& cond = *S.GetPtr(conducted_source_key_, tag)->ViewComponent("cell", false); unsigned int ncells = res.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { res[0][c] += cond[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res[0][c] += cond[0][c]; + } } } diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_surface_evaluator.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_surface_evaluator.hh index 82b85ca3c..b8b450752 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_surface_evaluator.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_surface_evaluator.hh @@ -18,8 +18,8 @@ Thermal conductivity of surface water that can be either frozen or liquid phase. `"evaluator type`" = `"surface thermal conductivity`" -.. _thermal-conductivity-surface-evaluator-spec: -.. admonition:: thermal-conductivity-surface-evaluator-spec +.. _evaluator-thermal-conductivity-surface-spec: +.. admonition:: evaluator-thermal-conductivity-surface-spec * `"thermal conductivity parameters`" ``[thermal-conductivity-surface-spec]`` diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase.hh index 0c5ee9173..3dec36ed1 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase.hh @@ -27,10 +27,14 @@ class ThermalConductivityThreePhase { public: virtual ~ThermalConductivityThreePhase() {} - virtual double - ThermalConductivity(double porosity, double sat_liq, double sat_ice, double temp) = 0; - virtual double - DThermalConductivity_DPorosity(double porosity, double sat_liq, double sat_ice, double temp) + virtual double ThermalConductivity(double porosity, + double sat_liq, + double sat_ice, + double temp) = 0; + virtual double DThermalConductivity_DPorosity(double porosity, + double sat_liq, + double sat_ice, + double temp) { AMANZI_ASSERT(false); return 0.; @@ -43,14 +47,18 @@ class ThermalConductivityThreePhase { AMANZI_ASSERT(false); return 0.; } - virtual double - DThermalConductivity_DSaturationIce(double porosity, double sat_liq, double sat_ice, double temp) + virtual double DThermalConductivity_DSaturationIce(double porosity, + double sat_liq, + double sat_ice, + double temp) { AMANZI_ASSERT(false); return 0.; } - virtual double - DThermalConductivity_DTemperature(double porosity, double sat_liq, double sat_ice, double temp) + virtual double DThermalConductivity_DTemperature(double porosity, + double sat_liq, + double sat_ice, + double temp) { AMANZI_ASSERT(false); return 0.; diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_evaluator.cc b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_evaluator.cc index b11daf0ba..26607cdc3 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_evaluator.cc +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_evaluator.cc @@ -44,7 +44,7 @@ ThermalConductivityThreePhaseEvaluator::ThermalConductivityThreePhaseEvaluator( ThermalConductivityThreePhaseFactory fac; - for (Teuchos::ParameterList::ConstIterator lcv = tc_sublist.begin(); lcv != tc_sublist.end(); + for (Teuchos::ParameterList::ConstIterator lcv = tc_sublist.begin() ; lcv != tc_sublist.end(); ++lcv) { std::string name = lcv->first; if (tc_sublist.isSublist(name)) { @@ -90,7 +90,7 @@ ThermalConductivityThreePhaseEvaluator::Evaluate_(const State& S, const Epetra_MultiVector& sat2_v = *sat2->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp, false); - for (std::vector::const_iterator lcv = tcs_.begin(); lcv != tcs_.end(); + for (std::vector::const_iterator lcv = tcs_.begin() ; lcv != tcs_.end(); ++lcv) { std::string region_name = lcv->first; if (mesh->isValidSetName(region_name, AmanziMesh::Entity_kind::CELL)) { @@ -140,7 +140,7 @@ ThermalConductivityThreePhaseEvaluator::EvaluatePartialDerivative_( Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp, false); if (wrt_key == poro_key_) { - for (std::vector::const_iterator lcv = tcs_.begin(); lcv != tcs_.end(); + for (std::vector::const_iterator lcv = tcs_.begin() ; lcv != tcs_.end(); ++lcv) { std::string region_name = lcv->first; if (mesh->isValidSetName(region_name, AmanziMesh::Entity_kind::CELL)) { @@ -162,7 +162,7 @@ ThermalConductivityThreePhaseEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sat_key_) { - for (std::vector::const_iterator lcv = tcs_.begin(); lcv != tcs_.end(); + for (std::vector::const_iterator lcv = tcs_.begin() ; lcv != tcs_.end(); ++lcv) { std::string region_name = lcv->first; if (mesh->isValidSetName(region_name, AmanziMesh::Entity_kind::CELL)) { @@ -184,7 +184,7 @@ ThermalConductivityThreePhaseEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sat2_key_) { - for (std::vector::const_iterator lcv = tcs_.begin(); lcv != tcs_.end(); + for (std::vector::const_iterator lcv = tcs_.begin() ; lcv != tcs_.end(); ++lcv) { std::string region_name = lcv->first; if (mesh->isValidSetName(region_name, AmanziMesh::Entity_kind::CELL)) { @@ -206,7 +206,7 @@ ThermalConductivityThreePhaseEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == temp_key_) { - for (std::vector::const_iterator lcv = tcs_.begin(); lcv != tcs_.end(); + for (std::vector::const_iterator lcv = tcs_.begin() ; lcv != tcs_.end(); ++lcv) { std::string region_name = lcv->first; if (mesh->isValidSetName(region_name, AmanziMesh::Entity_kind::CELL)) { diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_evaluator.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_evaluator.hh index dbe9fd3f7..494ef433d 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_evaluator.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_evaluator.hh @@ -14,10 +14,10 @@ porous media. `"evaluator type`" = `"three-phase thermal conductivity`" -.. _thermal-conductivity-threephase-evaluator-spec: -.. admonition:: thermal-conductivity-threephase-evaluator-spec +.. _evaluator-three-phase-thermal-conductivity-spec: +.. admonition:: evaluator-three-phase-thermal-conductivity-spec - * `"thermal conductivity parameters`" ``[thermal-conductivity-threephase-typedinline-spec-list]`` + * `"thermal conductivity parameters`" ``[thermal-conductivity-threephase-typed-spec-list]`` KEYS: diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_factory.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_factory.hh index 1d7cf22ef..1af7d539c 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_factory.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_factory.hh @@ -7,12 +7,22 @@ Authors: Ethan Coon */ -/* ------------------------------------------------------------------------- +/*! - ATS +Three-phase thermal conductivity models are used to compute the bulk thermal +conductivity from the constitutive parts -- gas, liquid, ice, and background +material. - Self-registering factory for EOS implementations. - ------------------------------------------------------------------------- */ +.. _thermal-conductivity-threephase-typed-spec: +.. admonition:: thermal-conductivity-threephase-typed-spec + + * `"region`" ``[string]`` Region on which the model is valid. + * `"thermal conductivity type`" ``[string]`` Name of the model, see below for options. + * `"_thermal_conductivity_type_ parameters`" + ``[_thermal_conductivity_type_-spec]`` See below for the required + parameter spec for each type. + +*/ #ifndef PK_ENERGY_RELATIONS_TC_THREEPHASE_FACTORY_HH_ #define PK_ENERGY_RELATIONS_TC_THREEPHASE_FACTORY_HH_ @@ -28,8 +38,8 @@ namespace Energy { class ThermalConductivityThreePhaseFactory : public Utils::Factory { public: - Teuchos::RCP - createThermalConductivityModel(Teuchos::ParameterList& plist); + Teuchos::RCP createThermalConductivityModel( + Teuchos::ParameterList& plist); }; } // namespace Energy diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_factory_reg.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_factory_reg.hh index 41b40a61a..e7d856780 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_factory_reg.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_factory_reg.hh @@ -17,6 +17,6 @@ #include "thermal_conductivity_threephase_factory.hh" // explicity instantitate the static data of Factory -template <> +template<> Amanzi::Utils::Factory::map_type* Amanzi::Utils::Factory::map_; diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_peterslidard.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_peterslidard.hh index 7a42b0f2b..675587edb 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_peterslidard.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_peterslidard.hh @@ -22,7 +22,6 @@ See Atchley et al GMD 2015 Supplementary Material for equations. .. _thermal-conductivity-threephase-peterslidard-spec: .. admonition:: thermal-conductivity-threephase-peterslidard-spec - * `"region`" ``[string]`` Region name on which to apply these parameters. * `"thermal conductivity of soil [W m^-1 K^-1]`" ``[double]`` Thermal conductivity of soil grains (not bulk soil) * `"thermal conductivity of liquid [W m^-1 K^-1]`" ``[double]`` Thermal conductivity of liquid (water) * `"thermal conductivity of gas [W m^-1 K^-1]`" ``[double]`` Thermal conductivity of gas (air) diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_volume_averaged.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_volume_averaged.hh index 50d4ef466..a0bfce778 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_volume_averaged.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_volume_averaged.hh @@ -20,7 +20,6 @@ See Atchley et al GMD 2015 Supplementary Material for equations. .. _thermal-conductivity-volume-averaged-spec: .. admonition:: thermal-conductivity-volume-averaged-spec - * `"region`" ``[string]`` Region name on which to apply these parameters. * `"thermal conductivity of soil [W m^-1 K^-1]`" ``[double]`` Thermal conductivity of soil **grains** * `"thermal conductivity of liquid [W m^-1 K^-1]`" ``[double]`` Thermal diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_wetdry.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_wetdry.hh index 9a5cfead8..79957de51 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_wetdry.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_threephase_wetdry.hh @@ -51,16 +51,22 @@ class ThermalConductivityThreePhaseWetDry : public ThermalConductivityThreePhase ThermalConductivityThreePhaseWetDry(Teuchos::ParameterList& plist); double ThermalConductivity(double porosity, double sat_liq, double sat_ice, double temp); - double - DThermalConductivity_DPorosity(double porosity, double sat_liq, double sat_ice, double temp); + double DThermalConductivity_DPorosity(double porosity, + double sat_liq, + double sat_ice, + double temp); double DThermalConductivity_DSaturationLiquid(double porosity, double sat_liq, double sat_ice, double temp); - double - DThermalConductivity_DSaturationIce(double porosity, double sat_liq, double sat_ice, double temp); - double - DThermalConductivity_DTemperature(double porosity, double sat_liq, double sat_ice, double temp); + double DThermalConductivity_DSaturationIce(double porosity, + double sat_liq, + double sat_ice, + double temp); + double DThermalConductivity_DTemperature(double porosity, + double sat_liq, + double sat_ice, + double temp); private: void InitializeFromPlist_(); diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_evaluator.cc b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_evaluator.cc index f40ea887e..1166c2182 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_evaluator.cc +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_evaluator.cc @@ -34,7 +34,7 @@ ThermalConductivityTwoPhaseEvaluator::ThermalConductivityTwoPhaseEvaluator( Teuchos::ParameterList tc_sublist = plist_.sublist("thermal conductivity parameters"); ThermalConductivityTwoPhaseFactory fac; - for (Teuchos::ParameterList::ConstIterator lcv = tc_sublist.begin(); lcv != tc_sublist.end(); + for (Teuchos::ParameterList::ConstIterator lcv = tc_sublist.begin() ; lcv != tc_sublist.end(); ++lcv) { std::string name = lcv->first; if (tc_sublist.isSublist(name)) { @@ -76,7 +76,7 @@ ThermalConductivityTwoPhaseEvaluator::Evaluate_(const State& S, const Epetra_MultiVector& sat_v = *sat->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp, false); - for (std::vector::const_iterator lcv = tcs_.begin(); lcv != tcs_.end(); + for (std::vector::const_iterator lcv = tcs_.begin() ; lcv != tcs_.end(); ++lcv) { std::string region_name = lcv->first; if (mesh->isValidSetName(region_name, AmanziMesh::Entity_kind::CELL)) { diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_evaluator.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_evaluator.hh index 41ff54026..d0f478905 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_evaluator.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_evaluator.hh @@ -6,12 +6,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -/* - Interface for a thermal conductivity model with two phases. - -*/ - /*! Thermal conductivity based on two-phases (air,liquid) composition of the @@ -19,10 +13,10 @@ porous media. `"evaluator type`" = `"two-phase thermal conductivity`" -.. _thermal-conductivity-twophase-evaluator-spec: -.. admonition:: thermal-conductivity-twophase-evaluator-spec +.. _evaluator-two-phase-thermal-conductivity-spec: +.. admonition:: evaluator-two-phase-thermal-conductivity-spec - * `"thermal conductivity parameters`" ``[thermal-conductivity-twophase-typedinline-spec-list]`` + * `"thermal conductivity parameters`" ``[thermal-conductivity-twophase-typed-spec-list]`` KEYS: diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_factory.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_factory.hh index 4284c99cc..9966a111d 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_factory.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_factory.hh @@ -7,12 +7,22 @@ Authors: Ethan Coon */ -/* ------------------------------------------------------------------------- +/* + +Two-phase thermal conductivity models are used to compute the bulk thermal +conductivity from the constitutive parts -- gas, liquid, ice, and background +material. - ATS +.. _thermal-conductivity-twophase-typed-spec: +.. admonition:: thermal-conductivity-twophase-typed-spec - Self-registering factory for EOS implementations. - ------------------------------------------------------------------------- */ + * `"region`" ``[string]`` Region on which the model is valid. + * `"thermal conductivity type`" ``[string]`` Name of the model, see below for options. + * `"_thermal_conductivity_type_ parameters`" + ``[_thermal_conductivity_type_-spec]`` See below for the required + parameter spec for each type. + +*/ #ifndef PK_ENERGY_RELATIONS_TC_TWOPHASE_FACTORY_HH_ #define PK_ENERGY_RELATIONS_TC_TWOPHASE_FACTORY_HH_ @@ -28,8 +38,8 @@ namespace Energy { class ThermalConductivityTwoPhaseFactory : public Utils::Factory { public: - Teuchos::RCP - createThermalConductivityModel(Teuchos::ParameterList& plist); + Teuchos::RCP createThermalConductivityModel( + Teuchos::ParameterList& plist); }; } // namespace Energy diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_factory_reg.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_factory_reg.hh index f261d4540..ffb3fdd5e 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_factory_reg.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_factory_reg.hh @@ -17,6 +17,6 @@ #include "thermal_conductivity_twophase_factory.hh" // explicity instantitate the static data of Factory -template <> +template<> Amanzi::Utils::Factory::map_type* Amanzi::Utils::Factory::map_; diff --git a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_wetdry.hh b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_wetdry.hh index 8d96dcca4..8930ad08c 100644 --- a/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_wetdry.hh +++ b/src/pks/energy/constitutive_relations/thermal_conductivity/thermal_conductivity_twophase_wetdry.hh @@ -19,7 +19,6 @@ Simple model of two-phase thermal conductivity, based upon: .. _thermal-conductivity-twophase-wetdry-spec: .. admonition:: thermal-conductivity-twophase-wetdry-spec - * `"region`" ``[string]`` Region name on which to apply these parameters. * `"thermal conductivity, wet [W m^-1 K^-1]`" ``[double]`` Thermal conductivity of saturated soil * `"thermal conductivity, dry [W m^-1 K^-1]`" ``[double]`` Thermal conductivity of dry soil * `"unsaturated alpha [-]`" ``[double]`` Interpolating exponent diff --git a/src/pks/energy/energy_base.hh b/src/pks/energy/energy_base.hh index ab3a45c62..1fe480c0e 100644 --- a/src/pks/energy/energy_base.hh +++ b/src/pks/energy/energy_base.hh @@ -6,140 +6,148 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! An advection-diffusion equation for energy. /*! -Solves an advection-diffusion equation for energy: +Solves an advection-diffusion equation for transport of energy: .. math:: \frac{\partial E}{\partial t} - \nabla \cdot \kappa \nabla T + \nabla \cdot \mathbf{q} e(T) = Q_w e(T) + Q_e -.. todo:: Document the energy error norm! +Note that this is implemented rather differently than chemical transport, +likely for unclear (historical) reasons. At some point energy and chemical +transport should probably be merged into a shared PK which supports both +sequential and globally implicit coupling of flow and transport. + +Note that this is a base class and cannot be directly created. Instead, use +two-phase or three-phase energy PKs. + +.. _pk-energy-base-spec: +.. admonition:: pk-energy-base-spec + + * `"domain`" ``[string]`` **"domain"** Defaults to the subsurface mesh. -.. _energy-pk-spec: -.. admonition:: energy-pk-spec + * `"primary variable`" ``[string]`` **DOMAIN-temperature** The primary + variable associated with this PK. - * `"domain`" ``[string]`` **"domain"** Defaults to the subsurface mesh. + * `"boundary conditions`" ``[list]`` Defaults to 0 diffusive flux + boundary condition. See :ref:`Energy-specific Boundary Conditions` - * `"primary variable`" ``[string]`` The primary variable associated with - this PK, typically `"DOMAIN-temperature`" Note there is no default -- this - must be provided by the user. + * `"absolute error tolerance`" ``[double]`` **76.e-6** A small amount of + energy, see error norm. [MJ] - * `"boundary conditions`" ``[list]`` Defaults to 0 diffusive flux - boundary condition. See `Energy-specific Boundary Conditions`_ + * `"upwind conductivity method`" ``[string]`` **arithmetic mean** Method of + moving cell-based thermal conductivities onto faces. One of: - * `"thermal conductivity evaluator`" ``[list]`` - The thermal conductivity. This - needs to go away, and should get moved to State. + - `"arithmetic mean`" the default, average of neighboring cells + - `"cell centered`" harmonic mean - * `"absolute error tolerance`" ``[double]`` **76.e-6** A small amount of - energy, see error norm. `[MJ]` + Math and solver algorithm options: - * `"upwind conductivity method`" ``[string]`` **arithmetic mean** Method of - moving cell-based thermal conductivities onto faces. One of: + * `"inverse`" ``[inverse-spec]`` **optional** The inverse used for + preconditioning in a non-globally coupled problem. See :ref:`Inverse`. - - `"arithmetic mean`" the default, average of neighboring cells - - `"cell centered`" harmonic mean + * `"advection`" ``[advection-upwind-op-spec]`` See :ref:`Advection`. Only + one current implementation, so defaults are typically fine. - IF + IF - * `"explicit advection`" ``[bool]`` **false** Treat the advection term implicitly. + * `"explicit advection`" ``[bool]`` **false** Treat the advection term explicitly. - ELSE + ELSE - * `"supress advective terms in preconditioner`" ``[bool]`` **false** - Typically subsurface energy equations are strongly diffusion dominated, - and the advective terms may add little. With this flag on, we ignore - theem in the preconditioner, making an easier linear solve and often not - negatively impacting the nonlinear solve. + * `"supress advective terms in preconditioner`" ``[bool]`` **false** + Typically subsurface energy equations are strongly diffusion dominated, + and the advective terms may add little. With this flag on, we ignore them + in the preconditioner, making an easier linear solve and often not + negatively impacting the nonlinear solve. Note that this does NOT change + the answer, just the performance. - * `"advection preconditioner`" ``[list]`` **optional** - Typically defaults are correct. + * `"advection preconditioner`" ``[advection-upwind-op-spec`` **optional** + Typically defaults are correct. See :ref:`Advection`. - END + END - * `"diffusion`" ``[pde-diffusion-spec]`` See PDE_Diffusion_, the diffusion operator. + * `"diffusion`" ``[pde-diffusion-typedinline-spec]`` See :ref:`Diffusion`, + the diffusion operator. - * `"diffusion preconditioner`" ``[pde-diffusion-spec]`` See - PDE_Diffusion_, the inverse operator. Typically only adds Jacobian - terms, as all the rest default to those values from `"diffusion`". + * `"diffusion preconditioner`" ``[pde-diffusion-typedinline-spec]`` See + :ref:`Diffusion`, the inverse operator. Typically only adds Jacobian terms, + as all the rest default to those values from `"diffusion`". - IF + IF - * `"source term`" ``[bool]`` **false** Is there a source term? + * `"source term`" ``[bool]`` **false** Is there a source term? - THEN + THEN - * `"source key`" ``[string]`` **DOMAIN-total_energy_source** Typically - not set, as the default is good. ``[MJ s^-1]`` + * `"source key`" ``[string]`` **DOMAIN-total_energy_source** Typically + not set, as the default is good. [MJ s^-1] - * `"source term finite difference`" ``[bool]`` **false** Option to do a - finite difference approximation of the source term's derivative with - respect to the primary variable. This is useful for - difficult-to-differentiate terms like a surface energy balance, which - includes many terms. + * `"source term finite difference`" ``[bool]`` **false** Option to do a + finite difference approximation of the source term's derivative with + respect to the primary variable. This is useful for + difficult-to-differentiate terms like a surface energy balance, which + includes many terms. - END + END - Globalization: + Globalization: - * `"modify predictor with consistent faces`" ``[bool]`` **false** In a - face+cell diffusion discretization, this modifies the predictor to make - sure that faces, which are a DAE, are consistent with the predicted cells - (i.e. face fluxes from each sides match). + * `"modify predictor with consistent faces`" ``[bool]`` **false** In a + face+cell diffusion discretization, this modifies the predictor to make + sure that faces, which are algebraic relative to cells, are consistent + with the predicted cells values (i.e. face fluxes from each side match). - * `"modify predictor for freezing`" ``[bool]`` **false** A simple limiter - that keeps temperature corrections from jumping over the phase change. + * `"modify predictor for freezing`" ``[bool]`` **false** A simple limiter + that keeps temperature corrections from jumping over the phase change. - * `"limit correction to temperature change [K]`" ``[double]`` **-1.0** If > - 0, stops nonlinear updates from being too big through clipping. + * `"limit correction to temperature change [K]`" ``[double]`` **-1.0** If > + 0, stops nonlinear updates from being too big through clipping. - The following are rarely set by the user, as the defaults are typically right. + The following are rarely set by the user, as the defaults are typically right. - * `"advection`" ``[list]`` **optional** The PDE_Advection_ spec. Only one - current implementation, so defaults are typically fine. + * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` **optional** + The inverse of the accumulation operator. See :ref:`Accumulation`. + Typically not provided by users, as defaults are correct. - * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` **optional** - The inverse of the accumulation operator. See PDE_Accumulation_. - Typically not provided by users, as defaults are correct. + Algorithmic physics control: - IF + IF - * `"coupled to surface via flux`" ``[bool]`` **false** If true, apply - surface boundary conditions from an exchange flux. Note, if this is a - coupled problem, it is probably set by the MPC. No need for a user to - set it. + * `"coupled to surface via flux`" ``[bool]`` **false** If true, apply + surface boundary conditions from an exchange flux. Note, if this is a + coupled problem, it is probably set by the MPC. No need for a user to + set it. - THEN + THEN - * `"surface-subsurface energy flux key`" ``[string]`` **DOMAIN-surface_subsurface_energy_flux** + * `"surface-subsurface energy flux key`" ``[string]`` **DOMAIN-surface_subsurface_energy_flux** - END + END - * `"coupled to surface via temperature`" ``[bool]`` **false** If true, apply - surface boundary conditions from the surface temperature (Dirichlet). + * `"coupled to surface via temperature`" ``[bool]`` **false** If true, apply + surface boundary conditions from the surface temperature (Dirichlet). - KEYS: + KEYS: - - `"conserved quantity`" **DOMAIN-energy** The total energy :math:`E` `[MJ]` - - `"energy`" **DOMAIN-energy** The total energy :math:`E`, also the conserved quantity. `[MJ]` - - `"water content`" **DOMAIN-water_content** The total mass :math:`\Theta`, used in error norm `[mol]` - - `"enthalpy`" **DOMAIN-enthalpy** The specific enthalpy :math`e` `[MJ mol^-1]` - - `"flux`" **DOMAIN-water_flux** The water flux :math:`\mathbf{q}` used in advection. `[mol s^-1]` - - `"diffusive energy`" **DOMAIN-diffusive_energy_flux** :math:`\mathbf{q_e}` `[MJ s^-1]` - - `"advected energy`" **DOMAIN-advected_energy_flux** :math:`\mathbf{q_e^{adv}} = q e` `[MJ s^-1]` - - `"thermal conductivity`" **DOMAIN-thermal_conductivity** Thermal conductivity on cells `[W m^-1 K^-1]` - - `"upwinded thermal conductivity`" **DOMAIN-upwinded_thermal_conductivity** Thermal conductivity on faces `[W m^-1 K^-1]` + - `"conserved quantity`" **DOMAIN-energy** The total energy :math:`E` `[MJ]` + - `"energy`" **DOMAIN-energy** The total energy :math:`E`, also the conserved quantity. `[MJ]` + - `"water content`" **DOMAIN-water_content** The total mass :math:`\Theta`, used in error norm `[mol]` + - `"enthalpy`" **DOMAIN-enthalpy** The specific enthalpy :math`e` `[MJ mol^-1]` + - `"flux`" **DOMAIN-water_flux** The water flux :math:`\mathbf{q}` used in advection. `[mol s^-1]` + - `"diffusive energy`" **DOMAIN-diffusive_energy_flux** :math:`\mathbf{q_e}` `[MJ s^-1]` + - `"advected energy`" **DOMAIN-advected_energy_flux** :math:`\mathbf{q_e^{adv}} = q e` `[MJ s^-1]` + - `"thermal conductivity`" **DOMAIN-thermal_conductivity** Thermal conductivity on cells `[W m^-1 K^-1]` + - `"upwinded thermal conductivity`" **DOMAIN-upwinded_thermal_conductivity** Thermal conductivity on faces `[W m^-1 K^-1]` - EVALUATORS: + EVALUATORS: - - `"source term`" **optional** If source key is provided. - - `"enthalpy`" - - `"cell volume`" - - `"thermal conductivity`" - - `"conserved quantity`" - - `"energy`" + - `"source term`" **optional** If source key is provided. + - `"enthalpy`" + - `"cell volume`" + - `"thermal conductivity`" + - `"conserved quantity`" + - `"energy`" */ @@ -154,7 +162,6 @@ Solves an advection-diffusion equation for energy: #include "PDE_Accumulation.hh" #include "PDE_AdvectionUpwind.hh" -//#include "PK_PhysicalBDF_ATS.hh" #include "pk_physical_bdf_default.hh" #include "upwinding.hh" @@ -196,8 +203,8 @@ class EnergyBase : public PK_PhysicalBDF_Default { // Default implementations of BDFFnBase methods. // -- Compute a norm on u-du and return the result. - virtual double - ErrorNorm(Teuchos::RCP u, Teuchos::RCP du) override; + virtual double ErrorNorm(Teuchos::RCP u, + Teuchos::RCP du) override; // EnergyBase is a BDFFnBase // computes the non-linear functional f = f(t,u,udot) @@ -209,8 +216,8 @@ class EnergyBase : public PK_PhysicalBDF_Default { // applies preconditioner to u and returns the result in Pu - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; // updates the preconditioner virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; @@ -218,17 +225,18 @@ class EnergyBase : public PK_PhysicalBDF_Default { // problems with temperatures -- setting a range of admissible temps virtual bool IsAdmissible(Teuchos::RCP up) override; - virtual bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + virtual bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; // evaluating consistent faces for given BCs and cell values virtual void CalculateConsistentFaces(const Teuchos::Ptr& u); - virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult - ModifyCorrection(double h, - Teuchos::RCP res, - Teuchos::RCP u, - Teuchos::RCP du) override; + virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult ModifyCorrection( + double h, + Teuchos::RCP res, + Teuchos::RCP u, + Teuchos::RCP du) override; protected: // These must be provided by the deriving PK. diff --git a/src/pks/energy/energy_base_physics.cc b/src/pks/energy/energy_base_physics.cc index cb7bd04de..ef7ec6652 100644 --- a/src/pks/energy/energy_base_physics.cc +++ b/src/pks/energy/energy_base_physics.cc @@ -19,7 +19,7 @@ de/dt + q dot grad h = div Ke grad T + S? #include "Evaluator.hh" #include "energy_base.hh" #include "Op.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "MeshAlgorithms.hh" namespace Amanzi { @@ -149,10 +149,10 @@ EnergyBase::AddSources_(const Tag& tag, const Teuchos::Ptr& g) unsigned int ncells = g_c.MyLength(); for (unsigned int c = 0; c != ncells; ++c) { g_c[0][c] -= source1[0][c] * cv[0][c]; - } - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Adding external source term" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) + ) *vo_->os() << "Adding external source term" << std::endl; db_->WriteVector(" Q_ext", S_->GetPtr(source_key_, tag).ptr(), false); db_->WriteVector("res (src)", g, false); } @@ -184,8 +184,8 @@ EnergyBase::AddSourcesToPrecon_(double h) } else if (is_source_term_differentiable_) { // evaluate the derivative through the dag S_->GetEvaluator(source_key_, tag_next_).UpdateDerivative(*S_, name_, key_, tag_next_); - dsource_dT = S_->GetDerivativePtrW( - source_key_, tag_next_, key_, tag_next_, source_key_); + dsource_dT = + S_->GetDerivativePtrW(source_key_, tag_next_, key_, tag_next_, source_key_); } if (dsource_dT != Teuchos::null) { diff --git a/src/pks/energy/energy_base_pk.cc b/src/pks/energy/energy_base_pk.cc index b94cfa49f..ea136788f 100644 --- a/src/pks/energy/energy_base_pk.cc +++ b/src/pks/energy/energy_base_pk.cc @@ -7,8 +7,7 @@ Authors: Ethan Coon (ecoon@ornl.gov) */ -#include "energy_bc_factory.hh" -#include "advection_factory.hh" +#include "Reductions.hh" #include "PDE_DiffusionFactory.hh" #include "PDE_Diffusion.hh" @@ -17,12 +16,14 @@ #include "upwind_cell_centered.hh" #include "upwind_arithmetic_mean.hh" #include "upwind_total_flux.hh" +#include "energy_bc_factory.hh" +#include "advection_factory.hh" #include "enthalpy_evaluator.hh" #include "CompositeVectorFunction.hh" #include "CompositeVectorFunctionFactory.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "MeshAlgorithms.hh" #include "energy_base.hh" @@ -55,7 +56,6 @@ EnergyBase::EnergyBase(Teuchos::ParameterList& FElist, {} - // call to allow a PK to modify its own list or lists of its children. void EnergyBase::parseParameterList() @@ -66,6 +66,8 @@ EnergyBase::parseParameterList() } // set some defaults for inherited PKs + if (!plist_->isParameter("primary variable key suffix")) + plist_->set("primary variable key suffix", "temperature"); if (!plist_->isParameter("conserved quantity key suffix")) plist_->set("conserved quantity key suffix", "energy"); @@ -94,7 +96,8 @@ EnergyBase::parseParameterList() is_source_term_ = plist_->get("source term", false); if (is_source_term_ && source_key_.empty()) { source_key_ = Keys::readKey(*plist_, domain_, "source", "total_energy_source"); - is_source_term_finite_differentiable_ = plist_->get("source term finite difference", false); + is_source_term_finite_differentiable_ = + plist_->get("source term finite difference", false); } // get keys @@ -132,7 +135,7 @@ EnergyBase::SetupPhysicalEvaluators_() { // Get data and evaluators needed by the PK // -- energy, energy evaluator, and energy derivative - requireAtNext(conserved_key_, tag_next_, *S_) + requireEvaluatorAtNext(conserved_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -140,7 +143,7 @@ EnergyBase::SetupPhysicalEvaluators_() conserved_key_, tag_next_, key_, tag_next_); // -- conductivity - requireAtNext(conductivity_key_, tag_next_, *S_) + requireEvaluatorAtNext(conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -154,7 +157,7 @@ void EnergyBase::SetupEnergy_() { // Get data for special-case entities. - requireAtNext(cell_vol_key_, tag_next_, *S_) + requireEvaluatorAtNext(cell_vol_key_, tag_next_, *S_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -162,12 +165,12 @@ EnergyBase::SetupEnergy_() // require data for source terms if (is_source_term_) { - requireAtNext(source_key_, tag_next_, *S_) + requireEvaluatorAtNext(source_key_, tag_next_, *S_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - if (!is_source_term_finite_differentiable_ - && S_->GetEvaluator(source_key_, tag_next_).IsDifferentiableWRT(*S_, key_, tag_next_)) { + if (!is_source_term_finite_differentiable_ && + S_->GetEvaluator(source_key_, tag_next_).IsDifferentiableWRT(*S_, key_, tag_next_)) { is_source_term_differentiable_ = true; // require derivative of source S_->RequireDerivative( @@ -176,7 +179,7 @@ EnergyBase::SetupEnergy_() } // is dynamic mesh? If so, get a key for indicating when the mesh has changed. - if (!deform_key_.empty()) S_->RequireEvaluator(deform_key_, tag_next_); + if (!deform_key_.empty() ) S_->RequireEvaluator(deform_key_, tag_next_); // Set up Operators // -- boundary conditions @@ -322,7 +325,7 @@ EnergyBase::SetupEnergy_() } // -- enthalpy data, evaluator - requireAtNext(enthalpy_key_, tag_next_, *S_) + requireEvaluatorAtNext(enthalpy_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) @@ -332,21 +335,21 @@ EnergyBase::SetupEnergy_() .SetGhosted(); // -- diagnostic for advected energy - requireAtNext(adv_energy_flux_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(adv_energy_flux_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetGhosted() ->SetComponent("face", AmanziMesh::Entity_kind::FACE, 1); } else { // -- enthalpy data, evaluator - requireAtCurrent(enthalpy_key_, tag_current_, *S_) + requireEvaluatorAtCurrent(enthalpy_key_, tag_current_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) ->AddComponent("boundary_face", AmanziMesh::Entity_kind::BOUNDARY_FACE, 1); // -- diagnostic for advected energy - requireAtCurrent(adv_energy_flux_key_, tag_current_, *S_, name_) + requireEvaluatorAtCurrent(adv_energy_flux_key_, tag_current_, *S_, name_) .SetMesh(mesh_) ->SetGhosted() ->SetComponent("face", AmanziMesh::Entity_kind::FACE, 1); @@ -403,22 +406,22 @@ EnergyBase::SetupEnergy_() ->SetGhosted(); // require a water flux field - requireAtNext(flux_key_, tag_next_, *S_) + requireEvaluatorAtNext(flux_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("face", AmanziMesh::Entity_kind::FACE, 1); // and at the current time, where it is a copy evaluator - requireAtCurrent(flux_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(flux_key_, tag_current_, *S_, name_); // require a water content field -- used for computing energy density in the // error norm - requireAtNext(wc_key_, tag_next_, *S_) + requireEvaluatorAtNext(wc_key_, tag_next_, *S_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(wc_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(wc_key_, tag_current_, *S_, name_); // Require fields for the energy fluxes - requireAtNext(energy_flux_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(energy_flux_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetGhosted() ->SetComponent("face", AmanziMesh::Entity_kind::FACE, 1); @@ -494,7 +497,7 @@ EnergyBase::UpdateConductivityData_(const Tag& tag) S_->GetPtrW(uw_conductivity_key_, tag, name_); upwinding_->Update(*cond, *uw_cond, *S_); - if (uw_cond->HasComponent("face")) uw_cond->ScatterMasterToGhosted("face"); + if (uw_cond->HasComponent("face") ) uw_cond->ScatterMasterToGhosted("face"); } return update; } @@ -504,7 +507,7 @@ bool EnergyBase::UpdateConductivityDerivativeData_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating conductivity derivatives? "; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating conductivity derivatives? "; bool update = S_->GetEvaluator(conductivity_key_, tag).UpdateDerivative(*S_, name_, key_, tag); @@ -517,7 +520,7 @@ EnergyBase::UpdateConductivityDerivativeData_(const Tag& tag) S_->GetPtrW(duw_conductivity_key_, tag, name_); duw_cond->PutScalar(0.); upwinding_deriv_->Update(*dcond, *duw_cond, *S_); - if (duw_cond->HasComponent("face")) duw_cond->ScatterMasterToGhosted("face"); + if (duw_cond->HasComponent("face") ) duw_cond->ScatterMasterToGhosted("face"); } else { dcond->ScatterMasterToGhosted("cell"); } @@ -543,7 +546,7 @@ void EnergyBase::UpdateBoundaryConditions_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating BCs." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating BCs." << std::endl; auto& markers = bc_markers(); auto& values = bc_values(); @@ -661,96 +664,35 @@ bool EnergyBase::IsAdmissible(Teuchos::RCP up) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Checking admissibility..." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Checking admissibility..." << std::endl; // For some reason, wandering PKs break most frequently with an unreasonable // temperature. This simply tries to catch that before it happens. Teuchos::RCP temp = up->Data(); - double minT, maxT; const Epetra_MultiVector& temp_c = *temp->ViewComponent("cell", false); - double minT_c(1.e6), maxT_c(-1.e6); - int min_c(-1), max_c(-1); - for (int c = 0; c != temp_c.MyLength(); ++c) { - if (temp_c[0][c] < minT_c) { - minT_c = temp_c[0][c]; - min_c = c; - } - if (temp_c[0][c] > maxT_c) { - maxT_c = temp_c[0][c]; - max_c = c; - } - } + Reductions::MinMaxLoc minmaxT_c = Reductions::reduceAllMinMaxLoc(*temp_c(0)); + Reductions::MinMaxLoc minmaxT_f = Reductions::createEmptyMinMaxLoc(); - double minT_f(1.e6), maxT_f(-1.e6); - int min_f(-1), max_f(-1); if (temp->HasComponent("face")) { const Epetra_MultiVector& temp_f = *temp->ViewComponent("face", false); - for (int f = 0; f != temp_f.MyLength(); ++f) { - if (temp_f[0][f] < minT_f) { - minT_f = temp_f[0][f]; - min_f = f; - } - if (temp_f[0][f] > maxT_f) { - maxT_f = temp_f[0][f]; - max_f = f; - } - } - minT = std::min(minT_c, minT_f); - maxT = std::max(maxT_c, maxT_f); - - } else { - minT = minT_c; - maxT = maxT_c; + minmaxT_f = Reductions::reduceAllMinMaxLoc(*temp_f(0)); } - - double minT_l = minT; - double maxT_l = maxT; - mesh_->getComm()->MaxAll(&maxT_l, &maxT, 1); - mesh_->getComm()->MinAll(&minT_l, &minT, 1); + double minT = std::min(minmaxT_c[0].value, minmaxT_f[0].value); + double maxT = std::max(minmaxT_c[1].value, minmaxT_f[1].value); if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << " Admissible T? (min/max): " << minT << ", " << maxT << std::endl; } - Teuchos::RCP comm_p = mesh_->getComm(); - Teuchos::RCP mpi_comm_p = - Teuchos::rcp_dynamic_cast(comm_p); - const MPI_Comm& comm = mpi_comm_p->Comm(); - if (minT < 200.0 || maxT > 330.0) { if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { *vo_->os() << " is not admissible, as it is not within bounds of constitutive models:" << std::endl; - ENorm_t global_minT_c, local_minT_c; - ENorm_t global_maxT_c, local_maxT_c; - - local_minT_c.value = minT_c; - local_minT_c.gid = temp_c.Map().GID(min_c); - local_maxT_c.value = maxT_c; - local_maxT_c.gid = temp_c.Map().GID(max_c); - - MPI_Allreduce(&local_minT_c, &global_minT_c, 1, MPI_DOUBLE_INT, MPI_MINLOC, comm); - MPI_Allreduce(&local_maxT_c, &global_maxT_c, 1, MPI_DOUBLE_INT, MPI_MAXLOC, comm); - - *vo_->os() << " cells (min/max): [" << global_minT_c.gid << "] " << global_minT_c.value - << ", [" << global_maxT_c.gid << "] " << global_maxT_c.value << std::endl; + *vo_->os() << " cells (min/max): " << minmaxT_c << std::endl; if (temp->HasComponent("face")) { - const Epetra_MultiVector& temp_f = *temp->ViewComponent("face", false); - ENorm_t global_minT_f, local_minT_f; - ENorm_t global_maxT_f, local_maxT_f; - - local_minT_f.value = minT_f; - local_minT_f.gid = temp_f.Map().GID(min_f); - local_maxT_f.value = maxT_f; - local_maxT_f.gid = temp_f.Map().GID(max_f); - - - MPI_Allreduce(&local_minT_f, &global_minT_f, 1, MPI_DOUBLE_INT, MPI_MINLOC, comm); - MPI_Allreduce(&local_maxT_f, &global_maxT_f, 1, MPI_DOUBLE_INT, MPI_MAXLOC, comm); - *vo_->os() << " cells (min/max): [" << global_minT_f.gid << "] " << global_minT_f.value - << ", [" << global_maxT_f.gid << "] " << global_maxT_f.value << std::endl; + *vo_->os() << " faces (min/max): " << minmaxT_f << std::endl; } } return false; @@ -766,7 +708,7 @@ bool EnergyBase::ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Modifying predictor:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Modifying predictor:" << std::endl; // update boundary conditions //ComputeBoundaryConditions_(tag_next_); @@ -824,7 +766,7 @@ EnergyBase::ModifyPredictor(double h, Teuchos::RCP u0, Teuchos void EnergyBase::CalculateConsistentFaces(const Teuchos::Ptr& u) { - if (!u->HasComponent("face")) return; + if (!u->HasComponent("face") ) return; // average cells to faces to give a reasonable initial guess u->ScatterMasterToGhosted("cell"); @@ -837,7 +779,9 @@ EnergyBase::CalculateConsistentFaces(const Teuchos::Ptr& u) int ncells = cells.size(); double face_value = 0.0; - for (int n = 0; n != ncells; ++n) { face_value += u_c[0][cells[n]]; } + for (int n = 0; n != ncells; ++n) { + face_value += u_c[0][cells[n]]; + } u_f[0][f] = face_value / ncells; } ChangedSolution(); @@ -906,7 +850,7 @@ EnergyBase::ModifyCorrection(double h, int my_limited = 0; int n_limited = 0; if (T_limit_ > 0.) { - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); @@ -927,7 +871,9 @@ EnergyBase::ModifyCorrection(double h, } if (n_limited > 0) { - if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << " limited by temperature." << std::endl; } + if (vo_->os_OK(Teuchos::VERB_HIGH)) { + *vo_->os() << " limited by temperature." << std::endl; + } return AmanziSolvers::FnBaseDefs::CORRECTION_MODIFIED; } return AmanziSolvers::FnBaseDefs::CORRECTION_NOT_MODIFIED; diff --git a/src/pks/energy/energy_base_ti.cc b/src/pks/energy/energy_base_ti.cc index 5daad18bb..37874decc 100644 --- a/src/pks/energy/energy_base_ti.cc +++ b/src/pks/energy/energy_base_ti.cc @@ -7,12 +7,15 @@ Authors: Ethan Coon */ +#include "Reductions.hh" #include "Debugger.hh" #include "BoundaryFunction.hh" #include "Evaluator.hh" -#include "energy_base.hh" +#include "PK_Helpers.hh" #include "Op.hh" +#include "energy_base.hh" + namespace Amanzi { namespace Energy { @@ -118,7 +121,7 @@ EnergyBase::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCPgetOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon application:" << std::endl; db_->WriteVector("T_res", u->Data().ptr(), true); #endif @@ -141,7 +144,7 @@ EnergyBase::UpdatePreconditioner(double t, Teuchos::RCP up, do { // VerboseObject stuff. Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon update at t = " << t << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon update at t = " << t << std::endl; // update state with the solution up. AMANZI_ASSERT(std::abs(S_->get_time(tag_next_) - t) <= 1.e-4 * t); @@ -283,15 +286,9 @@ EnergyBase::ErrorNorm(Teuchos::RCP u, Teuchos::RCP dvec = res->Data(); double h = S_->get_time(tag_next_) - S_->get_time(tag_current_); - Teuchos::RCP comm_p = mesh_->getComm(); - Teuchos::RCP mpi_comm_p = - Teuchos::rcp_dynamic_cast(comm_p); - const MPI_Comm& comm = mpi_comm_p->Comm(); - double enorm_val = 0.0; for (CompositeVector::name_iterator comp = dvec->begin(); comp != dvec->end(); ++comp) { - double enorm_comp = 0.0; - int enorm_loc = -1; + Reductions::MaxLoc enorm_comp = Reductions::createEmptyMaxLoc(); const Epetra_MultiVector& dvec_v = *dvec->ViewComponent(*comp, false); if (*comp == std::string("cell")) { @@ -304,9 +301,9 @@ EnergyBase::ErrorNorm(Teuchos::RCP u, Teuchos::RCP enorm_comp) { - enorm_comp = enorm_c; - enorm_loc = c; + if (enorm_c > enorm_comp.value) { + enorm_comp.value = enorm_c; + enorm_comp.gid = dvec_v.Map().GID(c); } } @@ -326,9 +323,9 @@ EnergyBase::ErrorNorm(Teuchos::RCP u, Teuchos::RCP enorm_comp) { - enorm_comp = enorm_f; - enorm_loc = f; + if (enorm_f > enorm_comp.value) { + enorm_comp.value = enorm_f; + enorm_comp.gid = dvec_v.Map().GID(f); } } @@ -339,32 +336,19 @@ EnergyBase::ErrorNorm(Teuchos::RCP u, Teuchos::RCPgetComm(), enorm_comp); // Write out Inf norms too. if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { double infnorm(0.); dvec_v.NormInf(&infnorm); - ENorm_t err; - ENorm_t l_err; - l_err.value = enorm_comp; - l_err.gid = dvec_v.Map().GID(enorm_loc); - - int ierr; - ierr = MPI_Allreduce(&l_err, &err, 1, MPI_DOUBLE_INT, MPI_MAXLOC, comm); - AMANZI_ASSERT(!ierr); - *vo_->os() << " ENorm (" << *comp << ") = " << err.value << "[" << err.gid << "] (" - << infnorm << ")" << std::endl; + *vo_->os() << " ENorm (" << *comp << ") = " << enorm_comp << " (" << infnorm << ")" + << std::endl; } - enorm_val = std::max(enorm_val, enorm_comp); + enorm_val = std::max(enorm_val, enorm_comp.value); } - - double enorm_val_l = enorm_val; - - int ierr; - ierr = MPI_Allreduce(&enorm_val_l, &enorm_val, 1, MPI_DOUBLE, MPI_MAX, comm); - AMANZI_ASSERT(!ierr); return enorm_val; }; diff --git a/src/pks/energy/energy_bc_factory.hh b/src/pks/energy/energy_bc_factory.hh index bcf5bae0a..4fe378297 100644 --- a/src/pks/energy/energy_bc_factory.hh +++ b/src/pks/energy/energy_bc_factory.hh @@ -10,7 +10,7 @@ /*! Energy boundary conditions must follow the general format shown in -BoundaryConditions_. Energy-specific conditions implemented include: +`Boundary Conditions`_. Energy-specific conditions implemented include: Dirichlet (temperature) boundary conditions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/pks/energy/energy_interfrost.cc b/src/pks/energy/energy_interfrost.cc index e8cf0042b..7eeba12a9 100644 --- a/src/pks/energy/energy_interfrost.cc +++ b/src/pks/energy/energy_interfrost.cc @@ -74,7 +74,7 @@ InterfrostEnergy::UpdatePreconditioner(double t, Teuchos::RCP { // VerboseObject stuff. Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon update at t = " << t << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon update at t = " << t << std::endl; // update state with the solution up. AMANZI_ASSERT(std::abs(S_->get_time(tag_next_) - t) <= 1.e-4 * t); diff --git a/src/pks/energy/energy_surface_ice.cc b/src/pks/energy/energy_surface_ice.cc index 87b42737b..4480f519d 100644 --- a/src/pks/energy/energy_surface_ice.cc +++ b/src/pks/energy/energy_surface_ice.cc @@ -23,7 +23,7 @@ Process kernel for energy equation for overland flow. #include "EvaluatorPrimary.hh" #include "Op.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "energy_surface_ice.hh" namespace Amanzi { @@ -79,13 +79,13 @@ EnergySurfaceIce::SetupPhysicalEvaluators_() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // -- ensure enthalpy exists at the new time - requireAtNext(enthalpy_key_, tag_next_, *S_) + requireEvaluatorAtNext(enthalpy_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // -- and on the subsurface - requireAtNext(Keys::getKey(domain_ss_, "enthalpy"), tag_next_, *S_) + requireEvaluatorAtNext(Keys::getKey(domain_ss_, "enthalpy"), tag_next_, *S_) .SetMesh(S_->GetMesh(domain_ss_)) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -109,7 +109,7 @@ EnergySurfaceIce::Initialize() { // -- set the cell initial condition if it is taken from the subsurface if (!S_->GetRecord(key_, tag_next_).initialized()) { - if (!plist_->isSublist("initial condition")) { + if (!plist_->isSublist("initial conditions")) { Errors::Message message; message << name_ << " has no initial condition parameter list."; Exceptions::amanzi_throw(message); @@ -122,7 +122,7 @@ EnergySurfaceIce::Initialize() // Set the cell initial condition if it is taken from the subsurface if (!S_->GetRecord(key_, tag_next_).initialized()) { // TODO: make this go away! This should be in an MPC? - Teuchos::ParameterList& ic_plist = plist_->sublist("initial condition"); + Teuchos::ParameterList& ic_plist = plist_->sublist("initial conditions"); if (ic_plist.get("initialize surface temperature from subsurface", false)) { Teuchos::RCP surf_temp_cv = S_->GetPtrW(key_, tag_next_, name_); @@ -254,7 +254,9 @@ EnergySurfaceIce::AddSources_(const Tag& tag, const Teuchos::PtrWriteVector("res (s-s adv src)", g, false); } } @@ -295,7 +297,9 @@ EnergySurfaceIce::AddSourcesToPrecon_(double h) const Epetra_MultiVector& cell_vol = *S_->Get(cell_vol_key_, tag_next_).ViewComponent("cell", false); unsigned int ncells = dsource_dT.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { acc_c[0][c] = -dsource_dT[0][c] * cell_vol[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + acc_c[0][c] = -dsource_dT[0][c] * cell_vol[0][c]; + } preconditioner_acc_->AddAccumulationTerm(acc, "cell"); if (vo_->os_OK(Teuchos::VERB_EXTREME)) { diff --git a/src/pks/energy/energy_surface_ice.hh b/src/pks/energy/energy_surface_ice.hh index 29cb05d28..63a6a8444 100644 --- a/src/pks/energy/energy_surface_ice.hh +++ b/src/pks/energy/energy_surface_ice.hh @@ -6,32 +6,36 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! An advection-diffusion equation for surface energy in two phases. /*! -This is simply a surface energy equation that places a few more requirements -on the base class. It could probably go away if we refactor to remove -hard-coded evaluators. +Modifies the energy equation to implement overland energy transport, +particularly dealing with coupling terms to the subsurface energy equation. + +Note that this does not, but default, include all terms for a surface energy +balance. Those would typically be included on a snow surface energy balance +PK, which would also compute a skin energy flux that would become a source term +for this PK. + +`"PK type`" = `"suface energy`" -.. _energy-surface-ice-pk-spec: -.. admonition:: energy-surface-ice-pk-spec +.. _pk-surface-energy-spec: +.. admonition:: pk-surface-energy-spec - These are typically not set by the user: + These are typically not set by the user: - * `"coupled to subsurface via temperature`" ``[bool]`` **false** A coupling - scheme, provided by MPC. + * `"coupled to subsurface via temperature`" ``[bool]`` **false** A coupling + scheme, provided by MPC. - * `"coupled to subsurface via flux`" ``[bool]`` **false** A coupling - scheme, provided by MPC. + * `"coupled to subsurface via flux`" ``[bool]`` **false** A coupling + scheme, provided by MPC. - * `"subsurface domain name`" ``[string]`` **optional** If one of the above - coupling schemes is turned on, we need to know the subsurface mesh. - Provided by MPC. + * `"subsurface domain name`" ``[string]`` **optional** If one of the above + coupling schemes is turned on, we need to know the subsurface mesh. + Provided by MPC. - INCLUDES: + INCLUDES: - - ``[energy-pk-spec]`` See `Energy Base PK`_ + - ``[pk-energy-base-spec]`` See :ref:`Energy Base PK` */ diff --git a/src/pks/energy/energy_three_phase.cc b/src/pks/energy/energy_three_phase.cc index f95205f82..2ea108440 100644 --- a/src/pks/energy/energy_three_phase.cc +++ b/src/pks/energy/energy_three_phase.cc @@ -45,9 +45,9 @@ void ThreePhase::Initialize() { // INTERFROST comparison needs some very specialized ICs - if (plist_->sublist("initial condition").isParameter("interfrost initial condition")) { + if (plist_->sublist("initial conditions").isParameter("interfrost initial condition")) { AMANZI_ASSERT( - plist_->sublist("initial condition").get("interfrost initial condition") == + plist_->sublist("initial conditions").get("interfrost initial condition") == "TH3"); Teuchos::RCP temp = S_->GetPtrW(key_, tag_next_, name_); double r_sq = std::pow(0.5099, 2); @@ -67,7 +67,7 @@ ThreePhase::Initialize() S_->GetRecordW(key_, tag_next_, name_).set_initialized(); // additionally call Initalize() to get faces from cell values - S_->GetRecordW(key_, tag_next_, name_).Initialize(plist_->sublist("initial condition")); + S_->GetRecordW(key_, tag_next_, name_).Initialize(plist_->sublist("initial conditions")); } EnergyBase::Initialize(); diff --git a/src/pks/energy/energy_three_phase.hh b/src/pks/energy/energy_three_phase.hh index d04bcdba8..66d10f92c 100644 --- a/src/pks/energy/energy_three_phase.hh +++ b/src/pks/energy/energy_three_phase.hh @@ -6,20 +6,18 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! An advection-diffusion equation for energy in three phases. /*! -This is simply a subsurface energy equation that places a few more requirements -on the base class. It could probably go away if we refactor to remove -hard-coded evaluators. +Modifies the energy equation to provide three-phase energy (water + ice + vapor/air). + +`"PK type`" = `"three-phase energy`" -.. _energy-three-phase-pk-spec: -.. admonition:: energy-three-phase-pk-spec +.. _pk-three-phase-energy-spec: +.. admonition:: pk-three-phase-energy-spec - INCLUDES: + INCLUDES: - - ``[energy-two-phase-pk-spec]`` See `Two-Phase subsurface Energy PK`_ + - ``[pk-two-phase-energy-spec]`` See :ref:`Two-Phase Energy PK` */ diff --git a/src/pks/energy/energy_two_phase.hh b/src/pks/energy/energy_two_phase.hh index dbca701a1..a8c6416d6 100644 --- a/src/pks/energy/energy_two_phase.hh +++ b/src/pks/energy/energy_two_phase.hh @@ -7,19 +7,18 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! An advection-diffusion equation for energy in two phases. /*! -This is simply a subsurface energy equation that places a few more requirements -on the base class. It could probably go away if we refactor to remove -hard-coded evaluators. +Modifies the energy equation to provide two-phase energy (water + vapor/air). -.. _energy-two-phase-pk-spec: -.. admonition:: energy-two-phase-pk-spec +`"PK type`" = `"two-phase energy`" - INCLUDES: +.. _pk-two-phase-energy-spec: +.. admonition:: pk-two-phase-energy-spec - - ``[energy-pk-spec]`` See `Energy Base PK`_ + INCLUDES: + + - ``[energy-pk-spec]`` See `Energy Base PK`_ */ diff --git a/src/pks/energy/test/energy_test_class.cc b/src/pks/energy/test/energy_test_class.cc index 1051765ab..c2cd80029 100644 --- a/src/pks/energy/test/energy_test_class.cc +++ b/src/pks/energy/test/energy_test_class.cc @@ -38,7 +38,9 @@ EnergyTest::initialize() initialize_water_flux(); // finish checking state and create the state at the new timestep - if (!S0->CheckAllInitialized()) { std::cout << "DID NOT INITIALIZE THINGS!" << std::endl; } + if (!S0->CheckAllInitialized()) { + std::cout << "DID NOT INITIALIZE THINGS!" << std::endl; + } S1 = Teuchos::rcp(new State(*S0)); *S1 = *S0; EPK->set_states(S0, S0, S1); diff --git a/src/pks/flow/constitutive_relations/elevation/depth_evaluator.cc b/src/pks/flow/constitutive_relations/elevation/depth_evaluator.cc index b78a4c3e2..08958c5a5 100644 --- a/src/pks/flow/constitutive_relations/elevation/depth_evaluator.cc +++ b/src/pks/flow/constitutive_relations/elevation/depth_evaluator.cc @@ -14,7 +14,8 @@ namespace Amanzi { namespace Flow { -DepthEvaluator::DepthEvaluator(Teuchos::ParameterList& plist) : EvaluatorIndependentCV(plist) +DepthEvaluator::DepthEvaluator(Teuchos::ParameterList& plist) + : EvaluatorIndependentCV(plist) { algorithm_ = plist_.get("algorithm", "mean face centroid"); if (!(algorithm_ == "mean face centroid" || algorithm_ == "cell centroid")) { diff --git a/src/pks/flow/constitutive_relations/elevation/depth_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/depth_evaluator.hh index 2ba1849ed..2b24da139 100644 --- a/src/pks/flow/constitutive_relations/elevation/depth_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/depth_evaluator.hh @@ -23,8 +23,8 @@ assumption that dz is uniform (e.g. this is an extruded mesh). `"evaluator type`" = `"depth`" -.. _depth-evaluator-spec: -.. admonition:: depth-evaluator-spec +.. _evaluator-depth-spec: +.. admonition:: evaluator-depth-spec * `"algorithm`" ``[string]`` **mean face centroid** Valid is `"mean face centroid`" and `"cell centroid`", see above. diff --git a/src/pks/flow/constitutive_relations/elevation/depth_model.hh b/src/pks/flow/constitutive_relations/elevation/depth_model.hh index 3476b0db4..00948d590 100644 --- a/src/pks/flow/constitutive_relations/elevation/depth_model.hh +++ b/src/pks/flow/constitutive_relations/elevation/depth_model.hh @@ -22,11 +22,9 @@ namespace Amanzi { namespace Flow { -void -computeDepth_MeanFaceCentroid(const AmanziMesh::Mesh& mesh, Epetra_MultiVector& depth); +void computeDepth_MeanFaceCentroid(const AmanziMesh::Mesh& mesh, Epetra_MultiVector& depth); -void -computeDepth_CellCentroid(const AmanziMesh::Mesh& mesh, Epetra_MultiVector& depth); +void computeDepth_CellCentroid(const AmanziMesh::Mesh& mesh, Epetra_MultiVector& depth); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/elevation/effective_height_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/effective_height_evaluator.hh index 338527bbf..db0501747 100644 --- a/src/pks/flow/constitutive_relations/elevation/effective_height_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/effective_height_evaluator.hh @@ -6,13 +6,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -/* - Evaluator for determining effective_height(height), which is a smoothing - term near 0 height. - -*/ - /*! Computes ponded depth from surface water pressure using a smoothed term to make @@ -20,15 +13,16 @@ derivative smooth near 0. This is pretty much never used anymore. `"evaluator type`" = `"effective height`" -.. _effective-height-evaluator-spec: -.. admonition:: effective-height-evaluator-spec +.. _evaluator-effective-height-spec: +.. admonition:: evaluator-effective-height-spec - * `"smoothing width [m]`" ``[double]`` **0.01** the width over which smoothing - is applied. + * `"smoothing width [m]`" ``[double]`` **0.01** the length scale over which + smoothing is applied. KEYS: - `"height`" The unsmoothed ponded depth + */ #ifndef AMANZI_FLOW_RELATIONS_EFFECTIVE_HEIGHT_EVALUATOR_ #define AMANZI_FLOW_RELATIONS_EFFECTIVE_HEIGHT_EVALUATOR_ diff --git a/src/pks/flow/constitutive_relations/elevation/effective_height_evaluator_reg.hh b/src/pks/flow/constitutive_relations/elevation/effective_height_evaluator_reg.hh index 64457bbc8..cfde1f384 100644 --- a/src/pks/flow/constitutive_relations/elevation/effective_height_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/elevation/effective_height_evaluator_reg.hh @@ -20,8 +20,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - EffectiveHeightEvaluator::factory_("effective height"); +Utils::RegisteredFactory EffectiveHeightEvaluator::factory_( + "effective height"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/elevation/effective_height_model.hh b/src/pks/flow/constitutive_relations/elevation/effective_height_model.hh index 6346f48ff..2ab6b5e82 100644 --- a/src/pks/flow/constitutive_relations/elevation/effective_height_model.hh +++ b/src/pks/flow/constitutive_relations/elevation/effective_height_model.hh @@ -22,7 +22,8 @@ namespace Flow { class EffectiveHeightModel { public: - explicit EffectiveHeightModel(Teuchos::ParameterList& plist) : plist_(plist) + explicit EffectiveHeightModel(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPList_(); } diff --git a/src/pks/flow/constitutive_relations/elevation/elevation_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/elevation_evaluator.hh index e47c2a39a..f6262fe7c 100644 --- a/src/pks/flow/constitutive_relations/elevation/elevation_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/elevation_evaluator.hh @@ -40,8 +40,8 @@ class ElevationEvaluator : public EvaluatorSecondaryMonotypeCV { const Tag& wrt_tag, const std::vector& results) override; - virtual void - EvaluateElevationAndSlope_(const State& S, const std::vector& results) = 0; + virtual void EvaluateElevationAndSlope_(const State& S, + const std::vector& results) = 0; // // This is required to make sure that elevation, slope, and aspect share a @@ -53,6 +53,8 @@ class ElevationEvaluator : public EvaluatorSecondaryMonotypeCV { EnsureCompatibility_StructureSame_(S); } + // there are no requirements on the structure of the indicater dependency + virtual void EnsureCompatibility_ToDeps_(State& S) override {} protected: bool updated_once_; diff --git a/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column.cc b/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column.cc index ab1b7be69..3c58fad4f 100644 --- a/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column.cc +++ b/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column.cc @@ -38,7 +38,7 @@ ColumnElevationEvaluator::Clone() const void ColumnElevationEvaluator::EnsureEvaluators(State& S) { - Tag tag = Keys::readTag(plist_, my_keys_.front().second); + Tag tag = Keys::readTag(plist_, "", my_keys_.front().second); auto dset = S.GetDomainSet(dset_name_); for (const auto& domain : *dset) { dependencies_.insert(KeyTag{ Keys::getKey(domain, base_poro_suffix_), tag }); @@ -122,7 +122,7 @@ ColumnElevationEvaluator::EvaluateElevationAndSlope_(const State& S, AmanziGeometry::Point fnor = S.GetMesh(my_name)->getFaceNormal(0); //0 is the id of top face Nor_avg = (nface_pcell - Normal.size()) * fnor; - for (int i = 0; i < Normal.size(); i++) Nor_avg += Normal[i]; + for (int i = 0; i < Normal.size() ; i++) Nor_avg += Normal[i]; Nor_avg /= nface_pcell; slope_c[0][c] = @@ -144,7 +144,9 @@ ColumnElevationEvaluator::EvaluateElevationAndSlope_(const State& S, for (int f = 0; f != nfaces; ++f) { auto nadj_cellids = S.GetMesh(surface_domain_)->getFaceCells(f); double ef = 0; - for (int i = 0; i < nadj_cellids.size(); i++) { ef += elev_ngb_c[0][nadj_cellids[i]]; } + for (int i = 0; i < nadj_cellids.size(); i++) { + ef += elev_ngb_c[0][nadj_cellids[i]]; + } elev_f[0][f] = ef / nadj_cellids.size(); } } diff --git a/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column.hh b/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column.hh index 4c20640d9..c0e42e77b 100644 --- a/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column.hh +++ b/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column.hh @@ -31,8 +31,8 @@ Instead, it is a mix of: `"evaluator type`" = `"elevation column`" -.. _column-elevation-evaluator-spec: -.. admonition:: column-elevation-evaluator-spec +.. _evaluator-column-elevation-spec: +.. admonition:: evaluator-column-elevation-spec * `"elevation key`" ``[string]`` **elevation** Name the elevation variable. [m] * `"slope magnitude key`" ``[string]`` **slope_magnitude** Name the elevation @@ -71,8 +71,8 @@ class ColumnElevationEvaluator : public ElevationEvaluator { Teuchos::RCP Clone() const override; protected: - virtual void - EvaluateElevationAndSlope_(const State& S, const std::vector& results) override; + virtual void EvaluateElevationAndSlope_(const State& S, + const std::vector& results) override; // Custom EnsureCompatibility fills dependencies based on domain set. virtual void EnsureEvaluators(State& S) override; diff --git a/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column_reg.hh b/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column_reg.hh index 1db9ae092..ab43c19b8 100644 --- a/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column_reg.hh +++ b/src/pks/flow/constitutive_relations/elevation/elevation_evaluator_column_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - ColumnElevationEvaluator::reg_("column elevation"); +Utils::RegisteredFactory ColumnElevationEvaluator::reg_( + "column elevation"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/elevation/fractional_conductance_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/fractional_conductance_evaluator.hh index c38010304..1cf353e58 100644 --- a/src/pks/flow/constitutive_relations/elevation/fractional_conductance_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/fractional_conductance_evaluator.hh @@ -17,8 +17,8 @@ This implements the term, from Jan et al WRR 2018. -.. _fractional-conductance-evaluator-spec -.. admonition:: fractional-conductance-evaluator-spec +.. _evaluator-fractional-conductance-spec +.. admonition:: evaluator-fractional-conductance-spec DEPENDENCIES: - `"volumetric ponded depth`" **DOMAIN-volumetric_ponded_depth** diff --git a/src/pks/flow/constitutive_relations/elevation/height_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/height_evaluator.hh index 4ba1fe4d3..38c66d6f9 100644 --- a/src/pks/flow/constitutive_relations/elevation/height_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/height_evaluator.hh @@ -6,12 +6,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -/* - Evaluator for determining height( rho, head ) - -*/ - /*! Computes ponded depth from surface water pressure. @@ -23,13 +17,15 @@ where :math:`H` is the Heaviside function. `"evaluator type`" = `"ponded depth`" -.. _height-evaluator-spec: -.. admonition:: height-evaluator-spec +.. _evaluator-ponded-depth-spec: +.. admonition:: evaluator-ponded-depth-spec KEYS: - - `"mass density`" - `"pressure`" + - `"mass density`" + - `"atmospheric pressure`" + - `"gravity`" */ #ifndef AMANZI_FLOW_RELATIONS_HEIGHT_EVALUATOR_ diff --git a/src/pks/flow/constitutive_relations/elevation/height_model.hh b/src/pks/flow/constitutive_relations/elevation/height_model.hh index 76d8fc111..7cd3327fd 100644 --- a/src/pks/flow/constitutive_relations/elevation/height_model.hh +++ b/src/pks/flow/constitutive_relations/elevation/height_model.hh @@ -7,11 +7,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -/* - Evaluates height(pressure) - -*/ - #ifndef AMANZI_FLOWRELATIONS_HEIGHT_MODEL_ #define AMANZI_FLOWRELATIONS_HEIGHT_MODEL_ @@ -22,7 +17,9 @@ namespace Flow { class HeightModel { public: - explicit HeightModel(Teuchos::ParameterList& plist) : plist_(plist) {} + explicit HeightModel(Teuchos::ParameterList& plist) + : plist_(plist) + {} double Height(double pres, double rho, double p_atm, double g_z) { diff --git a/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator.cc b/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator.cc index 587f27ee4..7ecc74a0c 100644 --- a/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator.cc +++ b/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator.cc @@ -7,11 +7,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -/* - Evaluator for determining height( rho, head ) - -*/ - #include "icy_height_model.hh" #include "icy_height_evaluator.hh" @@ -20,7 +15,8 @@ namespace Amanzi { namespace Flow { -IcyHeightEvaluator::IcyHeightEvaluator(Teuchos::ParameterList& plist) : HeightEvaluator(plist) +IcyHeightEvaluator::IcyHeightEvaluator(Teuchos::ParameterList& plist) + : HeightEvaluator(plist) { Key domain = Keys::getDomain(my_keys_.front().first); Tag tag = my_keys_.front().second; diff --git a/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator.hh index e285c403f..9172e10de 100644 --- a/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator.hh @@ -6,9 +6,27 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - Evaluator for determining height( rho, head ) +Computes ponded depth from surface water pressure and an unfrozen fraction. + +.. math:: + + h = \frac{p - p_{atm}}{[\eta \rho_l + (1 - \eta) \rho_i] g} + +`"evaluator type`" = `"icy ponded depth`" + +.. _evaluator-icy-ponded-depth-spec: +.. admonition:: evaluator-icy-ponded-depth-spec + + KEYS: + + - `"pressure`" + - `"unfrozen fraction`" + - `"mass density liquid`" + - `"mass density ice`" + - `"atmospheric pressure`" + - `"gravity`" */ diff --git a/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator_reg.hh b/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator_reg.hh index 04800a772..1aaa8430d 100644 --- a/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/elevation/icy_height_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - IcyHeightEvaluator::factory_("icy ponded depth"); +Utils::RegisteredFactory IcyHeightEvaluator::factory_( + "icy ponded depth"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/elevation/icy_height_model.hh b/src/pks/flow/constitutive_relations/elevation/icy_height_model.hh index b0fd10758..f2f6b3e1e 100644 --- a/src/pks/flow/constitutive_relations/elevation/icy_height_model.hh +++ b/src/pks/flow/constitutive_relations/elevation/icy_height_model.hh @@ -7,11 +7,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -/* - Evaluates height(pressure) - -*/ - #ifndef AMANZI_FLOWRELATIONS_ICY_HEIGHT_MODEL_ #define AMANZI_FLOWRELATIONS_ICY_HEIGHT_MODEL_ @@ -22,15 +17,21 @@ namespace Flow { class IcyHeightModel { public: - explicit IcyHeightModel(Teuchos::ParameterList& plist) : plist_(plist) {} + explicit IcyHeightModel(Teuchos::ParameterList& plist) + : plist_(plist) + {} double Height(double pres, double eta, double rhol, double rhoi, double p_atm, double g_z) { return (pres - p_atm) / ((eta * rhol + (1. - eta) * rhoi) * g_z); } - double - DHeightDPressure(double pres, double eta, double rhol, double rhoi, double p_atm, double g_z) + double DHeightDPressure(double pres, + double eta, + double rhol, + double rhoi, + double p_atm, + double g_z) { return 1. / ((eta * rhol + (1. - eta) * rhoi) * g_z); } diff --git a/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator.cc b/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator.cc index 717bfc340..b29064654 100644 --- a/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator.cc +++ b/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator.cc @@ -72,7 +72,7 @@ slope_aspect(const AmanziGeometry::Point& normal, double& slope, double& aspect) MeshedElevationEvaluator::MeshedElevationEvaluator(Teuchos::ParameterList& plist) - : ElevationEvaluator(plist){}; + : ElevationEvaluator(plist) {}; Teuchos::RCP diff --git a/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator.hh index 66573aaab..01681ed49 100644 --- a/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator.hh @@ -14,8 +14,8 @@ Evaluates the z-coordinate and the magnitude of the slope :math:``|\nambla_h z|`` -.. _meshed-elevation-evaluator-spec: -.. admonition:: meshed-elevation-evaluator-spec +.. _evaluator-meshed-elevation-spec: +.. admonition:: evaluator-meshed-elevation-spec * `"parent domain name`" ``[string]`` **SUBSURFACE_DOMAIN** Domain name of the parent mesh, which is the 3D version of this domain. Attempts to generate an @@ -45,8 +45,7 @@ namespace Amanzi { namespace Flow { namespace Impl { -void -slope_aspect(const AmanziGeometry::Point& normal, double& slope, double& aspect); +void slope_aspect(const AmanziGeometry::Point& normal, double& slope, double& aspect); } @@ -56,8 +55,8 @@ class MeshedElevationEvaluator : public ElevationEvaluator { MeshedElevationEvaluator(const MeshedElevationEvaluator& other) = default; Teuchos::RCP Clone() const override; - virtual void - EvaluateElevationAndSlope_(const State& S, const std::vector& results) override; + virtual void EvaluateElevationAndSlope_(const State& S, + const std::vector& results) override; private: static Utils::RegisteredFactory reg_; diff --git a/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator_reg.hh b/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator_reg.hh index 7c62b0947..454f305b2 100644 --- a/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/elevation/meshed_elevation_evaluator_reg.hh @@ -14,8 +14,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - MeshedElevationEvaluator::reg_("meshed elevation"); +Utils::RegisteredFactory MeshedElevationEvaluator::reg_( + "meshed elevation"); Utils::RegisteredFactory StandaloneElevationEvaluator::reg_("standalone elevation"); diff --git a/src/pks/flow/constitutive_relations/elevation/pres_elev_evaluator.cc b/src/pks/flow/constitutive_relations/elevation/pres_elev_evaluator.cc deleted file mode 100644 index 76e40ec82..000000000 --- a/src/pks/flow/constitutive_relations/elevation/pres_elev_evaluator.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -/* - The elevation evaluator gets the surface elevation, slope, and updates pres + elev. - -*/ - -#include "pres_elev_evaluator.hh" - -namespace Amanzi { -namespace Flow { - -PresElevEvaluator::PresElevEvaluator(Teuchos::ParameterList& plist) - : EvaluatorSecondaryMonotypeCV(plist) -{ - Key domain = Keys::getDomain(my_keys_.front().first); - Tag tag = my_keys_.front().second; - - pres_key_ = Keys::readKey(plist_, domain, "ponded depth", "ponded_depth"); - dependencies_.insert(KeyTag{ pres_key_, tag }); - elev_key_ = Keys::readKey(plist_, domain, "elevation", "elevation"); - dependencies_.insert(KeyTag{ elev_key_, tag }); -} - - -Teuchos::RCP -PresElevEvaluator::Clone() const -{ - return Teuchos::rcp(new PresElevEvaluator(*this)); -} - - -void -PresElevEvaluator::Evaluate_(const State& S, const std::vector& result) -{ - Tag tag = my_keys_.front().second; - - // update pressure + elevation - Teuchos::RCP pres = S.GetPtr(pres_key_, tag); - Teuchos::RCP elev = S.GetPtr(elev_key_, tag); - result[0]->Update(1.0, *elev, 1.0, *pres, 0.0); -} - - -// This is hopefully never called? -void -PresElevEvaluator::EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, - const Tag& wrt_tag, - const std::vector& result) -{ - result[0]->PutScalar(1.0); -} - -} // namespace Flow -} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/elevation/pres_elev_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/pres_elev_evaluator.hh deleted file mode 100644 index c4b5572dc..000000000 --- a/src/pks/flow/constitutive_relations/elevation/pres_elev_evaluator.hh +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -//! Evaluates the potential surface upon which overland flow acts. -/*! - -.. math:: - h + z - -`"evaluator type`" = - -.. _pres-elev-evaluator-spec: -.. admonition:: pres-elev-evaluator-spec - - KEYS: - - - `"height`" **DOMAIN-ponded_depth** Names the height variable. [m] - - `"elevation`" **DOMAIN-elevation** Names the elevation variable. [m] - - -NOTE: This is a legacy evaluator, and is not in the factory, so need not be in -the input spec. However, we include it here because this could easily be -abstracted for new potential surfaces, kinematic wave, etc, at which point it -would need to be added to the factory and the input spec. - -NOTE: This could easily be replaced by a generic Additive_ Evaluator. - -*/ - -#ifndef AMANZI_FLOWRELATIONS_PRES_ELEV_EVALUATOR_ -#define AMANZI_FLOWRELATIONS_PRES_ELEV_EVALUATOR_ - -#include "EvaluatorSecondaryMonotype.hh" - -namespace Amanzi { -namespace Flow { - -class PresElevEvaluator : public EvaluatorSecondaryMonotypeCV { - public: - explicit PresElevEvaluator(Teuchos::ParameterList& plist); - PresElevEvaluator(const PresElevEvaluator& other) = default; - Teuchos::RCP Clone() const override; - - protected: - // Required methods from EvaluatorSecondaryMonotypeCV - virtual void Evaluate_(const State& S, const std::vector& result) override; - virtual void EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, - const Tag& wrt_tag, - const std::vector& result) override; - - private: - Key pres_key_; - Key elev_key_; -}; - -} // namespace Flow -} // namespace Amanzi - -#endif diff --git a/src/pks/flow/constitutive_relations/elevation/snow_skin_potential_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/snow_skin_potential_evaluator.hh index a49240b51..cc9bcbd21 100644 --- a/src/pks/flow/constitutive_relations/elevation/snow_skin_potential_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/snow_skin_potential_evaluator.hh @@ -19,8 +19,8 @@ snow precip, so defines what we mean by low-lying. `"evaluator type`" = `"snow skin potential`" -.. _snow-skin-potential-evaluator-spec: -.. admonition:: snow-skin-potential-evaluator-spec +.. _evaluator-snow-skin-potential-spec: +.. admonition:: evaluator-snow-skin-potential-spec * `"dt factor [s]`" ``[double]`` A free-parameter factor for providing a time scale for diffusion of snow precipitation into low-lying areas. diff --git a/src/pks/flow/constitutive_relations/elevation/standalone_elevation_evaluator.cc b/src/pks/flow/constitutive_relations/elevation/standalone_elevation_evaluator.cc index 8fcb9433b..e9524281a 100644 --- a/src/pks/flow/constitutive_relations/elevation/standalone_elevation_evaluator.cc +++ b/src/pks/flow/constitutive_relations/elevation/standalone_elevation_evaluator.cc @@ -66,7 +66,7 @@ StandaloneElevationEvaluator::EvaluateElevationAndSlope_( // Evaluate the functions. elevation_function_->Compute(S.get_time(), elev); slope_function_->Compute(S.get_time(), slope); - if (aspect_function_.get()) aspect_function_->Compute(S.get_time(), aspect); + if (aspect_function_.get() ) aspect_function_->Compute(S.get_time(), aspect); }; diff --git a/src/pks/flow/constitutive_relations/elevation/standalone_elevation_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/standalone_elevation_evaluator.hh index fc59cc34d..ff40bb40c 100644 --- a/src/pks/flow/constitutive_relations/elevation/standalone_elevation_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/standalone_elevation_evaluator.hh @@ -29,8 +29,8 @@ class StandaloneElevationEvaluator : public ElevationEvaluator { Teuchos::RCP Clone() const override; protected: - virtual void - EvaluateElevationAndSlope_(const State& S, const std::vector& results) override; + virtual void EvaluateElevationAndSlope_(const State& S, + const std::vector& results) override; protected: Teuchos::RCP elevation_function_; diff --git a/src/pks/flow/constitutive_relations/elevation/water_level_evaluator.cc b/src/pks/flow/constitutive_relations/elevation/water_level_evaluator.cc index 24f215ca7..7adb8509d 100644 --- a/src/pks/flow/constitutive_relations/elevation/water_level_evaluator.cc +++ b/src/pks/flow/constitutive_relations/elevation/water_level_evaluator.cc @@ -9,7 +9,7 @@ */ /* - Evaluator for determining water level, a combined variable of + Evaluator for determining water level, a combined variable of water table and ponded depth. */ @@ -101,10 +101,8 @@ WaterLevelEvaluator::Evaluate_(const State& S, const std::vector 0.) - res_c[0][sc] = -val[1] / cv_surf_c[0][sc] * val[0]; - else - res_c[0][sc] = -1. / cv_surf_c[0][sc] * val[0]; + if (val[1] > 0.) res_c[0][sc] = -val[1] / cv_surf_c[0][sc] * val[0]; + else res_c[0][sc] = -1. / cv_surf_c[0][sc] * val[0]; } else { // ponded depth res_c[0][sc] = model_->Height(pres_c[0][sc], rho[0][sc], p_atm, gz); diff --git a/src/pks/flow/constitutive_relations/elevation/water_level_evaluator.hh b/src/pks/flow/constitutive_relations/elevation/water_level_evaluator.hh index f77f7175a..b2b533e12 100644 --- a/src/pks/flow/constitutive_relations/elevation/water_level_evaluator.hh +++ b/src/pks/flow/constitutive_relations/elevation/water_level_evaluator.hh @@ -28,8 +28,8 @@ Computes water table by looping through cells in the column until saturation of `"evaluator type`" = `"ponded depth`" -.. _height-evaluator-spec: -.. admonition:: height-evaluator-spec +.. _evaluator-height-spec: +.. admonition:: evaluator-height-spec KEYS: diff --git a/src/pks/flow/constitutive_relations/elevation/water_level_evaluator_reg.hh b/src/pks/flow/constitutive_relations/elevation/water_level_evaluator_reg.hh index 0dc9d8796..d5530b304 100644 --- a/src/pks/flow/constitutive_relations/elevation/water_level_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/elevation/water_level_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - WaterLevelEvaluator::factory_("water level"); +Utils::RegisteredFactory WaterLevelEvaluator::factory_( + "water level"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_constant_model.hh b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_constant_model.hh index 86a065805..651f7c65f 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_constant_model.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_constant_model.hh @@ -7,10 +7,16 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -/* - The manning coefficient with variable litter model is an algebraic model with dependencies. +/*! + +A constant Manning's n + +`"Manning coefficient model type`" = `"constant`" + +.. manning-coefficient-constant-spec: +.. admonition:: manning-coefficient-constant-spec - Constant values. + * `"Manning coefficient [s m^-1/3]`" ``[double]`` */ @@ -27,7 +33,7 @@ class ManningCoefficientLitterConstantModel : public ManningCoefficientLitterMod public: ManningCoefficientLitterConstantModel(Teuchos::ParameterList& plist) { - n_ = plist.get("manning coefficient [s m^-1/3]"); + n_ = plist.get("Manning coefficient [s m^-1/3]"); } diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator.cc b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator.cc index b2209268e..fda24bf1e 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator.cc +++ b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator.cc @@ -26,7 +26,7 @@ namespace Relations { ManningCoefficientLitterEvaluator::ManningCoefficientLitterEvaluator(Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(plist) { - Teuchos::ParameterList& sublist = plist_.sublist("manning coefficient parameters"); + Teuchos::ParameterList& sublist = plist_.sublist("Manning coefficient parameters"); models_ = createManningCoefPartition(sublist); InitializeFromPlist_(); } @@ -209,7 +209,7 @@ createManningCoefPartition(Teuchos::ParameterList& plist) Teuchos::ParameterList sublist = plist.sublist(name); region_list.push_back(sublist.get("region")); - std::string coef_type = sublist.get("manning coefficient model type"); + std::string coef_type = sublist.get("Manning coefficient model type"); if (coef_type == "constant") { models.push_back(Teuchos::rcp(new ManningCoefficientLitterConstantModel(sublist))); } else if (coef_type == "variable") { diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator.hh b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator.hh index 4cafcb66c..a49388b7a 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator.hh @@ -6,18 +6,21 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - The manning coefficient with variable litter evaluator is an algebraic evaluator of a given model. - - Generated via evaluator_generator with: Manning's coefficient that varies based on litter thickness and ponded depth. -*/ +`"evaluator type`" = `"Manning coefficient, litter`" -/*! +.. evaluator-manning-coefficient-litter-spec: +.. admonition:: evaluator-manning-coefficient-litter-spec + + * `"Manning coefficient parameters`" ``[manning-coefficient-typedinline-spec-list]`` + + DEPENDENCIES: -(missing documentation!) + - `"litter thickness`" + - `"ponded depth`" */ #ifndef AMANZI_FLOW_MANNING_COEFFICIENT_LITTER_EVALUATOR_HH_ @@ -67,8 +70,7 @@ class ManningCoefficientLitterEvaluator : public EvaluatorSecondaryMonotypeCV { // Non-member factory -Teuchos::RCP -createManningCoefPartition(Teuchos::ParameterList& plist); +Teuchos::RCP createManningCoefPartition(Teuchos::ParameterList& plist); } // namespace Relations diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator_reg.hh b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator_reg.hh index 105373cd2..828929083 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_evaluator_reg.hh @@ -14,7 +14,7 @@ namespace Flow { namespace Relations { Utils::RegisteredFactory - ManningCoefficientLitterEvaluator::reg_("manning coefficient with litter"); + ManningCoefficientLitterEvaluator::reg_("Manning coefficient, litter"); } // namespace Relations } // namespace Flow diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_model.hh b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_model.hh index c4cfb83c7..8aae08f21 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_model.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_model.hh @@ -28,11 +28,11 @@ class ManningCoefficientLitterModel { virtual double ManningCoefficient(double litter_depth, double ponded_depth) const = 0; - virtual double - DManningCoefficientDLitterThickness(double litter_depth, double ponded_depth) const = 0; + virtual double DManningCoefficientDLitterThickness(double litter_depth, + double ponded_depth) const = 0; - virtual double - DManningCoefficientDPondedDepth(double litter_depth, double ponded_depth) const = 0; + virtual double DManningCoefficientDPondedDepth(double litter_depth, + double ponded_depth) const = 0; }; } // namespace Relations diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_variable_model.hh b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_variable_model.hh index 8f348fe79..f7783fcfb 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_variable_model.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/manning_coefficient_litter_variable_model.hh @@ -7,10 +7,20 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -/* - The manning coefficient with variable litter model is an algebraic model with dependencies. +/*! + +A Manning coefficient with variable litter thickness. Manning's n is taken to +vary with litter depth. If ponded depth is less than the litter depth, then n +is given by litter n. If ponded depth is greater than litter depth, it is +approaches bare ground n for ponded depth >> litter depth. + +`"Manning coefficient model type`" = `"variable`" - Constant values. +.. manning-coefficient-variable-spec: +.. admonition:: manning-coefficient-variable-spec + + * `"Manning coefficient bare ground [s m^-1/3]`" ``[double]`` **0.02** + * `"Manning coefficient litter [s m^-1/3]`" ``[double]`` **0.1** */ @@ -27,8 +37,8 @@ class ManningCoefficientLitterVariableModel : public ManningCoefficientLitterMod public: ManningCoefficientLitterVariableModel(Teuchos::ParameterList& plist) { - n_bg_ = plist.get("manning coefficient bare ground [s * m^-1/3]", 0.02); - n_l_ = plist.get("manning coefficient litter [s * m^-1/3]", 0.1); + n_bg_ = plist.get("Manning coefficient bare ground [s m^-1/3]", 0.02); + n_l_ = plist.get("Manning coefficient litter [s m^-1/3]", 0.1); } @@ -57,7 +67,9 @@ class ManningCoefficientLitterVariableModel : public ManningCoefficientLitterMod { double n = 0.; - if (pd > 0 && pd > ld) { n = n_l_ / pd - n_bg_ / pd; } + if (pd > 0 && pd > ld) { + n = n_l_ / pd - n_bg_ / pd; + } return n; } @@ -65,7 +77,9 @@ class ManningCoefficientLitterVariableModel : public ManningCoefficientLitterMod double DManningCoefficientDPondedDepth(double ld, double pd) const { double n = 0.; - if (pd > 0 && pd > ld) { n = n_bg_ / pd - (ld * n_l_ + n_bg_ * (-ld + pd)) / std::pow(pd, 2); } + if (pd > 0 && pd > ld) { + n = n_bg_ / pd - (ld * n_l_ + n_bg_ * (-ld + pd)) / std::pow(pd, 2); + } return n; } diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/manning_conductivity_model.cc b/src/pks/flow/constitutive_relations/overland_conductivity/manning_conductivity_model.cc index 890ab09e7..736c98783 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/manning_conductivity_model.cc +++ b/src/pks/flow/constitutive_relations/overland_conductivity/manning_conductivity_model.cc @@ -10,7 +10,6 @@ /* Evaluates the conductivity of surface flow as a function of ponded depth and surface slope using Manning's model. - */ #include "manning_conductivity_model.hh" @@ -21,7 +20,7 @@ namespace Flow { ManningConductivityModel::ManningConductivityModel(Teuchos::ParameterList& plist) { slope_regularization_ = plist.get("slope regularization epsilon", 1.e-8); - manning_exp_ = plist.get("Manning exponent"); + manning_exp_ = plist.get("Manning exponent", 2. / 3); depth_max_ = plist.get("maximum ponded depth [m]", 1.e8); } diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/manning_conductivity_model.hh b/src/pks/flow/constitutive_relations/overland_conductivity/manning_conductivity_model.hh index b9b4b759d..5a859ff23 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/manning_conductivity_model.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/manning_conductivity_model.hh @@ -6,12 +6,22 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -/* - Evaluates the conductivity of surface flow as a function of ponded - depth and surface slope using Manning's model. - -*/ +/*! + +.. _overland-conductivity-manning-spec: +.. admonition:: overland-conductivity-manning-spec + + * `"Manning exponent`" ``[double]`` **2/3** + * `"slope regularization epsilon`" ``[double]`` **1.e-8** In ATS's + implementation of the diffusion wave equation, it is expected that |S| > + 0. This may be arbitrarily small, but it keeps slope from being exactly + 0, which crashes the code. + * `"maximum ponded depth [m]`" ``[double]`` **1.e8** Arbitrarily large + ponded depth creates arbitrarily large flowing velocities -- sometimes we + wish to use this model (even though it is incorrect) for larger rivers. + This limits the velocity from being unbounded. + + */ #ifndef AMANZI_FLOWRELATIONS_MANNING_CONDUCTIVITY_MODEL_ #define AMANZI_FLOWRELATIONS_MANNING_CONDUCTIVITY_MODEL_ diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/one_surface_relperm_model_reg.hh b/src/pks/flow/constitutive_relations/overland_conductivity/one_surface_relperm_model_reg.hh index 18443072e..ae2ac92f5 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/one_surface_relperm_model_reg.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/one_surface_relperm_model_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - OneSurfaceRelPermModel::reg_("one surface rel perm"); +Utils::RegisteredFactory OneSurfaceRelPermModel::reg_( + "one surface rel perm"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/one_uf_relperm_model.cc b/src/pks/flow/constitutive_relations/overland_conductivity/one_uf_relperm_model.cc index 884057756..f45bd2069 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/one_uf_relperm_model.cc +++ b/src/pks/flow/constitutive_relations/overland_conductivity/one_uf_relperm_model.cc @@ -21,7 +21,8 @@ namespace Amanzi { namespace Flow { -OneUFRelPermModel::OneUFRelPermModel(Teuchos::ParameterList& plist) : plist_(plist), pi_(M_PI) +OneUFRelPermModel::OneUFRelPermModel(Teuchos::ParameterList& plist) + : plist_(plist), pi_(M_PI) { alpha_ = plist_.get("unfrozen rel perm alpha", 4); if (alpha_ % 2 != 0) { diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/one_uf_relperm_model_reg.hh b/src/pks/flow/constitutive_relations/overland_conductivity/one_uf_relperm_model_reg.hh index 06a08ca3f..a251f7e37 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/one_uf_relperm_model_reg.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/one_uf_relperm_model_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - OneUFRelPermModel::reg_("unfrozen fraction rel perm, limit one"); +Utils::RegisteredFactory OneUFRelPermModel::reg_( + "unfrozen fraction rel perm, limit one"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_evaluator.cc b/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_evaluator.cc index 818081d91..ee3fe50d3 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_evaluator.cc +++ b/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_evaluator.cc @@ -177,7 +177,9 @@ OverlandConductivityEvaluator::EvaluatePartialDerivative_( if (dens_) { const Epetra_MultiVector& dens_v = *S.Get(dens_key_, tag).ViewComponent(comp, false); - for (int i = 0; i != ncomp; ++i) { result_v[0][i] *= dens_v[0][i]; } + for (int i = 0; i != ncomp; ++i) { + result_v[0][i] *= dens_v[0][i]; + } } } diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_evaluator.hh b/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_evaluator.hh index 6dbc86a89..f71a9da2f 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_evaluator.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_evaluator.hh @@ -6,15 +6,14 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Evaluates the conductivity of surface flow. /*! -This implements the conductivity of overland flow, which is the nonlinear +This implements the conductivity term in overland flow, which is the nonlinear coefficient in the diffusion wave equation. The term is given by: -.. math: - k = \frac{\delta^{coef}}{n_{mann} \sqrt(| \nabla z |)} +.. math:: + + k = \delta \frac{\delta^{\alpha}}{n_{mann} \sqrt(| \nabla z |)} Optionally, this may include a density factor, typically a molar density, which converts the flow law to water flux rather than volumetric flux. @@ -24,23 +23,25 @@ some extra factors (timestep size) to ensure the correct flow law in that case. `"evaluator type`" = `"overland conductivity`" -.. _overland-conductivity-evaluator-spec: -.. admonition:: overland-conductivity-evaluator-spec +.. _evaluator-overland-conductivity-spec: +.. admonition:: evaluator-overland-conductivity-spec * `"include density`" ``[bool]`` **true** Include the density prefactor, converting the flux from volumetric flux to water flux. * `"dt factor [s]`" ``[double]`` **-1** The artificial timestep size used in calculating - snow redistribution, only used in that case. - * `"swe density factor [-]`" ``[double]`` **10** Ratio of water to snow density. + snow redistribution, only used in that case. + * `"swe density factor [-]`" ``[double]`` **10** Ratio of water to snow + density. Also only used in the snow distribution case. + * `"overland conductivity model`" ``[overland-conductivity-manning-spec]`` DEPENDENCIES: - - `"mobile depth`" **DOMAIN-mobile_depth** Depth of the mobile water; delta + - `"mobile depth`" **DOMAIN-mobile_depth** Depth of the mobile water; :math:`\delta` in the above equation. - `"slope`" **DOMAIN-slope_magnitude** Magnitude of the bed surface driving - flow; | \nabla z | above. + flow; :math:`| \nabla z |` above. - `"coefficient`" **DOMAIN-manning_coefficient** Surface roughness/shape - coefficient; n_{mann} above. + coefficient; :math:`n_{mann}` above. - `"molar density liquid`" **DOMAIN-molar_density_liquid** If `"include density`" is true, the density. diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_model.hh b/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_model.hh index e56fead06..1fe5031e3 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_model.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_model.hh @@ -27,13 +27,21 @@ class OverlandConductivityModel { virtual double DConductivityDDepth(double depth, double slope, double coef) = 0; //Add for the subgrid model -- Not pure virtual - virtual double - Conductivity(double depth, double slope, double coef, double d, double frac, double beta) + virtual double Conductivity(double depth, + double slope, + double coef, + double d, + double frac, + double beta) { return Conductivity(depth, slope, coef); } - virtual double - DConductivityDDepth(double depth, double slope, double coef, double p, double frac, double beta) + virtual double DConductivityDDepth(double depth, + double slope, + double coef, + double p, + double frac, + double beta) { return DConductivityDDepth(depth, slope, coef); } diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_subgrid_evaluator.hh b/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_subgrid_evaluator.hh index a3fc03202..f5fa7322c 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_subgrid_evaluator.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/overland_conductivity_subgrid_evaluator.hh @@ -21,8 +21,8 @@ diffusion wave equation. The term is given by: This includes a density factor, typically a molar density, which converts the flow law to water flux rather than volumetric flux. -.. _overland-conductivity-subgrid-evaluator-spec -.. admonition:: overland-conductivity-subgrid-evaluator-spec +.. _evaluator-overland-conductivity-subgrid-spec +.. admonition:: evaluator-overland-conductivity-subgrid-spec DEPENDENCIES: - `"mobile depth`" **DOMAIN-mobile_depth** Depth of the mobile water; delta diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_evaluator.cc b/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_evaluator.cc index b028604e5..ea6fa58e4 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_evaluator.cc +++ b/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_evaluator.cc @@ -57,7 +57,7 @@ SurfaceRelPermEvaluator::Evaluate_(const State& S, const std::vector uf = S.GetPtr(uf_key_, tag); Teuchos::RCP h = S.GetPtr(h_key_, tag); - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& uf_v = *uf->ViewComponent(*comp, false); const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); @@ -72,13 +72,15 @@ SurfaceRelPermEvaluator::Evaluate_(const State& S, const std::vector h = S.GetPtr(h_key_, tag); - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& h_v = *h->ViewComponent(*comp, false); Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp, false); int ncomp = result[0]->size(*comp, false); - for (int i = 0; i != ncomp; ++i) { result_v[0][i] = model_->SurfaceRelPerm(0., h_v[0][i]); } + for (int i = 0; i != ncomp; ++i) { + result_v[0][i] = model_->SurfaceRelPerm(0., h_v[0][i]); + } } } } diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_evaluator_reg.hh b/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_evaluator_reg.hh index 2d89523bc..5894eb033 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_evaluator_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - SurfaceRelPermEvaluator::fac_("surface rel perm"); +Utils::RegisteredFactory SurfaceRelPermEvaluator::fac_( + "surface rel perm"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_model_factory.cc b/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_model_factory.cc index ca516bb11..56f906abe 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_model_factory.cc +++ b/src/pks/flow/constitutive_relations/overland_conductivity/surface_relperm_model_factory.cc @@ -18,7 +18,7 @@ #include "surface_relperm_model_factory.hh" // explicity instantitate the static data of Factory -template <> +template<> Amanzi::Utils::Factory::map_type* Amanzi::Utils::Factory::map_; diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_effective_depth_evaluator.hh b/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_effective_depth_evaluator.hh index 1ec1a3d65..a34815e27 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_effective_depth_evaluator.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_effective_depth_evaluator.hh @@ -6,29 +6,29 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Evaluates the unfrozen mobile depth. /*! In freezing conditions, water is only mobile if it is unfrozen. This evaluator determines how much water is allowed to flow given that it is partially frozen. +It is an empirical model. -.. math: +.. math:: - \delta_{mobile} = \delta \chi^{\alpha} + \delta_{mobile} = h \eta^{\alpha} Given a ponded depth, an unfrozen fraction, and an optional power-law exponent, which we call the ice retardation exponent. -.. _unfrozen-effective-depth-evaluator-spec: -.. admonition:: unfrozen-effective-depth-evaluator-spec +.. _evaluator-unfrozen-effective-depth-spec: +.. admonition:: evaluator-unfrozen-effective-depth-spec + + * `"ice retardation exponent [-]`" ``[double]`` **1.0** exponent alpha + controlling how quickly ice turns off flow. - * `"ice retardation exponent [-]`" ``[double]`` **1.0** exponent alpha - controlling how quickly ice turns off flow. + DEPENDENCIES: - DEPENDENCIES: - - `"depth`" **DOMAIN-depth** - - `"unfrozen fraction`" **DOMAIN-unfrozen_fraction** + - `"depth`" + - `"unfrozen fraction`" */ diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator.cc b/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator.cc index 6c89e9416..212c2f74c 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator.cc +++ b/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator.cc @@ -53,7 +53,9 @@ UnfrozenFractionEvaluator::Evaluate_(const State& S, const std::vectorViewComponent(*comp, false); int ncomp = result[0]->size(*comp, false); - for (int i = 0; i != ncomp; ++i) { result_v[0][i] = model_->UnfrozenFraction(temp_v[0][i]); } + for (int i = 0; i != ncomp; ++i) { + result_v[0][i] = model_->UnfrozenFraction(temp_v[0][i]); + } } } @@ -73,7 +75,9 @@ UnfrozenFractionEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp, false); int ncomp = result[0]->size(*comp, false); - for (int i = 0; i != ncomp; ++i) { result_v[0][i] = model_->DUnfrozenFractionDT(temp_v[0][i]); } + for (int i = 0; i != ncomp; ++i) { + result_v[0][i] = model_->DUnfrozenFractionDT(temp_v[0][i]); + } } } diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator.hh b/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator.hh index 8404bbfec..942c41074 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator.hh @@ -18,8 +18,8 @@ sinusoidal curve from 0 to 1 over a given transition in temperature. `"evaluator type`" = `"unfrozen fraction`" -.. _unfrozen-fraction-evaluator-spec: -.. admonition:: unfrozen-fraction-evaluator-spec +.. _evaluator-unfrozen-fraction-spec: +.. admonition:: evaluator-unfrozen-fraction-spec * `"unfrozen fraction model`" ``[unfrozen-fraction-model-spec]`` diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator_reg.hh b/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator_reg.hh index 75fa76da3..09c041e99 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/unfrozen_fraction_evaluator_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - UnfrozenFractionEvaluator::fac_("unfrozen fraction"); +Utils::RegisteredFactory UnfrozenFractionEvaluator::fac_( + "unfrozen fraction"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/zero_uf_relperm_model.cc b/src/pks/flow/constitutive_relations/overland_conductivity/zero_uf_relperm_model.cc index 7e2b10add..ad39f907d 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/zero_uf_relperm_model.cc +++ b/src/pks/flow/constitutive_relations/overland_conductivity/zero_uf_relperm_model.cc @@ -21,7 +21,8 @@ namespace Amanzi { namespace Flow { -ZeroUFRelPermModel::ZeroUFRelPermModel(Teuchos::ParameterList& plist) : plist_(plist), pi_(M_PI) +ZeroUFRelPermModel::ZeroUFRelPermModel(Teuchos::ParameterList& plist) + : plist_(plist), pi_(M_PI) { alpha_ = plist_.get("unfrozen rel perm alpha", 4); if (alpha_ % 2 != 0) { diff --git a/src/pks/flow/constitutive_relations/overland_conductivity/zero_uf_relperm_model_reg.hh b/src/pks/flow/constitutive_relations/overland_conductivity/zero_uf_relperm_model_reg.hh index 6af51052c..d3fd8cf13 100644 --- a/src/pks/flow/constitutive_relations/overland_conductivity/zero_uf_relperm_model_reg.hh +++ b/src/pks/flow/constitutive_relations/overland_conductivity/zero_uf_relperm_model_reg.hh @@ -18,8 +18,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - ZeroUFRelPermModel::reg_("unfrozen fraction rel perm, limit zero"); +Utils::RegisteredFactory ZeroUFRelPermModel::reg_( + "unfrozen fraction rel perm, limit zero"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_evaluator.cc b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_evaluator.cc index 2051400b8..c990ceb9b 100644 --- a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_evaluator.cc +++ b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_evaluator.cc @@ -23,10 +23,10 @@ CompressiblePorosityEvaluator::CompressiblePorosityEvaluator(Teuchos::ParameterL { std::string domain_name = Keys::getDomain(my_keys_.front().first); Tag tag = my_keys_.front().second; - pres_key_ = Keys::readKey(plist_, domain_name, "pressure key", "pressure"); + pres_key_ = Keys::readKey(plist_, domain_name, "pressure", "pressure"); dependencies_.insert(KeyTag{ pres_key_, tag }); - poro_key_ = Keys::readKey(plist_, domain_name, "base porosity key", "base_porosity"); + poro_key_ = Keys::readKey(plist_, domain_name, "base porosity", "base_porosity"); dependencies_.insert(KeyTag{ poro_key_, tag }); AMANZI_ASSERT(plist_.isSublist("compressible porosity model parameters")); @@ -95,7 +95,7 @@ CompressiblePorosityEvaluator::EvaluatePartialDerivative_( if (wrt_key == pres_key_) { // evaluate the model - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { AMANZI_ASSERT( *comp == @@ -113,7 +113,7 @@ CompressiblePorosityEvaluator::EvaluatePartialDerivative_( } else if (wrt_key == poro_key_) { // evaluate the model - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { AMANZI_ASSERT( *comp == diff --git a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_evaluator.hh b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_evaluator.hh index 9a97fb404..50d9b52a2 100644 --- a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_evaluator.hh +++ b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_evaluator.hh @@ -24,8 +24,8 @@ converge. `"evaluator type`" = `"compressible porosity`" -.. _compressible-porosity-evaluator-spec: -.. admonition:: compressible-porosity-evaluator-spec +.. _evaluator-compressible-porosity-spec: +.. admonition:: evaluator-compressible-porosity-spec * `"compressible porosity model parameters`" ``[compressible-porosity-standard-model-spec-list]`` diff --git a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator.cc b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator.cc index 6aaa48c3c..bfae8df64 100644 --- a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator.cc +++ b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator.cc @@ -97,7 +97,7 @@ CompressiblePorosityLeijnseEvaluator::EvaluatePartialDerivative_( if (wrt_key == pres_key_) { // evaluate the model - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { AMANZI_ASSERT( *comp == @@ -115,7 +115,7 @@ CompressiblePorosityLeijnseEvaluator::EvaluatePartialDerivative_( } else if (wrt_key == poro_key_) { // evaluate the model - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { AMANZI_ASSERT( *comp == diff --git a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator.hh b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator.hh index 58318c9cd..afc3a0162 100644 --- a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator.hh +++ b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator.hh @@ -16,8 +16,8 @@ converge. After Leijnse thesis, 1992. `"evaluator type`" = `"compressible porosity leijnse`" -.. _compressible-porosity-leijnse-evaluator-spec -.. admonition:: compressible-porosity-leijnse-evaluator-spec +.. _evaluator-compressible-porosity-leijnse-spec +.. admonition:: evaluator-compressible-porosity-leijnse-spec * `"compressible porosity model parameters`" ``[compressible-porosity-leijnse-model-spec]`` diff --git a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator_reg.hh b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator_reg.hh index 886380f83..da8455758 100644 --- a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_evaluator_reg.hh @@ -19,7 +19,7 @@ namespace Flow { // registry of method Utils::RegisteredFactory - CompressiblePorosityLeijnseEvaluator::fac_("compressible porosity leijnse"); + CompressiblePorosityLeijnseEvaluator::fac_("compressible porosity, Leijnse"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_model.hh b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_model.hh index 2d8745afd..944f807a2 100644 --- a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_model.hh +++ b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_leijnse_model.hh @@ -50,7 +50,8 @@ namespace Flow { class CompressiblePorosityLeijnseModel { public: - explicit CompressiblePorosityLeijnseModel(Teuchos::ParameterList& plist) : plist_(plist) + explicit CompressiblePorosityLeijnseModel(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); } diff --git a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_model.hh b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_model.hh index a3b1f5e55..102dcd4c0 100644 --- a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_model.hh +++ b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_model.hh @@ -55,7 +55,8 @@ namespace Flow { class CompressiblePorosityModel { public: - explicit CompressiblePorosityModel(Teuchos::ParameterList& plist) : plist_(plist) + explicit CompressiblePorosityModel(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); } @@ -70,10 +71,8 @@ class CompressiblePorosityModel { poro = base_poro + compressibility_ * (std::pow(p_over, 2.) / 2. / cutoff_); } - if (max_is_one_) - return poro > 1. ? 1. : poro; - else - return poro; + if (max_is_one_) return poro > 1. ? 1. : poro; + else return poro; } double DPorosityDPressure(double base_poro, double pres, double patm) @@ -93,10 +92,8 @@ class CompressiblePorosityModel { double DPorosityDBasePorosity(double base_poro, double pres, double patm) { - if (max_is_one_) - return pres > patm ? (Porosity(base_poro, pres, patm) > 1.0 ? 0. : 1.) : 1.; - else - return 1; + if (max_is_one_) return pres > patm ? (Porosity(base_poro, pres, patm) > 1.0 ? 0. : 1.) : 1.; + else return 1; } protected: diff --git a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_model_partition.hh b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_model_partition.hh index 5c4fcb481..61cc8886e 100644 --- a/src/pks/flow/constitutive_relations/porosity/compressible_porosity_model_partition.hh +++ b/src/pks/flow/constitutive_relations/porosity/compressible_porosity_model_partition.hh @@ -25,8 +25,8 @@ typedef std::pair, CompressiblePorosityMo CompressiblePorosityModelPartition; // Non-member factory -Teuchos::RCP -createCompressiblePorosityModelPartition(Teuchos::ParameterList& plist); +Teuchos::RCP createCompressiblePorosityModelPartition( + Teuchos::ParameterList& plist); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/distributed_tiles_evaluator.cc b/src/pks/flow/constitutive_relations/sources/distributed_tiles_evaluator.cc index 31b50ef41..b875d9003 100644 --- a/src/pks/flow/constitutive_relations/sources/distributed_tiles_evaluator.cc +++ b/src/pks/flow/constitutive_relations/sources/distributed_tiles_evaluator.cc @@ -162,7 +162,9 @@ DistributedTilesRateEvaluator::Update_(State& S) } total = 0.; - for (AmanziMesh::Entity_ID c = 0; c != ncells; ++c) { total += sub_sink[0][c] * cv[0][c]; } + for (AmanziMesh::Entity_ID c = 0; c != ncells; ++c) { + total += sub_sink[0][c] * cv[0][c]; + } Teuchos::RCP comm_p = S.GetMesh(domain_)->getComm(); Teuchos::RCP mpi_comm_p = @@ -183,7 +185,9 @@ DistributedTilesRateEvaluator::EnsureCompatibility(State& S) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // Cop-out -- ensure not fully implemented for this evaluator. FIXME --ETC - for (const auto& dep : dependencies_) { S.RequireEvaluator(dep.first, dep.second); } + for (const auto& dep : dependencies_) { + S.RequireEvaluator(dep.first, dep.second); + } } diff --git a/src/pks/flow/constitutive_relations/sources/distributed_tiles_evaluator.hh b/src/pks/flow/constitutive_relations/sources/distributed_tiles_evaluator.hh index 665c2ab41..7848639bb 100644 --- a/src/pks/flow/constitutive_relations/sources/distributed_tiles_evaluator.hh +++ b/src/pks/flow/constitutive_relations/sources/distributed_tiles_evaluator.hh @@ -12,6 +12,8 @@ Distributed, subsurface sources due to tile drains. +`"evaluator type"` = `"distributed tiles"` + .. _distributed-tiles-spec: .. admonition:: distributed-tiles-spec @@ -57,14 +59,15 @@ class DistributedTilesRateEvaluator : public EvaluatorSecondary { virtual void EnsureCompatibility(State& S) override; // derivatives aren't implemented here - bool IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override { + bool IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override + { return false; } protected: // Required methods from EvaluatorSecondary virtual void Update_(State& S) override; - virtual void UpdateDerivative_(State& S, const Key& wrt_key, const Tag& wrt_tag) override{}; + virtual void UpdateDerivative_(State& S, const Key& wrt_key, const Tag& wrt_tag) override {}; protected: Key domain_; diff --git a/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator.cc b/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator.cc new file mode 100644 index 000000000..86325c2ad --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator.cc @@ -0,0 +1,106 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon (coonet@ornl.gov) +*/ + +#include "Epetra_Import.h" +#include "Epetra_Export.h" +#include "impervious_interception_evaluator.hh" + +namespace Amanzi { +namespace Flow { +namespace Relations { + + +ImperviousInterceptionEvaluator::ImperviousInterceptionEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) +{ + auto domain = Keys::getDomain(my_keys_.front().first); + Tag tag = my_keys_.front().second; + + // dependencies + imp_frac_key_ = Keys::readKey(plist, domain, "impervious fraction", "impervious_fraction"); + dependencies_.insert(KeyTag{ imp_frac_key_, tag }); + + imp_rec_id_key_ = + Keys::readKey(plist, domain, "impervious runoff receiver", "impervious_runoff_receiver"); + dependencies_.insert(KeyTag{ imp_rec_id_key_, tag }); + + src_key_ = Keys::readKey(plist, domain, "incoming water source", "precipitation_rain"); + dependencies_.insert(KeyTag{ src_key_, tag }); + + cv_key_ = Keys::readKey(plist, domain, "cell volume", "cell_volume"); + dependencies_.insert(KeyTag{ cv_key_, tag }); + + Qs_max_ = plist.get("maximum specific diversion rate [m s^-1]", -1); +} + + +void +ImperviousInterceptionEvaluator::Evaluate_(const State& S, + const std::vector& result) +{ + Tag tag = my_keys_.front().second; + const auto& cv = *S.Get(cv_key_, tag).ViewComponent("cell", false); + const auto& src = *S.Get(src_key_, tag).ViewComponent("cell", false); + const auto& imp_frac = *S.Get(imp_frac_key_, tag).ViewComponent("cell", false); + const auto& imp_rec_id = + *S.Get(imp_rec_id_key_, tag).ViewComponent("cell", false); + + Epetra_BlockMap natural_map(src.GlobalLength(), src.MyLength(), 1, 0, src.Comm()); + if (importer_ == Teuchos::null) { + // target map is the destination/receiving ID. Note if there is no + // receiving ID, we send the water to ourselves. + std::vector target_id(src.MyLength(), -1); + for (int c = 0; c != src.MyLength(); ++c) { + AmanziMesh::Entity_GID gid = natural_map.GID(c); + AmanziMesh::Entity_GID target = (AmanziMesh::Entity_GID)(imp_rec_id[0][c]); + target_id[c] = (target < 0) ? gid : target; + } + + Epetra_BlockMap target_map( + src.GlobalLength(), src.MyLength(), target_id.data(), 1, 0, src.Comm()); + importer_ = Teuchos::rcp(new Epetra_Import(target_map, natural_map)); + } + + Epetra_MultiVector& modified_src = *result[0]->ViewComponent("cell", false); + Epetra_MultiVector diverted_water(natural_map, 1); + + int source_c = natural_map.LID(897); + int dest_c = natural_map.LID(1466); + + // first split incoming water into diverted and not diverted + for (int c = 0; c != diverted_water.MyLength(); ++c) { + if (imp_rec_id[0][c] < 0) { + diverted_water[0][c] = 0.; + modified_src[0][c] = cv[0][c] * src[0][c]; + } else { + double rate = Qs_max_ > 0 ? std::min(Qs_max_, src[0][c]) : src[0][c]; + diverted_water[0][c] = cv[0][c] * imp_frac[0][c] * rate; + modified_src[0][c] = cv[0][c] * src[0][c] - diverted_water[0][c]; + } + } + + // then sum diverted into modified + modified_src.Export(diverted_water, *importer_, Epetra_AddLocalAlso); + + // lastly divide by the local cell volume + modified_src.ReciprocalMultiply(1., cv, modified_src, 0.); + diverted_water.PutScalar(0.); + diverted_water.Update(1.0, modified_src, 1.0); + diverted_water.Update(-1.0, src, 1.0); + + // double-check mass conservation + double orig_mass = 0., mod_mass = 0.; + int ierr = src.Dot(cv, &orig_mass); + ierr |= modified_src.Dot(cv, &mod_mass); + AMANZI_ASSERT(std::abs(orig_mass - mod_mass) < 1.e-10); +} + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator.hh b/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator.hh new file mode 100644 index 000000000..64567993c --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator.hh @@ -0,0 +1,98 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon (coonet@ornl.gov) +*/ + +//! An evaluator for rerouting precipitation due to impervious surface interception. + +/*! + +This evaluator reroutes incoming precipitation, taking a portion of it (where +the portion is determined by the impervious area fraction) and moving it +(instantly) into nearby cells specified by the runoff receiver IDs. + +The evaluator performs the following operations: +1. Splits incoming water into diverted (to impervious areas) and non-diverted portions. +2. Applies a maximum specific diversion rate if specified. +3. Redistributes diverted water to target cells using Epetra_Import. +4. Ensures mass conservation throughout the process. + +Note: This assumes that the runoff receiver IDs are constant in time! + +`"evaluator type"` = `"impervious surface interception"` + +.. _impervious-interception-evaluator-spec: +.. admonition:: impervious-interception-evaluator-spec + + * `"maximum specific diversion rate [m s^-1]"` ``[double]`` + Maximum rate of water removal through storm drains, etc, in units of m^3 + water per second per m^2 of impervious area (specific area). If negative, + no limit is applied. + + KEYS: + - `"impervious fraction"` **DOMAIN-impervious_fraction** The fraction of surface area that is impervious, which also defines the fraction of precipitation that is rerouted. + - `"impervious runoff receiver"` **DOMAIN-impervious_runoff_receiver** The Global ID of the cell that will receive water from this cell. If negative, water is not diverted. + - `"incoming water source"` **DOMAIN-precipitation_rain** The source of water to be rerouted -- this is typically rain, but might be canopy-throughfall_drainage_rain. + - `"cell volume"` **DOMAIN-cell_volume** Cell volumes for proper mass balance calculations. + +*/ + +#pragma once + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" +#include "FunctionFactory.hh" + +class Epetra_Import; + +namespace Amanzi { +namespace Flow { +namespace Relations { + +class ImperviousInterceptionEvaluator : public EvaluatorSecondaryMonotypeCV { + public: + explicit ImperviousInterceptionEvaluator(Teuchos::ParameterList& plist); + ImperviousInterceptionEvaluator(const ImperviousInterceptionEvaluator& other) = default; + + virtual Teuchos::RCP Clone() const override + { + return Teuchos::rcp(new ImperviousInterceptionEvaluator(*this)); + } + + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override + { + // calculate of derivatives of this is a tricky thing to do, with + // non-cell-local terms due to rescaling. Just turn off derivatives + // instead. + return false; + } + + protected: + virtual void Evaluate_(const State& S, const std::vector& result) override; + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, + const Tag& wrt_tag, + const std::vector& result) override {}; + + protected: + Key imp_frac_key_; + Key imp_rec_id_key_; + Key src_key_; + Key cv_key_; + double Qs_max_; + + Teuchos::RCP importer_; + + private: + static Utils::RegisteredFactory reg_; +}; + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator_reg.hh b/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator_reg.hh new file mode 100644 index 000000000..04c884a69 --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/impervious_interception_evaluator_reg.hh @@ -0,0 +1,21 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: +*/ + +#include "impervious_interception_evaluator.hh" + +namespace Amanzi { +namespace Flow { +namespace Relations { + +Utils::RegisteredFactory + ImperviousInterceptionEvaluator::reg_("impervious surface interception"); + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/soil_resistance_model_partition.hh b/src/pks/flow/constitutive_relations/sources/soil_resistance_model_partition.hh index 553f4b068..4c06ff790 100644 --- a/src/pks/flow/constitutive_relations/sources/soil_resistance_model_partition.hh +++ b/src/pks/flow/constitutive_relations/sources/soil_resistance_model_partition.hh @@ -39,8 +39,8 @@ typedef std::pair, SoilResistanceSakaguck SoilResistanceModelPartition; // Non-member factory -Teuchos::RCP -createSoilResistanceModelPartition(Teuchos::ParameterList& plist); +Teuchos::RCP createSoilResistanceModelPartition( + Teuchos::ParameterList& plist); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_evaluator.cc b/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_evaluator.cc index a09b9a768..08c66bd6f 100644 --- a/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_evaluator.cc +++ b/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_evaluator.cc @@ -103,7 +103,7 @@ SoilResistanceSakaguckiZengEvaluator::EvaluatePartialDerivative_( if (wrt_key == sat_gas_key_) { // evaluate the model - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { AMANZI_ASSERT(*comp == "cell"); // partition on cell only const Epetra_MultiVector& sat_gas_v = *(sat_gas->ViewComponent(*comp, false)); @@ -121,7 +121,7 @@ SoilResistanceSakaguckiZengEvaluator::EvaluatePartialDerivative_( } else if (wrt_key == poro_key_) { // evaluate the model - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { AMANZI_ASSERT(*comp == "cell"); // partition on cell only const Epetra_MultiVector& sat_gas_v = *(sat_gas->ViewComponent(*comp, false)); diff --git a/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_evaluator.hh b/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_evaluator.hh index 5dce0356e..95cbc217e 100644 --- a/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_evaluator.hh +++ b/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_evaluator.hh @@ -14,30 +14,27 @@ referred to Sakagucki and Zeng (2009). `"evaluator type`" = `"soil resistance, Sakagucki-Zeng`" -.. _soil-resistance-sakagucki-zeng-evaluator-spec -.. admonition:: soil-resistance-sakagucki-zeng-evaluator-spec - - * `"model parameters`" ``[string]`` **WRM parameters** ``[WRM-typedinline-spec-list]`` - Soil resistance based on Sakagucki-Zeng method uses soil properties defined in - `"WRM parameters`" which is given through `"model parameters`" under state. - - - If `"van Genuchten`" is used for WRM, either `"van Genuchten n [-]`" - or `"van Genuchten m [-]`" will be used to determine Clapp-Hornberger-b - through method 2 in Ma et al. (1999). Originally this method is from - Lenhard et al. (1989). - - - If `"Brooks-Corey`" is used for WRM, `"Brooks-Corey lambda [-]`" will - be used to determine Clapp-Hornberger-b, which is the reciprocal of - `"Brooks-Corey lambda [-]`". - - - `"residual saturation [-]`" ``[double]`` **0.0** - - - `"dessicated zone thickness [m]`" ``[double]`` **0.1** - - KEYS: - - - `"gas saturation`" of top cells - - `"porosity`" of top cells +.. _evaluator-soil-resistance-sakagucki-zeng-spec +.. admonition:: evaluator-soil-resistance-sakagucki-zeng-spec + + * `"model parameters`" ``[string]`` **WRM parameters** Soil resistance based + on Sakagucki-Zeng method uses soil properties defined in `"WRM + parameters`" which is given through `"model parameters`" under state. + + - If `"van Genuchten`" is used for WRM, either `"van Genuchten n [-]`" or + `"van Genuchten m [-]`" will be used to determine Clapp-Hornberger-b + through method 2 in Ma et al. (1999). Originally this method is from + Lenhard et al. (1989). + - If `"Brooks-Corey`" is used for WRM, `"Brooks-Corey lambda [-]`" will be + used to determine Clapp-Hornberger-b, which is the reciprocal of + `"Brooks-Corey lambda [-]`". + - `"residual saturation [-]`" ``[double]`` **0.0** + - `"dessicated zone thickness [m]`" ``[double]`` **0.1** + + KEYS: + + - `"gas saturation`" Note only the column's top grid cell is used + - `"porosity`" Note only the column's top grid cell is used Example: diff --git a/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_model.hh b/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_model.hh index 8a3475062..c67bd7c6b 100644 --- a/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_model.hh +++ b/src/pks/flow/constitutive_relations/sources/soil_resistance_sakagucki_zeng_model.hh @@ -27,7 +27,8 @@ namespace Flow { class SoilResistanceSakaguckiZengModel { public: - explicit SoilResistanceSakaguckiZengModel(Teuchos::ParameterList& plist) : plist_(plist) + explicit SoilResistanceSakaguckiZengModel(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); } diff --git a/src/pks/flow/constitutive_relations/sources/soil_resistance_sellers_evaluator.cc b/src/pks/flow/constitutive_relations/sources/soil_resistance_sellers_evaluator.cc index 5e4d257ea..41fd942cd 100644 --- a/src/pks/flow/constitutive_relations/sources/soil_resistance_sellers_evaluator.cc +++ b/src/pks/flow/constitutive_relations/sources/soil_resistance_sellers_evaluator.cc @@ -80,7 +80,7 @@ SoilResistanceSellersEvaluator::EvaluatePartialDerivative_( if (wrt_key == sat_key_) { // evaluate the model - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { AMANZI_ASSERT(*comp == "cell"); // partition on cell only const Epetra_MultiVector& sat_v = *(sat->ViewComponent(*comp, false)); diff --git a/src/pks/flow/constitutive_relations/sources/soil_resistance_sellers_evaluator.hh b/src/pks/flow/constitutive_relations/sources/soil_resistance_sellers_evaluator.hh index 66195dcc3..739f0b795 100644 --- a/src/pks/flow/constitutive_relations/sources/soil_resistance_sellers_evaluator.hh +++ b/src/pks/flow/constitutive_relations/sources/soil_resistance_sellers_evaluator.hh @@ -12,10 +12,15 @@ Evaluates the soil resistance at top cells through the Sellers model referred to Sellers et al. (1992). +.. math:: + + R_{soil} = \mathrm{exp}(8.206 - 4.255 s_l) + + `"evaluator type`" = `"soil resistance, Sellers`" -.. _soil-resistance-sellers-evaluator-spec -.. admonition:: soil-resistance-sellers-evaluator-spec +.. _evaluator-soil-resistance-sellers-spec +.. admonition:: evaluator-soil-resistance-sellers-spec KEYS: diff --git a/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator.cc b/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator.cc new file mode 100644 index 000000000..82a6adfbd --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator.cc @@ -0,0 +1,196 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Saubhagya Rathore (rathoress@ornl.gov) +*/ + +#include "Key.hh" +#include "Factory.hh" +#include "Function.hh" +#include "surface_culvert_evaluator.hh" +#include "FunctionFactory.hh" +#include +#include +#include + +namespace Amanzi { +namespace Flow { +namespace Relations { + +// Helper function to compute area-weighted average of a variable over a set of mesh entities +inline double +computeAreaWeightedAverage( + const AmanziMesh::Mesh& mesh, + const Amanzi::AmanziMesh::MeshCache::cEntity_ID_View& entity_list, + const Epetra_MultiVector& cv, + const Epetra_MultiVector& var) +{ + double terms_local[2] = { 0, 0 }; + for (auto c : entity_list) { + terms_local[0] += cv[0][c] * var[0][c]; + terms_local[1] += cv[0][c]; + } + double terms_global[2] = { 0, 0 }; + mesh.getComm()->SumAll(terms_local, terms_global, 2); + return terms_global[0] / terms_global[1]; // Area-weighted average +} + + +// Constructor: Set up dependencies and culvert parameters +SurfCulvertEvaluator::SurfCulvertEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) +{ + domain_ = Keys::getDomain(my_keys_.front().first); + auto tag = my_keys_.front().second; + + // Set up dependencies for required field variables + cv_key_ = Keys::readKey(plist, domain_, "cell volume", "cell_volume"); + dependencies_.insert(KeyTag{ cv_key_, tag }); + + pd_key_ = Keys::readKey(plist, domain_, "ponded depth", "ponded_depth"); + dependencies_.insert(KeyTag{ pd_key_, tag }); + + wc_key_ = Keys::readKey(plist, domain_, "water content", "water_content"); + dependencies_.insert(KeyTag{ wc_key_, tag }); + + pe_key_ = Keys::readKey(plist, domain_, "potential", "pres_elev"); + dependencies_.insert(KeyTag{ pe_key_, tag }); + + elev_key_ = Keys::readKey(plist, domain_, "elevation", "elevation"); + dependencies_.insert(KeyTag{ elev_key_, tag }); + + liq_den_key_ = Keys::readKey(plist, domain_, "molar density liquid", "molar_density_liquid"); + dependencies_.insert(KeyTag{ liq_den_key_, tag }); + + // Read culvert configuration parameters + culvert_inlet_region_ = plist.get("culvert inlet region"); + culvert_outlet_region_ = plist.get("culvert outlet region"); + Nb_ = plist.get("number of barrels", 1); + L_feet_ = plist.get("culvert length", 10) * 3.28084; + D_feet_ = plist.get("culvert diameter", 1) * 3.28084; + n_ = plist.get("culvert roughness coefficient", 0.013); + C_ = plist.get("culvert discharge coefficient", 0.6); +} + +void +SurfCulvertEvaluator::Evaluate_(const State& S, const std::vector& result) +{ + Tag tag = my_keys_.front().second; + double dt = S.Get("dt", tag); + + // Get required field variables + const auto& cv = *S.Get(cv_key_, tag).ViewComponent("cell", false); + const auto& pd = *S.Get(pd_key_, tag).ViewComponent("cell", false); + const auto& liq_den = *S.Get(liq_den_key_, tag).ViewComponent("cell", false); + const auto& wc = *S.Get(wc_key_, tag).ViewComponent("cell", false); + const auto& pe = *S.Get(pe_key_, tag).ViewComponent("cell", false); + const auto& elev = *S.Get(elev_key_, tag).ViewComponent("cell", false); + + auto& surf_src = *result[0]->ViewComponent("cell"); + const AmanziMesh::Mesh& mesh = *result[0]->Mesh(); + + // Get mesh entities for inlet and outlet regions + auto inlet_id_list = mesh.getSetEntities( + culvert_inlet_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + + auto outlet_id_list = mesh.getSetEntities( + culvert_outlet_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + + // Compute area-weighted averages for hydraulic calculations + double avg_pe_inlet = computeAreaWeightedAverage(mesh, inlet_id_list, cv, pe); + double avg_elev_inlet = computeAreaWeightedAverage(mesh, inlet_id_list, cv, elev); + double avg_pe_outlet = computeAreaWeightedAverage(mesh, outlet_id_list, cv, pe); + + // Convert to feet for hydraulic calculations (using US customary units) + double h_up_feet = avg_pe_inlet * 3.28084; + double h_down_feet = avg_pe_outlet * 3.28084; + double z_invert_feet = avg_elev_inlet * 3.28084; + + // Calculate culvert geometry parameters + double A = M_PI * D_feet_ * D_feet_ / 4.0; // Cross-sectional area + double P = M_PI * D_feet_; // Wetted perimeter + double R = A / P; // Hydraulic radius + double d = h_up_feet - z_invert_feet; // Depth at inlet + + // Calculate inlet head for discharge calculations based on different hydraulic regimes + double d_eps = 0.01; // feet - small depth threshold + double h_i = 0.0; // inlet head for discharge calculation + if (d <= 0) { + // No water depth - no flow + h_i = 0.0; + } else if (d < d_eps) { + // Very shallow flow - use cubic ramp to avoid numerical issues + h_i = 0.5 * d * (d / d_eps); + } else if (d < D_feet_) { + // Partial flow regime - culvert not full, inlet control + h_i = 0.5 * d; + } else { + // Full flow regime - culvert running full, pressure flow + h_i = h_up_feet - (z_invert_feet + D_feet_ / 2.0); + } + + + // Calculate flow rates using culvert hydraulics equations + double g = 9.81; + double Q_inlet = 0.0; + if (h_i > 0.0) Q_inlet = Nb_ * C_ * A * std::sqrt(2.0 * g * h_i); + + double h_o = std::max(h_up_feet - h_down_feet, 0.0001); + double k = 1.5 + (29.0 * n_ * n_ * L_feet_) / std::pow(R, 1.33); + double Q_outlet = Nb_ * C_ * A * std::sqrt((2.0 * g * h_o) / k); + double Q_cfs = (Q_inlet * Q_outlet) / std::sqrt(Q_inlet * Q_inlet + Q_outlet * Q_outlet + 1e-12); + + + double Q = Q_cfs * 0.028316847; // Convert from ft³/s to m³/s + + // Check water availability constraints + double available_water_mol = 0.0; + for (auto c : inlet_id_list) { + available_water_mol += wc[0][c] * liq_den[0][c] * cv[0][c]; + } + double total_available_water_mol = 0.0; + mesh.getComm()->SumAll(&available_water_mol, &total_available_water_mol, 1); + + // Early return if no flow or no water available + if (Q == 0.0 || total_available_water_mol <= 0.0) { + for (auto c : inlet_id_list) surf_src[0][c] = 0.0; + for (auto c : outlet_id_list) surf_src[0][c] = 0.0; + return; + } + + // Limit flow rate by available water + double mols_required = Q * dt; + if (mols_required > total_available_water_mol && mols_required > 0.0) { + Q *= total_available_water_mol / mols_required; + } + + // Distribute source terms at inlet (water removal) + double sum_wc_l = 0; + for (auto c : inlet_id_list) sum_wc_l += wc[0][c]; + double sum_wc_g = 0; + mesh.getComm()->SumAll(&sum_wc_l, &sum_wc_g, 1); + double safe_sum_wc_g = std::max(sum_wc_g, 1e-8); + + for (auto c : inlet_id_list) { + double safe_cv = std::max(cv[0][c], 1e-8); + surf_src[0][c] = -Q * liq_den[0][c] * wc[0][c] / (safe_sum_wc_g * safe_cv); + } + + // Distribute source terms at outlet (water addition) + double sum_cv_l = 0; + for (auto c : outlet_id_list) sum_cv_l += cv[0][c]; + double sum_cv_g = 0; + mesh.getComm()->SumAll(&sum_cv_l, &sum_cv_g, 1); + double safe_sum_cv_g = std::max(sum_cv_g, 1e-8); + + for (auto c : outlet_id_list) { + surf_src[0][c] = Q * liq_den[0][c] / safe_sum_cv_g; + } +} + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator.hh b/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator.hh new file mode 100644 index 000000000..6a4431cc2 --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator.hh @@ -0,0 +1,160 @@ +/* + Copyright 2010–202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Saubhagya Rathore (rathoress@ornl.gov) + +*/ + +//! Simulates water movement through culverts by instant transfer of water from inlet to outlet region. +/*! + +Flow is calculated using standard culvert hydraulics, considering both inlet-controlled and outlet-controlled regimes. + +Implements the following culvert hydraulics equations: +- **Inlet control**: + + .. math:: + Q_{\text{inlet}} = N_b \, C \, A \, \sqrt{2 g h_i} + + where: + + - :math:`N_b` = number of barrels *(unitless)* + - :math:`C` = discharge coefficient *(unitless)* + - :math:`A` = culvert cross-sectional area *(m^2)* + - :math:`h_i` = head at culvert inlet *(m)* + - :math:`g` = acceleration due to gravity *(9.81 m/s^2)* + - :math:`Q_{\text{inlet}}` = inlet discharge *(m^3/s)* + +- **Outlet control**: + + .. math:: + Q_{\text{outlet}} = N_b \, C \, A \, \sqrt{ \frac{2 g h_o}{k} } + + where: + + - :math:`h_o` = head difference between inlet and outlet *(m)* + - :math:`k = 1.5 + \frac{29 n^2 L}{R^{4/3}}` *(unitless resistance term)* + - :math:`n` = Manning's roughness coefficient *(s/m^{1/3})* + - :math:`L` = culvert length *(m)* + - :math:`R` = hydraulic radius *(m)* + - :math:`Q_{\text{outlet}}` = outlet discharge *(m^3/s)* + +- **Blended total discharge**: + + .. math:: + Q = \frac{Q_{\text{inlet}} \, Q_{\text{outlet}}}{\sqrt{Q_{\text{inlet}}^2 + Q_{\text{outlet}}^2 + \epsilon}} + + where: + + - :math:`\epsilon` = small positive constant to avoid divide-by-zero + - :math:`Q` = total culvert discharge *(m^3/s)* + +The resulting :math:`Q` is used to compute area-weighted water removal at the inlet and volume-weighted water addition at the outlet. + + +`"evaluator type`" = `"culvert`" + +.. _evaluator-culvert-spec: +.. admonition:: evaluator-culvert-spec + + * `"culvert inlet region"`" ``[str]`` Region of cells where culvert flow is taken out. + * `"culvert outlet region"`" ``[str]`` Region of cells where culvert flow is introduced. + * `"number of barrels"`" ``[int]`` Number of culvert barrels, default is 1. + * `"culvert length"`" ``[double]`` Length of the culvert in meters, default is 10. + * `"culvert diameter"`" ``[double]`` Diameter of the culvert in meters, default is 1. + * `"culvert roughness coefficient"`" ``[double]`` Manning's roughness coefficient for the culvert, default is 0.013. + * `"culvert discharge coefficient"`" ``[double]`` Discharge coefficient for the culvert, default is 0.6. + + KEYS: + - `"cell volume"`" **DOMAIN-cell_volume** + - `"ponded depth"`" **DOMAIN-ponded_depth** + - `"potential"`" **DOMAIN-pres_elev** (stage or water surface elevation) + - `"elevation"`" **DOMAIN-elevation** + - `"water content"`" **DOMAIN-water_content** + - `"molar density liquid"`" **DOMAIN-molar_density_liquid** + +Example: + +.. code-block:: xml + + + + + + + + + + + + +*/ + +#pragma once + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" +#include "FunctionFactory.hh" + +namespace Amanzi { +namespace Flow { +namespace Relations { + +class SurfCulvertEvaluator : public EvaluatorSecondaryMonotypeCV { + public: + explicit SurfCulvertEvaluator(Teuchos::ParameterList& plist); + SurfCulvertEvaluator(const SurfCulvertEvaluator& other) = default; + + virtual Teuchos::RCP Clone() const override + { + return Teuchos::rcp(new SurfCulvertEvaluator(*this)); + } + + // virtual void EnsureCompatibility(State& S) override; + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override + { + // calculate of derivatives of this is a tricky thing to do, with + // non-cell-local terms due to rescaling. Just turn off derivatives + // instead. + return false; + } + + protected: + virtual void Evaluate_(const State& S, const std::vector& result) override; + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, + const Tag& wrt_tag, + const std::vector& result) override {}; + + protected: + Key domain_; + Key cv_key_; + Key pd_key_; + Key pe_key_; + Key elev_key_; + Key liq_den_key_; + Key wc_key_; + + std::string culvert_inlet_region_; + std::string culvert_outlet_region_; + int Nb_; + double L_; + double D_; + double L_feet_; + double D_feet_; + double n_; + double C_; + bool allow_reverse_flow_; + + private: + static Utils::RegisteredFactory reg_; +}; + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator_reg.hh b/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator_reg.hh new file mode 100644 index 000000000..46eb997da --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_culvert_evaluator_reg.hh @@ -0,0 +1,20 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: +*/ + +#include "surface_culvert_evaluator.hh" + +namespace Amanzi { +namespace Flow { +namespace Relations { + +Utils::RegisteredFactory SurfCulvertEvaluator::reg_("culvert"); + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/surface_distributed_tiles_evaluator.cc b/src/pks/flow/constitutive_relations/sources/surface_distributed_tiles_evaluator.cc index 7ca06e79b..58aca07ee 100644 --- a/src/pks/flow/constitutive_relations/sources/surface_distributed_tiles_evaluator.cc +++ b/src/pks/flow/constitutive_relations/sources/surface_distributed_tiles_evaluator.cc @@ -80,7 +80,9 @@ SurfDistributedTilesRateEvaluator::Update_(State& S) } total = 0.0; - for (AmanziMesh::Entity_ID c = 0; c != ncells; ++c) { total += surf_src[0][c] * cv[0][c]; } + for (AmanziMesh::Entity_ID c = 0; c != ncells; ++c) { + total += surf_src[0][c] * cv[0][c]; + } } void @@ -97,7 +99,9 @@ SurfDistributedTilesRateEvaluator::EnsureCompatibility(State& S) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // Cop-out -- ensure not fully implemented for this evaluator. FIXME --ETC - for (const auto& dep : dependencies_) { S.RequireEvaluator(dep.first, dep.second); } + for (const auto& dep : dependencies_) { + S.RequireEvaluator(dep.first, dep.second); + } } } // namespace Relations diff --git a/src/pks/flow/constitutive_relations/sources/surface_distributed_tiles_evaluator.hh b/src/pks/flow/constitutive_relations/sources/surface_distributed_tiles_evaluator.hh index 1c0341598..e4b4bbbf3 100644 --- a/src/pks/flow/constitutive_relations/sources/surface_distributed_tiles_evaluator.hh +++ b/src/pks/flow/constitutive_relations/sources/surface_distributed_tiles_evaluator.hh @@ -10,6 +10,8 @@ //! Evaluates water/solute source which represent effect of distributed subsurface tiles on overland flow /*! +`"evaluator type"` = `"surface distributed tiles"` + .. _surface-distributed-tiles-spec: .. admonition:: surface-distributed-tiles-spec @@ -47,7 +49,7 @@ class SurfDistributedTilesRateEvaluator : public EvaluatorSecondary { protected: virtual void Update_(State& S) override; - virtual void UpdateDerivative_(State& S, const Key& wrt_key, const Tag& wrt_tag) override{}; + virtual void UpdateDerivative_(State& S, const Key& wrt_key, const Tag& wrt_tag) override {}; protected: Key domain_; diff --git a/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator.cc b/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator.cc new file mode 100644 index 000000000..20c905aed --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator.cc @@ -0,0 +1,159 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Saubhagya Rathore (rathoress@ornl.gov) + Ethan Coon (coonet@ornl.gov) +*/ + +/* +This evaluator models gate structure inside 2D flow area. The gate curve is kept general and can be provided by the user. +Gate structure can be used to move water between two canals, two storage areas or canal to storage area. +*/ + +#include "Key.hh" +#include "Factory.hh" +#include "Function.hh" +#include "surface_gate_structure_evaluator.hh" +#include "FunctionFactory.hh" + + +namespace Amanzi { +namespace Flow { +namespace Relations { + +// Helper function to compute area-weighted average +inline double +computeAreaWeightedAverage( + const AmanziMesh::Mesh& mesh, + const Amanzi::AmanziMesh::MeshCache::cEntity_ID_View& entity_list, + const Epetra_MultiVector& cv, + const Epetra_MultiVector& var) +{ + double terms_local[2] = { 0, 0 }; + for (auto c : entity_list) { + terms_local[0] += cv[0][c] * var[0][c]; + terms_local[1] += cv[0][c]; + } + double terms_global[2] = { 0, 0 }; + mesh.getComm()->SumAll(terms_local, terms_global, 2); + return terms_global[0] / terms_global[1]; // Area-weighted average +} + + +SurfGateEvaluator::SurfGateEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) +{ + domain_ = Keys::getDomain(my_keys_.front().first); + auto tag = my_keys_.front().second; + + // dependencies + cv_key_ = Keys::readKey(plist, domain_, "cell volume", "cell_volume"); + dependencies_.insert(KeyTag{ cv_key_, tag }); + + pd_key_ = Keys::readKey(plist, domain_, "ponded depth", "ponded_depth"); + dependencies_.insert(KeyTag{ pd_key_, tag }); + + wc_key_ = Keys::readKey(plist, domain_, "water content", "water_content"); + dependencies_.insert(KeyTag{ wc_key_, tag }); + + pe_key_ = Keys::readKey(plist, domain_, "potential", "pres_elev"); + dependencies_.insert(KeyTag{ pe_key_, tag }); + + elev_key_ = Keys::readKey(plist, domain_, "elevation", "elevation"); + dependencies_.insert(KeyTag{ elev_key_, tag }); + + liq_den_key_ = Keys::readKey(plist, domain_, "molar density liquid", "molar_density_liquid"); + dependencies_.insert(KeyTag{ liq_den_key_, tag }); + + gate_intake_region_ = plist.get("gate intake region"); + storage_region_ = plist.get("storage area region"); + is_ponded_depth_function_ = plist.get("is ponded depth function", false); + stage_close_ = plist.get("gate close stage", 1e6); + + Teuchos::ParameterList& gate_func = plist.sublist("function"); + FunctionFactory fac; + Q_gate_ = Teuchos::rcp(fac.Create(gate_func)); +} + + +// Required methods from SecondaryVariableFieldEvaluator +void +SurfGateEvaluator::Evaluate_(const State& S, const std::vector& result) +{ + Tag tag = my_keys_.front().second; + + double dt = S.Get("dt", tag); + const auto& cv = *S.Get(cv_key_, tag).ViewComponent("cell", false); + const auto& pd = *S.Get(pd_key_, tag).ViewComponent("cell", false); + const auto& liq_den = *S.Get(liq_den_key_, tag).ViewComponent("cell", false); + const auto& wc = *S.Get(wc_key_, tag).ViewComponent("cell", false); + const auto& pe = *S.Get(pe_key_, tag).ViewComponent("cell", false); + const auto& elev = *S.Get(elev_key_, tag).ViewComponent("cell", false); + + auto& surf_src = *result[0]->ViewComponent("cell"); + + double total = 0.0; + const AmanziMesh::Mesh& mesh = *result[0]->Mesh(); + + auto gate_intake_id_list = mesh.getSetEntities( + gate_intake_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + + auto storage_id_list = mesh.getSetEntities( + storage_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + + // Calculate the flow rate from gate (from reach into detention pond) + double Q; + double avg_pe_storage = computeAreaWeightedAverage(mesh, storage_id_list, cv, pe); + + if (is_ponded_depth_function_) { + double avg_pd_inlet = computeAreaWeightedAverage(mesh, gate_intake_id_list, cv, pd); + // test that for zero ponded depth, the function returns zero flow + double Q0 = (*Q_gate_)(std::vector{ 0 }); + AMANZI_ASSERT(Q0 == 0); + Q = (*Q_gate_)(std::vector{ avg_pd_inlet }); // m^3/s + } else { + double avg_pe_inlet = computeAreaWeightedAverage(mesh, gate_intake_id_list, cv, pe); + double avg_elev_inlet = computeAreaWeightedAverage(mesh, gate_intake_id_list, cv, elev); + double Q0 = (*Q_gate_)(std::vector{ avg_elev_inlet }); + AMANZI_ASSERT(Q0 == 0); + Q = (*Q_gate_)(std::vector{ avg_pe_inlet }); + } + + // to overcome "bang-bang" behavior, we use a smooth transition + double delta_ = 0.01; // should we make it available to the user? + double alpha = 0.5 * (1.0 - std::tanh((avg_pe_storage - stage_close_) / delta_)); + Q = alpha * Q; + + // Sink to the reach cells + double sum_wc_l = 0; + for (auto c : gate_intake_id_list) { + sum_wc_l += wc[0][c]; + } + double sum_wc_g = 0; + mesh.getComm()->SumAll(&sum_wc_l, &sum_wc_g, 1); + + for (auto c : gate_intake_id_list) { + if (sum_wc_g > 0) { + surf_src[0][c] = -Q * liq_den[0][c] * wc[0][c] / (sum_wc_g * cv[0][c]); // mol/(m^2 * s) + } + } + + // Source to the detention pond cells + double sum_cv_l = 0; + for (auto c : storage_id_list) { + sum_cv_l += cv[0][c]; + } + double sum_cv_g = 0; + mesh.getComm()->SumAll(&sum_cv_l, &sum_cv_g, 1); + + for (auto c : storage_id_list) { + surf_src[0][c] = Q * liq_den[0][c] / (sum_cv_g); // mol/(m^2 * s) + } +} + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator.hh b/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator.hh new file mode 100644 index 000000000..2abb4ded2 --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator.hh @@ -0,0 +1,117 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Saubhagya Rathore (rathoress@ornl.gov) + Ethan Coon (coonet@ornl.gov) +*/ + +//! Simulates gravity-driven water movement/diversions through gate structure. +/*! + +This evaluator models gate structure inside 2D flow area. The gate curve is kept general and can be provided by the user. +Gate structure can be used to move water two canals, two storage areas or canal to storage area. + +`"evaluator type`" = `"gate structure`" + +.. _evaluator-gate-structure-spec: +.. admonition:: evaluator-gate-structure-spec + + * `"gate intake region`" ``[str]`` Region of cells where gate flow is taken out. + * `"storage area region`" ``[str]`` Region of cells where gate flow is introduced. + * `"gate stage close`" ``[double]`` The water surface elevation in the storage area that should trigger the gate close. + * `"is ponded depth function`" ``[bool]`` If true, the gate efficiency curve is a function of ponded depth in the intake region rather than stage. + * `"function`" ``[function-tabular]`` This is a function/table of head and flow. Here, head is the stage or ponded depth in the intake region (upstream) of the gate structure. + + KEYS: + - `"cell volume`" **DOMAIN-cell_volume** + - `"ponded depth`" **DOMAIN-ponded_depth** + - `"potential`" **DOMAIN-pres_elev** stage or water surface elevation + - `"elevation`" **DOMAIN-elevation** + - `"water content`" **DOMAIN-water_content** + - `"molar liquid density`" **DOMAIN-molar_density_liquid** + +Example: + +.. code-block:: xml + + + + + + + + + + + + + + + +*/ + + +#pragma once + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" +#include "FunctionFactory.hh" + +namespace Amanzi { +namespace Flow { +namespace Relations { + +class SurfGateEvaluator : public EvaluatorSecondaryMonotypeCV { + public: + explicit SurfGateEvaluator(Teuchos::ParameterList& plist); + SurfGateEvaluator(const SurfGateEvaluator& other) = default; + + virtual Teuchos::RCP Clone() const override + { + return Teuchos::rcp(new SurfGateEvaluator(*this)); + } + + // virtual void EnsureCompatibility(State& S) override; + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override + { + // calculate of derivatives of this is a tricky thing to do, with + // non-cell-local terms due to rescaling. Just turn off derivatives + // instead. + return false; + } + + protected: + virtual void Evaluate_(const State& S, const std::vector& result) override; + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, + const Tag& wrt_tag, + const std::vector& result) override {}; + + protected: + Key domain_; + Key cv_key_; + Key pd_key_; + Key pe_key_; + Key elev_key_; + Key liq_den_key_; + Key wc_key_; + + std::string storage_region_; + std::string gate_intake_region_; + double stage_close_; + bool is_ponded_depth_function_; + + Teuchos::RCP Q_gate_; + + private: + static Utils::RegisteredFactory reg_; +}; + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator_reg.hh b/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator_reg.hh new file mode 100644 index 000000000..56d0d87fe --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_gate_structure_evaluator_reg.hh @@ -0,0 +1,20 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: +*/ + +#include "surface_gate_structure_evaluator.hh" + +namespace Amanzi { +namespace Flow { +namespace Relations { + +Utils::RegisteredFactory SurfGateEvaluator::reg_("gate structure"); + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator.cc b/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator.cc new file mode 100644 index 000000000..f1c30ff5e --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator.cc @@ -0,0 +1,252 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Saubhagya Rathore (rathoress@ornl.gov) + Ethan Coon (coonet@ornl.gov) + +*/ + +/* +This evaluator models stage-based pump station model inside 2D flow area. +Pump stations can be used to move water between any combination of river reaches, storage areas or catchment regions. +Based on pump on-off conditions and pump-operation curve, water is moved from pump-inlet to -outlet region instantly. +*/ + +#include "Key.hh" +#include "Factory.hh" +#include "Function.hh" +#include "surface_pump_system_evaluator.hh" +#include "FunctionFactory.hh" +#include + + +namespace Amanzi { +namespace Flow { +namespace Relations { + +static const double NaN = std::numeric_limits::signaling_NaN(); + +// Helper function to compute area-weighted average +inline double +computeAreaWeightedAverage( + const AmanziMesh::Mesh& mesh, + const Amanzi::AmanziMesh::MeshCache::cEntity_ID_View& entity_list, + const Epetra_MultiVector& cv, + const Epetra_MultiVector& var) +{ + double terms_local[2] = { 0, 0 }; + for (auto c : entity_list) { + terms_local[0] += cv[0][c] * var[0][c]; + terms_local[1] += cv[0][c]; + } + double terms_global[2] = { 0, 0 }; + mesh.getComm()->SumAll(terms_local, terms_global, 2); + return terms_global[0] / terms_global[1]; // Area-weighted average +} + + +SurfPumpEvaluator::SurfPumpEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) +{ + auto domain = Keys::getDomain(my_keys_.front().first); + auto tag = my_keys_.front().second; + + // dependencies + cv_key_ = Keys::readKey(plist, domain, "cell volume", "cell_volume"); + dependencies_.insert(KeyTag{ cv_key_, tag }); + + pd_key_ = Keys::readKey(plist, domain, "ponded depth", "ponded_depth"); + dependencies_.insert(KeyTag{ pd_key_, tag }); + + pe_key_ = Keys::readKey(plist, domain, "potential", "pres_elev"); + dependencies_.insert(KeyTag{ pe_key_, tag }); + + elev_key_ = Keys::readKey(plist, domain, "elevation", "elevation"); + dependencies_.insert(KeyTag{ elev_key_, tag }); + + wc_key_ = Keys::readKey(plist, domain, "water content", "water_content"); + dependencies_.insert(KeyTag{ wc_key_, tag }); + + liq_den_key_ = Keys::readKey(plist, domain, "molar density liquid", "molar_density_liquid"); + dependencies_.insert(KeyTag{ liq_den_key_, tag }); + + // need an extra flag stored in state to indiciate, from + // timestep-to-timestep, that the pump is on or off. + pump_on_key_ = Keys::readKey( + plist, domain, "pump on", Keys::getVarName(my_keys_.front().first) + "_pump_on_flag"); + + pump_outlet_region_ = plist.get("pump outlet region", ""); + pump_inlet_region_ = plist.get("pump inlet region"); + on_off_region_ = plist.get("on off reference region", ""); + + max_elev_pumpline_ = plist.get("maximum pumpline elevation", NaN); + stage_on_ = plist.get("pump start at stage", NaN); + stage_off_ = plist.get("pump stop at stage", NaN); + + Teuchos::ParameterList& pump_func = plist.sublist("function"); + FunctionFactory fac; + Q_pump_ = Teuchos::rcp(fac.Create(pump_func)); +} + + +void +SurfPumpEvaluator::EnsureCompatibility_Structure_(State& S) +{ + auto tag = my_keys_.front().second; + S.Require(pump_on_key_, tag, my_keys_.front().first); + + EvaluatorSecondaryMonotypeCV::EnsureCompatibility_Structure_(S); +} + + +void +SurfPumpEvaluator::Update_(State& S) +{ + // vector of pointers to results + std::vector results; + for (const auto& keytag : my_keys_) { + results.push_back(&S.GetW(keytag.first, keytag.second, keytag.first)); + } + // call the evaluate method + int& pump_on = S.GetW(pump_on_key_, my_keys_.front().second, my_keys_.front().first); + if (!S.GetRecord(pump_on_key_, my_keys_.front().second).initialized()) { + // first call -- set the pump to default to off + pump_on = 0; + S.GetRecordW(pump_on_key_, my_keys_.front().second, my_keys_.front().first).set_initialized(); + } + Evaluate_(S, results, pump_on); +} + + +// Required methods from SecondaryVariableFieldEvaluator +void +SurfPumpEvaluator::Evaluate_(const State& S, + const std::vector& result, + int& pump_on) +{ + Tag tag = my_keys_.front().second; + + double dt = S.Get("dt", tag); + const auto& cv = *S.Get(cv_key_, tag).ViewComponent("cell", false); + const auto& pd = *S.Get(pd_key_, tag).ViewComponent("cell", false); + const auto& liq_den = *S.Get(liq_den_key_, tag).ViewComponent("cell", false); + const auto& wc = *S.Get(wc_key_, tag).ViewComponent("cell", false); + const auto& pe = *S.Get(pe_key_, tag).ViewComponent("cell", false); + const auto& elev = *S.Get(elev_key_, tag).ViewComponent("cell", false); + + auto& surf_src = *result[0]->ViewComponent("cell"); + + double total = 0.0; + const AmanziMesh::Mesh& mesh = *result[0]->Mesh(); + + surf_src.PutScalar(0.); // initializing with zero + + // collect gids in relevant regions + auto pump_inlet_id_list = mesh.getSetEntities( + pump_inlet_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + + Amanzi::AmanziMesh::MeshCache::cEntity_ID_View pump_outlet_id_list; + if (!pump_outlet_region_.empty()) { + auto pump_outlet_id_list = mesh.getSetEntities( + pump_outlet_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + } + + // stage_on value should be greater than elevation at inlet or inlet is the reference region + double avg_elev_inlet; + if (on_off_region_.empty()) { + avg_elev_inlet = computeAreaWeightedAverage(mesh, pump_inlet_id_list, cv, elev); + AMANZI_ASSERT(stage_on_ > avg_elev_inlet); + } + + // Calculate Stage Difference and Pump Status + // average stage at inlet + double avg_pe_inlet = computeAreaWeightedAverage(mesh, pump_inlet_id_list, cv, pe); + double avg_pd_inlet = computeAreaWeightedAverage(mesh, pump_inlet_id_list, cv, pd); + + // average stage at outlet if outlet region provided + double avg_pe_outlet; + if (!pump_outlet_region_.empty()) { + avg_pe_outlet = computeAreaWeightedAverage(mesh, pump_outlet_id_list, cv, pe); + } else { + // if the pump is at the domain boundary pumping water out of the domain, + // need to provide max pumpline elevation + avg_pe_outlet = max_elev_pumpline_; + } + + double avg_pe_on_off = 0; + if (on_off_region_.empty()) { + avg_pe_on_off = avg_pe_inlet; + } else { // if on off region is separate from the inlet region + auto on_off_id_list = mesh.getSetEntities( + on_off_region_, AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); + avg_pe_on_off = computeAreaWeightedAverage(mesh, on_off_id_list, cv, pe); + } + + // Determine if the pump should be on or off + if (avg_pe_on_off > stage_on_) { + pump_on = 1; + } else if (avg_pe_on_off < stage_off_) { + pump_on = 0; + } else { + // pump is left at the same state as last timestep + // pass + } + + // Calculate pumpflow rate and distribute sources and sinks + double Q = 0.; + if (pump_on) { + double head_diff = std::max(max_elev_pumpline_, avg_pe_outlet) - avg_pe_inlet; + Q = (*Q_pump_)(std::vector{ head_diff }); // m^3/s + + // sink distribution proportional to available water + double sum_wc_l = 0; + for (auto c : pump_inlet_id_list) { + sum_wc_l += wc[0][c]; + } + double sum_wc_g = 0; + mesh.getComm()->SumAll(&sum_wc_l, &sum_wc_g, 1); + + // Pump flowrate as sink to inlet cells + for (auto c : pump_inlet_id_list) { + if (sum_wc_g != 0) { + surf_src[0][c] = -Q * liq_den[0][c] * wc[0][c] / (sum_wc_g * cv[0][c]); // mol/(m^2 * s) + } + } + + // Pump flowrate as source to outlet cells + if (!pump_outlet_region_.empty()) { + double sum_cv_l = 0; + for (auto c : pump_outlet_id_list) { + sum_cv_l += cv[0][c]; + } + double sum_cv_g = 0; + mesh.getComm()->SumAll(&sum_cv_l, &sum_cv_g, 1); + + for (auto c : pump_outlet_id_list) { + surf_src[0][c] = Q * liq_den[0][c] / (sum_cv_g); // mol/(m^2 * s) + } + } + } + + // double-check mass conservation + double mass_balance = 0.0; + if (!pump_outlet_region_.empty()) { + surf_src.Dot(cv, &mass_balance); + // Check if the mass balance is zero + AMANZI_ASSERT(std::abs(mass_balance) < 1.e-10); + } else { // Debug code + for (auto c : pump_inlet_id_list) { + mass_balance += surf_src[0][c] * cv[0][c] / liq_den[0][c]; // m^3/s + } + double mass_balance_g = 0; + mesh.getComm()->SumAll(&mass_balance, &mass_balance_g, 1); + AMANZI_ASSERT(std::abs(mass_balance_g + Q) < 1.e-10); + } +} + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator.hh b/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator.hh new file mode 100644 index 000000000..05c44a276 --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator.hh @@ -0,0 +1,139 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Saubhagya Rathore (rathoress@ornl.gov) + Ethan Coon (coonet@ornl.gov) +*/ + +//! An evaluator for stage-based pump systems +/*! + +This evaluator models stage-based pump station model inside 2D flow area. +Pump stations can be used to move water between any combination of river reaches, storage areas or catchment regions. +Based on pump on-off conditions and pump-operation curve, water is moved from pump-inlet to -outlet region instantly. + +`"evaluator type`" = `"pump system`" + +.. _evaluator-pump-system-spec: +.. admonition:: evaluator-pump-system-spec + + * `"pump inlet region`" ``[str]`` Region of cells where pump flow is taken out. + * `"pump outlet region`" ``[str]`` Region of cells where pump flow is introduced (optional). + * `"on off reference region`" ``[str]`` Region used to determine when the pump should turn on or off (optional). Defaults to "pump inlet region". + * `"pump start at stage`" ``[double]`` The water surface elevation that should trigger the pump start. + * `"pump stop at stage`" ``[double]`` The water surface elevation that should trigger the pump stop. + * `"maximum pumpline elevation`" ``[double]`` Allows the user to enter the highest elevation in the pump line. E.g., pumping water over top of a levee. + * `"function`" ``[function-tabular]`` This is a function/table of head and pump flow. Here, head is head difference between outlet and inlet (or head by which the water is to be lifted). + + KEYS: + - `"cell volume`" **DOMAIN-cell_volume** + - `"ponded depth`" **DOMAIN-ponded_depth** + - `"potential`" **DOMAIN-pres_elev** stage or water surface elevation + - `"elevation`" **DOMAIN-elevation** + - `"water content`" **DOMAIN-water_content** + - `"molar liquid density`" **DOMAIN-molar_density_liquid** + - `"pump on`" **DOMAIN-pump_on_flag** status of pump + +Example: + +.. code-block:: xml + + + + + + + + + + + + + + + + +*/ + +#pragma once + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" +#include "FunctionFactory.hh" + +namespace Amanzi { +namespace Flow { +namespace Relations { + +class SurfPumpEvaluator : public EvaluatorSecondaryMonotypeCV { + public: + explicit SurfPumpEvaluator(Teuchos::ParameterList& plist); + SurfPumpEvaluator(const SurfPumpEvaluator& other) = default; + + virtual Teuchos::RCP Clone() const override + { + return Teuchos::rcp(new SurfPumpEvaluator(*this)); + } + + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override + { + // calculate of derivatives of this is a tricky thing to do, with + // non-cell-local terms due to rescaling. Just turn off derivatives + // instead. + return false; + } + + protected: + virtual void EnsureCompatibility_Structure_(State& S) override; + + // note, we override Update here because we are working around the fact that + // this is not really a Monotype evaluator, but also evaluates a flag + // (pump_on). Therefore we must override Update to get the non-const flag + // from State prior to calling Evaluate_. + virtual void Update_(State& S) override; + + // Two Evaluates are implemented here -- one is the one that accepts the + // flag, the other is the one required by the EvaluatorSecondaryMonotypeCV + // API, which is just empty and throws an error. + virtual void Evaluate_(const State& S, const std::vector& result, int& pump_on); + + virtual void Evaluate_(const State& S, const std::vector& result) override + { + AMANZI_ASSERT(false); + } + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, + const Tag& wrt_tag, + const std::vector& result) override {}; + + protected: + Key cv_key_; + Key pd_key_; + Key liq_den_key_; + Key wc_key_; + Key pe_key_; + Key elev_key_; + + Key pump_on_key_; + + std::string pump_outlet_region_; + std::string pump_inlet_region_; + std::string on_off_region_; + double max_elev_pumpline_; + double stage_on_; + double stage_off_; + + Teuchos::RCP Q_pump_; + + private: + static Utils::RegisteredFactory reg_; +}; + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator_reg.hh b/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator_reg.hh new file mode 100644 index 000000000..8c58713a9 --- /dev/null +++ b/src/pks/flow/constitutive_relations/sources/surface_pump_system_evaluator_reg.hh @@ -0,0 +1,20 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: +*/ + +#include "surface_pump_system_evaluator.hh" + +namespace Amanzi { +namespace Flow { +namespace Relations { + +Utils::RegisteredFactory SurfPumpEvaluator::reg_("pump system"); + +} // namespace Relations +} // namespace Flow +} // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/water_content/interfrost_denergy_dtemperature_evaluator.cc b/src/pks/flow/constitutive_relations/water_content/interfrost_denergy_dtemperature_evaluator.cc index c693197c3..fc0567b2f 100644 --- a/src/pks/flow/constitutive_relations/water_content/interfrost_denergy_dtemperature_evaluator.cc +++ b/src/pks/flow/constitutive_relations/water_content/interfrost_denergy_dtemperature_evaluator.cc @@ -128,7 +128,7 @@ InterfrostDenergyDtemperatureEvaluator::EvaluatePartialDerivative_( Teuchos::RCP T = S.GetPtr(T_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -147,7 +147,7 @@ InterfrostDenergyDtemperatureEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -166,7 +166,7 @@ InterfrostDenergyDtemperatureEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -185,7 +185,7 @@ InterfrostDenergyDtemperatureEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == si_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -204,7 +204,7 @@ InterfrostDenergyDtemperatureEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -223,7 +223,7 @@ InterfrostDenergyDtemperatureEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == rhos_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -242,7 +242,7 @@ InterfrostDenergyDtemperatureEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == T_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); diff --git a/src/pks/flow/constitutive_relations/water_content/interfrost_denergy_dtemperature_model.hh b/src/pks/flow/constitutive_relations/water_content/interfrost_denergy_dtemperature_model.hh index 55195fec1..059f593dc 100644 --- a/src/pks/flow/constitutive_relations/water_content/interfrost_denergy_dtemperature_model.hh +++ b/src/pks/flow/constitutive_relations/water_content/interfrost_denergy_dtemperature_model.hh @@ -26,9 +26,13 @@ class InterfrostDenergyDtemperatureModel { public: explicit InterfrostDenergyDtemperatureModel(Teuchos::ParameterList& plist); - double - DEnergyDTCoef(double phi, double sl, double nl, double si, double ni, double rhos, double T) - const; + double DEnergyDTCoef(double phi, + double sl, + double nl, + double si, + double ni, + double rhos, + double T) const; double DDEnergyDTCoefDPorosity(double phi, double sl, diff --git a/src/pks/flow/constitutive_relations/water_content/interfrost_dtheta_dpressure_evaluator.cc b/src/pks/flow/constitutive_relations/water_content/interfrost_dtheta_dpressure_evaluator.cc index 22e9f1e3c..400a88348 100644 --- a/src/pks/flow/constitutive_relations/water_content/interfrost_dtheta_dpressure_evaluator.cc +++ b/src/pks/flow/constitutive_relations/water_content/interfrost_dtheta_dpressure_evaluator.cc @@ -99,7 +99,7 @@ InterfrostDthetaDpressureEvaluator::EvaluatePartialDerivative_( Teuchos::RCP phi = S.GetPtr(phi_key_, tag); if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -114,7 +114,7 @@ InterfrostDthetaDpressureEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -129,7 +129,7 @@ InterfrostDthetaDpressureEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& nl_v = *nl->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); diff --git a/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_evaluator.cc b/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_evaluator.cc index a7ed514e2..d7eb7b6c1 100644 --- a/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_evaluator.cc +++ b/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_evaluator.cc @@ -111,7 +111,7 @@ InterfrostSlWcEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -128,7 +128,7 @@ InterfrostSlWcEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -145,7 +145,7 @@ InterfrostSlWcEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -162,7 +162,7 @@ InterfrostSlWcEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -179,7 +179,7 @@ InterfrostSlWcEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); diff --git a/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_evaluator_reg.hh b/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_evaluator_reg.hh index 4a8d9f97f..d5928e7c1 100644 --- a/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { namespace Relations { -Utils::RegisteredFactory - InterfrostSlWcEvaluator::reg_("interfrost sl water content"); +Utils::RegisteredFactory InterfrostSlWcEvaluator::reg_( + "interfrost sl water content"); } // namespace Relations } // namespace Flow diff --git a/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_model.hh b/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_model.hh index 6f1fe5ee2..5f55dbc53 100644 --- a/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_model.hh +++ b/src/pks/flow/constitutive_relations/water_content/interfrost_sl_wc_model.hh @@ -29,12 +29,21 @@ class InterfrostSlWcModel { double WaterContent(double phi, double sl, double nl, double ni, double cv) const; double DWaterContentDPorosity(double phi, double sl, double nl, double ni, double cv) const; - double - DWaterContentDSaturationLiquid(double phi, double sl, double nl, double ni, double cv) const; - double - DWaterContentDMolarDensityLiquid(double phi, double sl, double nl, double ni, double cv) const; - double - DWaterContentDMolarDensityIce(double phi, double sl, double nl, double ni, double cv) const; + double DWaterContentDSaturationLiquid(double phi, + double sl, + double nl, + double ni, + double cv) const; + double DWaterContentDMolarDensityLiquid(double phi, + double sl, + double nl, + double ni, + double cv) const; + double DWaterContentDMolarDensityIce(double phi, + double sl, + double nl, + double ni, + double cv) const; double DWaterContentDCellVolume(double phi, double sl, double nl, double ni, double cv) const; protected: diff --git a/src/pks/flow/constitutive_relations/water_content/interfrost_water_content.cc b/src/pks/flow/constitutive_relations/water_content/interfrost_water_content.cc index d3f29ee02..cb7e04ccb 100644 --- a/src/pks/flow/constitutive_relations/water_content/interfrost_water_content.cc +++ b/src/pks/flow/constitutive_relations/water_content/interfrost_water_content.cc @@ -119,16 +119,22 @@ InterfrostWaterContent::EvaluatePartialDerivative_(const State& S, result_v[0][c] = phi[0][c] * s_l[0][c] * (1 + beta_ * pr); } } else if (wrt_key == "saturation_ice") { - for (int c = 0; c != ncells; ++c) { result_v[0][c] = phi[0][c] * n_i[0][c]; } + for (int c = 0; c != ncells; ++c) { + result_v[0][c] = phi[0][c] * n_i[0][c]; + } } else if (wrt_key == "molar_density_ice") { - for (int c = 0; c != ncells; ++c) { result_v[0][c] = phi[0][c] * s_i[0][c]; } + for (int c = 0; c != ncells; ++c) { + result_v[0][c] = phi[0][c] * s_i[0][c]; + } } else if (wrt_key == "pressure") { for (int c = 0; c != ncells; ++c) { result_v[0][c] = phi[0][c] * s_l[0][c] * n_l[0][c] * beta_; } } - for (int c = 0; c != ncells; ++c) { result_v[0][c] *= cell_volume[0][c]; } + for (int c = 0; c != ncells; ++c) { + result_v[0][c] *= cell_volume[0][c]; + } }; diff --git a/src/pks/flow/constitutive_relations/water_content/interfrost_water_content_reg.hh b/src/pks/flow/constitutive_relations/water_content/interfrost_water_content_reg.hh index a1b98630a..1f7b3e174 100644 --- a/src/pks/flow/constitutive_relations/water_content/interfrost_water_content_reg.hh +++ b/src/pks/flow/constitutive_relations/water_content/interfrost_water_content_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { namespace Relations { -Utils::RegisteredFactory - InterfrostWaterContent::reg_("interfrost water content"); +Utils::RegisteredFactory InterfrostWaterContent::reg_( + "interfrost water content"); } // namespace Relations } // namespace Flow diff --git a/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_evaluator.cc b/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_evaluator.cc index 6d15e1a2e..5ca96e6b8 100644 --- a/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_evaluator.cc +++ b/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_evaluator.cc @@ -127,7 +127,7 @@ LiquidGasWaterContentEvaluator::EvaluatePartialDerivative_( Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -146,7 +146,7 @@ LiquidGasWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -165,7 +165,7 @@ LiquidGasWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -184,7 +184,7 @@ LiquidGasWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sg_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -203,7 +203,7 @@ LiquidGasWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == ng_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -222,7 +222,7 @@ LiquidGasWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == omega_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -241,7 +241,7 @@ LiquidGasWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); diff --git a/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_evaluator.hh b/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_evaluator.hh index 8ec3b99ee..f4697eac8 100644 --- a/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_evaluator.hh +++ b/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_evaluator.hh @@ -14,10 +14,10 @@ \Theta = (n_l s_l + n_g s_g \omega) \phi V -Specified with evaluator type: `"liquid+gas water content`" +`"evaluator type`" = `"liquid+gas water content`" -.. _field-evaluator-type-liquid-gas-water-content-spec: -.. admonition:: field-evaluator-type-liquid-gas-water-content-spec +.. _evaluator-liquid-gas-water-content-spec: +.. admonition:: evaluator-liquid-gas-water-content-spec DEPENDENCIES: diff --git a/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_model.hh b/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_model.hh index a253af7dc..24dee1334 100644 --- a/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_model.hh +++ b/src/pks/flow/constitutive_relations/water_content/liquid_gas_water_content_model.hh @@ -26,9 +26,13 @@ class LiquidGasWaterContentModel { public: explicit LiquidGasWaterContentModel(Teuchos::ParameterList& plist); - double - WaterContent(double phi, double sl, double nl, double sg, double ng, double omega, double cv) - const; + double WaterContent(double phi, + double sl, + double nl, + double sg, + double ng, + double omega, + double cv) const; double DWaterContentDPorosity(double phi, double sl, diff --git a/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_evaluator.cc b/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_evaluator.cc index ac30f8e0e..41f321cb3 100644 --- a/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_evaluator.cc +++ b/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_evaluator.cc @@ -120,7 +120,7 @@ LiquidIceWaterContentEvaluator::EvaluatePartialDerivative_( Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -138,7 +138,7 @@ LiquidIceWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -156,7 +156,7 @@ LiquidIceWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -174,7 +174,7 @@ LiquidIceWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == si_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -192,7 +192,7 @@ LiquidIceWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -210,7 +210,7 @@ LiquidIceWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); diff --git a/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_evaluator.hh b/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_evaluator.hh index 8fc03c6b7..f451c11d7 100644 --- a/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_evaluator.hh +++ b/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_evaluator.hh @@ -14,10 +14,10 @@ \Theta = (n_l s_l + n_i s_i) \phi V -Specified with evaluator type: `"liquid+ice water content`" +`"evaluator type`" = `"liquid+ice water content`" -.. _field-evaluator-type-liquid-ice-water-content-spec: -.. admonition:: field-evaluator-type-liquid-ice-water-content-spec +.. _evaluator-liquid-ice-water-content-spec: +.. admonition:: evaluator-liquid-ice-water-content-spec DEPENDENCIES: diff --git a/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_model.hh b/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_model.hh index 9884d55e9..584431fd4 100644 --- a/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_model.hh +++ b/src/pks/flow/constitutive_relations/water_content/liquid_ice_water_content_model.hh @@ -28,25 +28,34 @@ class LiquidIceWaterContentModel { double WaterContent(double phi, double sl, double nl, double si, double ni, double cv) const; - double - DWaterContentDPorosity(double phi, double sl, double nl, double si, double ni, double cv) const; - double - DWaterContentDSaturationLiquid(double phi, double sl, double nl, double si, double ni, double cv) + double DWaterContentDPorosity(double phi, double sl, double nl, double si, double ni, double cv) const; + double DWaterContentDSaturationLiquid(double phi, + double sl, + double nl, + double si, + double ni, + double cv) const; double DWaterContentDMolarDensityLiquid(double phi, double sl, double nl, double si, double ni, double cv) const; - double - DWaterContentDSaturationIce(double phi, double sl, double nl, double si, double ni, double cv) + double DWaterContentDSaturationIce(double phi, + double sl, + double nl, + double si, + double ni, + double cv) const; + double DWaterContentDMolarDensityIce(double phi, + double sl, + double nl, + double si, + double ni, + double cv) const; + double DWaterContentDCellVolume(double phi, double sl, double nl, double si, double ni, double cv) const; - double - DWaterContentDMolarDensityIce(double phi, double sl, double nl, double si, double ni, double cv) - const; - double - DWaterContentDCellVolume(double phi, double sl, double nl, double si, double ni, double cv) const; protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); diff --git a/src/pks/flow/constitutive_relations/water_content/overland_pressure_water_content_evaluator.cc b/src/pks/flow/constitutive_relations/water_content/overland_pressure_water_content_evaluator.cc index 705bd84e4..1ad1c908e 100644 --- a/src/pks/flow/constitutive_relations/water_content/overland_pressure_water_content_evaluator.cc +++ b/src/pks/flow/constitutive_relations/water_content/overland_pressure_water_content_evaluator.cc @@ -22,9 +22,9 @@ OverlandPressureWaterContentEvaluator::OverlandPressureWaterContentEvaluator( Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(plist) { - M_ = plist_.get("molar mass", 0.0180153); + M_ = plist_.get("molar mass [kg mol^-1]", 0.0180153); bar_ = plist_.get("allow negative water content", false); - rollover_ = plist_.get("water content rollover", 0.); + rollover_ = plist_.get("water content rollover [Pa]", 0.); Key domain_name = Keys::getDomain(my_keys_.front().first); Tag tag = my_keys_.front().second; @@ -62,7 +62,9 @@ OverlandPressureWaterContentEvaluator::Evaluate_(const State& S, int ncells = res.MyLength(); if (bar_) { - for (int c = 0; c != ncells; ++c) { res[0][c] = cv[0][c] * (pres[0][c] - p_atm) / (gz * M_); } + for (int c = 0; c != ncells; ++c) { + res[0][c] = cv[0][c] * (pres[0][c] - p_atm) / (gz * M_); + } } else if (rollover_ > 0.) { for (int c = 0; c != ncells; ++c) { double dp = pres[0][c] - p_atm; @@ -103,7 +105,9 @@ OverlandPressureWaterContentEvaluator::EvaluatePartialDerivative_( if (wrt_key == pres_key_) { int ncells = res.MyLength(); if (bar_) { - for (int c = 0; c != ncells; ++c) { res[0][c] = cv[0][c] / (gz * M_); } + for (int c = 0; c != ncells; ++c) { + res[0][c] = cv[0][c] / (gz * M_); + } } else if (rollover_ > 0.) { for (int c = 0; c != ncells; ++c) { double dp = pres[0][c] - p_atm; diff --git a/src/pks/flow/constitutive_relations/water_content/overland_pressure_water_content_evaluator.hh b/src/pks/flow/constitutive_relations/water_content/overland_pressure_water_content_evaluator.hh index 2720eeb75..15361dd07 100644 --- a/src/pks/flow/constitutive_relations/water_content/overland_pressure_water_content_evaluator.hh +++ b/src/pks/flow/constitutive_relations/water_content/overland_pressure_water_content_evaluator.hh @@ -6,9 +6,48 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - Evaluator for determining height( rho, head ) +Computes water content for a water-only surface water problem. This can be +used to both compute an extensive water content (which is always non-negative) +or a "bar" water content which can be negative for pressures less than +atmospheric pressure for use in preconditioners. + +By default: + +.. math:: + + \Theta_s = \begin{cases} + 0 & \text{if} \, p < p_{atm} \\ + V \frac{1}{M_{H2O} g_z} \frac{(p - p_{atm})^2}{2 R} & \text{if} \, p_{atm} <= p < R \\ + V \frac{1}{M_{H2O} g_z} (p - p_{atm} - \frac{R}{2}) & \text{if} \, \text{R <= p} + \end{cases} + +for molar mass :math:`M_{H2O}`, rollover cutoff :math:`R`, and gravity :math:`g`. + +If `"allow negative water content`" is true, then the first conditional is +ignored (in this case :math:`R = 0` and is ignored). + +Note this is not valid for concentration-dependent density problems. + +`"evaluator type`" = `"overland pressure water content`" + +.. _evaluator-overland-pressure-water-content-spec: +.. admonition:: evaluator-overland-pressure-water-content-spec + + * `"allow negative water content`" ``[bool]`` **false** See above + + * `"water content rollover [Pa]`" ``[double]`` **0** A smoothing term that + also can represent subgrid topography. Not typically used. + + * `"molar mass [kg mol^-1]`" ``[double]`` **0.0180153** + + DEPENDENCIES: + + - `"pressure`" + - `"cell volume`" + - `"atmospheric_pressure`" + - `"gravity`" */ diff --git a/src/pks/flow/constitutive_relations/water_content/richards_water_content_evaluator.cc b/src/pks/flow/constitutive_relations/water_content/richards_water_content_evaluator.cc index 894810b02..53709daf9 100644 --- a/src/pks/flow/constitutive_relations/water_content/richards_water_content_evaluator.cc +++ b/src/pks/flow/constitutive_relations/water_content/richards_water_content_evaluator.cc @@ -105,7 +105,7 @@ RichardsWaterContentEvaluator::EvaluatePartialDerivative_( Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -121,7 +121,7 @@ RichardsWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -137,7 +137,7 @@ RichardsWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -153,7 +153,7 @@ RichardsWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); diff --git a/src/pks/flow/constitutive_relations/water_content/richards_water_content_evaluator.hh b/src/pks/flow/constitutive_relations/water_content/richards_water_content_evaluator.hh index f982e1d1a..76b0499c1 100644 --- a/src/pks/flow/constitutive_relations/water_content/richards_water_content_evaluator.hh +++ b/src/pks/flow/constitutive_relations/water_content/richards_water_content_evaluator.hh @@ -13,10 +13,10 @@ .. math:: \Theta = n s \phi V -Specified with evaluator type: `"richards water content`" +`"evaluator type`" = `"richards water content`" -.. _field-evaluator-type-richards-water-content-spec: -.. admonition:: field-evaluator-type-richards-water-content-spec +.. _evaluator-richards-water-content-spec: +.. admonition:: evaluator-richards-water-content-spec DEPENDENCIES: diff --git a/src/pks/flow/constitutive_relations/water_content/three_phase_water_content_evaluator.cc b/src/pks/flow/constitutive_relations/water_content/three_phase_water_content_evaluator.cc index 6a0597a50..1ea6bf760 100644 --- a/src/pks/flow/constitutive_relations/water_content/three_phase_water_content_evaluator.cc +++ b/src/pks/flow/constitutive_relations/water_content/three_phase_water_content_evaluator.cc @@ -148,7 +148,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -176,7 +176,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -204,7 +204,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == nl_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -232,7 +232,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == si_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -260,7 +260,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == ni_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -288,7 +288,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == sg_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -316,7 +316,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == ng_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -344,7 +344,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == omega_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); @@ -372,7 +372,7 @@ ThreePhaseWaterContentEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == cv_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); diff --git a/src/pks/flow/constitutive_relations/water_content/three_phase_water_content_evaluator.hh b/src/pks/flow/constitutive_relations/water_content/three_phase_water_content_evaluator.hh index 6ae0fb073..1341bdf33 100644 --- a/src/pks/flow/constitutive_relations/water_content/three_phase_water_content_evaluator.hh +++ b/src/pks/flow/constitutive_relations/water_content/three_phase_water_content_evaluator.hh @@ -13,10 +13,10 @@ .. math:: \Theta = (n_l s_l + n_i s_i + n_g s_g \omega_g ) \phi V -Specified with evaluator type: `"three phase water content`" +`"evaluator type`" = `"three phase water content`" -.. _field-evaluator-type-three-phase-water-content-spec: -.. admonition:: field-evaluator-type-three-phase-water-content-spec +.. _evaluator-three-phase-water-content-spec: +.. admonition:: evaluator-three-phase-water-content-spec DEPENDENCIES: diff --git a/src/pks/flow/constitutive_relations/wrm/models/test/plot_wrm.cc b/src/pks/flow/constitutive_relations/wrm/models/test/plot_wrm.cc index ceeb67788..6da7c58fd 100644 --- a/src/pks/flow/constitutive_relations/wrm/models/test/plot_wrm.cc +++ b/src/pks/flow/constitutive_relations/wrm/models/test/plot_wrm.cc @@ -48,7 +48,9 @@ main(int argc, char* argv[]) Epetra_Vector pc(sat); Epetra_Vector krel(sat); - for (int i = 0; i != count; ++i) { sat[i] = i / (count - 1.0); } + for (int i = 0; i != count; ++i) { + sat[i] = i / (count - 1.0); + } double eps = 1e-8; bool warned = false; diff --git a/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator.cc index 2bda787d5..75f82fbbb 100644 --- a/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator.cc @@ -18,7 +18,8 @@ namespace Amanzi { namespace Flow { -PCIceEvaluator::PCIceEvaluator(Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(plist) +PCIceEvaluator::PCIceEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) { Key domain_name = Keys::getDomain(my_keys_.front().first); Tag tag = my_keys_.front().second; @@ -87,7 +88,7 @@ PCIceEvaluator::EvaluatePartialDerivative_(const State& S, if (wrt_key == temp_key_) { // evaluate d/dT( pc ) - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& temp_v = *(temp->ViewComponent(*comp, false)); const Epetra_MultiVector& dens_v = *(dens->ViewComponent(*comp, false)); @@ -100,7 +101,7 @@ PCIceEvaluator::EvaluatePartialDerivative_(const State& S, } } else if (wrt_key == dens_key_) { // evaluate d/drho( pc ) - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& temp_v = *(temp->ViewComponent(*comp, false)); const Epetra_MultiVector& dens_v = *(dens->ViewComponent(*comp, false)); diff --git a/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator.hh index 56adf0d77..50cd4f63b 100644 --- a/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator.hh @@ -6,9 +6,32 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - PCIceEvaluator is the interface between state/data and the model, an EOS. +Capillary pressure for liquid on ice. + +.. math:: + + p_{c}^{liq-ice} = \begin{cases} + 0 &\text{if} \, T >= T_0 \\ + L_f \frac{\sigma_{gas}^{liq}}{\sigma_{liq}^{ice}} \rho_l \frac{T_0 - T}{T_0} &\text{otherwise} + \end{cases} + +This may also be modified with a smoothing spline at :math:`T = T_0` for a +slower nonlinear transition. + +`"evaluator type`" = `"capillary pressure, water over ice`" + +.. _evaluator-capillary-pressure-water-over-ice-spec: +.. admonition:: evaluator-capillary-pressure-water-over-ice-spec + + * `"capillary pressure of ice-water`" ``[pc-ice-water-spec]`` + + DEPENDENCIES: + + - `"temperature`" + - `"molar density`" **molar_density_liquid** + - `"mass density`" **mass_density_liquid** */ diff --git a/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator_reg.hh b/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator_reg.hh index 050a44503..5f7ddd894 100644 --- a/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/pc_ice_evaluator_reg.hh @@ -19,8 +19,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - PCIceEvaluator::factory_("capillary pressure, water over ice"); +Utils::RegisteredFactory PCIceEvaluator::factory_( + "capillary pressure, water over ice"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/pc_ice_water.cc b/src/pks/flow/constitutive_relations/wrm/pc_ice_water.cc index 86c6bb404..05ea14cb9 100644 --- a/src/pks/flow/constitutive_relations/wrm/pc_ice_water.cc +++ b/src/pks/flow/constitutive_relations/wrm/pc_ice_water.cc @@ -18,7 +18,8 @@ namespace Flow { /* ****************************************************************** * Setup fundamental parameters for this model. ****************************************************************** */ -PCIceWater::PCIceWater(Teuchos::ParameterList& pc_plist) : pc_plist_(pc_plist) +PCIceWater::PCIceWater(Teuchos::ParameterList& pc_plist) + : pc_plist_(pc_plist) { InitializeFromPlist_(); }; diff --git a/src/pks/flow/constitutive_relations/wrm/pc_ice_water.hh b/src/pks/flow/constitutive_relations/wrm/pc_ice_water.hh index ae751a1a1..1a41d1b4a 100644 --- a/src/pks/flow/constitutive_relations/wrm/pc_ice_water.hh +++ b/src/pks/flow/constitutive_relations/wrm/pc_ice_water.hh @@ -6,26 +6,33 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Capillary pressure of ice on water. /*! + +Note that the choice of molar vs mass density above must match the units of +latent heat chosen below. + .. _pc-ice-water-spec .. admonition:: pc-ice-water-spec - * `"reference temperature [K]`" ``[double]`` **273.15** The phase transition point, T_ref above - * `"interfacial tension ice-water [mN m^-1]`" ``[double]`` **33.1** - * `"interfacial tension air-water [mN m^-1]`" ``[double]`` **72.7** - * `"smoothing width [K]`" ``[double]`` **0.** Smoothing out the freeze curve allows this to be slightly easier to solve. + * `"reference temperature [K]`" ``[double]`` **273.15** The phase transition + point, :math:`T_0` above + * `"interfacial tension ice-water [mN m^-1]`" ``[double]`` **33.1** + :math:`\sigma_{liq}^{ice} above. Note units need only match that below. + * `"interfacial tension air-water [mN m^-1]`" ``[double]`` **72.7** + :math:`\sigma_{gas}^{liq} above. Note units need only match that above. + * `"smoothing width [K]`" ``[double]`` **0.** Smoothing out the freeze + curve allows this to be slightly easier to solve. - ONE OF + ONE OF - * `"latent heat [J kg^-1]`" ``[double]`` **3.34e5** Latent heat of fusion + * `"latent heat [J kg^-1]`" ``[double]`` **3.34e5** Latent heat of fusion, + :math:`L_f` above. - OR + OR - * `"latent heat [J mol^-1]`" ``[double]`` Latent heat of fusion + * `"latent heat [J mol^-1]`" ``[double]`` Latent heat of fusion - END + END */ diff --git a/src/pks/flow/constitutive_relations/wrm/pc_liquid_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/pc_liquid_evaluator.hh index 35168bcac..c2b8fd7d6 100644 --- a/src/pks/flow/constitutive_relations/wrm/pc_liquid_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/pc_liquid_evaluator.hh @@ -7,15 +7,23 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Capillary pressure for gas on a liquid. /*! -.. _pc-liquid-evaluator-spec: -.. admonition:: pc-liquid-evaluator-spec +Capillary pressure for gas on a liquid. - KEYS: +.. math:: + + p_{c}^{gas-liq} = p - p_{atm} + +`"evaluator type`" = `"capillary pressure, atmospheric gas over liquid`" + +.. _evaluator-capillary-pressure-atmospheric-gas-over-liquid-spec: +.. admonition:: evaluator-capillary-pressure-atmospheric-gas-over-liquid-spec + + DEPENDENCIES: - `"pressure`" **DOMAIN-pressure** + - `"atmospheric pressure`" */ diff --git a/src/pks/flow/constitutive_relations/wrm/pc_liquid_evaluator_reg.hh b/src/pks/flow/constitutive_relations/wrm/pc_liquid_evaluator_reg.hh index f4a1f44a4..77f20bccc 100644 --- a/src/pks/flow/constitutive_relations/wrm/pc_liquid_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/pc_liquid_evaluator_reg.hh @@ -19,8 +19,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - PCLiquidEvaluator::factory_("capillary pressure, atmospheric gas over liquid"); +Utils::RegisteredFactory PCLiquidEvaluator::factory_( + "capillary pressure, atmospheric gas over liquid"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator.cc index 785ad4273..f5c9f0967 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator.cc @@ -221,7 +221,9 @@ RelPermEvaluator::Evaluate_(const State& S, const std::vector& const Epetra_MultiVector& visc_c = *S.GetPtr(visc_key_, tag)->ViewComponent("cell", false); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; + } // Potentially scale boundary faces. if (result[0]->HasComponent("boundary_face")) { @@ -294,7 +296,9 @@ RelPermEvaluator::EvaluatePartialDerivative_(const State& S, const Epetra_MultiVector& visc_c = *S.GetPtr(visc_key_, tag)->ViewComponent("cell", false); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; + } } // rescale as neeeded @@ -311,7 +315,9 @@ RelPermEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); int ncells = res_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] = kr_c[0][c] / dens_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] = kr_c[0][c] / dens_c[0][c]; + } // Potentially scale boundary faces. if (result[0]->HasComponent("boundary_face")) { @@ -339,7 +345,9 @@ RelPermEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); int ncells = res_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] = -kr_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] = -kr_c[0][c] / visc_c[0][c]; + } // Potentially scale boundary faces. diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator.hh index 182e0ac3a..88a79404e 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator.hh @@ -7,7 +7,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Evaluates relative permeability using water retention models. /*! Uses a list of regions and water retention models on those regions to evaluate @@ -20,10 +19,10 @@ flow PKs. Some additional parameters are available. -`"evaluator type`" = `"relative permeability, van Genuchten`" +`"evaluator type`" = `"relative permeability, water retention model`" -.. _rel-perm-evaluator-spec: -.. admonition:: rel-perm-evaluator-spec +.. _evaluator-relative-permeability-water-retention-model-spec: +.. admonition:: evaluator-relative-permeability-water-retention-model-spec * `"use density on viscosity in rel perm`" ``[bool]`` **true** @@ -40,27 +39,31 @@ Some additional parameters are available. * `"minimum rel perm cutoff`" ``[double]`` **0.** Provides a lower bound on rel perm. - * `"permeability rescaling`" ``[double]`` Typically rho * kr / mu is very big - and K_sat is very small. To avoid roundoff propagation issues, rescaling - this quantity by offsetting and equal values is encourage. Typically 10^7 or so is good. - - * `"model parameters`" ``[string]`` **WRM parameters** ``[WRM-typedinline-spec-list]`` - List (by region) of WRM specs. This will copy `"WRM parameters`" given in `"model parameters`" - under state here to evaluate relative permeability. If use `"WRM parameters`", both WRM and - relative permeability evaluators use the same set of `"WRM parameters`", which can be van Genuchten - or Brooks-Corey. If use a customed name, e.g., `"relative permeability parameters`", and declare - `"relative permeability parameters`" in `"model parameters`" under state, this allows to use - different models for WRM (by default through `"WRM parameters`") and relative permeability. + * `"model parameters`" ``[string]`` **"WRM parameters"** This will copy the + named set of parameters, which must be in :ref:`State`'s `"model + parameters`" list, into this list to evaluate relative + permeability. Usually this shares a common set of parameters (usually + called `"WRM parameters`"), with the :ref:`WRM Evaluator`. Some models + may use a customed name, e.g., `"relative permeability parameters`", and + declare `"relative permeability parameters`" in `"model parameters`" under + state, which allows one to use different models for the WRM and relative + permeability. KEYS: - - `"rel perm`" + - `"relative permeability`" + + DEPENDENCIES: + - `"saturation_liquid`" - `"density`" (if `"use density on viscosity in rel perm`" == true) - `"viscosity`" (if `"use density on viscosity in rel perm`" == true) - `"surface relative permeability`" (if `"boundary rel perm strategy`" == `"surface rel perm`") -Example 1: + + +**Example 1:** + Using the same set of van Genuchten model paramters for WRM and relative permeability .. code-block:: xml @@ -104,7 +107,9 @@ Using the same set of van Genuchten model paramters for WRM and relative permeab ... -Example 2: + +**Example 2:** + Using different set of model/paramters for WRM and relative permeability, van Genuchten for WRM and Brooks-Corey for relative permeability. Note that in this case, van Genuchten parameters and Brooks-Corey parameters need to @@ -144,7 +149,7 @@ parameters to Brooks-Corey parameters. - + diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator_reg.hh b/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator_reg.hh index be1ee796e..2e5d9bc63 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - RelPermEvaluator::factory_("relative permeability, water retention model"); +Utils::RegisteredFactory RelPermEvaluator::factory_( + "relative permeability, water retention model"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.cc index b2017fd74..ba6298dea 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.cc @@ -246,7 +246,9 @@ RelPermFrzBCEvaluator::Evaluate_(const State& S, const std::vector(visc_key_, tag)->ViewComponent("cell", false); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; + } // Potentially scale boundary faces. if (result[0]->HasComponent("boundary_face")) { @@ -324,7 +326,9 @@ RelPermFrzBCEvaluator::EvaluatePartialDerivative_(const State& S, const Epetra_MultiVector& visc_c = *S.GetPtr(visc_key_, tag)->ViewComponent("cell", false); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; + } } // rescale as neeeded @@ -368,7 +372,9 @@ RelPermFrzBCEvaluator::EvaluatePartialDerivative_(const State& S, const Epetra_MultiVector& visc_c = *S.GetPtr(visc_key_, tag)->ViewComponent("cell", false); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; + } } // rescale as neeeded @@ -384,7 +390,9 @@ RelPermFrzBCEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); int ncells = res_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] = kr_c[0][c] / dens_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] = kr_c[0][c] / dens_c[0][c]; + } // Potentially scale boundary faces. if (result[0]->HasComponent("boundary_face")) { @@ -412,7 +420,9 @@ RelPermFrzBCEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); int ncells = res_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] = -kr_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] = -kr_c[0][c] / visc_c[0][c]; + } // Potentially scale boundary faces. diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.hh index d2747a994..cf0e406bc 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator.hh @@ -4,34 +4,35 @@ The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. - Authors: Ethan Coon (ecoon@lanl.gov) - Bo Gao (gaob@ornl.gov) + Authors: Bo Gao (gaob@ornl.gov) */ - -//! Evaluates relative permeability using an empirical model for frozen conditions. /*! -This is an empirical relative permeability model according to Niu and Yang (2006). -This model is based on Brooks-Corey relative permeability model and an additional -coefficient term is added to account for the effect of soil ice. This model is -used for freezing conditions to make snowmelt water infiltrate deeper. See paper -Agnihotri et al. (2023) for discussions about the influence of relative permeability -model on discharge under freezing conditions. +This is an empirical relative permeability model according to Niu and Yang +(2006). This model is based on Brooks-Corey relative permeability model and an +additional coefficient term is added to account for the effect of soil +ice. This model is used for freezing conditions to make snowmelt water +infiltrate deeper. See paper Agnihotri et al. (2023) for discussions about the +influence of relative permeability model on discharge under freezing +conditions. .. math:: - k_{rel} = ( 1 - F_{frz} ) \times ( \frac{1 - s_{g} - s_r}{1 - s_r} )^{2*b + 3} \\ - F_{frz} = \mathrm{exp}( -\omega \times ( s_{l} + s_{g} ) ) - \mathrm{exp}( -\omega ) -Under freezing conditions, it is recommended to call Brooks-Corey based relative -permeability corrected by ice content. This model needs Brooks-Corey parameters: -Brooks-Corey lambda, Brooks-Corey saturated matric suction (Pa), and residual -saturation. The reciprocal of Brooks-Corey lambda is Clapp-Hornberger b. Use tool -`"convert_paramters_vg2bc.py`" to convert van Genuchten parameters to Brooks-Corey -paramters. The conversion method is referred to Lenhard et al. (1989) or Ma et al. (1999) -method 2. + k_{rel} &= ( 1 - F_{frz} ) \times ( \frac{1 - s_{g} - s_r}{1 - s_r} )^{2*b + 3} \\ + F_{frz} &= \mathrm{exp}( -\omega \times ( s_{l} + s_{g} ) ) - \mathrm{exp}( -\omega ) + +Under freezing conditions, it is recommended to call Brooks-Corey based +relative permeability corrected by ice content. This model needs Brooks-Corey +parameters: Brooks-Corey lambda, Brooks-Corey saturated matric suction (Pa), +and residual saturation. The reciprocal of Brooks-Corey lambda is +Clapp-Hornberger b. Use tool `"convert_paramters_vg2bc.py`" to convert van +Genuchten parameters to Brooks-Corey paramters. The conversion method is +referred to Lenhard et al. (1989) or Ma et al. (1999) method 2. -.. _rel-perm-evaluator-spec -.. admonition:: rel-perm-evaluator-spec +`"evaluator type`" = `"relative permeability, freezing Brooks-Corey`" + +.. _evaluator-relative-permeability-freezing-brooks-corey-spec: +.. admonition:: evaluator-relative-permeability-freezing-brooks-corey-spec * `"use density on viscosity in rel perm`" ``[bool]`` **true** @@ -39,31 +40,37 @@ method 2. how the rel perm is calculated on boundary faces. Note, this may be overwritten by upwinding later! One of: - - `"boundary pressure`" Evaluates kr of pressure on the boundary face, upwinds normally. - - `"interior pressure`" Evaluates kr of the pressure on the interior cell (bad idea). - - `"harmonic mean`" Takes the harmonic mean of kr on the boundary face and kr on the interior cell. - - `"arithmetic mean`" Takes the arithmetic mean of kr on the boundary face and kr on the interior cell. + - `"boundary pressure`" Evaluates kr of pressure on the boundary face, + upwinds normally. + - `"interior pressure`" Evaluates kr of the pressure on the interior cell + (bad idea). + - `"harmonic mean`" Takes the harmonic mean of kr on the boundary face + and kr on the interior cell. + - `"arithmetic mean`" Takes the arithmetic mean of kr on the boundary + face and kr on the interior cell. - `"one`" Sets the boundary kr to 1. - - `"surface rel perm`" Looks for a field on the surface mesh and uses that. - - * `"minimum rel perm cutoff`" ``[double]`` **0.** Provides a lower bound on rel perm. - - * `"permeability rescaling`" ``[double]`` Typically rho * kr / mu is very big - and K_sat is very small. To avoid roundoff propagation issues, rescaling - this quantity by offsetting and equal values is encourage. Typically 10^7 or so is good. - - * `"omega [-]`" ``[double]`` **2.0** A scale dependent parameter in the relative permeability model. - See paper Niu & Yang (2006) for details about the model. Typical values range from 2-3. - - * `"model parameters`" ``[string]`` **WRM parameters** ``[wrm-typedinline-spec-list]`` - List (by region) of WRM specs. This will copy `"WRM parameters`" given in `"model parameters`" - under state here to evaluate relative permeability. If use `"WRM parameters`", both WRM and - relative permeability evaluators use the same set of `"WRM parameters`", which can be van Genuchten - or Brooks-Corey. If use a customed name, e.g., `"relative permeability parameters`", and declare - `"relative permeability parameters`" in `"model parameters`" under state, this allows to use - different models for WRM (by default through `"WRM parameters`") and relative permeability. Typically, - under freezing conditions, van Genuchten model is used as WRM and Brooks-Corey based high frozen - rel perm is used for relative permeability. + - `"surface rel perm`" Looks for a field on the surface mesh and uses + that. + + * `"minimum rel perm cutoff`" ``[double]`` **0.** Provides a lower bound on + rel perm. + + * `"omega [-]`" ``[double]`` **2.0** A scale dependent parameter in the + relative permeability model. See paper Niu & Yang (2006) for details + about the model. Typical values range from 2-3. + + * `"model parameters`" ``[string]`` **WRM parameters** + ``[wrm-typedinline-spec-list]`` List (by region) of WRM specs. This will + copy `"WRM parameters`" given in `"model parameters`" under state here to + evaluate relative permeability. If use `"WRM parameters`", both WRM and + relative permeability evaluators use the same set of `"WRM parameters`", + which can be van Genuchten or Brooks-Corey. If use a customed name, e.g., + `"relative permeability parameters`", and declare `"relative permeability + parameters`" in `"model parameters`" under state, this allows to use + different models for WRM (by default through `"WRM parameters`") and + relative permeability. Typically, under freezing conditions, van Genuchten + model is used as WRM and Brooks-Corey based high frozen rel perm is used + for relative permeability. KEYS: @@ -74,11 +81,13 @@ method 2. - `"viscosity`" (if `"use density on viscosity in rel perm`" == true) - `"surface relative permeability`" (if `"boundary rel perm strategy`" == `"surface rel perm`") -Example: -Using van Genuchten for WRM and Brooks-Corey based high frozen rel perm for relative permeability. -Note that in this case, van Genuchten parameters and Brooks-Corey parameters need to -be consistent. Using tool `"convert_parameters_vg2bc.py`" to convert van Genuchten -parameters to Brooks-Corey parameters. +**Example:** + +Using van Genuchten for WRM and Brooks-Corey based high frozen rel perm for +relative permeability. Note that in this case, van Genuchten parameters and +Brooks-Corey parameters need to be consistent. Using tool +`"convert_parameters_vg2bc.py`" to convert van Genuchten parameters to +Brooks-Corey parameters. .. code-block:: xml diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator_reg.hh b/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator_reg.hh index 3780d1633..d9b15ba1d 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_frzBC_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - RelPermFrzBCEvaluator::factory_("relative permeability, freezing Brooks-Corey"); +Utils::RegisteredFactory RelPermFrzBCEvaluator::factory_( + "relative permeability, freezing Brooks-Corey"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator.cc index 842d01cc8..f1c211b91 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator.cc @@ -241,7 +241,9 @@ RelPermSutraIceEvaluator::Evaluate_(const State& S, const std::vector(visc_key_, tag)->ViewComponent("cell", false); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; + } // Potentially scale boundary faces. if (result[0]->HasComponent("boundary_face")) { @@ -320,7 +322,9 @@ RelPermSutraIceEvaluator::EvaluatePartialDerivative_(const State& S, const Epetra_MultiVector& visc_c = *S.GetPtr(visc_key_, tag)->ViewComponent("cell", false); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; + } } // rescale as neeeded @@ -365,7 +369,9 @@ RelPermSutraIceEvaluator::EvaluatePartialDerivative_(const State& S, const Epetra_MultiVector& visc_c = *S.GetPtr(visc_key_, tag)->ViewComponent("cell", false); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] *= dens_c[0][c] / visc_c[0][c]; + } } // rescale as neeeded @@ -381,7 +387,9 @@ RelPermSutraIceEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); int ncells = res_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] = kr_c[0][c] / dens_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] = kr_c[0][c] / dens_c[0][c]; + } // Potentially scale boundary faces. if (result[0]->HasComponent("boundary_face")) { @@ -409,7 +417,9 @@ RelPermSutraIceEvaluator::EvaluatePartialDerivative_(const State& S, Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); int ncells = res_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { res_c[0][c] = -kr_c[0][c] / visc_c[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + res_c[0][c] = -kr_c[0][c] / visc_c[0][c]; + } // Potentially scale boundary faces. diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator.hh index e29c705be..d19d795a9 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator.hh @@ -4,14 +4,11 @@ The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. - Authors: Ethan Coon (ecoon@lanl.gov) + Authors: Bo Gao (gaob@ornl.gov) */ - -//! Evaluates relative permeability using water retention models. /*! -Uses a list of regions and water retention models on those regions to evaluate -relative permeability, typically as a function of liquid saturation. +Implements the SUTRA Ice model for relative permeability. Most of the parameters are provided to the WRM model, and not the evaluator. Typically these share lists to ensure the same water retention curves, and this @@ -20,8 +17,10 @@ flow PKs. Some additional parameters are available. -.. _rel-perm-evaluator-spec -.. admonition:: rel-perm-evaluator-spec +`"evaluator type`" = `"relative permeability, SutraICE`" + +.. _evaluator-relative-permeability-sutraice-spec: +.. admonition:: evaluator-relative-permeability-sutraice-spec * `"use density on viscosity in rel perm`" ``[bool]`` **true** @@ -29,26 +28,33 @@ Some additional parameters are available. how the rel perm is calculated on boundary faces. Note, this may be overwritten by upwinding later! One of: - - `"boundary pressure`" Evaluates kr of pressure on the boundary face, upwinds normally. - - `"interior pressure`" Evaluates kr of the pressure on the interior cell (bad idea). - - `"harmonic mean`" Takes the harmonic mean of kr on the boundary face and kr on the interior cell. - - `"arithmetic mean`" Takes the arithmetic mean of kr on the boundary face and kr on the interior cell. + - `"boundary pressure`" Evaluates kr of pressure on the boundary face, + upwinds normally. + - `"interior pressure`" Evaluates kr of the pressure on the interior cell + (bad idea). + - `"harmonic mean`" Takes the harmonic mean of kr on the boundary face + and kr on the interior cell. + - `"arithmetic mean`" Takes the arithmetic mean of kr on the boundary + face and kr on the interior cell. - `"one`" Sets the boundary kr to 1. - - `"surface rel perm`" Looks for a field on the surface mesh and uses that. + - `"surface rel perm`" Looks for a field on the surface mesh and uses + that. - * `"minimum rel perm cutoff`" ``[double]`` **0.** Provides a lower bound on rel perm. + * `"minimum rel perm cutoff`" ``[double]`` **0.** Provides a lower bound on + rel perm. - * `"permeability rescaling`" ``[double]`` Typically rho * kr / mu is very big - and K_sat is very small. To avoid roundoff propagation issues, rescaling - this quantity by offsetting and equal values is encourage. Typically 10^7 or so is good. + * `"model parameters`" ``[string]`` **WRM parameters** + ``[wrm-typedinline-spec-list]`` List (by region) of WRM specs. This will + copy `"WRM parameters`" given in `"model parameters`" under state here to + evaluate relative permeability. If use `"WRM parameters`", both WRM and + relative permeability evaluators use the same set of `"WRM parameters`", + which can be van Genuchten or Brooks-Corey. If use a customed name, e.g., + `"relative permeability parameters`", and declare `"relative permeability + parameters`" in `"model parameters`" under state, this allows to use + different models for WRM (by default through `"WRM parameters`") and + relative permeability. - * `"model parameters`" ``[string]`` **WRM parameters** ``[wrm-typedinline-spec-list]`` - List (by region) of WRM specs. This will copy `"WRM parameters`" given in `"model parameters`" - under state here to evaluate relative permeability. If use `"WRM parameters`", both WRM and - relative permeability evaluators use the same set of `"WRM parameters`", which can be van Genuchten - or Brooks-Corey. If use a customed name, e.g., `"relative permeability parameters`", and declare - `"relative permeability parameters`" in `"model parameters`" under state, this allows to use - different models for WRM (by default through `"WRM parameters`") and relative permeability. + * `"coefficient in drag term of kr`" ``[double]`` **1.0** [-] KEYS: @@ -59,6 +65,7 @@ Some additional parameters are available. - `"viscosity`" (if `"use density on viscosity in rel perm`" == true) - `"surface relative permeability`" (if `"boundary rel perm strategy`" == `"surface rel perm`") + Example: Using the same set of van Genuchten model paramters for WRM and relative permeability diff --git a/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator_reg.hh b/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator_reg.hh index d4b5372d3..605f4c6fe 100644 --- a/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/rel_perm_sutraice_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - RelPermSutraIceEvaluator::factory_("relative permeability, SutraICE"); +Utils::RegisteredFactory RelPermSutraIceEvaluator::factory_( + "relative permeability, SutraICE"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator_reg.hh b/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator_reg.hh index aaa9bccb3..f6830ea09 100644 --- a/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - SuctionHeadEvaluator::factory_("WRM suction head"); +Utils::RegisteredFactory SuctionHeadEvaluator::factory_( + "WRM suction head"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_brooks_corey.cc b/src/pks/flow/constitutive_relations/wrm/wrm_brooks_corey.cc index 388356468..26d4edef9 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_brooks_corey.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_brooks_corey.cc @@ -21,7 +21,8 @@ namespace Flow { /* ****************************************************************** * Setup fundamental parameters for this model. ****************************************************************** */ -WRMBrooksCorey::WRMBrooksCorey(Teuchos::ParameterList& plist) : plist_(plist) +WRMBrooksCorey::WRMBrooksCorey(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; @@ -36,7 +37,9 @@ WRMBrooksCorey::InitializeFromPlist_() sr_ = plist_.get("residual saturation [-]", 0.0); s0_ = 1.0 - plist_.get("smoothing interval width [saturation]", 0.0); - if (s0_ < 1.) { fit_kr_.Setup(s0_, k_relative(s0_), d_k_relative(s0_), 1.0, 1.0, 0.0); } + if (s0_ < 1.) { + fit_kr_.Setup(s0_, k_relative(s0_), d_k_relative(s0_), 1.0, 1.0, 0.0); + } } diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_brooks_corey.hh b/src/pks/flow/constitutive_relations/wrm/wrm_brooks_corey.hh index 48eedc3f8..05bbb70f0 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_brooks_corey.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_brooks_corey.hh @@ -15,8 +15,10 @@ Brooks-Corey's water retention curve, typically used to determine relative permeability under freezing conditions by converting van Genuchten parameters to Brooks-Corey parameters. -.. _WRM-Brooks-Corey-spec -.. admonition:: WRM-Brooks-Corey-spec +`"WRM type`" = `"Brooks-Corey`" + +.. _wrm-brooks-corey-spec +.. admonition:: wrm-brooks-corey-spec * `"region`" ``[string]`` Region to which this applies * `"Brooks-Corey lambda [-]`" ``[double]`` Brooks-Corey's lambda diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_constant.cc b/src/pks/flow/constitutive_relations/wrm/wrm_constant.cc index 7535be61c..5be711112 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_constant.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_constant.cc @@ -22,7 +22,8 @@ const double FLOW_WRM_TOLERANCE = 1e-10; /* ****************************************************************** * Setup fundamental parameters for this model. ****************************************************************** */ -WRMConstant::WRMConstant(Teuchos::ParameterList& plist) : plist_(plist) +WRMConstant::WRMConstant(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc index d07b834b1..7decc32c2 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc @@ -130,7 +130,7 @@ WRMEvaluator::Evaluate_(const State& S, const std::vector& res // If needed, also do gas saturation if (calc_other_sat_) { - for (CompositeVector::name_iterator comp = results[1]->begin(); comp != results[1]->end(); + for (CompositeVector::name_iterator comp = results[1]->begin() ; comp != results[1]->end(); ++comp) { if (results[0]->HasComponent(*comp)) { // sat_g = 1 - sat_l @@ -202,7 +202,7 @@ WRMEvaluator::EvaluatePartialDerivative_(const State& S, // If needed, also do gas saturation if (calc_other_sat_) { - for (CompositeVector::name_iterator comp = results[1]->begin(); comp != results[1]->end(); + for (CompositeVector::name_iterator comp = results[1]->begin() ; comp != results[1]->end(); ++comp) { if (results[0]->HasComponent(*comp)) { // d_sat_g = - d_sat_l diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.hh index dc2a36b30..ce360ac4f 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.hh @@ -6,8 +6,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Evaluates saturation through water retention models. /*! Water Retention Models (WRMs) determine the saturation as a function of @@ -16,12 +14,12 @@ commonly used in practice is the van Genuchten model, but others are available d `"evaluator type`" = `"wrm`" -.. _wrm-evaluator-spec: -.. admonition:: wrm-evaluator-spec +.. _evaluator-wrm-spec: +.. admonition:: evaluator-wrm-spec - * `"model parameters`" ``[string]`` - List (by region) of WRM specs. This will copy `"WRM parameters`" given in `"model parameters`" - under state here to evaluate WRM. + * `"model parameters`" ``[string]`` **"WRM parameters"** This will + copy `"WRM parameters`" given in `"model parameters`" under state here to + evaluate WRM. KEYS: @@ -31,9 +29,24 @@ commonly used in practice is the van Genuchten model, but others are available d - `"other saturation`" **determined from evaluator name** The name of the other saturation, usually gas -- typically this is determined from the evaluator name and need not be set. + + DEPENDENCIES: + - `"capillary pressure`"` **DOMAIN-capillary_pressure_gas_liq** The name of the capillary pressure. +The resulting `"model parameters`" are expected to be a WRM partition. A WRM +partition is a list of (region, WRM) pairs, where the regions partition the +mesh. + +.. _wrm-partition-typedinline-spec: +.. admonition:: wrm-partition-typedinline-spec + + * `"region`" ``[string]`` Region on which the WRM is valid. + * `"WRM type`" ``[string]`` Name of the WRM type. + * `"_WRM_type_ parameters`" ``[_WRM_type_-spec]`` See below for the required + parameter spec for each type. + Example: .. code-block:: xml diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_factory.cc b/src/pks/flow/constitutive_relations/wrm/wrm_factory.cc index ffb9368a2..065547d3f 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_factory.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_factory.cc @@ -32,13 +32,13 @@ WRMFactory::createWRM(Teuchos::ParameterList& plist) wrm_typename = plist.get("wrm type"); } else if (plist.isParameter("WRM Type")) { Errors::Message msg; - msg << "WRMFactory: deprecated parameter \"WRM Type\" in list \"" - << plist.name() << "\" -- new parameter name is \"wrm type\""; + msg << "WRMFactory: deprecated parameter \"WRM Type\" in list \"" << plist.name() + << "\" -- new parameter name is \"wrm type\""; Exceptions::amanzi_throw(msg); } else if (plist.isParameter("WRM type")) { Errors::Message msg; - msg << "WRMFactory: deprecated parameter \"WRM type\" in list \"" - << plist.name() << "\" -- new parameter name is \"wrm type\""; + msg << "WRMFactory: deprecated parameter \"WRM type\" in list \"" << plist.name() + << "\" -- new parameter name is \"wrm type\""; Exceptions::amanzi_throw(msg); } else { // throw the missing parameter error diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_factory_reg.hh b/src/pks/flow/constitutive_relations/wrm/wrm_factory_reg.hh index 1ddfe528c..66ce7b3eb 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_factory_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_factory_reg.hh @@ -17,6 +17,6 @@ #include "wrm_factory.hh" // explicity instantitate the static data of Factory -template <> +template<> Amanzi::Utils::Factory::map_type* Amanzi::Utils::Factory::map_; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh index f44c51541..b43a52957 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh @@ -6,12 +6,18 @@ Authors: Ethan Coon */ - -/* +/*! Painter's permafrost model with freezing point depression. - */ +`"permafrost wrm type`" = `"fpd permafrost model`" + +.. _permafrost-wrm-fpd-permafrost-model-spec: +.. admonition:: permafrost-wrm-fpd-permafrost-model-spec + + * `"empty`" ``[double]`` **-1** No parameters are required for this model + +*/ #ifndef AMANZI_FLOWRELATIONS_WRM_FPD_PERMAFROST_MODEL_ #define AMANZI_FLOWRELATIONS_WRM_FPD_PERMAFROST_MODEL_ @@ -26,7 +32,9 @@ class WRM; class WRMFPDPermafrostModel : public WRMPermafrostModel { public: - explicit WRMFPDPermafrostModel(Teuchos::ParameterList& plist) : WRMPermafrostModel(plist) {} + explicit WRMFPDPermafrostModel(Teuchos::ParameterList& plist) + : WRMPermafrostModel(plist) + {} // required methods from the base class // sats[0] = sg, sats[1] = sl, sats[2] = si diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model_reg.hh b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model_reg.hh index 44d7e4311..5ec2663cc 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model_reg.hh @@ -21,8 +21,8 @@ namespace Flow { // registry of method -Utils::RegisteredFactory - WRMFPDPermafrostModel::factory_("fpd permafrost model"); +Utils::RegisteredFactory WRMFPDPermafrostModel::factory_( + "fpd permafrost model"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_smoothed_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_smoothed_permafrost_model.hh index 657f96881..59f0537c6 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_smoothed_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_smoothed_permafrost_model.hh @@ -6,19 +6,24 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Painter's permafrost model with freezing point depression, smoothed. /*! -.. _wrm-fpd-smoothed-permafrost-spec: -.. admonition:: wrm-fpd-smoothed-permafrost-spec +Painter's permafrost model with freezing point depression, smoothed. + +`"permafrost wrm type`" = `"fpd smoothed permafrost model`" + +.. _permafrost-wrm-fpd-smoothed-permafrost-model-spec: +.. admonition:: permafrost-wrm-fpd-smoothed-permafrost-model-spec - * `"reference temperature [K]`" ``[double]`` **273.15** The phase transition point - * `"interfacial tension ice-water [mN m^-1]`" ``[double]`` **33.1** - * `"interfacial tension air-water [mN m^-1]`" ``[double]`` **72.7** - * `"smoothing width [K]`" ``[double]`` **1.** Smoothing out the freeze curve allows this to be slightly easier to solve. - * `"latent heat [J kg^-1]`" ``[double]`` **3.34e5** Latent heat of fusion - * `"water density [kg m^-3]`" ``[double]`` **998.87** Density of water. Note this probably should use the calculated value. + * `"reference temperature [K]`" ``[double]`` **273.15** The phase transition + point + * `"interfacial tension ice-water [mN m^-1]`" ``[double]`` **33.1** + * `"interfacial tension air-water [mN m^-1]`" ``[double]`` **72.7** + * `"smoothing width [K]`" ``[double]`` **1.** Smoothing out the freeze curve + allows this to be slightly easier to solve. + * `"latent heat [J kg^-1]`" ``[double]`` **3.34e5** Latent heat of fusion + * `"water density [kg m^-3]`" ``[double]`` **998.87** Density of water. + Note this probably should use the calculated value. */ diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_implicit_permafrost_model.cc b/src/pks/flow/constitutive_relations/wrm/wrm_implicit_permafrost_model.cc index 27a1ff898..16150fb16 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_implicit_permafrost_model.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_implicit_permafrost_model.cc @@ -382,7 +382,9 @@ WRMImplicitPermafrostModel::si_frozen_unsaturated_nospline_(double pc_liq, std::cerr << "WRMImplicitPermafrostModel did not converge, " << max_it << " iterations, error = " << func(si) << ", s_i = " << si << ", PC_{lg,il} = " << pc_liq << "," << pc_ice << std::endl; - if (throw_ok) { Exceptions::amanzi_throw(Errors::CutTimestep()); } + if (throw_ok) { + Exceptions::amanzi_throw(Errors::CutTimestep()); + } } return si; } @@ -430,8 +432,8 @@ WRMImplicitPermafrostModel::dsi_dpc_ice_frozen_unsaturated_nospline_(double pc_l void WRMImplicitPermafrostModel::saturations(double pc_liq, double pc_ice, double (&sats)[3]) { - if (sats_unfrozen_(pc_liq, pc_ice, sats)) return; - if (sats_saturated_(pc_liq, pc_ice, sats)) return; + if (sats_unfrozen_(pc_liq, pc_ice, sats) ) return; + if (sats_saturated_(pc_liq, pc_ice, sats) ) return; sats_frozen_unsaturated_(pc_liq, pc_ice, sats); return; } @@ -439,16 +441,16 @@ WRMImplicitPermafrostModel::saturations(double pc_liq, double pc_ice, double (&s void WRMImplicitPermafrostModel::dsaturations_dpc_liq(double pc_liq, double pc_ice, double (&dsats)[3]) { - if (dsats_dpc_liq_unfrozen_(pc_liq, pc_ice, dsats)) return; - if (dsats_dpc_liq_saturated_(pc_liq, pc_ice, dsats)) return; + if (dsats_dpc_liq_unfrozen_(pc_liq, pc_ice, dsats) ) return; + if (dsats_dpc_liq_saturated_(pc_liq, pc_ice, dsats) ) return; dsats_dpc_liq_frozen_unsaturated_(pc_liq, pc_ice, dsats); }; void WRMImplicitPermafrostModel::dsaturations_dpc_ice(double pc_liq, double pc_ice, double (&dsats)[3]) { - if (dsats_dpc_ice_unfrozen_(pc_liq, pc_ice, dsats)) return; - if (dsats_dpc_ice_saturated_(pc_liq, pc_ice, dsats)) return; + if (dsats_dpc_ice_unfrozen_(pc_liq, pc_ice, dsats) ) return; + if (dsats_dpc_ice_saturated_(pc_liq, pc_ice, dsats) ) return; dsats_dpc_ice_frozen_unsaturated_(pc_liq, pc_ice, dsats); }; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_implicit_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_implicit_permafrost_model.hh index 0cc7ca742..c116b6cdf 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_implicit_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_implicit_permafrost_model.hh @@ -7,15 +7,21 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Painter's original, implicitly defined permafrost model. /*! -.. _wrm-implicit-permafrost-spec: -.. admonition:: wrm-implicit-permafrost-spec +Painter's original, implicitly defined permafrost model. - * `"converged tolerance`" ``[double]`` **1.e-12** Convergence tolerance of the implicit solve. - * `"max iterations`" ``[int]`` **100** Maximum allowable iterations of the implicit solve. - * `"solver algorithm [brent]`" ``[string]`` **brent** Only brent is currently supported. +`"permafrost wrm type`" = `"permafrost model`" + +.. _permafrost-wrm-permafrost-model-spec: +.. admonition:: permafrost-wrm-permafrost-model-spec + + * `"converged tolerance`" ``[double]`` **1.e-12** Convergence tolerance of + the implicit solve. + * `"max iterations`" ``[int]`` **100** Maximum allowable iterations of the + implicit solve. + * `"solver algorithm [brent]`" ``[string]`` **brent** Only brent is + currently supported. */ @@ -98,7 +104,9 @@ class WRMImplicitPermafrostModel : public WRMPermafrostModel { // Convergence criteria for root-finding struct Tol_ { - Tol_(double eps) : eps_(eps) {} + Tol_(double eps) + : eps_(eps) + {} bool operator()(const double& a, const double& b) const { return std::abs(a - b) <= eps_; } double eps_; }; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_interfrost_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_interfrost_permafrost_model.hh index df36b7d98..4c816cacb 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_interfrost_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_interfrost_permafrost_model.hh @@ -26,7 +26,8 @@ class WRM; class WRMInterfrostPermafrostModel : public WRMPermafrostModel { public: - explicit WRMInterfrostPermafrostModel(Teuchos::ParameterList& plist) : WRMPermafrostModel(plist) + explicit WRMInterfrostPermafrostModel(Teuchos::ParameterList& plist) + : WRMPermafrostModel(plist) { W_ = plist.get("W [K]"); sr_ = plist.get("residual saturation [-]"); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_linear_relperm.cc b/src/pks/flow/constitutive_relations/wrm/wrm_linear_relperm.cc index 751ca7818..38a3b8248 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_linear_relperm.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_linear_relperm.cc @@ -18,7 +18,8 @@ namespace Amanzi { namespace Flow { -WRMLinearRelPerm::WRMLinearRelPerm(Teuchos::ParameterList& plist) : plist_(plist) +WRMLinearRelPerm::WRMLinearRelPerm(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_linear_system.cc b/src/pks/flow/constitutive_relations/wrm/wrm_linear_system.cc index 1f182a6b0..74ab1cb90 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_linear_system.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_linear_system.cc @@ -29,7 +29,8 @@ namespace Flow { /* ****************************************************************** * Setup fundamental parameters for this model. ****************************************************************** */ -WRMLinearSystem::WRMLinearSystem(Teuchos::ParameterList& plist) : plist_(plist) +WRMLinearSystem::WRMLinearSystem(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_linear_system.hh b/src/pks/flow/constitutive_relations/wrm/wrm_linear_system.hh index 15d933b50..6586a1c72 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_linear_system.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_linear_system.hh @@ -7,17 +7,33 @@ Authors: Markus Berndt (berndt@lanl.gov) Konstantin Lipnikov (lipnikov@lanl.gov) */ - -//! A linear sat-pc curve. /*! - A linear sat-pc curve, plus a constant rel perm, makes the system linear, so - nonlinear solver should always converge in one step. +A linear sat-pc curve, plus a constant rel perm, makes the system linear, so +the nonlinear solver should always converge in one step. + +No error-checking, so the user is responsible for ensuring that the pressure +is always less than atmospheric and within the acceptable range of the slope. + +Note this is mostly for testing. + +`"WRM type`" = `"linear system`" + +.. _wrm-linear-system-spec +.. admonition:: wrm-linear-system-spec + + * `"saturation at pc=0`" ``[double]`` **1.0** + + ONE OF + + * `"alpha`" ``[double]`` Slope of the linear curve. + + OR + + * `"max pc`" ``[double]`` Capillary pressure at saturation = 0. - No error-checking, so the user is responsible for ensuring that the pressure - is always less than atmospheric and within the acceptable range of the slope. + END - Note this is mostly for testing. */ diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_macropore.cc b/src/pks/flow/constitutive_relations/wrm/wrm_macropore.cc index 18917b910..484c3b815 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_macropore.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_macropore.cc @@ -22,7 +22,8 @@ const double FLOW_WRM_TOLERANCE = 1e-10; /* ****************************************************************** * Setup fundamental parameters for this model. ****************************************************************** */ -WRMMacropore::WRMMacropore(Teuchos::ParameterList& plist) : plist_(plist) +WRMMacropore::WRMMacropore(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_mck_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_mck_permafrost_model.hh index 8faebc9ad..8de056875 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_mck_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_mck_permafrost_model.hh @@ -27,7 +27,8 @@ class WRM; class WRMMCKPermafrostModel : public WRMPermafrostModel { public: double residualSaturation(); - explicit WRMMCKPermafrostModel(Teuchos::ParameterList& plist) : WRMPermafrostModel(plist) + explicit WRMMCKPermafrostModel(Teuchos::ParameterList& plist) + : WRMPermafrostModel(plist) { T0_ = plist.get("freezing point [K]", 273.15); w_ = plist.get("sfc fitting coefficient", 3.0); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_mck_permafrost_model_reg.hh b/src/pks/flow/constitutive_relations/wrm/wrm_mck_permafrost_model_reg.hh index c363f5f5a..53086fbcf 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_mck_permafrost_model_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_mck_permafrost_model_reg.hh @@ -21,8 +21,8 @@ namespace Flow { // registry of method -Utils::RegisteredFactory - WRMMCKPermafrostModel::factory_("mck permafrost model"); +Utils::RegisteredFactory WRMMCKPermafrostModel::factory_( + "mck permafrost model"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_old_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_old_permafrost_model.hh index 74aace05c..e2612470a 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_old_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_old_permafrost_model.hh @@ -26,7 +26,9 @@ class WRM; class WRMOldPermafrostModel : public WRMPermafrostModel { public: - WRMOldPermafrostModel(Teuchos::ParameterList& plist) : WRMPermafrostModel(plist) {} + WRMOldPermafrostModel(Teuchos::ParameterList& plist) + : WRMPermafrostModel(plist) + {} // required methods from the base class // sats[0] = s_g, sats[1] = s_l, sats[2] = s_i diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_old_permafrost_model_reg.hh b/src/pks/flow/constitutive_relations/wrm/wrm_old_permafrost_model_reg.hh index a89e1e7b2..d5dd34a58 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_old_permafrost_model_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_old_permafrost_model_reg.hh @@ -19,8 +19,8 @@ Painter's permafrost model. namespace Amanzi { namespace Flow { -Utils::RegisteredFactory - WRMOldPermafrostModel::factory_("old permafrost model"); +Utils::RegisteredFactory WRMOldPermafrostModel::factory_( + "old permafrost model"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_partition.hh b/src/pks/flow/constitutive_relations/wrm/wrm_partition.hh index eae8a2bd8..bce44dfd7 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_partition.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_partition.hh @@ -7,22 +7,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! A collection of WRMs along with a Mesh Partition. -/*! - -A WRM partition is a list of (region, WRM) pairs, where the regions partition -the mesh. - -.. _wrm-partition-typedinline-spec: -.. admonition:: wrm-partition-typedinline-spec - - * `"region`" ``[string]`` Region on which the WRM is valid. - * `"WRM type`" ``[string]`` Name of the WRM type. - * `"_WRM_type_ parameters`" ``[_WRM_type_-spec]`` See below for the required - parameter spec for each type. - -*/ - #ifndef AMANZI_FLOW_RELATIONS_WRM_PARTITION_ #define AMANZI_FLOW_RELATIONS_WRM_PARTITION_ @@ -41,11 +25,11 @@ typedef std::pair, WRMPermafrostModelList WRMPermafrostModelPartition; // Non-member factory -Teuchos::RCP -createWRMPartition(Teuchos::ParameterList& plist); +Teuchos::RCP createWRMPartition(Teuchos::ParameterList& plist); -Teuchos::RCP -createWRMPermafrostModelPartition(Teuchos::ParameterList& plist, Teuchos::RCP& wrms); +Teuchos::RCP createWRMPermafrostModelPartition( + Teuchos::ParameterList& plist, + Teuchos::RCP& wrms); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh index 1b567f2da..5704ed4df 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh @@ -6,9 +6,62 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +/*! -/* - This WRM model evaluates the saturation of ice, water, and gas. +A Water Retention Model for permafrost requires the computation of saturations +of gas, liquid, and ice. Multiple models for this are available, based on the +work of `(Painter & Karra 2014) `_ + +`"evaluator type`" = `"water retention model with ice`" + +.. _evaluator-water-retention-model-with-ice-spec: +.. admonition:: evaluator-water-retention-model-with-ice-spec + + ONE OF + + * `"model parameters`" ``[string]`` **"WRM parameters"** Copies this list from + :ref:`State`'s `"model parameters`" list. + + OR + + * `"model parameters`" ``[wrm-partition-typedinline-spec-list]`` + + END + + ONE OF + + * `"permafrost model parameters`" ``[string]`` Copies this list from + :ref:`State`'s `"model parameters`" list. + + OR + + * `"permafrost model parameters`" ``[permafrost-wrm-partition-typedinline-spec]`` + + END + + + KEYS: + + - `"liquid saturation`" + - `"gas saturation`" + - `"ice saturation`" + + DEPENDENCIES: + + - `"gas-liquid capillary pressure`" **capillary_pressure_gas_liq** + - `"liquid-ice capillary pressure`" **capillary_pressure_liq_ice** + + +Like the WRM partition, the permafrost WRM partition provides (region, model) +pairs: + +.. _permafrost-wrm-partition-typedinline-spec: +.. admonition:: permafrost-wrm-partition-typedinline-spec + + * `"region`" ``[string]`` region name + * `"permafrost wrm type`" ``[string]`` name of the model + * `"_PERMAFROST_WRM_type_ parameters`" ``[_PERMAFROST_WRM_type_-spec]`` See + below for each type's spec. */ diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator_reg.hh b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator_reg.hh index 5547a12c9..611425675 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator_reg.hh @@ -20,8 +20,8 @@ namespace Amanzi { namespace Flow { // registry of method -Utils::RegisteredFactory - WRMPermafrostEvaluator::factory_("water retention model with ice"); +Utils::RegisteredFactory WRMPermafrostEvaluator::factory_( + "water retention model with ice"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_factory.hh b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_factory.hh index 4215344d7..1a876453b 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_factory.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_factory.hh @@ -28,8 +28,8 @@ namespace Flow { class WRMPermafrostFactory : public Utils::Factory { public: - Teuchos::RCP - createWRMPermafrostModel(Teuchos::ParameterList& plist, const Teuchos::RCP& wrm); + Teuchos::RCP createWRMPermafrostModel(Teuchos::ParameterList& plist, + const Teuchos::RCP& wrm); }; } // namespace Flow diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_factory_reg.hh b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_factory_reg.hh index 41b7e9d12..2b598fe34 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_factory_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_factory_reg.hh @@ -17,6 +17,6 @@ #include "wrm_permafrost_factory.hh" // explicity instantitate the static data of Factory -template <> +template<> Amanzi::Utils::Factory::map_type* Amanzi::Utils::Factory::map_; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_model.hh index 39b19695a..05b939faf 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_model.hh @@ -23,7 +23,9 @@ class WRM; class WRMPermafrostModel { public: - WRMPermafrostModel(Teuchos::ParameterList& plist) : plist_(plist) {} + WRMPermafrostModel(Teuchos::ParameterList& plist) + : plist_(plist) + {} virtual ~WRMPermafrostModel() {} diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen.cc b/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen.cc index 825f5323d..3e73c66fe 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen.cc @@ -25,7 +25,8 @@ const double FLOW_WRM_TOLERANCE = 1e-10; /* ****************************************************************** * Setup fundamental parameters for this model. ****************************************************************** */ -WRMPlantChristoffersen::WRMPlantChristoffersen(Teuchos::ParameterList& plist) : plist_(plist) +WRMPlantChristoffersen::WRMPlantChristoffersen(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; @@ -46,12 +47,9 @@ double WRMPlantChristoffersen::potential(double s) const { double psi; - if (s > sft_) - psi = potentialLinear(s); - else if (s > stlp_) - psi = fmin(potentialSol(s) + potentialP(s), potentialLinear(s)); - else - psi = potentialSol(s); + if (s > sft_) psi = potentialLinear(s); + else if (s > stlp_) psi = fmin(potentialSol(s) + potentialP(s), potentialLinear(s)); + else psi = potentialSol(s); return psi; } @@ -59,15 +57,12 @@ double WRMPlantChristoffersen::d_potential(double s) const { double dpsi; - if (s > sft_) - dpsi = d_potentialLinear(s); + if (s > sft_) dpsi = d_potentialLinear(s); else if (s > stlp_) { if ((potentialSol(s) + potentialP(s)) < potentialLinear(s)) dpsi = d_potentialSol(s) + d_potentialP(s); - else - dpsi = d_potentialLinear(s); - } else - dpsi = d_potentialSol(s); + else dpsi = d_potentialLinear(s); + } else dpsi = d_potentialSol(s); return dpsi; } @@ -123,15 +118,12 @@ WRMPlantChristoffersen::saturation(double pc) psi = -pc * 1E-6; - if (psi > psi0_) - se = (1.0 - sr_) / (sft_ - sr_); - else if (psi > psicapfttrans_) - se = (1.0 - sr_) / (sft_ - sr_) - (psi0_ - psi) / mcapstar_; + if (psi > psi0_) se = (1.0 - sr_) / (sft_ - sr_); + else if (psi > psicapfttrans_) se = (1.0 - sr_) / (sft_ - sr_) - (psi0_ - psi) / mcapstar_; else if (psi > psitlp_) { double b = std::abs(pi0_) - psi - eps_; se = (-b + sqrt(std::pow(b, 2) + 4 * eps_ * std::abs(pi0_))) / (2 * eps_); - } else - se = -std::abs(pi0_) / psi; + } else se = -std::abs(pi0_) / psi; return (se * (sft_ - sr_)) + sr_; } @@ -145,16 +137,13 @@ WRMPlantChristoffersen::d_saturation(double pc) psi = -pc * 1E-6; double dpsi = -1E-6; - if (psi > psi0_) - dse = 0; - else if (psi > psicapfttrans_) - dse = dpsi / mcapstar_; + if (psi > psi0_) dse = 0; + else if (psi > psicapfttrans_) dse = dpsi / mcapstar_; else if (psi > psitlp_) { double b = std::abs(pi0_) - psi - eps_; double db = -dpsi; dse = (db + ((db * b) / sqrt(std::pow(b, 2) + 4 * eps_ * std::abs(pi0_)))) / (2 * eps_); - } else - dse = std::abs(pi0_) * (std::pow(psi, -2)) * (dpsi); + } else dse = std::abs(pi0_) * (std::pow(psi, -2)) * (dpsi); return dse * (sft_ - sr_); } diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen.hh b/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen.hh index b50afa5d1..6d32b001b 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen.hh @@ -92,7 +92,9 @@ class WRMPlantChristoffersen : public WRM { struct Tol_ { - Tol_(double eps) : eps_(eps) {} + Tol_(double eps) + : eps_(eps) + {} bool operator()(const double& a, const double& b) const { return std::abs(a - b) <= eps_; } double eps_; }; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen_reg.hh b/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen_reg.hh index 5e46e4edb..32f455df7 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen_reg.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_plants_christoffersen_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { -Utils::RegisteredFactory - WRMPlantChristoffersen::factory_("plant Christoffersen"); +Utils::RegisteredFactory WRMPlantChristoffersen::factory_( + "plant Christoffersen"); } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_sutra_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_sutra_permafrost_model.hh index 00680a1ad..e6bac2e19 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_sutra_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_sutra_permafrost_model.hh @@ -12,8 +12,8 @@ This model is based on the emperical freezing curve used by Sutra-Ice, documented in papers by Voss & Walvoord. -.. _wrm-sutra-permafrost-model-spec: -.. admonition:: wrm-sutra-permafrost-model-spec +.. _permafrost-wrm-sutra-permafrost-model-spec: +.. admonition:: permafrost-wrm-sutra-permafrost-model-spec * `"temperature transition [K]`" ``[double]`` thickness of the transition from frozen to thawed * `"residual saturation [-]`" ``[double]`` Standard residual saturation @@ -35,7 +35,8 @@ class WRM; class WRMSutraPermafrostModel : public WRMPermafrostModel { public: - explicit WRMSutraPermafrostModel(Teuchos::ParameterList& plist) : WRMPermafrostModel(plist) + explicit WRMSutraPermafrostModel(Teuchos::ParameterList& plist) + : WRMPermafrostModel(plist) { T0_ = plist.get("freezing point [K]", 273.15); dT_ = plist.get("temperature transition [K]"); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc index 1cacf485d..afe26e865 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc @@ -23,7 +23,8 @@ const double FLOW_WRM_TOLERANCE = 1e-10; /* ****************************************************************** * Setup fundamental parameters for this model. ****************************************************************** */ -WRMVanGenuchten::WRMVanGenuchten(Teuchos::ParameterList& plist) : plist_(plist) +WRMVanGenuchten::WRMVanGenuchten(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; @@ -69,8 +70,7 @@ WRMVanGenuchten::d_k_relative(double s) double dkdse; if (function_ == FLOW_WRM_MUALEM) dkdse = (1.0 - y) * (l_ * (1.0 - y) + 2 * x * y / (1.0 - x)) * pow(se, l_ - 1.0); - else - dkdse = (2 * (1.0 - y) + x / (1.0 - x)) * se; + else dkdse = (2 * (1.0 - y) + x / (1.0 - x)) * se; return dkdse / (1 - sr_); @@ -223,10 +223,14 @@ WRMVanGenuchten::InitializeFromPlist_() } s0_ = 1.0 - plist_.get("smoothing interval width [saturation]", 0.0); - if (s0_ < 1.) { fit_kr_.Setup(s0_, k_relative(s0_), d_k_relative(s0_), 1.0, 1.0, 0.0); } + if (s0_ < 1.) { + fit_kr_.Setup(s0_, k_relative(s0_), d_k_relative(s0_), 1.0, 1.0, 0.0); + } pc0_ = plist_.get("saturation smoothing interval [Pa]", 0.0); - if (pc0_ > 0.) { fit_s_.Setup(0.0, 1.0, 0.0, pc0_, saturation(pc0_), d_saturation(pc0_)); } + if (pc0_ > 0.) { + fit_s_.Setup(0.0, 1.0, 0.0, pc0_, saturation(pc0_), d_saturation(pc0_)); + } }; /* ****************************************************************** diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.hh b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.hh index d594a07a3..b1fc70d12 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.hh @@ -12,8 +12,10 @@ van Genuchten's water retention curve. -.. _WRM-van-Genuchten-spec: -.. admonition:: WRM-van-Genuchten-spec +`"WRM type`" = `"van Genuchten`" + +.. _wrm-van-genuchten-spec: +.. admonition:: wrm-van-genuchten-spec * `"region`" ``[string]`` Region to which this applies * `"van Genuchten alpha [Pa^-1]`" ``[double]`` van Genuchten's alpha diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_zero_relperm.cc b/src/pks/flow/constitutive_relations/wrm/wrm_zero_relperm.cc index f07660fad..e4618d91b 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_zero_relperm.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_zero_relperm.cc @@ -18,7 +18,8 @@ namespace Amanzi { namespace Flow { -WRMZeroRelPerm::WRMZeroRelPerm(Teuchos::ParameterList& plist) : plist_(plist) +WRMZeroRelPerm::WRMZeroRelPerm(Teuchos::ParameterList& plist) + : plist_(plist) { InitializeFromPlist_(); }; diff --git a/src/pks/flow/flow_bc_factory.hh b/src/pks/flow/flow_bc_factory.hh index e6ac788ce..561198cd2 100644 --- a/src/pks/flow/flow_bc_factory.hh +++ b/src/pks/flow/flow_bc_factory.hh @@ -18,7 +18,7 @@ /*! Flow boundary conditions must follow the general format shown in -BoundaryConditions_. Specific conditions implemented include: +`Boundary Conditions`_. Specific conditions implemented include: Dirichlet (pressure) boundary conditions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/pks/flow/icy_overland.cc b/src/pks/flow/icy_overland.cc index 7615ff4ff..5177dac00 100644 --- a/src/pks/flow/icy_overland.cc +++ b/src/pks/flow/icy_overland.cc @@ -17,8 +17,6 @@ IcyOverlandFlow::SetupPhysicalEvaluators_() { // ensure that the overland conductivity uses the unfrozen ponded depth // -- set the height key to be eta * h, not just h, for the frozen case. - //AMANZI_ASSERT(plist_->isSublist("overland conductivity evaluator") || plist_->isSublist("overland conductivity subgrid evaluator")); - if (plist_->isSublist("overland conductivity evaluator")) { if (!plist_->sublist("overland conductivity evaluator").isParameter("depth key")) { plist_->sublist("overland conductivity evaluator") @@ -27,6 +25,7 @@ IcyOverlandFlow::SetupPhysicalEvaluators_() AMANZI_ASSERT( plist_->sublist("overland conductivity evaluator").get("depth key") != Keys::getKey(domain_, "ponded_depth")); + } else if (plist_->isSublist("overland conductivity subgrid evaluator")) { if (!plist_->sublist("overland conductivity subgrid evaluator").isParameter("depth key")) { plist_->sublist("overland conductivity subgrid evaluator") diff --git a/src/pks/flow/icy_overland.hh b/src/pks/flow/icy_overland.hh index b295f1d4c..54edb921e 100644 --- a/src/pks/flow/icy_overland.hh +++ b/src/pks/flow/icy_overland.hh @@ -6,18 +6,15 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Two-phase overland flow equation. /*! This modifies the diffusion wave equation for overland flow that includes -freeze-thaw processes. This class could completely go away, but it does some -error checking on the input file to make sure freeze-thaw processes are done -correctly. In the future this service should be done by a preprocessor -generating the input file, and this class would go away. +freeze-thaw processes. + +`"PK type`" = `"overland flow with ice`" -.. _icy-overland-spec: -.. admonition:: icy-overland-spec +.. _pk-overland-flow-with-ice-spec: +.. admonition:: pk-overland-flow-with-ice-spec INCLUDES: diff --git a/src/pks/flow/interfrost.cc b/src/pks/flow/interfrost.cc index 70f49caa6..fcc9effb3 100644 --- a/src/pks/flow/interfrost.cc +++ b/src/pks/flow/interfrost.cc @@ -7,6 +7,7 @@ Authors: Ethan Coon (coonet@ornl.gov) */ +#include "TensorVector.hh" #include "Op.hh" #include "interfrost.hh" @@ -45,12 +46,14 @@ Interfrost::UpdatePreconditioner(double t, Teuchos::RCP up, do { // VerboseObject stuff. Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon update at t = " << t << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon update at t = " << t << std::endl; // Recreate mass matrices - if (!deform_key_.empty() && - S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " precon")) - preconditioner_diff_->SetTensorCoefficient(K_); + if ((!deform_key_.empty() && + S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " precon")) || + S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " precon")) + preconditioner_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); // update state with the solution up. AMANZI_ASSERT(std::abs(S_->get_time(tag_next_) - t) <= 1.e-4 * t); diff --git a/src/pks/flow/overland_pressure.hh b/src/pks/flow/overland_pressure.hh index 40e160da0..6ca6ef39a 100644 --- a/src/pks/flow/overland_pressure.hh +++ b/src/pks/flow/overland_pressure.hh @@ -6,115 +6,105 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Overland flow using the diffusion wave equation. /*! -Solves the diffusion wave equation for overland flow with pressure as a primary variable: +The overland flow PK solves the diffusion wave equation for overland flow with +pressure as a primary variable: .. math:: \frac{\partial \Theta}{\partial t} - \nabla n_l k \nabla h(p) = Q_w +`"PK type`" = `"overland flow, pressure basis`" -.. _overland-pressure-spec: -.. admonition:: overland-pressure-spec - - Keys name variables: - - * `"domain`" ``[string]`` **"surface"** Defaults to the extracted surface mesh. - - * `"primary variable`" ``[string]`` The primary variable associated with - this PK, typically `"DOMAIN-pressure`" Note there is no default -- this - must be provided by the user. +.. _pk-overland-flow-pressure-basis-spec: +.. admonition:: pk-overland-flow-pressure-basis-spec - * `"boundary conditions`" ``[list]`` Defaults to Neuman, 0 normal flux. + * `"domain`" ``[string]`` **"surface"** Defaults to the extracted surface mesh. - * `"overland conductivity evaluator`" ``[list]`` - See `Overland Conductivity Evaluator`_. + * `"primary variable`" ``[string]`` **DOMAIN-pressure** The primary + variable associated with this PK. - IF + * `"boundary conditions`" ``[list]`` Defaults to Neuman, 0 normal flux. + See :ref:`Flow-specific Boundary Conditions` - * `"source term`" ``[bool]`` **false** Is there a source term? + IF - THEN + * `"source term`" ``[bool]`` **false** Is there a source term? - * `"source key`" ``[string]`` **DOMAIN-water_source** Typically - not set, as the default is good. ``[m s^-1]`` or ``[mol s^-1]`` - * `"water source in meters`" ``[bool]`` **true** Is the source term in ``[m s^-1]``? + THEN - END + * `"source key`" ``[string]`` **DOMAIN-water_source** Typically + not set, as the default is good. ``[m s^-1]`` or ``[mol s^-1]`` + * `"water source in meters`" ``[bool]`` **true** Is the source term in ``[m s^-1]``? - Math and solver algorithm options: + END - * `"diffusion`" ``[pde-diffusion-spec]`` The (forward) diffusion operator, - see PDE_Diffusion_. + Math and solver algorithm options: - * `"diffusion preconditioner`" ``[pde-diffusion-spec]`` **optional** The - inverse of the diffusion operator. See PDE_Diffusion_. Typically this - is only needed to set Jacobian options, as all others probably should - match those in `"diffusion`", and default to those values. + * `"absolute error tolerance`" ``[double]`` **550.** Defaults to 1 cm of + water (in mols). A small, but significant, amount of water. - * `"absolute error tolerance`" ``[double]`` **550.** Defaults to 1 cm of - water. A small, but significant, amount of water. + * `"inverse`" ``[inverse-spec]`` **optional** The inverse used for + preconditioning in a non-globally coupled problem. See :ref:`Inverse`. - * `"limit correction to pressure change [Pa]`" ``[double]`` **-1** If > 0, - this limits an iterate's max pressure change to this value. Not usually - helpful. + * `"diffusion`" ``[pde-diffusion-typedinline-spec]`` The (forward) diffusion + operator, see :ref:`Diffusion`. - * `"limit correction to pressure change when crossing atmospheric [Pa]`" ``[double]`` **-1** - If > 0, this limits an iterate's max pressure change - to this value when they cross atmospheric pressure. Not usually helpful. + * `"diffusion preconditioner`" ``[pde-diffusion-typedinline-spec]`` + **optional** The inverse of the diffusion operator. See :ref:`Diffusion`. + Typically this is only needed to set Jacobian options, as all others + probably should match those in `"diffusion`", and default to those values. - * `"allow no negative ponded depths`" ``[bool]`` **false** Modifies all - correction updates to ensure only positive ponded depth is allowed. + * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` **optional** + The inverse of the accumulation operator. See :ref:`Accumulation`. + Typically not provided by users, as defaults are sufficient. - * `"min ponded depth for velocity calculation`" ``[double]`` **1.e-2** For - ponded depth below this height, declare the velocity 0. + Globalization: - * `"min ponded depth for tidal bc`" ``[double]`` **0.02** Control on the - tidal boundary condition. TODO: This should live in the BC spec? + * `"limit correction to pressure change [Pa]`" ``[double]`` **-1** If > 0, + this limits an iterate's max pressure change to this value. Not usually + helpful. - INCLUDES: + * `"limit correction to pressure change when crossing atmospheric [Pa]`" + ``[double]`` **-1** If > 0, this limits an iterate's max pressure change + to this value when they cross atmospheric pressure. Not usually helpful. - - ``[pk-physical-bdf-default-spec]`` A `PK: Physical and BDF`_ spec. + * `"allow no negative ponded depths`" ``[bool]`` **false** Modifies all + correction updates to ensure only positive ponded depth is allowed. - Everything below this point is usually not provided by the user, but are - documented here for completeness. + * `"min ponded depth for velocity calculation`" ``[double]`` **1.e-2** For + ponded depth below this height, declare the velocity 0. - Keys name variables: + * `"min ponded depth for tidal bc`" ``[double]`` **0.02** Control on the + tidal boundary condition. TODO: This should live in the BC spec? - * `"conserved quantity key`" ``[string]`` **DOMAIN-water_content** Typically - not set, as the default is good. ``[mol]`` - * `"elevation key`" ``[string]`` **DOMAIN-elevation** Typically - not set, as the default is good. ``[mol]`` - * `"slope magnitude key`" ``[string]`` **DOMAIN-slope_magnitude** Typically - not set, as the default is good. ``[mol]`` + Algorithmic physics control: - Algorithmic parameters: + * `"coupled to subsurface via flux`" ``[bool]`` **false** Set by MPC. + * `"coupled to subsurface via head`" ``[bool]`` **false** Set by MPC. - * `"coupled to subsurface via flux`" ``[bool]`` **false** Set by MPC. - * `"coupled to subsurface via head`" ``[bool]`` **false** Set by MPC. + INCLUDES: - * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` **optional** - The inverse of the accumulation operator. See PDE_Accumulation_. - Typically not provided by users, as defaults are correct. + - ``[pk-physical-bdf-default-spec]`` A :ref:`PK: Physical and BDF` spec. - EVALUATORS: + KEYS: - - `"conserved quantity`" - - `"water content`" - - `"cell volume`" - - `"surface_subsurface_flux`" - - `"elevation`" - - `"slope magnitude`" - - `"overland_conductivity`" - - `"ponded_depth`" - - `"pres_elev`" - - `"source`" + - `"conserved quantity`" **DOMAIN-water_content** ``[mol]`` + - `"elevation`" **DOMAIN-elevation** ``[m]`` + - `"slope magnitude`" **DOMAIN-slope_magnitude** ``[-]`` + EVALUATORS: -.. todo: - Nearly all variable name roots are hard-coded here, this should get updated. + - `"conserved quantity`" + - `"water content`" + - `"cell volume`" + - `"surface_subsurface_flux`" + - `"elevation`" + - `"slope magnitude`" + - `"overland_conductivity`" + - `"ponded_depth`" + - `"pres_elev`" + - `"source`" */ @@ -180,24 +170,25 @@ class OverlandPressureFlow : public PK_PhysicalBDF_Default { Teuchos::RCP g) override; // applies preconditioner to u and returns the result in Pu - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; // updates the preconditioner virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; - virtual bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + virtual bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; // evaluating consistent faces for given BCs and cell values virtual void CalculateConsistentFaces(const Teuchos::Ptr& u); // -- Possibly modify the correction before it is applied - virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult - ModifyCorrection(double h, - Teuchos::RCP res, - Teuchos::RCP u, - Teuchos::RCP du) override; + virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult ModifyCorrection( + double h, + Teuchos::RCP res, + Teuchos::RCP u, + Teuchos::RCP du) override; protected: // setup methods @@ -210,8 +201,8 @@ class OverlandPressureFlow : public PK_PhysicalBDF_Default { virtual void ApplyBoundaryConditions_(const Teuchos::Ptr& u, const Teuchos::Ptr& elev); - virtual void - FixBCsForOperator_(const Tag& tag, const Teuchos::Ptr& diff_op); + virtual void FixBCsForOperator_(const Tag& tag, + const Teuchos::Ptr& diff_op); virtual void FixBCsForPrecon_(const Tag& tag); // computational concerns in managing abs, rel perm diff --git a/src/pks/flow/overland_pressure_physics.cc b/src/pks/flow/overland_pressure_physics.cc index d63991aab..f9ef0455d 100644 --- a/src/pks/flow/overland_pressure_physics.cc +++ b/src/pks/flow/overland_pressure_physics.cc @@ -7,7 +7,7 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "overland_pressure.hh" namespace Amanzi { @@ -102,7 +102,9 @@ OverlandPressureFlow::AddSourceTerms_(const Teuchos::Ptr& g) *S_->Get(source_key_, tag_next_).ViewComponent("cell", false); db_->WriteVector(" source", S_->GetPtr(source_key_, tag_next_).ptr(), false); int ncells = g_c.MyLength(); - for (int c = 0; c != ncells; ++c) { g_c[0][c] -= cv1[0][c] * source1[0][c]; } + for (int c = 0; c != ncells; ++c) { + g_c[0][c] -= cv1[0][c] * source1[0][c]; + } } if (coupled_to_subsurface_via_head_) { diff --git a/src/pks/flow/overland_pressure_pk.cc b/src/pks/flow/overland_pressure_pk.cc index f4310e996..512b3e1db 100644 --- a/src/pks/flow/overland_pressure_pk.cc +++ b/src/pks/flow/overland_pressure_pk.cc @@ -26,7 +26,7 @@ #include "upwind_total_flux.hh" #include "UpwindFluxFactory.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "overland_pressure.hh" @@ -64,6 +64,8 @@ OverlandPressureFlow::parseParameterList() plist_->set("absolute error tolerance", 0.01 * 55000.0); // h * nl // set some defaults for inherited PKs + if (!plist_->isParameter("primary variable key suffix")) + plist_->set("primary variable key suffix", "pressure"); if (!plist_->isParameter("conserved quantity key suffix")) plist_->set("conserved quantity key suffix", "water_content"); @@ -115,8 +117,13 @@ OverlandPressureFlow::parseParameterList() patm_limit_ = plist_->get("limit correction when crossing atmospheric pressure [Pa]", -1.); patm_hard_limit_ = plist_->get("allow no negative ponded depths", false); + + // see amanzi/ats#32 -- this seems way too high min_vel_ponded_depth_ = plist_->get("min ponded depth for velocity calculation", 1e-2); min_tidal_bc_ponded_depth_ = plist_->get("min ponded depth for tidal bc", 0.02); + + // require a few primary variable keys now to set the leaf node in the dep graph + requireEvaluatorAtCurrent(pd_key_, tag_current_, *S_, name_); } @@ -129,16 +136,16 @@ OverlandPressureFlow::Setup() PK_PhysicalBDF_Default::Setup(); // -- water content, and evaluator, and derivative for PC - requireAtNext(conserved_key_, tag_next_, *S_) + requireEvaluatorAtNext(conserved_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // and at the current time, where it is a copy evaluator - requireAtCurrent(conserved_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(conserved_key_, tag_current_, *S_, name_); // this pk uses density to invert for velocity from flux - requireAtNext(molar_dens_key_, tag_next_, *S_) + requireEvaluatorAtNext(molar_dens_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -327,23 +334,24 @@ OverlandPressureFlow::SetupOverlandFlow_() // NOTE: no need to require evaluator for p here, this was done in pk_physical // potential may not actually need cells, but for debugging and sanity's sake, we require them - requireAtNext(potential_key_, tag_next_, *S_) + requireEvaluatorAtNext(potential_key_, tag_next_, *S_) .Update(matrix_->RangeMap()) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) ->AddComponent("boundary_face", AmanziMesh::Entity_kind::BOUNDARY_FACE, 1); // flux - requireAtNext(flux_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(flux_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetGhosted() ->SetComponent("face", AmanziMesh::Entity_kind::FACE, 1); // velocity for diagnostics - requireAtNext(velocity_key_, Tags::NEXT, *S_, name_) + requireEvaluatorAtNext(velocity_key_, Tags::NEXT, *S_, name_) .SetMesh(mesh_) ->SetGhosted() - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 3); + ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 2); + S_->GetRecordSetW(velocity_key_).set_subfieldnames(mesh_->getSpaceDimensionNames()); }; @@ -375,7 +383,7 @@ OverlandPressureFlow::SetupPhysicalEvaluators_() "dependencies", std::vector{ source_key_meters, source_molar_dens_key_ }); } - requireAtNext(source_key_, tag_next_, *S_) + requireEvaluatorAtNext(source_key_, tag_next_, *S_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -388,7 +396,7 @@ OverlandPressureFlow::SetupPhysicalEvaluators_() } // -- water content bar (can be negative) - requireAtNext(wc_bar_key_, tag_next_, *S_) + requireEvaluatorAtNext(wc_bar_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -396,13 +404,13 @@ OverlandPressureFlow::SetupPhysicalEvaluators_() wc_bar_key_, tag_next_, key_, tag_next_); // -- ponded depth - requireAtNext(pd_key_, tag_next_, *S_).Update(matrix_->RangeMap())->SetGhosted(); + requireEvaluatorAtNext(pd_key_, tag_next_, *S_, true).Update(matrix_->RangeMap())->SetGhosted(); S_->RequireDerivative(pd_key_, tag_next_, key_, tag_next_); // ...with a copy at the old time - requireAtCurrent(pd_key_, tag_current_, *S_, pd_key_); + requireEvaluatorAtCurrent(pd_key_, tag_current_, *S_, pd_key_); // -- ponded depth bar (can be negative) - requireAtNext(pd_bar_key_, tag_next_, *S_) + requireEvaluatorAtNext(pd_bar_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -410,7 +418,7 @@ OverlandPressureFlow::SetupPhysicalEvaluators_() pd_bar_key_, tag_next_, key_, tag_next_); // -- conductivity evaluator - requireAtNext(cond_key_, tag_next_, *S_) + requireEvaluatorAtNext(cond_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) @@ -428,7 +436,7 @@ OverlandPressureFlow::Initialize() // initial condition is tricky if (!S_->GetRecord(key_, tag_next_).initialized()) { - if (!plist_->isSublist("initial condition")) { + if (!plist_->isSublist("initial conditions")) { Errors::Message message; message << name_ << " has no initial condition parameter list."; Exceptions::amanzi_throw(message); @@ -443,7 +451,7 @@ OverlandPressureFlow::Initialize() // There is a function to do this already in that MPC. // // set the cell initial condition if it is taken from the subsurface - Teuchos::ParameterList ic_plist = plist_->sublist("initial condition"); + Teuchos::ParameterList ic_plist = plist_->sublist("initial conditions"); if (ic_plist.get("initialize surface head from subsurface", false)) { Epetra_MultiVector& pres = *pres_cv->ViewComponent("cell", false); @@ -498,10 +506,8 @@ OverlandPressureFlow::Initialize() .ViewComponent("cell", false); // -- get the surface cell's equivalent subsurface face and neighboring cell - if (pres[0][0] > 101325.) - pres_star[0][c] = pres[0][0]; - else - pres_star[0][c] = 101325.0; + if (pres[0][0] > 101325.) pres_star[0][c] = pres[0][0]; + else pres_star[0][c] = 101325.0; } S_->GetRecordW(key_, tag_next_, name_).set_initialized(); } @@ -613,7 +619,9 @@ OverlandPressureFlow::CalculateDiagnostics(const Tag& tag) for (int i = 0; i != d; ++i) { rhs[i] += normal[i] * flux_f[0][f]; matrix(i, i) += normal[i] * normal[i]; - for (int j = i + 1; j < d; ++j) { matrix(j, i) = matrix(i, j) += normal[i] * normal[j]; } + for (int j = i + 1; j < d; ++j) { + matrix(j, i) = matrix(i, j) += normal[i] * normal[j]; + } } } @@ -637,7 +645,7 @@ bool OverlandPressureFlow::UpdatePermeabilityData_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating permeability?"; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating permeability?"; bool update_perm = S_->GetEvaluator(pd_key_, tag).Update(*S_, name_); @@ -692,7 +700,7 @@ OverlandPressureFlow::UpdatePermeabilityData_(const Tag& tag) upwinding_->Update(*cond, *uw_cond, *S_); } - if (update_perm && vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " TRUE." << std::endl; + if (update_perm && vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " TRUE." << std::endl; return update_perm; } @@ -704,7 +712,7 @@ bool OverlandPressureFlow::UpdatePermeabilityDerivativeData_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating permeability derivatives?"; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating permeability derivatives?"; bool update_perm = S_->GetEvaluator(cond_key_, tag).UpdateDerivative(*S_, name_, pd_key_, tag); Teuchos::RCP dcond = @@ -722,9 +730,10 @@ OverlandPressureFlow::UpdatePermeabilityDerivativeData_(const Tag& tag) } } - db_->WriteVector("dk_cond", S_->GetDerivativePtr(cond_key_, tag, pd_key_, tag).ptr(), true); + db_->WriteVector( + "dk_cond", S_->GetDerivativePtr(cond_key_, tag, pd_key_, tag).ptr(), true); - if (update_perm && vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " TRUE." << std::endl; + if (update_perm && vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " TRUE." << std::endl; return update_perm; } @@ -757,7 +766,7 @@ void OverlandPressureFlow::UpdateBoundaryConditions_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating BCs." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating BCs." << std::endl; auto& markers = bc_markers(); auto& values = bc_values(); @@ -838,10 +847,8 @@ OverlandPressureFlow::UpdateBoundaryConditions_(const Tag& tag) markers[f] = Operators::OPERATOR_BC_DIRICHLET; double val = bc.second; - if (elevation[0][f] > val) - values[f] = 0; - else - values[f] = val; + if (elevation[0][f] > val) values[f] = 0; + else values[f] = val; } if (bc_dynamic_->size() > 0) { @@ -873,7 +880,7 @@ OverlandPressureFlow::UpdateBoundaryConditions_(const Tag& tag) const Epetra_MultiVector& nliq_c = *S_->GetPtr(molar_dens_key_, tag)->ViewComponent("cell"); - for (auto bc_lvl = bc_level_flux_lvl_->begin(), bc_vel = bc_level_flux_vel_->begin(); + for (auto bc_lvl = bc_level_flux_lvl_->begin() , bc_vel = bc_level_flux_vel_->begin(); bc_lvl != bc_level_flux_lvl_->end(); ++bc_lvl, ++bc_vel) { int f = bc_lvl->first; @@ -882,8 +889,7 @@ OverlandPressureFlow::UpdateBoundaryConditions_(const Tag& tag) markers[f] = Operators::OPERATOR_BC_NEUMANN; double val = bc_lvl->second; - if (elevation[0][f] > val) - values[f] = 0; + if (elevation[0][f] > val) values[f] = 0; else { values[f] = (val - elevation[0][f]) * nliq_c[0][c] * bc_vel->second; } @@ -1237,7 +1243,7 @@ OverlandPressureFlow::ModifyPredictor(double h, Teuchos::RCP u) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Modifying predictor:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Modifying predictor:" << std::endl; return false; }; @@ -1263,7 +1269,7 @@ OverlandPressureFlow::ModifyCorrection(double h, } // debugging -- remove me! --etc - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); double max, l2; @@ -1312,12 +1318,14 @@ OverlandPressureFlow::ModifyCorrection(double h, } if (n_limited_spurt > 0) { - if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << " limiting the spurt." << std::endl; } + if (vo_->os_OK(Teuchos::VERB_HIGH)) { + *vo_->os() << " limiting the spurt." << std::endl; + } } // debugging -- remove me! --etc if (vo_->os_OK(Teuchos::VERB_HIGH)) { - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); double max, l2; @@ -1334,7 +1342,7 @@ OverlandPressureFlow::ModifyCorrection(double h, *vo_->os() << "p_limit_ = " << p_limit_ << std::endl; if (p_limit_ > 0.) { - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); @@ -1356,11 +1364,13 @@ OverlandPressureFlow::ModifyCorrection(double h, } if (n_limited_change > 0) { - if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << " limited by pressure." << std::endl; } + if (vo_->os_OK(Teuchos::VERB_HIGH)) { + *vo_->os() << " limited by pressure." << std::endl; + } } // debugging -- remove me! --etc - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); double max, l2; diff --git a/src/pks/flow/overland_pressure_pk_reg.hh b/src/pks/flow/overland_pressure_pk_reg.hh index d531e81c4..d08dc9cd8 100644 --- a/src/pks/flow/overland_pressure_pk_reg.hh +++ b/src/pks/flow/overland_pressure_pk_reg.hh @@ -12,8 +12,8 @@ namespace Amanzi { namespace Flow { -RegisteredPKFactory - OverlandPressureFlow::reg_("overland flow, pressure basis"); +RegisteredPKFactory OverlandPressureFlow::reg_( + "overland flow, pressure basis"); } // namespace Flow diff --git a/src/pks/flow/overland_pressure_ti.cc b/src/pks/flow/overland_pressure_ti.cc index 5d0694d8d..f647cbe73 100644 --- a/src/pks/flow/overland_pressure_ti.cc +++ b/src/pks/flow/overland_pressure_ti.cc @@ -53,7 +53,9 @@ OverlandPressureFlow::FunctionalResidual(double t_old, // debugging -- write primary variables to screen db_->WriteCellInfo(true); std::vector vnames{ "p_old", "p_new" }; - std::vector> vecs{ S_->GetPtr(key_, tag_current_).ptr(), u.ptr() }; + std::vector> vecs{ + S_->GetPtr(key_, tag_current_).ptr(), u.ptr() + }; db_->WriteVectors(vnames, vecs, true); // update boundary conditions @@ -67,15 +69,18 @@ OverlandPressureFlow::FunctionalResidual(double t_old, // more debugging -- write diffusion/flux variables to screen vnames = { "z", "h_old", "h_new", "h+z" }; vecs = { S_->GetPtr(elev_key_, tag_next_).ptr(), - S_->GetPtr(pd_key_, tag_current_).ptr(), - S_->GetPtr(pd_key_, tag_next_).ptr(), - S_->GetPtr(potential_key_, tag_next_).ptr() }; + S_->GetPtr(pd_key_, tag_current_).ptr(), + S_->GetPtr(pd_key_, tag_next_).ptr(), + S_->GetPtr(potential_key_, tag_next_).ptr() }; if (plist_->isSublist("overland conductivity subgrid evaluator")) { vnames.emplace_back("pd - dd"); vnames.emplace_back("frac_cond"); - vecs.emplace_back(S_->GetPtr(Keys::getKey(domain_, "mobile_depth"), tag_next_).ptr()); - vecs.emplace_back(S_->GetPtr(Keys::getKey(domain_, "fractional_conductance"), tag_next_).ptr()); + vecs.emplace_back( + S_->GetPtr(Keys::getKey(domain_, "mobile_depth"), tag_next_).ptr()); + vecs.emplace_back( + S_->GetPtr(Keys::getKey(domain_, "fractional_conductance"), tag_next_) + .ptr()); } @@ -119,7 +124,7 @@ OverlandPressureFlow::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon application:" << std::endl; AMANZI_ASSERT(!precon_scaled_); // otherwise this factor was built into the matrix // apply the preconditioner @@ -134,7 +139,9 @@ OverlandPressureFlow::ApplyPreconditioner(Teuchos::RCP u, Epetra_MultiVector& Pu_c = *Pu->Data()->ViewComponent("cell", false); unsigned int ncells = Pu_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { Pu_c[0][c] /= dh_dp[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + Pu_c[0][c] /= dh_dp[0][c]; + } db_->WriteVector("PC*h_res (p-coords)", Pu->Data().ptr(), true); return (ierr > 0) ? 0 : 1; @@ -149,7 +156,7 @@ OverlandPressureFlow::UpdatePreconditioner(double t, Teuchos::RCPgetOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Precon update at t = " << t << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Precon update at t = " << t << std::endl; // update state with the solution up. if (std::abs(t - iter_counter_time_) / t > 1.e-4) { @@ -244,7 +251,7 @@ OverlandPressureFlow::UpdatePreconditioner(double t, Teuchos::RCPGetDerivativePtr(pd_key_, tag_next_, key_, tag_next_); preconditioner_->Rescale(*dh0_dp); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Right scaling TPFA" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Right scaling TPFA" << std::endl; db_->WriteVector(" dh_dp", dh0_dp.ptr()); } diff --git a/src/pks/flow/permafrost.hh b/src/pks/flow/permafrost.hh index 43c4ccd13..8cfed6102 100644 --- a/src/pks/flow/permafrost.hh +++ b/src/pks/flow/permafrost.hh @@ -15,16 +15,18 @@ constitutive relations -- the WRM changes to provide three saturations, while the water content changes to account for water in ice phase. As these are now drop-in field evaluators, there is very little to change in the PK. -In the future, this should not even need a different PK. +In the future, this will not need a different PK. -.. _permafrost-spec: -.. admonition:: permafrost-spec +`"PK type`" = `"permafrost flow`" + +.. _pk-permafrost-flow-spec: +.. admonition:: pk-permafrost-flow-spec * `"saturation ice key`" ``[string]`` **"DOMAIN-saturation_ice"** volume fraction of the ice phase (only when relevant) ``[-]`` Typically the default is correct. INCLUDES: - - ``[richards-spec]`` See `Richards PK`_ + - ``[pk-richards-flow-spec]`` See `Richards PK`_ */ #ifndef PK_FLOW_PERMAFROST_HH_ diff --git a/src/pks/flow/permafrost_pk.cc b/src/pks/flow/permafrost_pk.cc index 38bef4c00..07e65a0a9 100644 --- a/src/pks/flow/permafrost_pk.cc +++ b/src/pks/flow/permafrost_pk.cc @@ -22,7 +22,7 @@ #include "rel_perm_evaluator.hh" #include "rel_perm_sutraice_evaluator.hh" #include "rel_perm_frzBC_evaluator.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "permafrost.hh" @@ -36,15 +36,8 @@ namespace Flow { void Permafrost::SetupPhysicalEvaluators_() { - // -- Absolute permeability. - // For now, we assume scalar permeability. This will change. - requireAtNext(perm_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, num_perm_vals_); - // -- water content, and evaluator, and derivative for PC - requireAtNext(conserved_key_, tag_next_, *S_) + requireEvaluatorAtNext(conserved_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -52,20 +45,20 @@ Permafrost::SetupPhysicalEvaluators_() conserved_key_, tag_next_, key_, tag_next_); // and at the current time, where it is a copy evaluator - requireAtCurrent(conserved_key_, tag_current_, *S_, name_, true); + requireEvaluatorAtCurrent(conserved_key_, tag_current_, *S_, name_); // -- saturation - requireAtNext(sat_key_, tag_next_, *S_) + requireEvaluatorAtNext(sat_key_, tag_next_, *S_, true) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) ->AddComponent("boundary_face", AmanziMesh::Entity_kind::BOUNDARY_FACE, 1); - requireAtNext(sat_gas_key_, tag_next_, *S_) + requireEvaluatorAtNext(sat_gas_key_, tag_next_, *S_, true) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) ->AddComponent("boundary_face", AmanziMesh::Entity_kind::BOUNDARY_FACE, 1); - requireAtNext(sat_ice_key_, tag_next_, *S_) + requireEvaluatorAtNext(sat_ice_key_, tag_next_, *S_, true) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) @@ -73,12 +66,11 @@ Permafrost::SetupPhysicalEvaluators_() auto& wrm = S_->RequireEvaluator(sat_key_, tag_next_); // and at the current time, where it is a copy evaluator - requireAtCurrent(sat_key_, tag_current_, *S_, name_, true); - requireAtCurrent(sat_ice_key_, tag_current_, *S_, name_, true); + requireEvaluatorAtCurrent(sat_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(sat_ice_key_, tag_current_, *S_, name_); // -- the rel perm evaluator, also with the same underlying WRM. - S_->GetEvaluatorList(coef_key_).set("permeability rescaling", perm_scale_); - requireAtNext(coef_key_, tag_next_, *S_) + requireEvaluatorAtNext(coef_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) @@ -90,13 +82,13 @@ Permafrost::SetupPhysicalEvaluators_() wrms_ = wrm_eval->get_WRMs(); // -- molar density used to infer liquid Darcy velocity from flux - requireAtNext(molar_dens_key_, tag_next_, *S_) + requireEvaluatorAtNext(molar_dens_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // -- liquid mass density for the gravity fluxes - requireAtNext(mass_dens_key_, tag_next_, *S_) + requireEvaluatorAtNext(mass_dens_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); diff --git a/src/pks/flow/predictor_delegate_bc_flux.cc b/src/pks/flow/predictor_delegate_bc_flux.cc index a9b2c5c6d..eab173590 100644 --- a/src/pks/flow/predictor_delegate_bc_flux.cc +++ b/src/pks/flow/predictor_delegate_bc_flux.cc @@ -86,9 +86,9 @@ PredictorDelegateBCFlux::CreateFunctor_(int f, const Teuchos::PtrSetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) @@ -111,7 +112,7 @@ bool Preferential::UpdatePermeabilityData_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating permeability?"; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating permeability?"; Teuchos::RCP rel_perm = S_->GetPtr(coef_key_, tag); Teuchos::RCP rel_perm_grav = @@ -131,9 +132,11 @@ Preferential::UpdatePermeabilityData_(const Tag& tag) S_->GetPtrW(flux_dir_key_, tag, name_); Teuchos::RCP pres = S_->GetPtr(key_, tag); - if (!deform_key_.empty() && - S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " flux dir")) - face_matrix_diff_->SetTensorCoefficient(K_); + if ((!deform_key_.empty() && + S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " flux dir")) || + S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " flux dir")) + face_matrix_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); face_matrix_diff_->SetDensity(rho); face_matrix_diff_->UpdateMatrices(Teuchos::null, pres.ptr()); @@ -192,7 +195,9 @@ Preferential::UpdatePermeabilityData_(const Tag& tag) const auto& bfmap = mesh_->getMap(AmanziMesh::Entity_kind::BOUNDARY_FACE, true); for (int bf = 0; bf != rel_perm_bf.MyLength(); ++bf) { auto f = fmap.LID(bfmap.GID(bf)); - if (rel_perm_bf[0][bf] > uw_rel_perm_f[0][f]) { uw_rel_perm_f[0][f] = rel_perm_bf[0][bf]; } + if (rel_perm_bf[0][bf] > uw_rel_perm_f[0][f]) { + uw_rel_perm_f[0][f] = rel_perm_bf[0][bf]; + } } } else if (clobber_policy_ == "unsaturated") { // clobber only when the interior cell is unsaturated @@ -214,12 +219,14 @@ Preferential::UpdatePermeabilityData_(const Tag& tag) } } - if (uw_rel_perm->HasComponent("face")) uw_rel_perm->ScatterMasterToGhosted("face"); - if (uw_rel_perm->HasComponent("grav")) uw_rel_perm->ScatterMasterToGhosted("grav"); + if (uw_rel_perm->HasComponent("face") ) uw_rel_perm->ScatterMasterToGhosted("face"); + if (uw_rel_perm->HasComponent("grav") ) uw_rel_perm->ScatterMasterToGhosted("grav"); } // debugging - if (vo_->os_OK(Teuchos::VERB_EXTREME)) { *vo_->os() << " " << update_perm << std::endl; } + if (vo_->os_OK(Teuchos::VERB_EXTREME)) { + *vo_->os() << " " << update_perm << std::endl; + } return update_perm; }; @@ -229,7 +236,7 @@ bool Preferential::UpdatePermeabilityDerivativeData_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating permeability derivatives?"; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating permeability derivatives?"; bool update_perm = S_->GetEvaluator(coef_key_, tag).UpdateDerivative(*S_, name_, key_, tag); update_perm |= S_->GetEvaluator(coef_grav_key_, tag).UpdateDerivative(*S_, name_, key_, tag); @@ -258,7 +265,9 @@ Preferential::UpdatePermeabilityDerivativeData_(const Tag& tag) } // debugging - if (vo_->os_OK(Teuchos::VERB_EXTREME)) { *vo_->os() << " " << update_perm << std::endl; } + if (vo_->os_OK(Teuchos::VERB_EXTREME)) { + *vo_->os() << " " << update_perm << std::endl; + } return update_perm; }; diff --git a/src/pks/flow/richards.hh b/src/pks/flow/richards.hh index db4178340..60339fe8c 100644 --- a/src/pks/flow/richards.hh +++ b/src/pks/flow/richards.hh @@ -15,33 +15,18 @@ Solves Richards equation: .. math:: \frac{\partial \Theta}{\partial t} - \nabla \cdot \frac{k_r n_l}{\mu} K ( \nabla p + \rho g \hat{z} ) = Q_w -.. _richards-spec: -.. admonition:: richards-spec +`"PK type`" = `"richards flow`" + +.. _pk-richards-flow-spec: +.. admonition:: pk-richards-flow-spec * `"domain`" ``[string]`` **"domain"** Defaults to the subsurface mesh. - * `"primary variable key`" ``[string]`` The primary variable associated with - this PK, typically `"DOMAIN-pressure`" Note there is no default -- this - must be provided by the user. + * `"primary variable key`" ``[string]`` **DOMAIN-pressure** The primary + variable associated with this PK. * `"boundary conditions`" ``[list]`` Defaults to Neuman, 0 normal - flux. See `Flow-specific Boundary Conditions`_ - - * `"permeability type`" ``[string]`` **scalar** This controls the - number of values needed to specify the absolute permeability. - One of: - - - `"scalar`" Requires one scalar value. - - `"horizontal and vertical`" Requires two values, horizontal - then vertical. - - `"diagonal tensor`" Requires dim values: {xx, yy} or {xx, yy, - zz} - - `"full tensor`". (Note symmetry is required.) Either {xx, yy, - xy} or {xx,yy,zz,xy,xz,yz}. - - * `"water retention evaluator`" ``[wrm-evaluator-spec]`` The water - retention curve. This needs to go away, and should get moved to - State. + flux. See :ref:`Flow-specific Boundary Conditions` IF @@ -50,27 +35,46 @@ Solves Richards equation: THEN * `"source key`" ``[string]`` **DOMAIN-water_source** Typically not - set, as the default is good. ``[mol s^-1]`` + set, as the default is good. :math:`[mol \, s^{-1}]` * `"explicit source term`" ``[bool]`` **false** Apply the source - term from the previous timestep. + term from the previous timestep (source is lagged). END + * `"permeability rescaling`" ``[double]`` **1e7** Typically 1e7 or order + :math:`sqrt(K)` is about right. This rescales both the relative and + absolute permeabilities to avoid multiplying small numbers (absolute + permeability) by a large number (:math:`\rho / \mu`). + Math and solver algorithm options: - * `"diffusion`" ``[pde-diffusion-spec]`` The (forward) diffusion - operator, see PDE_Diffusion_. + * `"absolute error tolerance`" ``[double]`` **2750.0** in units of :math:`[mol]`. + + * `"inverse`" ``[inverse-spec]`` **optional** The inverse used for + preconditioning in a non-globally coupled problem. See :ref:`Inverse`. + + * `"diffusion`" ``[pde-diffusion-typedinline-spec]`` The (forward) diffusion + operator, see :ref:`Diffusion`. * `"diffusion preconditioner`" ``[pde-diffusion-spec]`` **optional** The inverse of the diffusion operator. See - PDE_Diffusion_. Typically this is only needed to set Jacobian + :ref:`Diffusion`. Typically this is only needed to set Jacobian options, as all others probably should match those in `"diffusion`", and default to those values. + * `"compute boundary values`" ``[bool]`` **false** Used to include boundary + face unknowns on diffusion discretizations that are cell-only (e.g. FV). + This can be useful for surface flow or other wierd boundary conditions. + Usually provided by MPCs that need them. + + * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` **optional** + The inverse of the accumulation operator. See :ref:`Accumulation`. + Typically not provided by users, as defaults are sufficient. + * `"surface rel perm strategy`" ``[string]`` **none** Approach for - specifying the relative permeabiilty on the surface face. - `"clobber`" is frequently used for cases where a surface rel - perm will be provided. One of: + specifying the relative permeabiilty on the surface face. `"clobber`" is + frequently used for cases where a surface rel perm will be provided. + TODO: this should be absorbed into an evaluator. One of: - `"none`" : use the upwind direction to determine whether to use the boundary face or internal cell @@ -132,25 +136,7 @@ Solves Richards equation: If > 0, this limits an iterate's max pressure change to this value when they cross atmospheric pressure. Not usually helpful. - Discretization / operators / solver controls: - - * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` **optional** - The inverse of the accumulation operator. See PDE_Accumulation_. - Typically not provided by users, as defaults are correct. - - * `"absolute error tolerance`" ``[double]`` **2750.0** in units of [mol]. - - * `"compute boundary values`" ``[bool]`` **false** Used to include boundary - face unknowns on discretizations that are cell-only (e.g. FV). This can - be useful for surface flow or other wierd boundary conditions. Usually - provided by MPCs that need them. - - Physics control: - - * `"permeability rescaling`" ``[double]`` **1e7** Typically 1e7 or order - :math:`sqrt(K)` is about right. This rescales things to stop from - multiplying by small numbers (permeability) and then by large number - (:math:`\rho / \mu`). + Algorithmic physics control: IF @@ -168,14 +154,9 @@ Solves Richards equation: * `"coupled to surface via head`" ``[bool]`` **false** If true, apply surface boundary conditions from the surface pressure (Dirichlet). -*/ - - -/* - Debugging including these.. - INCLUDES: - - ``[pk-physical-bdf-default-spec]`` A `PK: Physical and BDF`_ spec. + + - ``[pk-physical-bdf-default-spec]`` A :ref:`PK: Physical and BDF` spec. EVALUATORS: - `"conserved quantity`" @@ -184,37 +165,24 @@ Solves Richards equation: - `"permeability`" - `"conductivity`" - `"saturation`" - - `"primary variable`" - - - Everything below this point is usually not provided by the user, but are - documented here for completeness. KEYS: - - `"conserved quantity`" **DOMAIN-water_content** Typically - not set, as the default is good. ``[mol]`` - - `"mass density`" **DOMAIN-mass_density_liquid** liquid water - density ``[kg m^-3]`` - - `"molar density`" **DOMAIN-molar_density_liquid** liquid - water density ``[mol m^-3]`` - - `"permeability key`" **DOMAIN-permeability** permeability of the - soil medium ``[m^2]`` - - `"conductivity key`" **DOMAIN-relative_permeability** scalar - coefficient of the permeability ``[-]`` + - `"conserved quantity`" **DOMAIN-water_content** + - `"mass density`" **DOMAIN-mass_density_liquid** + - `"molar density`" **DOMAIN-molar_density_liquid** + - `"permeability key`" **DOMAIN-permeability** + - `"conductivity key`" **DOMAIN-relative_permeability** - `"upwind conductivity key`" ``[string]`` - **DOMAIN-upwind_relative_permeability** upwinded (face-based) scalar - coefficient of the permeability. Note the units of this are strange, but - this represents :math:`\frac{n_l k_r}{\mu}` ``[mol kg^-1 s^1 m^-2]`` + **DOMAIN-upwind_relative_permeability** upwinded (face-based) scalar + coefficient of the permeability. Note the units of this are strange, but + this represents :math:`\frac{n_l k_r}{\mu}` ``[mol kg^-1 s^1 m^-2]`` - `"darcy flux key`" **DOMAIN-water_flux** water flux across a face ``[mol s^-1]`` - `"darcy flux direction key`" **DOMAIN-water_flux_direction** - direction of the darcy flux (used in upwinding :math:`k_r`) ``[??]`` + direction of the darcy flux (used in upwinding :math:`k_r`) ``[??]`` - `"darcy velocity key`" **DOMAIN-darcy_velocity** darcy velocity - vector, interpolated from faces to cells ``[m s^-1]`` - - `"saturation key`" **DOMAIN-saturation_liquid** volume - fraction of the liquid phase ``[-]`` - - `"saturation gas key`" **DOMAIN-saturation_gas** volume - fraction of the gas phase ``[-]`` + vector, interpolated from faces to cells ``[m s^-1]`` + - `"saturation key`" **DOMAIN-saturation_liquid** ``[-]`` */ @@ -278,14 +246,15 @@ class Richards : public PK_PhysicalBDF_Default { Teuchos::RCP g) override; // applies preconditioner to u and returns the result in Pu - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; // updates the preconditioner virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; - virtual bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + virtual bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; // problems with pressures -- setting a range of admissible pressures virtual bool IsAdmissible(Teuchos::RCP up) override; @@ -309,7 +278,6 @@ class Richards : public PK_PhysicalBDF_Default { virtual void UpdateBoundaryConditions_(const Tag& tag, bool kr = true); // -- builds tensor K, along with faced-based Krel if needed by the rel-perm method - virtual void SetAbsolutePermeabilityTensor_(const Tag& tag); virtual bool UpdatePermeabilityData_(const Tag& tag); virtual bool UpdatePermeabilityDerivativeData_(const Tag& tag); @@ -343,11 +311,11 @@ class Richards : public PK_PhysicalBDF_Default { // virtual void PreconWC_(Teuchos::RCP u, Teuchos::RCP Pu); // -- Possibly modify the correction before it is applied - virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult - ModifyCorrection(double h, - Teuchos::RCP res, - Teuchos::RCP u, - Teuchos::RCP du) override; + virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult ModifyCorrection( + double h, + Teuchos::RCP res, + Teuchos::RCP u, + Teuchos::RCP du) override; protected: // control switches @@ -374,7 +342,6 @@ class Richards : public PK_PhysicalBDF_Default { double surface_head_eps_; // permeability - Teuchos::RCP> K_; // absolute permeability Teuchos::RCP upwinding_; Teuchos::RCP upwinding_deriv_; Teuchos::RCP wrms_; @@ -456,8 +423,8 @@ class Richards : public PK_PhysicalBDF_Default { bool fixed_kr_; // -- access methods - virtual Teuchos::RCP - my_operator(const Operators::OperatorType& type) override + virtual Teuchos::RCP my_operator( + const Operators::OperatorType& type) override { return matrix_; } diff --git a/src/pks/flow/richards_physics.cc b/src/pks/flow/richards_physics.cc index 5c8dd473f..14651da28 100644 --- a/src/pks/flow/richards_physics.cc +++ b/src/pks/flow/richards_physics.cc @@ -12,8 +12,9 @@ #include "Evaluator.hh" #include "Op.hh" +#include "TensorVector.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "richards.hh" namespace Amanzi { @@ -26,9 +27,11 @@ void Richards::ApplyDiffusion_(const Tag& tag, const Teuchos::Ptr& g) { // force mass matrices to change - if (!deform_key_.empty() && - S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " matrix")) - matrix_diff_->SetTensorCoefficient(K_); + if ((!deform_key_.empty() && + S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " matrix")) || + S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " matrix diff")) + matrix_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); // update the rel perm according to the scheme of choice UpdatePermeabilityData_(tag); @@ -104,7 +107,9 @@ Richards::AddSources_(const Tag& tag, const Teuchos::Ptr& g) // Add into residual unsigned int ncells = g_c.MyLength(); - for (unsigned int c = 0; c != ncells; ++c) { g_c[0][c] -= source1[0][c] * cv[0][c]; } + for (unsigned int c = 0; c != ncells; ++c) { + g_c[0][c] -= source1[0][c] * cv[0][c]; + } db_->WriteVector(" source", S_->GetPtr(source_key_, tag).ptr(), false); db_->WriteVector("res (src)", g, false); @@ -127,56 +132,6 @@ Richards::AddSourcesToPrecon_(double h) } -// ------------------------------------------------------------- -// Convert abs perm vector to tensor. -// ------------------------------------------------------------- -void -Richards::SetAbsolutePermeabilityTensor_(const Tag& tag) -{ - // currently assumes isotropic perm, should be updated - S_->GetEvaluator(perm_key_, tag).Update(*S_, name_); - const Epetra_MultiVector& perm = - *S_->Get(perm_key_, tag).ViewComponent("cell", false); - unsigned int ncells = perm.MyLength(); - unsigned int ndofs = perm.NumVectors(); - int space_dim = mesh_->getSpaceDimension(); - if (ndofs == 1) { // isotropic - for (unsigned int c = 0; c != ncells; ++c) { (*K_)[c](0, 0) = perm[0][c] * perm_scale_; } - } else if (ndofs == 2 && space_dim == 3) { - // horizontal and vertical perms - for (unsigned int c = 0; c != ncells; ++c) { - (*K_)[c](0, 0) = perm[0][c] * perm_scale_; - (*K_)[c](1, 1) = perm[0][c] * perm_scale_; - (*K_)[c](2, 2) = perm[1][c] * perm_scale_; - } - } else if (ndofs >= space_dim) { - // diagonal tensor - for (unsigned int dim = 0; dim != space_dim; ++dim) { - for (unsigned int c = 0; c != ncells; ++c) { - (*K_)[c](dim, dim) = perm[dim][c] * perm_scale_; - } - } - if (ndofs > space_dim) { - // full tensor - if (ndofs == 3) { // 2D - for (unsigned int c = 0; c != ncells; ++c) { - (*K_)[c](0, 1) = (*K_)[c](1, 0) = perm[2][c] * perm_scale_; - } - } else if (ndofs == 6) { // 3D - for (unsigned int c = 0; c != ncells; ++c) { - (*K_)[c](0, 1) = (*K_)[c](1, 0) = perm[3][c] * perm_scale_; // xy & yx - (*K_)[c](0, 2) = (*K_)[c](2, 0) = perm[4][c] * perm_scale_; // xz & zx - (*K_)[c](1, 2) = (*K_)[c](2, 1) = perm[5][c] * perm_scale_; // yz & zy - } - } - } - } else { - // ERROR -- unknown perm type - AMANZI_ASSERT(0); - } -}; - - void Richards::UpdateVelocity_(const Tag& tag) { @@ -215,7 +170,9 @@ Richards::UpdateVelocity_(const Tag& tag) for (int i = 0; i != d; ++i) { rhs[i] += normal[i] * flux[0][f]; matrix(i, i) += normal[i] * normal[i]; - for (int j = i + 1; j < d; ++j) { matrix(j, i) = matrix(i, j) += normal[i] * normal[j]; } + for (int j = i + 1; j < d; ++j) { + matrix(j, i) = matrix(i, j) += normal[i] * normal[j]; + } } } @@ -224,6 +181,8 @@ Richards::UpdateVelocity_(const Tag& tag) for (int i = 0; i != d; ++i) velocity[i][c] = rhs[i] / nliq_c[0][c]; } + + changedEvaluatorPrimary(velocity_key_, tag, *S_); } diff --git a/src/pks/flow/richards_pk.cc b/src/pks/flow/richards_pk.cc index e81dd6146..d0eabc872 100644 --- a/src/pks/flow/richards_pk.cc +++ b/src/pks/flow/richards_pk.cc @@ -11,6 +11,7 @@ #include "flow_bc_factory.hh" +#include "Reductions.hh" #include "Point.hh" #include "upwind_cell_centered.hh" @@ -27,7 +28,8 @@ #include "richards_water_content_evaluator.hh" #include "OperatorDefs.hh" #include "BoundaryFlux.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" +#include "TensorVector.hh" #include "richards.hh" @@ -65,11 +67,12 @@ Richards::Richards(Teuchos::ParameterList& pk_tree, {} - void Richards::parseParameterList() { // set some defaults for inherited PKs + if (!plist_->isParameter("primary variable key suffix")) + plist_->set("primary variable key suffix", "pressure"); if (!plist_->isParameter("conserved quantity key suffix")) plist_->set("conserved quantity key suffix", "water_content"); @@ -86,10 +89,13 @@ Richards::parseParameterList() Keys::readKey(*plist_, domain_, "upwinded conductivity", "upwind_relative_permeability"); flux_key_ = Keys::readKey(*plist_, domain_, "darcy flux", "water_flux"); - requireAtNext(flux_key_, tag_next_, *S_, name_); + requireEvaluatorAtNext(flux_key_, tag_next_, *S_, name_); flux_dir_key_ = Keys::readKey(*plist_, domain_, "darcy flux direction", "water_flux_direction"); + velocity_key_ = Keys::readKey(*plist_, domain_, "darcy velocity", "darcy_velocity"); + requireEvaluatorAtNext(velocity_key_, Tags::NEXT, *S_, name_); + sat_key_ = Keys::readKey(*plist_, domain_, "saturation", "saturation_liquid"); sat_gas_key_ = Keys::readKey(*plist_, domain_, "saturation gas", "saturation_gas"); sat_ice_key_ = Keys::readKey(*plist_, domain_, "saturation ice", "saturation_ice"); @@ -107,6 +113,7 @@ Richards::parseParameterList() perm_scale_ = plist_->get("permeability rescaling", 1.e7); S_->ICList().sublist("permeability_rescaling").set("value", perm_scale_); S_->GetEvaluatorList(coef_key_).set("permeability rescaling", perm_scale_); + S_->GetEvaluatorList(perm_key_).set("rescaling factor", perm_scale_); // source terms is_source_term_ = plist_->get("source term", false); @@ -131,6 +138,9 @@ Richards::parseParameterList() ss_primary_key_ = Keys::readKey(*plist_, domain_surf, "pressure", "pressure"); } + // require a few primary variable keys now to set the leaf node in the dep graph + requireEvaluatorAtCurrent(sat_key_, tag_current_, *S_, name_); + // parse inherited lists PK_PhysicalBDF_Default::parseParameterList(); } @@ -161,8 +171,6 @@ Richards::SetupRichardsFlow_() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); S_->RequireEvaluator(cell_vol_key_, tag_next_); - S_->Require("permeability_rescaling", Tags::DEFAULT); - // Set up Operators // -- boundary conditions Teuchos::ParameterList bc_plist = plist_->sublist("boundary conditions", true); @@ -190,38 +198,19 @@ Richards::SetupRichardsFlow_() bc_rho_water_ = bc_plist.get("hydrostatic water density [kg m^-3]", 1000.); // -- linear tensor coefficients - // permeability type - scalar or tensor? - Teuchos::ParameterList& perm_list = S_->GetEvaluatorList(perm_key_); - std::string perm_type = perm_list.get("permeability type", "scalar"); - if (perm_type == "scalar") { - perm_tensor_rank_ = 1; - num_perm_vals_ = 1; - } else if (perm_type == "horizontal and vertical") { - perm_tensor_rank_ = 2; - num_perm_vals_ = 2; - } else if (perm_type == "diagonal tensor") { - perm_tensor_rank_ = 2; - num_perm_vals_ = mesh_->getSpaceDimension(); - } else if (perm_type == "full tensor") { - perm_tensor_rank_ = 2; - num_perm_vals_ = (mesh_->getSpaceDimension() == 3) ? 6 : 3; - } else { - Errors::Message message( - "`permeability type` must be one of the following: \"scalar\", \"diagonal tensor\", \"full " - "tensor\", or \"horizontal and vertical\"."); - Exceptions::amanzi_throw(message); - } + S_->Require("permeability_rescaling", Tags::DEFAULT); + + CompositeVectorSpace perm_space; + perm_space.SetMesh(mesh_)->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + S_->Require(perm_key_, tag_next_).set_map(perm_space); + S_->RequireEvaluator(perm_key_, tag_next_); // is dynamic mesh? If so, get a key for indicating when the mesh has changed. - if (!deform_key_.empty()) S_->RequireEvaluator(deform_key_, tag_next_); + if (!deform_key_.empty() ) S_->RequireEvaluator(deform_key_, tag_next_); // data allocation -- move to State! unsigned int c_owned = mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); - K_ = Teuchos::rcp(new std::vector(c_owned)); - for (unsigned int c = 0; c != c_owned; ++c) { - (*K_)[c].Init(mesh_->getSpaceDimension(), perm_tensor_rank_); - } // -- nonlinear coefficients/upwinding // if coupled to the surface, how do we deal with the surface face @@ -243,7 +232,8 @@ Richards::SetupRichardsFlow_() std::string method_name = plist_->get("relative permeability method", "upwind with Darcy flux"); if (method_name == "upwind with gravity") { - upwinding_ = Teuchos::rcp(new Operators::UpwindGravityFlux(name_, tag_next_, K_)); + auto K = S_->GetPtr(perm_key_, tag_next_); + upwinding_ = Teuchos::rcp(new Operators::UpwindGravityFlux(name_, tag_next_, K)); Krel_method_ = Operators::UPWIND_METHOD_GRAVITY; } else if (method_name == "cell centered") { upwinding_ = Teuchos::rcp(new Operators::UpwindCellCentered(name_, tag_next_)); @@ -377,13 +367,15 @@ Richards::SetupRichardsFlow_() // -- source terms if (is_source_term_) { - requireAtNext(source_key_, tag_next_, *S_) + requireEvaluatorAtNext(source_key_, tag_next_, *S_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - if (!explicit_source_ && S_->GetEvaluator(source_key_, tag_next_).IsDifferentiableWRT(*S_, key_, tag_next_)) { + if (!explicit_source_ && + S_->GetEvaluator(source_key_, tag_next_).IsDifferentiableWRT(*S_, key_, tag_next_)) { is_source_term_differentiable_ = true; // require derivative of source - S_->RequireDerivative(source_key_, tag_next_, key_, tag_next_); + S_->RequireDerivative( + source_key_, tag_next_, key_, tag_next_); } } @@ -422,17 +414,18 @@ Richards::SetupRichardsFlow_() ->SetGhosted(); // -- flux is managed here as a primary variable - requireAtNext(flux_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(flux_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetGhosted() ->SetComponent("face", AmanziMesh::Entity_kind::FACE, 1); // -- also need a velocity, but only for vis/diagnostics, so might as well // -- only keep at NEXT - requireAtNext(velocity_key_, Tags::NEXT, *S_, name_) + requireEvaluatorAtNext(velocity_key_, Tags::NEXT, *S_, name_) .SetMesh(mesh_) ->SetGhosted() ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 3); + S_->GetRecordSetW(velocity_key_).set_subfieldnames(mesh_->getSpaceDimensionNames()); // Globalization and other timestep control flags // -- predictors @@ -461,37 +454,28 @@ Richards::SetupRichardsFlow_() void Richards::SetupPhysicalEvaluators_() { - // -- Absolute permeability. - requireAtNext(perm_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, num_perm_vals_); - // -- water content, and evaluator, and derivative for PC - requireAtNext(conserved_key_, tag_next_, *S_) + requireEvaluatorAtNext(conserved_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); S_->RequireDerivative( conserved_key_, tag_next_, key_, tag_next_); - // and at the current time, where it is a copy evaluator - requireAtCurrent(conserved_key_, tag_current_, *S_, name_); - // -- Water retention evaluators // -- saturation - requireAtNext(sat_key_, tag_next_, *S_) + requireEvaluatorAtNext(sat_key_, tag_next_, *S_, true) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtNext(sat_gas_key_, tag_next_, *S_) + requireEvaluatorAtNext(sat_gas_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); auto& wrm = S_->RequireEvaluator(sat_key_, tag_next_); // and at the current time, where it is a copy evaluator - requireAtCurrent(sat_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(sat_key_, tag_current_, *S_, name_); /*requireAtNext(matric_pressure_key_, tag_next_, *S_) .SetMesh(mesh_) @@ -503,7 +487,7 @@ Richards::SetupPhysicalEvaluators_() requireAtCurrent(sat_key_, tag_current_, *S_, name_); // -- rel perm - requireAtNext(coef_key_, tag_next_, *S_) + requireEvaluatorAtNext(coef_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1) @@ -515,13 +499,13 @@ Richards::SetupPhysicalEvaluators_() wrms_ = wrm_eval->get_WRMs(); // -- molar density used to infer liquid Darcy velocity from flux - requireAtNext(molar_dens_key_, tag_next_, *S_) + requireEvaluatorAtNext(molar_dens_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // -- liquid mass density for the gravity fluxes - requireAtNext(mass_dens_key_, tag_next_, *S_) + requireEvaluatorAtNext(mass_dens_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -559,7 +543,7 @@ void Richards::Initialize() { // Initialize via hydrostatic balance - if (!S_->GetRecordW(key_, tag_next_, name_).initialized()) InitializeHydrostatic_(tag_next_); + if (!S_->GetRecordW(key_, tag_next_, name_) .initialized()) InitializeHydrostatic_(tag_next_); // Initialize in the standard ways PK_PhysicalBDF_Default::Initialize(); @@ -583,22 +567,16 @@ Richards::Initialize() S_->GetW(velocity_key_, Tags::NEXT, name()).PutScalar(0.0); S_->GetRecordW(velocity_key_, Tags::NEXT, name()).set_initialized(); - // absolute perm - SetAbsolutePermeabilityTensor_(tag_next_); - // operators const AmanziGeometry::Point& g = S_->Get("gravity", Tags::DEFAULT); matrix_diff_->SetGravity(g); matrix_diff_->SetBCs(bc_, bc_); - matrix_diff_->SetTensorCoefficient(K_); preconditioner_diff_->SetGravity(g); preconditioner_diff_->SetBCs(bc_, bc_); - preconditioner_diff_->SetTensorCoefficient(K_); face_matrix_diff_->SetGravity(g); face_matrix_diff_->SetBCs(bc_, bc_); - face_matrix_diff_->SetTensorCoefficient(K_); face_matrix_diff_->SetScalarCoefficient(Teuchos::null, Teuchos::null); // if (vapor_diffusion_){ @@ -614,10 +592,10 @@ void Richards::InitializeHydrostatic_(const Tag& tag) { // constant head over the surface - if (plist_->sublist("initial condition").isParameter("hydrostatic head [m]")) { - double head_wt = plist_->sublist("initial condition").get("hydrostatic head [m]"); + if (plist_->sublist("initial conditions").isParameter("hydrostatic head [m]")) { + double head_wt = plist_->sublist("initial conditions").get("hydrostatic head [m]"); double rho = - plist_->sublist("initial condition").get("hydrostatic water density [kg m^-3]"); + plist_->sublist("initial conditions").get("hydrostatic water density [kg m^-3]"); int ncols = mesh_->columns.num_columns_owned; const auto& gvec = S_->Get("gravity", Tags::DEFAULT); @@ -634,7 +612,9 @@ Richards::InitializeHydrostatic_(const Tag& tag) { // context for viewcomponent -- do cells Epetra_MultiVector& pres_c = *pres->ViewComponent("cell", false); Teuchos::RCP pres_f = Teuchos::null; - if (pres->HasComponent("face")) { pres_f = pres->ViewComponent("face", false); } + if (pres->HasComponent("face")) { + pres_f = pres->ViewComponent("face", false); + } int ncells_per = -1; for (int col = 0; col != ncols; ++col) { @@ -689,10 +669,10 @@ Richards::InitializeHydrostatic_(const Tag& tag) } // constant head datum - if (plist_->sublist("initial condition").isParameter("hydrostatic water level [m]")) { - double z_wt = plist_->sublist("initial condition").get("hydrostatic water level [m]"); + if (plist_->sublist("initial conditions").isParameter("hydrostatic water level [m]")) { + double z_wt = plist_->sublist("initial conditions").get("hydrostatic water level [m]"); double rho = - plist_->sublist("initial condition").get("hydrostatic water density [kg m^-3]"); + plist_->sublist("initial conditions").get("hydrostatic water density [kg m^-3]"); int z_index = mesh_->getSpaceDimension() - 1; const auto& gravity = S_->Get("gravity", Tags::DEFAULT); @@ -735,7 +715,9 @@ Richards::CommitStep(double t_old, double t_new, const Tag& tag_next) // also save saturation assign(sat_key_, tag_current, tag_next, *S_); - if (S_->HasRecordSet(sat_ice_key_)) { assign(sat_ice_key_, tag_current, tag_next, *S_); } + if (S_->HasRecordSet(sat_ice_key_)) { + assign(sat_ice_key_, tag_current, tag_next, *S_); + } }; @@ -746,7 +728,7 @@ bool Richards::IsValid(const Teuchos::RCP& u) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Validating timestep." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Validating timestep." << std::endl; if (sat_change_limit_ > 0.0) { const Epetra_MultiVector& sl_new = @@ -755,7 +737,7 @@ Richards::IsValid(const Teuchos::RCP& u) *S_->GetPtr(sat_key_, tag_current_)->ViewComponent("cell", false); Epetra_MultiVector dsl(sl_new); dsl.Update(-1., sl_old, 1.); - auto change = maxValLoc(*dsl(0)); + auto change = Reductions::reduceAllMaxLoc(*dsl(0)); if (change.value > sat_change_limit_) { if (vo_->os_OK(Teuchos::VERB_LOW)) @@ -773,7 +755,7 @@ Richards::IsValid(const Teuchos::RCP& u) *S_->GetPtr(sat_ice_key_, tag_current_)->ViewComponent("cell", false); Epetra_MultiVector dsi(si_new); dsi.Update(-1., si_old, 1.); - auto change = maxValLoc(*dsi(0)); + auto change = Reductions::reduceAllMaxLoc(*dsi(0)); if (change.value > sat_ice_change_limit_) { if (vo_->os_OK(Teuchos::VERB_LOW)) @@ -805,6 +787,12 @@ Richards::CalculateDiagnostics(const Tag& tag) Teuchos::RCP rel_perm = S_->GetPtr(uw_coef_key_, tag_next_); Teuchos::RCP rho = S_->GetPtr(mass_dens_key_, tag_next_); + + // update mass matrix? + if (S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " matrix diff")) + matrix_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); + // update the stiffness matrix matrix_diff_->SetDensity(rho); matrix_diff_->SetScalarCoefficient(rel_perm, Teuchos::null); @@ -828,11 +816,14 @@ bool Richards::UpdatePermeabilityData_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating permeability?"; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating permeability?"; if (fixed_kr_) return false; Teuchos::RCP rel_perm = S_->GetPtr(coef_key_, tag); + bool update_abs_perm = + S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + "face matrix diff"); bool update_perm = S_->GetEvaluator(coef_key_, tag).Update(*S_, name_); + update_perm |= update_abs_perm; // requirements due to the upwinding method if (Krel_method_ == Operators::UPWIND_METHOD_TOTAL_FLUX) { @@ -846,9 +837,12 @@ Richards::UpdatePermeabilityData_(const Tag& tag) S_->GetPtrW(flux_dir_key_, tag, name_); Teuchos::RCP pres = S_->GetPtr(key_, tag); - if (!deform_key_.empty() && - S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " flux dir")) - face_matrix_diff_->SetTensorCoefficient(K_); + if ((!deform_key_.empty() && + S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " flux dir")) || + update_abs_perm) { + face_matrix_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); + } face_matrix_diff_->SetDensity(rho); face_matrix_diff_->UpdateMatrices(Teuchos::null, pres.ptr()); face_matrix_diff_->ApplyBCs(true, true, true); @@ -901,7 +895,9 @@ Richards::UpdatePermeabilityData_(const Tag& tag) const auto& bfmap = mesh_->getMap(AmanziMesh::Entity_kind::BOUNDARY_FACE, true); for (int bf = 0; bf != rel_perm_bf.MyLength(); ++bf) { auto f = fmap.LID(bfmap.GID(bf)); - if (rel_perm_bf[0][bf] > uw_rel_perm_f[0][f]) { uw_rel_perm_f[0][f] = rel_perm_bf[0][bf]; } + if (rel_perm_bf[0][bf] > uw_rel_perm_f[0][f]) { + uw_rel_perm_f[0][f] = rel_perm_bf[0][bf]; + } } } else if (clobber_policy_ == "unsaturated") { // clobber only when the interior cell is unsaturated @@ -925,7 +921,9 @@ Richards::UpdatePermeabilityData_(const Tag& tag) } // debugging - if (vo_->os_OK(Teuchos::VERB_EXTREME)) { *vo_->os() << " " << update_perm << std::endl; } + if (vo_->os_OK(Teuchos::VERB_EXTREME)) { + *vo_->os() << " " << update_perm << std::endl; + } return update_perm; }; @@ -934,7 +932,7 @@ bool Richards::UpdatePermeabilityDerivativeData_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating permeability derivatives?"; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating permeability derivatives?"; if (fixed_kr_) return false; bool update_perm = S_->GetEvaluator(coef_key_, tag).UpdateDerivative(*S_, name_, key_, tag); @@ -954,7 +952,8 @@ Richards::UpdatePermeabilityDerivativeData_(const Tag& tag) std::vector vnames{ "dkrel" }; std::vector> vecs{ - S_->GetDerivativePtr(coef_key_, tag, key_, tag).ptr() }; + S_->GetDerivativePtr(coef_key_, tag, key_, tag).ptr() + }; if (!duw_coef_key_.empty()) { vnames.emplace_back("uw_dkrel"); vecs.emplace_back(S_->GetPtr(duw_coef_key_, tag).ptr()); @@ -962,7 +961,9 @@ Richards::UpdatePermeabilityDerivativeData_(const Tag& tag) db_->WriteVectors(vnames, vecs, true); // debugging - if (vo_->os_OK(Teuchos::VERB_EXTREME)) { *vo_->os() << " " << update_perm << std::endl; } + if (vo_->os_OK(Teuchos::VERB_EXTREME)) { + *vo_->os() << " " << update_perm << std::endl; + } return update_perm; }; @@ -989,7 +990,7 @@ void Richards::UpdateBoundaryConditions_(const Tag& tag, bool kr) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating BCs." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating BCs." << std::endl; auto& markers = bc_markers(); auto& values = bc_values(); @@ -1308,7 +1309,7 @@ bool Richards::ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Modifying predictor:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Modifying predictor:" << std::endl; // update boundary conditions ComputeBoundaryConditions_(tag_next_); @@ -1325,9 +1326,13 @@ Richards::ModifyPredictor(double h, Teuchos::RCP u0, Teuchos:: changed |= ModifyPredictorFluxBCs_(h, u); } - if (modify_predictor_wc_) { changed |= ModifyPredictorWC_(h, u); } + if (modify_predictor_wc_) { + changed |= ModifyPredictorWC_(h, u); + } - if (modify_predictor_with_consistent_faces_) { changed |= ModifyPredictorConsistentFaces_(h, u); } + if (modify_predictor_with_consistent_faces_) { + changed |= ModifyPredictorConsistentFaces_(h, u); + } return changed; } @@ -1335,7 +1340,7 @@ Richards::ModifyPredictor(double h, Teuchos::RCP u0, Teuchos:: bool Richards::ModifyPredictorFluxBCs_(double h, Teuchos::RCP u) { - if (!u->Data()->HasComponent("face")) return false; + if (!u->Data() ->HasComponent("face")) return false; auto& markers = bc_markers(); auto& values = bc_values(); @@ -1357,6 +1362,12 @@ Richards::ModifyPredictorFluxBCs_(double h, Teuchos::RCP u) matrix_diff_->SetScalarCoefficient(rel_perm, Teuchos::null); Teuchos::RCP rho = S_->GetPtr(mass_dens_key_, tag_next_); Teuchos::RCP pres = S_->GetPtr(key_, tag_next_); + + // update mass matrix? + if (S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " matrix diff")) + matrix_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); + matrix_diff_->SetDensity(rho); matrix_diff_->UpdateMatrices(Teuchos::null, pres.ptr()); //matrix_diff_->ApplyBCs(true, true, true); @@ -1440,7 +1451,9 @@ Richards::CalculateConsistentFaces(const Teuchos::Ptr& u) int ncells = cells.size(); double face_value = 0.0; - for (int n = 0; n != ncells; ++n) { face_value += u_c[0][cells[n]]; } + for (int n = 0; n != ncells; ++n) { + face_value += u_c[0][cells[n]]; + } u_f[0][f] = face_value / ncells; } ChangedSolution(); @@ -1456,6 +1469,12 @@ Richards::CalculateConsistentFaces(const Teuchos::Ptr& u) // Update the preconditioner with darcy and gravity fluxes matrix_->Init(); + + // update mass matrix? + if (S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " matrix diff")) + matrix_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); + matrix_diff_->SetDensity(rho); matrix_diff_->SetScalarCoefficient(rel_perm, Teuchos::null); matrix_diff_->UpdateMatrices(Teuchos::null, u); @@ -1485,95 +1504,35 @@ bool Richards::IsAdmissible(Teuchos::RCP up) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Checking admissibility..." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Checking admissibility..." << std::endl; // For some reason, wandering PKs break most frequently with an unreasonable // pressure. This simply tries to catch that before it happens. Teuchos::RCP pres = up->Data(); - double minT, maxT; const Epetra_MultiVector& pres_c = *pres->ViewComponent("cell", false); - double minT_c(1.e15), maxT_c(-1.e15); - int min_c(-1), max_c(-1); - for (int c = 0; c != pres_c.MyLength(); ++c) { - if (pres_c[0][c] < minT_c) { - minT_c = pres_c[0][c]; - min_c = c; - } - if (pres_c[0][c] > maxT_c) { - maxT_c = pres_c[0][c]; - max_c = c; - } - } + Reductions::MinMaxLoc minmaxp_c = Reductions::reduceAllMinMaxLoc(*pres_c(0)); + Reductions::MinMaxLoc minmaxp_f = Reductions::createEmptyMinMaxLoc(); - double minT_f(1.e15), maxT_f(-1.e15); - int min_f(-1), max_f(-1); if (pres->HasComponent("face")) { const Epetra_MultiVector& pres_f = *pres->ViewComponent("face", false); - for (int f = 0; f != pres_f.MyLength(); ++f) { - if (pres_f[0][f] < minT_f) { - minT_f = pres_f[0][f]; - min_f = f; - } - if (pres_f[0][f] > maxT_f) { - maxT_f = pres_f[0][f]; - max_f = f; - } - } - minT = std::min(minT_c, minT_f); - maxT = std::max(maxT_c, maxT_f); - - } else { - minT = minT_c; - maxT = maxT_c; + minmaxp_f = Reductions::reduceAllMinMaxLoc(*pres_f(0)); } - - double minT_l = minT; - double maxT_l = maxT; - mesh_->getComm()->MaxAll(&maxT_l, &maxT, 1); - mesh_->getComm()->MinAll(&minT_l, &minT, 1); + double minp = std::min(minmaxp_c[0].value, minmaxp_f[0].value); + double maxp = std::max(minmaxp_c[1].value, minmaxp_f[1].value); if (vo_->os_OK(Teuchos::VERB_HIGH)) { - *vo_->os() << " Admissible p? (min/max): " << minT << ", " << maxT << std::endl; + *vo_->os() << " Admissible p? (min/max): " << minp << ", " << maxp << std::endl; } - if (minT < -1.e9 || maxT > 1.e8) { + if (minp < -1.e9 || maxp > 1.e8) { if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { *vo_->os() << " is not admissible, as it is not within bounds of constitutive models:" << std::endl; - - Teuchos::RCP comm_p = mesh_->getComm(); - Teuchos::RCP mpi_comm_p = - Teuchos::rcp_dynamic_cast(comm_p); - const MPI_Comm& comm = mpi_comm_p->Comm(); - - ENorm_t global_minT_c, local_minT_c; - ENorm_t global_maxT_c, local_maxT_c; - - local_minT_c.value = minT_c; - local_minT_c.gid = pres_c.Map().GID(min_c); - local_maxT_c.value = maxT_c; - local_maxT_c.gid = pres_c.Map().GID(max_c); - - MPI_Allreduce(&local_minT_c, &global_minT_c, 1, MPI_DOUBLE_INT, MPI_MINLOC, comm); - MPI_Allreduce(&local_maxT_c, &global_maxT_c, 1, MPI_DOUBLE_INT, MPI_MAXLOC, comm); - *vo_->os() << " cells (min/max): [" << global_minT_c.gid << "] " << global_minT_c.value - << ", [" << global_maxT_c.gid << "] " << global_maxT_c.value << std::endl; + *vo_->os() << " cells (min/max): " << minmaxp_c << std::endl; if (pres->HasComponent("face")) { - const Epetra_MultiVector& pres_f = *pres->ViewComponent("face", false); - ENorm_t global_minT_f, local_minT_f; - ENorm_t global_maxT_f, local_maxT_f; - - local_minT_f.value = minT_f; - local_minT_f.gid = pres_f.Map().GID(min_f); - local_maxT_f.value = maxT_f; - local_maxT_f.gid = pres_f.Map().GID(max_f); - - MPI_Allreduce(&local_minT_f, &global_minT_f, 1, MPI_DOUBLE_INT, MPI_MINLOC, comm); - MPI_Allreduce(&local_maxT_f, &global_maxT_f, 1, MPI_DOUBLE_INT, MPI_MAXLOC, comm); - *vo_->os() << " faces (min/max): [" << global_minT_f.gid << "] " << global_minT_f.value - << ", [" << global_maxT_f.gid << "] " << global_maxT_f.value << std::endl; + *vo_->os() << " faces (min/max): " << minmaxp_f << std::endl; } } return false; @@ -1598,7 +1557,7 @@ Richards::ModifyCorrection(double h, } // debugging -- remove me! --etc - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); double max, l2; @@ -1616,7 +1575,7 @@ Richards::ModifyCorrection(double h, int n_limited_spurt = 0; if (patm_limit_ > 0.) { double patm = S_->Get("atmospheric_pressure", Tags::DEFAULT); - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); const Epetra_MultiVector& u_c = *u->Data()->ViewComponent(*comp, false); @@ -1635,11 +1594,13 @@ Richards::ModifyCorrection(double h, } if (n_limited_spurt > 0) { - if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << " limiting the spurt." << std::endl; } + if (vo_->os_OK(Teuchos::VERB_HIGH)) { + *vo_->os() << " limiting the spurt." << std::endl; + } } // debugging -- remove me! --etc - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); double max, l2; @@ -1655,7 +1616,7 @@ Richards::ModifyCorrection(double h, my_limited = 0; int n_limited_change = 0; if (p_limit_ >= 0.) { - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); @@ -1677,7 +1638,7 @@ Richards::ModifyCorrection(double h, } // debugging -- remove me! --etc - for (CompositeVector::name_iterator comp = du->Data()->begin(); comp != du->Data()->end(); + for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { Epetra_MultiVector& du_c = *du->Data()->ViewComponent(*comp, false); double max, l2; @@ -1690,7 +1651,9 @@ Richards::ModifyCorrection(double h, } if (n_limited_change > 0) { - if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << " limited by pressure." << std::endl; } + if (vo_->os_OK(Teuchos::VERB_HIGH)) { + *vo_->os() << " limited by pressure." << std::endl; + } } if (n_limited_spurt > 0) { diff --git a/src/pks/flow/richards_steadystate.cc b/src/pks/flow/richards_steadystate.cc index 24dea6ef5..174d050a9 100644 --- a/src/pks/flow/richards_steadystate.cc +++ b/src/pks/flow/richards_steadystate.cc @@ -12,6 +12,7 @@ Steady state solution of Richards equation */ +#include "TensorVector.hh" #include "richards_steadystate.hh" namespace Amanzi { @@ -93,9 +94,6 @@ RichardsSteadyState::FunctionalResidual(double t_old, } vnames.push_back("poro"); vecs.push_back(S_->GetPtr(Keys::getKey(domain_, "porosity"), tag_next_).ptr()); - vnames.push_back("perm_K"); - vecs.push_back( - S_->GetPtr(Keys::getKey(domain_, "permeability"), tag_next_).ptr()); vnames.push_back("k_rel"); vecs.push_back(S_->GetPtr(coef_key_, tag_next_).ptr()); vnames.push_back("wind"); @@ -128,12 +126,16 @@ RichardsSteadyState::UpdatePreconditioner(double t, Teuchos::RCPgetOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << "Precon update at t = " << t << std::endl; } + if (vo_->os_OK(Teuchos::VERB_HIGH)) { + *vo_->os() << "Precon update at t = " << t << std::endl; + } // Recreate mass matrices - if (!deform_key_.empty() && - S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " precon")) - preconditioner_diff_->SetTensorCoefficient(K_); + if ((!deform_key_.empty() && + S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " precon")) || + S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " precon")) + preconditioner_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); AMANZI_ASSERT(std::abs(S_->get_time(tag_next_) - t) <= 1.e-4 * t); PK_PhysicalBDF_Default::Solution_to_State(*up, tag_next_); diff --git a/src/pks/flow/richards_steadystate.hh b/src/pks/flow/richards_steadystate.hh index 1af8ad405..d6990b10a 100644 --- a/src/pks/flow/richards_steadystate.hh +++ b/src/pks/flow/richards_steadystate.hh @@ -12,12 +12,14 @@ This is the same as Richards equation, but turns off the accumulation term. -.. _richards-steadystate-spec: -.. admonition:: richards-steadystate-spec +`"PK type`" = `"richards steady state`" - INCLUDES: +.. _pk-richards-steady-state-spec: +.. admonition:: pk-richards-steady-state-spec - - ``[richards-spec]`` See `Richards PK`_ + INCLUDES: + + - ``[pk-richards-flow-spec]`` See `Richards PK`_ */ diff --git a/src/pks/flow/richards_ti.cc b/src/pks/flow/richards_ti.cc index e28a99219..24a994c29 100644 --- a/src/pks/flow/richards_ti.cc +++ b/src/pks/flow/richards_ti.cc @@ -8,6 +8,7 @@ */ #include "Op.hh" +#include "TensorVector.hh" #include "richards.hh" namespace Amanzi { @@ -74,9 +75,6 @@ Richards::FunctionalResidual(double t_old, vecs.emplace_back( S_->GetPtr(Keys::getKey(domain_, "saturation_ice"), tag_next_).ptr()); } - vnames.emplace_back("perm_K"); - vecs.emplace_back( - S_->GetPtr(Keys::getKey(domain_, "permeability"), tag_next_).ptr()); vnames.emplace_back("k_rel"); vecs.emplace_back(S_->GetPtr(coef_key_, tag_next_).ptr()); vnames.emplace_back("wind"); @@ -93,10 +91,11 @@ Richards::FunctionalResidual(double t_old, db_->WriteVector("res (acc)", res.ptr(), true); // more debugging -- write accumulation variables to screen - vnames = { "poro", "WC_old", "WC_new" }; + vnames = { "poro", "WC_old", "WC_new", "mol_dens" }; vecs = { S_->GetPtr(Keys::getKey(domain_, "porosity"), tag_next_).ptr(), S_->GetPtr(conserved_key_, tag_current_).ptr(), - S_->GetPtr(conserved_key_, tag_next_).ptr() }; + S_->GetPtr(conserved_key_, tag_next_).ptr(), + S_->GetPtr(molar_dens_key_, tag_next_).ptr() }; db_->WriteVectors(vnames, vecs); db_->WriteVector("res (acc)", res.ptr(), true); @@ -118,7 +117,7 @@ int Richards::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon application:" << std::endl; // Apply the preconditioner db_->WriteVector("p_res", u->Data().ptr(), true); @@ -137,12 +136,14 @@ Richards::UpdatePreconditioner(double t, Teuchos::RCP up, doub { // VerboseObject stuff. Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon update at t = " << t << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon update at t = " << t << std::endl; // Recreate mass matrices - if (!deform_key_.empty() && - S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " precon")) - preconditioner_diff_->SetTensorCoefficient(K_); + if ((!deform_key_.empty() && + S_->GetEvaluator(deform_key_, tag_next_).Update(*S_, name_ + " precon")) || + S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " precon")) + preconditioner_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); // update state with the solution up. if (std::abs(t - iter_counter_time_) / t > 1.e-4) { @@ -181,6 +182,11 @@ Richards::UpdatePreconditioner(double t, Teuchos::RCP up, doub S_->GetPtr(uw_coef_key_, tag_next_); preconditioner_diff_->SetScalarCoefficient(rel_perm, dkrdp); + // update mass matrix? + if (S_->GetEvaluator(perm_key_, tag_next_).Update(*S_, name_ + " precon")) + preconditioner_diff_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); + // -- local matries, primary term preconditioner_->Init(); preconditioner_diff_->UpdateMatrices(Teuchos::null, up->Data().ptr()); diff --git a/src/pks/flow/snow_distribution.hh b/src/pks/flow/snow_distribution.hh index a4ab1de5b..7caf6898d 100644 --- a/src/pks/flow/snow_distribution.hh +++ b/src/pks/flow/snow_distribution.hh @@ -6,43 +6,40 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Preferential distribution of snow precip in low-lying areas. /*! This PK is a heuristic PK that distributes incoming snow precipitation using a diffusion wave equation. Think of it as an analogue to overland flow -- it -effectively ensures that new snow "flows downhill," due to a uniformly random -direction and strength wind, and lands on the lowest lying areas. - -Tweaking the snow-manning_coefficient lets you play with how uniform the snow -layer ends up. Most of the parameters are set by your snow precipitation input -data interval. The details of this are a bit tricky mathematically, and it may -take some fiddling with parameters to do this correctly if your data is not -daily (which all defaults are set for). +effectively ensures that new snow "flows downhill," due to a uniformly +distributed random direction wind, and lands on the lowest lying +areas. -.. _snow-distribution-spec: -.. admonition:: snow-distribution-spec +The Manning coefficient determines with how uniform the snow layer becomes. +Most of the parameters are set depending upon the snow precipitation input data +interval. - * `"distribution time`" ``[double]`` **86400.** Interval of snow precip input dataset. `[s]` - * `"precipitation function`" ``[function-spec]`` Snow precipitation function, see Functions_. +`"PK type`" = `"snow distribution`" - * `"diffusion`" ``[pde-diffusion-spec]`` Diffusion drives the distribution. - Typically we use finite volume here. See PDE_Diffusion_ +.. _pk-snow-distribution-spec: +.. admonition:: pk-snow-distribution-spec - * `"diffusion preconditioner`" ``[pde-diffusion-spec]`` Inverse of the - above. Likely only Jacobian term options are needed here, as the others - default to the same as the `"diffusion`" list. See PDE_Diffusion_. + * `"distribution time`" ``[double]`` **86400.** Interval of snow precip + input dataset. `[s]` - * `"inverse`" ``[inverse-typed-spec]`` Inverse_ method for the solve. + * `"precipitation function`" ``[function-spec]`` Snow precipitation + function, see :ref:`Functions`. - Not typically provided by the user, defaults are good: + * `"diffusion`" ``[pde-diffusion-spec]`` Diffusion drives the distribution. + Typically we use finite volume here. See :ref:`Diffusion`. - * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` See PDE_Accumulation_. + * `"diffusion preconditioner`" ``[pde-diffusion-spec]`` Inverse of the + above. Likely only Jacobian term options are needed here, as the others + default to the same as the `"diffusion`" list. See :ref:`Diffusion`. + * `"inverse`" ``[inverse-typed-spec]`` :ref:`Inverse` method for the solve. -.. todo:: - For this PK, all variable root names are hard-coded. This should get changed. + * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` **optional** + See :ref:`Accumulation`. */ @@ -98,15 +95,14 @@ class SnowDistribution : public PK_PhysicalBDF_Default { // error monitor double ErrorNorm(Teuchos::RCP u, Teuchos::RCP du) override; - bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; // Choose a timestep compatible with physics. double get_dt() override { return dt_factor_; } - // Advance PK from time t_old to time t_new. True value of the last - // parameter indicates drastic change of boundary and/or source terms - // that may need PK's attention. + // Advance PK from time t_old to time t_new. // // ALL SORTS OF FRAGILITY and UGLINESS HERE! // DO NOT USE THIS OUT IN THE WILD! diff --git a/src/pks/flow/snow_distribution_pk.cc b/src/pks/flow/snow_distribution_pk.cc index 8c4b4e962..56a76009e 100644 --- a/src/pks/flow/snow_distribution_pk.cc +++ b/src/pks/flow/snow_distribution_pk.cc @@ -24,7 +24,7 @@ #include "snow_distribution.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" namespace Amanzi { namespace Flow { @@ -85,13 +85,13 @@ SnowDistribution::SetupSnowDistribution_() precip_func_ = Teuchos::rcp(fac.Create(precip_func)); // -- get conserved variable (snow-precip) and evaluator and derivative for PC - requireAtNext(conserved_key_, tag_next_, *S_) + requireEvaluatorAtNext(conserved_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // and at the current time, where it is a copy evaluator - requireAtCurrent(conserved_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(conserved_key_, tag_current_, *S_, name_); // -- cell volume and evaluator S_->Require(cv_key_, tag_next_) @@ -183,13 +183,13 @@ void SnowDistribution::SetupPhysicalEvaluators_() { // -- evaluator for potential field, h + z - requireAtNext(potential_key_, tag_next_, *S_) + requireEvaluatorAtNext(potential_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // -- snow_conductivity evaluator - requireAtNext(cond_key_, tag_next_, *S_) + requireEvaluatorAtNext(cond_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -273,7 +273,7 @@ void SnowDistribution::UpdateBoundaryConditions_(const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " Updating BCs." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << " Updating BCs." << std::endl; auto& markers = bc_markers(); auto& values = bc_values(); diff --git a/src/pks/flow/snow_distribution_ti.cc b/src/pks/flow/snow_distribution_ti.cc index dcfdf93bf..d3e148ec9 100644 --- a/src/pks/flow/snow_distribution_ti.cc +++ b/src/pks/flow/snow_distribution_ti.cc @@ -7,7 +7,9 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ +#include "Reductions.hh" #include "Op.hh" +#include "PK_Helpers.hh" #include "snow_distribution.hh" #define DEBUG_FLAG 1 @@ -112,7 +114,7 @@ int SnowDistribution::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon application:" << std::endl; #if DEBUG_FLAG db_->WriteVector("h_res", u->Data().ptr(), true); @@ -139,7 +141,7 @@ SnowDistribution::UpdatePreconditioner(double t, Teuchos::RCP { // VerboseObject stuff. Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Precon update at t = " << t << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Precon update at t = " << t << std::endl; // update state with the solution up. @@ -199,37 +201,28 @@ SnowDistribution::ErrorNorm(Teuchos::RCP u, Teuchos::RCP enorm_cell) { - enorm_cell = tmp; - bad_cell = c; + if (tmp > enorm_c.value) { + enorm_c.value = tmp; + enorm_c.gid = res_c.Map().GID(c); } } + enorm_c = Reductions::reduceAllMaxLoc(*mesh_->getComm(), enorm_c); + // Write out Inf norms too. if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { double infnorm_c(0.); res_c.NormInf(&infnorm_c); - - ENorm_t err_c; - ENorm_t l_err_c; - l_err_c.value = enorm_cell; - l_err_c.gid = res_c.Map().GID(bad_cell); - - MPI_Allreduce(&l_err_c, &err_c, 1, MPI_DOUBLE_INT, MPI_MAXLOC, MPI_COMM_WORLD); - - *vo_->os() << "ENorm (cells) = " << err_c.value << "[" << err_c.gid << "] (" << infnorm_c << ")" - << std::endl; + *vo_->os() << "ENorm (cells) = " << enorm_c.value << " (" << infnorm_c << ")" << std::endl; } - double buf = enorm_cell; - MPI_Allreduce(&buf, &enorm_cell, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); - return enorm_cell; + return enorm_c.value; }; bool diff --git a/src/pks/mpc/CMakeLists.txt b/src/pks/mpc/CMakeLists.txt index adb395edb..788791e8a 100644 --- a/src/pks/mpc/CMakeLists.txt +++ b/src/pks/mpc/CMakeLists.txt @@ -47,12 +47,11 @@ set(ats_mpc_src_files mpc_coupled_transport.cc mpc_reactivetransport.cc mpc_coupled_reactivetransport.cc - + mpc_flow_transport.cc mpc_weak_subdomain.cc mpc_coupled_water_split_flux.cc mpc_permafrost_split_flux.cc - # mpc_morphology_pk.cc - # biomass_evaluator.cc + mpc_morphology_pk.cc ) set(ats_mpc_inc_files @@ -74,11 +73,10 @@ set(ats_mpc_inc_files mpc_coupled_transport.hh mpc_reactivetransport.hh mpc_coupled_reactivetransport.hh - + mpc_flow_transport.hh mpc_weak_subdomain.hh mpc_coupled_water_split_flux.hh mpc_permafrost_split_flux.hh - # biomass_evaluator.hh ) set(ats_mpc_link_libs @@ -137,10 +135,10 @@ register_evaluator_with_factory( LISTNAME ATS_MPC_REG ) -# register_evaluator_with_factory( -# HEADERFILE mpc_morphology_reg.hh -# LISTNAME ATS_MPC_REG -# ) +register_evaluator_with_factory( + HEADERFILE mpc_morphology_reg.hh + LISTNAME ATS_MPC_REG + ) register_evaluator_with_factory( HEADERFILE mpc_subsurface_reg.hh @@ -193,10 +191,10 @@ register_evaluator_with_factory( LISTNAME ATS_MPC_REG ) -# register_evaluator_with_factory( -# HEADERFILE biomass_evaluator_reg.hh -# LISTNAME ATS_MPC_REG -# ) +register_evaluator_with_factory( + HEADERFILE constitutive_relations/EvaluatorSubgridReturn_reg.hh + LISTNAME ATS_MPC_REG + ) generate_evaluators_registration_header( HEADERFILE ats_mpc_registration.hh diff --git a/src/pks/mpc/biomass_evaluator.cc b/src/pks/mpc/biomass_evaluator.cc deleted file mode 100644 index eba3f7328..000000000 --- a/src/pks/mpc/biomass_evaluator.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: -*/ - -/* - -*/ - -#include "biomass_evaluator.hh" -#include "Teuchos_ParameterList.hpp" - -namespace Amanzi { - -BiomassEvaluator::BiomassEvaluator(Teuchos::ParameterList& plist) - : EvaluatorSecondaryMonotypeCV(plist) -{ - last_update_ = -1; - InitializeFromPlist_(); -} - -BiomassEvaluator::BiomassEvaluator(const BiomassEvaluator& other) - : EvaluatorSecondaryMonotypeCV(other), - nspecies_(other.nspecies_), - type_(other.type_), - domain_name_(other.domain_name_), - biomass_key_(other.biomass_key_), - stem_density_key_(other.stem_density_key_), - stem_height_key_(other.stem_height_key_), - stem_diameter_key_(other.stem_diameter_key_), - plant_area_key_(other.plant_area_key_), - elev_key_(other.elev_key_), - msl_key_(other.msl_key_) -{ - last_update_ = other.last_update_; - update_frequency_ = other.update_frequency_; - - alpha_n.resize(nspecies_); - alpha_h.resize(nspecies_); - alpha_a.resize(nspecies_); - alpha_d.resize(nspecies_); - - beta_n.resize(nspecies_); - beta_h.resize(nspecies_); - beta_a.resize(nspecies_); - beta_d.resize(nspecies_); - - Bmax.resize(nspecies_); - zmax.resize(nspecies_); - zmin.resize(nspecies_); - for (int i = 0; i < nspecies_; i++) { - alpha_n[i] = other.alpha_n[i]; - alpha_h[i] = other.alpha_h[i]; - alpha_d[i] = other.alpha_d[i]; - alpha_a[i] = other.alpha_a[i]; - beta_n[i] = other.beta_n[i]; - beta_h[i] = other.beta_h[i]; - beta_d[i] = other.beta_d[i]; - beta_a[i] = other.beta_a[i]; - Bmax[i] = other.Bmax[i]; - zmax[i] = other.zmax[i]; - zmin[i] = other.zmin[i]; - } -} - -Teuchos::RCP -BiomassEvaluator::Clone() const -{ - return Teuchos::rcp(new BiomassEvaluator(*this)); -} - -void -BiomassEvaluator::InitializeFromPlist_() -{ - domain_name_ = "surface"; - biomass_key_ = Keys::getKey(domain_name_, "biomass"); - my_keys_.emplace_back(biomass_key_); - - stem_density_key_ = Keys::getKey(domain_name_, "stem_density"); - my_keys_.emplace_back(stem_density_key_); - - stem_height_key_ = Keys::getKey(domain_name_, "stem_height"); - my_keys_.emplace_back(stem_height_key_); - - - stem_diameter_key_ = Keys::getKey(domain_name_, "stem_diameter"); - my_keys_.emplace_back(stem_diameter_key_); - - plant_area_key_ = Keys::getKey(domain_name_, "plant_area"); - my_keys_.emplace_back(plant_area_key_); - - nspecies_ = plist_.get("number of vegitation species", 1); - //species_names_ = plist_.get >("species names").toVector(); - - last_update_ = -1.; - update_frequency_ = plist_.get("update frequency", -1); - - type_ = plist_.get("type"); - alpha_n = plist_.get>("alpha n").toVector(); - alpha_h = plist_.get>("alpha h").toVector(); - alpha_a = plist_.get>("alpha a").toVector(); - alpha_d = plist_.get>("alpha d").toVector(); - - beta_n = plist_.get>("beta n").toVector(); - beta_h = plist_.get>("beta h").toVector(); - beta_a = plist_.get>("beta a").toVector(); - beta_d = plist_.get>("beta d").toVector(); - - Bmax = plist_.get>("Bmax").toVector(); - zmax = plist_.get>("zmax").toVector(); - zmin = plist_.get>("zmin").toVector(); - - elev_key_ = Keys::getKey(domain_name_, "elevation"); - msl_key_ = "msl"; - dependencies_.insert(elev_key_); -} - - -bool -BiomassEvaluator::HasFieldChanged(const Teuchos::Ptr& S, Key request) -{ - if ((update_frequency_ > 0) && (last_update_ >= 0)) { - double time = S->get_time(); - if (requests_.find(request) == requests_.end()) { - requests_.insert(request); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) { - *vo_->os() << my_keys_[0] << " has changed, but no need to update... " << std::endl; - } - return true; - } - if (time - last_update_ < update_frequency_) return false; - } - - bool chg = EvaluatorSecondaryMonotypeCV::HasFieldChanged(S, request); - if (chg) last_update_ = S->get_time(); - - return chg; -} - -void -BiomassEvaluator::EvaluateField_(const Teuchos::Ptr& S, - const std::vector>& results) -{ - Epetra_MultiVector& biomass = *results[0]->ViewComponent("cell"); - Epetra_MultiVector& stem_density = *results[1]->ViewComponent("cell"); - Epetra_MultiVector& stem_height = *results[2]->ViewComponent("cell"); - Epetra_MultiVector& stem_diameter = *results[3]->ViewComponent("cell"); - Epetra_MultiVector& plant_area = *results[4]->ViewComponent("cell"); - - const Epetra_MultiVector& elev = *S->Get(elev_key_).ViewComponent("cell"); - - int ncells = biomass.MyLength(); - - const double MSL = *S->GetScalarData(msl_key_); - - for (int n = 0; n < nspecies_; n++) { - AMANZI_ASSERT((zmax[n] - zmin[n]) > 1e-6); - switch (type_) { - case 1: - for (int c = 0; c < ncells; c++) { - double z_b = elev[0][c] - MSL; - if ((z_b > zmin[n]) && (z_b < zmax[n])) { - biomass[n][c] = Bmax[n] * (zmax[n] - z_b) / (zmax[n] - zmin[n]); - } else { - biomass[n][c] = 0.; - } - } - break; - case 2: - for (int c = 0; c < ncells; c++) { - double z_b = elev[0][c] - MSL; - if (z_b >= zmax[n]) { - biomass[n][c] = Bmax[n]; - } else if ((z_b > zmin[n]) && (z_b < zmax[n])) { - biomass[n][c] = Bmax[n] * (z_b - zmin[n]) / (zmax[n] - zmin[n]); - } else if (z_b <= zmin[n]) { - biomass[n][c] = 0.; - } - } - break; - } - for (int c = 0; c < ncells; c++) { - stem_diameter[n][c] = alpha_d[n] * std::pow(biomass[n][c], beta_d[n]); - stem_height[n][c] = alpha_h[n] * std::pow(biomass[n][c], beta_h[n]); - stem_density[n][c] = alpha_n[n] * std::pow(biomass[n][c], beta_n[n]); - plant_area[n][c] = alpha_a[n] * std::pow(biomass[n][c], beta_a[n]); - } - } -} - -void -BiomassEvaluator::EvaluateFieldPartialDerivative_( - const Teuchos::Ptr& S, - Key wrt_key, - const std::vector>& results) -{ - AMANZI_ASSERT(0); -} - -} // namespace Amanzi diff --git a/src/pks/mpc/biomass_evaluator.hh b/src/pks/mpc/biomass_evaluator.hh deleted file mode 100644 index 065e2c704..000000000 --- a/src/pks/mpc/biomass_evaluator.hh +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: -*/ - -/* - This biomass model evaluates -*/ - -#ifndef AMANZI_BIOMASS_EVALUATOR -#define AMANZI_BIOMASS_EVALUATOR - -#include "EvaluatorSecondaryMonotype.hh" -#include "Factory.hh" - -namespace Amanzi { - -class BiomassEvaluator : public EvaluatorSecondaryMonotypeCV { - public: - explicit BiomassEvaluator(Teuchos::ParameterList& plist); - BiomassEvaluator(const BiomassEvaluator& other); - - virtual Teuchos::RCP Clone() const override; - - virtual bool HasFieldChanged(const Teuchos::Ptr& S, Key request) override; - - protected: - // Required methods from EvaluatorSecondaryMonotypeCV - virtual void EvaluateField_(const Teuchos::Ptr& S, - const std::vector>& results) override; - virtual void EvaluateFieldPartialDerivative_( - const Teuchos::Ptr& S, - Key wrt_key, - const std::vector>& results) override; - - void InitializeFromPlist_(); - - - int nspecies_, type_; - std::vector alpha_n, alpha_h, alpha_d, alpha_a; - std::vector beta_n, beta_h, beta_d, beta_a; - std::vector Bmax, zmax, zmin; - //std::vector species_names_; - double last_update_, update_frequency_; - - Key biomass_key_, stem_density_key_, stem_height_key_, stem_diameter_key_, plant_area_key_; - Key domain_name_, elev_key_, msl_key_; - - private: - static Utils::RegisteredFactory factory_; -}; - -} // namespace Amanzi - -#endif diff --git a/src/pks/mpc/constitutive_relations/CMakeLists.txt b/src/pks/mpc/constitutive_relations/CMakeLists.txt index 17f87e5a5..c1bda0124 100644 --- a/src/pks/mpc/constitutive_relations/CMakeLists.txt +++ b/src/pks/mpc/constitutive_relations/CMakeLists.txt @@ -18,6 +18,7 @@ set(ats_mpc_relations_src_files liquid_ice_model.cc permafrost_model.cc surface_ice_model.cc + EvaluatorSubgridReturn.cc ) set(ats_mpc_relations_inc_files @@ -27,6 +28,7 @@ set(ats_mpc_relations_inc_files permafrost_model.hh surface_ice_model.hh #thermal_richards_model.hh + EvaluatorSubgridReturn.hh ) diff --git a/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn.cc b/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn.cc new file mode 100644 index 000000000..4672622b2 --- /dev/null +++ b/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn.cc @@ -0,0 +1,116 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + Amanzi is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon (coonet@ornl.gov) +*/ + +#include "EvaluatorSubgridReturn.hh" + +namespace Amanzi { + +EvaluatorSubgridReturn::EvaluatorSubgridReturn(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) +{ + domain_ = Keys::getDomain(my_keys_.front().first); + const Tag& tag = my_keys_.front().second; + + domain_set_ = plist_.get("subgrid domain set"); + if (Keys::isDomainSet(domain_set_)) { // strip the :* + domain_set_ = Keys::getDomainSetName(domain_set_); + } + nonlocal_dependencies_ = true; // by definition! + + // first add the non-domain-set dependencies + cv_key_ = Keys::readKey(plist, domain_, "cell volume", "cell_volume"); + dependencies_.insert({ cv_key_, tag }); + + lwc_key_ = Keys::readKey(plist, domain_, "liquid water content", "water_content"); + dependencies_.insert({ lwc_key_, tag }); + + alpha_key_ = Keys::readKey(plist, domain_, "exchange coefficient", "exchange_coefficient_0"); + dependencies_.insert({ alpha_key_, tag }); + + // now add the domain-set dependencies + mf_suffix_ = plist.get("subgrid field suffix", "mole_fraction"); +} + +Teuchos::RCP +EvaluatorSubgridReturn::Clone() const +{ + return Teuchos::rcp(new EvaluatorSubgridReturn(*this)); +} + +void +EvaluatorSubgridReturn::Evaluate_(const State& S, const std::vector& results) +{ + const Tag& tag = my_keys_.front().second; + const Epetra_MultiVector& cv = *S.Get(cv_key_, tag).ViewComponent("cell", false); + const Epetra_MultiVector& alpha = + *S.Get(alpha_key_, tag).ViewComponent("cell", false); + const Epetra_MultiVector& lwc = + *S.Get(lwc_key_, tag).ViewComponent("cell", false); + + AMANZI_ASSERT(results.size() == 1); + Epetra_MultiVector& res = *results[0]->ViewComponent("cell", false); + + // this should be n subdomains + lwc, cv, and alpha? + AMANZI_ASSERT(res.MyLength() + 3 == dependencies_.size()); + auto ds = S.GetDomainSet(domain_set_); + int c = 0; + for (const auto& subdomain : *ds) { + const Epetra_MultiVector& mf = *S.Get(Keys::getKey(subdomain, mf_suffix_), tag) + .ViewComponent("cell", false); + + for (int k = 0; k != mf.NumVectors(); ++k) { + double integral = 0.; + for (int c_sg = 0; c_sg != mf.MyLength() ; ++c_sg) integral += mf[k][c_sg]; + + res[k][c] = integral * alpha[k][c] * lwc[0][c] / cv[0][c] / mf.MyLength(); + } + c++; + } + AMANZI_ASSERT(c == res.MyLength()); +} + + +void +EvaluatorSubgridReturn::EnsureCompatibility_ToDeps_(State& S) +{ + auto akeytag = my_keys_.front(); + if (dependencies_.size() == 3) { + auto ds = S.GetDomainSet(domain_set_); + for (const auto& subdomain : *ds) { + Key dep = Keys::getKey(subdomain, mf_suffix_); + dependencies_.insert({ dep, akeytag.second }); + } + } + + const auto& my_fac = + S.Require(akeytag.first, akeytag.second); + + if (my_fac.Mesh() != Teuchos::null && my_fac.HasComponent("cell")) { + S.Require(cv_key_, akeytag.second) + .SetMesh(my_fac.Mesh()) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + S.Require(lwc_key_, akeytag.second) + .SetMesh(my_fac.Mesh()) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + + S.Require(alpha_key_, akeytag.second) + .SetMesh(my_fac.Mesh()) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, my_fac.NumVectors("cell")); + + auto ds = S.GetDomainSet(domain_set_); + for (const auto& subdomain : *ds) { + S.Require(Keys::getKey(subdomain, mf_suffix_), + akeytag.second) + .SetMesh(S.GetMesh(subdomain)) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, my_fac.NumVectors("cell")); + } + } +} + +} // namespace Amanzi diff --git a/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn.hh b/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn.hh new file mode 100644 index 000000000..256e101ea --- /dev/null +++ b/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn.hh @@ -0,0 +1,81 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + Amanzi is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon (coonet@ornl.gov) +*/ +/*! + +Computes the subgrid return from the hyporheic zone back to the surface system, +which acts like a source term. + + +.. math:: + Q = \alpha \Theta \int_0^\infty \xi d\tau + +Note that the :math:`\tau` are equally spaced in travel time, so this integral +simplifies to a summation over grid cells in the subgrid domain, divided by the +number of grid cells. + +`"evaluator type`" = `"subgrid return`" + +.. _evaluator-subgrid-return-spec: +.. admonition:: evaluator-subgrid-return-spec + + KEYS: + - `"exchange coefficient`" + - `"liquid water content`" **water_content** + - `"exchanged key`" **mole_fraction** + +*/ + +#pragma once + +#include + +#include "Factory.hh" +#include "EvaluatorSecondaryMonotype.hh" + +namespace Amanzi { + +class EvaluatorSubgridReturn : public EvaluatorSecondaryMonotypeCV { + public: + EvaluatorSubgridReturn(Teuchos::ParameterList& plist); + EvaluatorSubgridReturn(const EvaluatorSubgridReturn& other) = default; + + // required inteface functions + virtual Teuchos::RCP Clone() const override; + + virtual void Evaluate_(const State& S, const std::vector& results) override; + + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, + const Tag& wrt_tag, + const std::vector& results) override + { + AMANZI_ASSERT(false); + } + + virtual bool IsDifferentiableWRT(const State& S, const Key& key, const Tag& tag) const override + { + return false; + } + + virtual void EnsureCompatibility_ToDeps_(State& S) override; + + private: + int n_dofs_; + Key alpha_key_; + Key mf_suffix_; + Key lwc_key_; + Key cv_key_; + + std::string domain_; + std::string domain_set_; + + static Utils::RegisteredFactory fac_; +}; + +} // namespace Amanzi diff --git a/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn_reg.hh b/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn_reg.hh new file mode 100644 index 000000000..3ec6ee52b --- /dev/null +++ b/src/pks/mpc/constitutive_relations/EvaluatorSubgridReturn_reg.hh @@ -0,0 +1,23 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + Amanzi is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon +*/ + +/* + State + + A field evaluator for an unchanging cell volume. +*/ + +#include "EvaluatorSubgridReturn.hh" + +namespace Amanzi { + +Utils::RegisteredFactory EvaluatorSubgridReturn::fac_( + "subgrid return"); + +} // namespace Amanzi diff --git a/src/pks/mpc/constitutive_relations/ewc_model.hh b/src/pks/mpc/constitutive_relations/ewc_model.hh index dd0ff7c9e..e3f78fa03 100644 --- a/src/pks/mpc/constitutive_relations/ewc_model.hh +++ b/src/pks/mpc/constitutive_relations/ewc_model.hh @@ -32,17 +32,24 @@ class EWCModel { public: virtual ~EWCModel() = default; virtual bool Freezing(double T, double p) = 0; - virtual void - InitializeModel(const Teuchos::Ptr& S, const Tag& tag, Teuchos::ParameterList& plist) = 0; + virtual void InitializeModel(const Teuchos::Ptr& S, + const Tag& tag, + Teuchos::ParameterList& plist) = 0; virtual void UpdateModel(const Teuchos::Ptr& S, int c) = 0; virtual int Evaluate(double T, double p, double& energy, double& wc) = 0; - virtual int - InverseEvaluate(double energy, double wc, double& T, double& p, bool verbose = false) = 0; + virtual int InverseEvaluate(double energy, + double wc, + double& T, + double& p, + bool verbose = false) = 0; virtual int InverseEvaluateEnergy(double energy, double p, double& T) = 0; - virtual int - EvaluateSaturations(double T, double p, double& s_gas, double& s_liq, double& s_ice) = 0; + virtual int EvaluateSaturations(double T, + double p, + double& s_gas, + double& s_liq, + double& s_ice) = 0; }; diff --git a/src/pks/mpc/constitutive_relations/ewc_model_base.cc b/src/pks/mpc/constitutive_relations/ewc_model_base.cc index 7401d2d2e..ec31d5619 100644 --- a/src/pks/mpc/constitutive_relations/ewc_model_base.cc +++ b/src/pks/mpc/constitutive_relations/ewc_model_base.cc @@ -117,7 +117,9 @@ EWCModelBase::InverseEvaluate(double energy, double wc, double& T, double& p, bo // cap the correction double scale = 1.; - if (std::abs(correction[0]) > T_corr_cap) { scale = T_corr_cap / std::abs(correction[0]); } + if (std::abs(correction[0]) > T_corr_cap) { + scale = T_corr_cap / std::abs(correction[0]); + } if (std::abs(correction[1]) > p_corr_cap) { double pscale = p_corr_cap / std::abs(correction[1]); scale = std::min(scale, pscale); diff --git a/src/pks/mpc/constitutive_relations/ewc_model_base.hh b/src/pks/mpc/constitutive_relations/ewc_model_base.hh index 8df6dc4c0..4d447d3be 100644 --- a/src/pks/mpc/constitutive_relations/ewc_model_base.hh +++ b/src/pks/mpc/constitutive_relations/ewc_model_base.hh @@ -31,8 +31,11 @@ class EWCModelBase : public EWCModel { virtual ~EWCModelBase() = default; virtual int Evaluate(double T, double p, double& energy, double& wc) override; - virtual int - InverseEvaluate(double energy, double wc, double& T, double& p, bool verbose = false) override; + virtual int InverseEvaluate(double energy, + double wc, + double& T, + double& p, + bool verbose = false) override; virtual int InverseEvaluateEnergy(double energy, double p, double& T) override; protected: diff --git a/src/pks/mpc/constitutive_relations/liquid_ice_model.cc b/src/pks/mpc/constitutive_relations/liquid_ice_model.cc index f86d91118..8b2751513 100644 --- a/src/pks/mpc/constitutive_relations/liquid_ice_model.cc +++ b/src/pks/mpc/constitutive_relations/liquid_ice_model.cc @@ -145,10 +145,8 @@ LiquidIceModel::UpdateModel(const Teuchos::Ptr& S, int c) poro_ = (*S->Get(Keys::getKey(domain, "base_porosity"), tag_) .ViewComponent("cell"))[0][c]; wrm_ = wrms_->second[(*wrms_->first)[c]]; - if (!poro_leij_) - poro_model_ = poro_models_->second[(*poro_models_->first)[c]]; - else - poro_leij_model_ = poro_leij_models_->second[(*poro_leij_models_->first)[c]]; + if (!poro_leij_) poro_model_ = poro_models_->second[(*poro_models_->first)[c]]; + else poro_leij_model_ = poro_leij_models_->second[(*poro_leij_models_->first)[c]]; AMANZI_ASSERT(IsSetUp_()); } @@ -235,7 +233,9 @@ LiquidIceModel::EvaluateSaturations(double T, double p, double& s_gas, double& s s_ice = sats[2]; } catch (const Exceptions::Amanzi_exception& e) { - if (e.what() == std::string("Cut timestep")) { ierr = 1; } + if (e.what() == std::string("Cut timestep")) { + ierr = 1; + } } return ierr; @@ -250,10 +250,8 @@ LiquidIceModel::EvaluateEnergyAndWaterContent_(double T, double p, AmanziGeometr int ierr = 0; try { double poro; - if (!poro_leij_) - poro = poro_model_->Porosity(poro_, p, p_atm_); - else - poro = poro_leij_model_->Porosity(poro_, p, p_atm_); + if (!poro_leij_) poro = poro_model_->Porosity(poro_, p, p_atm_); + else poro = poro_leij_model_->Porosity(poro_, p, p_atm_); double eff_p = std::max(p_atm_, p); @@ -298,7 +296,9 @@ LiquidIceModel::EvaluateEnergyAndWaterContent_(double T, double p, AmanziGeometr result[0] = poro * (u_l * rho_l * s_l + u_i * rho_i * s_i) + (1.0 - poro_) * (rho_rock_ * u_rock); } catch (const Exceptions::Amanzi_exception& e) { - if (e.what() == std::string("Cut timestep")) { ierr = 1; } + if (e.what() == std::string("Cut timestep")) { + ierr = 1; + } } return ierr; diff --git a/src/pks/mpc/constitutive_relations/liquid_ice_model.hh b/src/pks/mpc/constitutive_relations/liquid_ice_model.hh index 4d01a4682..6066b510f 100644 --- a/src/pks/mpc/constitutive_relations/liquid_ice_model.hh +++ b/src/pks/mpc/constitutive_relations/liquid_ice_model.hh @@ -44,15 +44,18 @@ class EOS; class LiquidIceModel : public EWCModelBase { public: LiquidIceModel() {} - virtual ~LiquidIceModel(){}; + virtual ~LiquidIceModel() {}; virtual void InitializeModel(const Teuchos::Ptr& S, const Tag& tag, Teuchos::ParameterList& plist) override; virtual void UpdateModel(const Teuchos::Ptr& S, int c) override; virtual bool Freezing(double T, double p) override; - virtual int - EvaluateSaturations(double T, double p, double& s_gas, double& s_liq, double& s_ice) override; + virtual int EvaluateSaturations(double T, + double p, + double& s_gas, + double& s_liq, + double& s_ice) override; protected: bool IsSetUp_(); diff --git a/src/pks/mpc/constitutive_relations/permafrost_model.cc b/src/pks/mpc/constitutive_relations/permafrost_model.cc index a2e80c495..7aecebe92 100644 --- a/src/pks/mpc/constitutive_relations/permafrost_model.cc +++ b/src/pks/mpc/constitutive_relations/permafrost_model.cc @@ -167,10 +167,8 @@ PermafrostModel::UpdateModel(const Teuchos::Ptr& S, int c) poro_ = (*S->Get(Keys::getKey(domain, "base_porosity"), tag_) .ViewComponent("cell"))[0][c]; wrm_ = wrms_->second[(*wrms_->first)[c]]; - if (!poro_leij_) - poro_model_ = poro_models_->second[(*poro_models_->first)[c]]; - else - poro_leij_model_ = poro_leij_models_->second[(*poro_leij_models_->first)[c]]; + if (!poro_leij_) poro_model_ = poro_models_->second[(*poro_models_->first)[c]]; + else poro_leij_model_ = poro_leij_models_->second[(*poro_leij_models_->first)[c]]; AMANZI_ASSERT(IsSetUp_()); } @@ -257,7 +255,9 @@ PermafrostModel::EvaluateSaturations(double T, s_ice = sats[2]; } catch (const Exceptions::Amanzi_exception& e) { - if (e.what() == std::string("Cut timestep")) { ierr = 1; } + if (e.what() == std::string("Cut timestep")) { + ierr = 1; + } } return ierr; @@ -274,10 +274,8 @@ PermafrostModel::EvaluateEnergyAndWaterContent_(double T, double p, AmanziGeomet try { double poro; - if (!poro_leij_) - poro = poro_model_->Porosity(poro_, p, p_atm_); - else - poro = poro_leij_model_->Porosity(poro_, p, p_atm_); + if (!poro_leij_) poro = poro_model_->Porosity(poro_, p, p_atm_); + else poro = poro_leij_model_->Porosity(poro_, p, p_atm_); double eff_p = std::max(p_atm_, p); @@ -319,7 +317,9 @@ PermafrostModel::EvaluateEnergyAndWaterContent_(double T, double p, AmanziGeomet result[0] = poro * (u_l * rho_l * s_l + u_i * rho_i * s_i + u_g * rho_g * s_g) + (1.0 - poro_) * (rho_rock_ * u_rock); } catch (const Exceptions::Amanzi_exception& e) { - if (e.what() == std::string("Cut timestep")) { ierr = 1; } + if (e.what() == std::string("Cut timestep")) { + ierr = 1; + } } return ierr; diff --git a/src/pks/mpc/constitutive_relations/permafrost_model.hh b/src/pks/mpc/constitutive_relations/permafrost_model.hh index a960696fc..dff06790a 100644 --- a/src/pks/mpc/constitutive_relations/permafrost_model.hh +++ b/src/pks/mpc/constitutive_relations/permafrost_model.hh @@ -47,15 +47,18 @@ class VaporPressureRelation; class PermafrostModel : public EWCModelBase { public: PermafrostModel() {} - virtual ~PermafrostModel(){}; + virtual ~PermafrostModel() {}; virtual void InitializeModel(const Teuchos::Ptr& S, const Tag& tag, Teuchos::ParameterList& plist) override; virtual void UpdateModel(const Teuchos::Ptr& S, int c) override; virtual bool Freezing(double T, double p) override; - virtual int - EvaluateSaturations(double T, double p, double& s_gas, double& s_liq, double& s_ice) override; + virtual int EvaluateSaturations(double T, + double p, + double& s_gas, + double& s_liq, + double& s_ice) override; protected: bool IsSetUp_(); diff --git a/src/pks/mpc/constitutive_relations/surface_ice_model.cc b/src/pks/mpc/constitutive_relations/surface_ice_model.cc index 5a1151f05..94a3e6a81 100644 --- a/src/pks/mpc/constitutive_relations/surface_ice_model.cc +++ b/src/pks/mpc/constitutive_relations/surface_ice_model.cc @@ -168,7 +168,9 @@ SurfaceIceModel::EvaluateEnergyAndWaterContent_(double T, double p, AmanziGeomet result[0] = E; } catch (const Exceptions::Amanzi_exception& e) { - if (e.what() == std::string("Cut timestep")) { ierr = 1; } + if (e.what() == std::string("Cut timestep")) { + ierr = 1; + } } return ierr; diff --git a/src/pks/mpc/constitutive_relations/surface_ice_model.hh b/src/pks/mpc/constitutive_relations/surface_ice_model.hh index d04ff2f3b..a87d3604d 100644 --- a/src/pks/mpc/constitutive_relations/surface_ice_model.hh +++ b/src/pks/mpc/constitutive_relations/surface_ice_model.hh @@ -42,15 +42,18 @@ class EOS; class SurfaceIceModel : public EWCModelBase { public: SurfaceIceModel() {} - virtual ~SurfaceIceModel(){}; + virtual ~SurfaceIceModel() {}; virtual void InitializeModel(const Teuchos::Ptr& S, const Tag& tag, Teuchos::ParameterList& plist) override; virtual void UpdateModel(const Teuchos::Ptr& S, int c) override; virtual bool Freezing(double T, double p) override; - virtual int - EvaluateSaturations(double T, double p, double& s_gas, double& s_liq, double& s_ice) override; + virtual int EvaluateSaturations(double T, + double p, + double& s_gas, + double& s_liq, + double& s_ice) override; protected: bool IsSetUp_(); diff --git a/src/pks/mpc/constitutive_relations/thermal_richards_model.cc b/src/pks/mpc/constitutive_relations/thermal_richards_model.cc index f2eccc6fc..82cfae269 100644 --- a/src/pks/mpc/constitutive_relations/thermal_richards_model.cc +++ b/src/pks/mpc/constitutive_relations/thermal_richards_model.cc @@ -347,7 +347,9 @@ ThermalRichardsModel::EvaluateEnergyAndWaterContent_(double T, result[0] = poro * (u_l * rho_l * s_l + u_g * rho_g * s_g) + (1.0 - poro) * (rho_rock_ * u_rock); } catch (const Exceptions::Amanzi_exception& e) { - if (e.what() == std::string("Cut timestep")) { ierr = 1; } + if (e.what() == std::string("Cut timestep")) { + ierr = 1; + } } return ierr; diff --git a/src/pks/mpc/constitutive_relations/thermal_richards_model.hh b/src/pks/mpc/constitutive_relations/thermal_richards_model.hh index ca87dcce2..cdaefc159 100644 --- a/src/pks/mpc/constitutive_relations/thermal_richards_model.hh +++ b/src/pks/mpc/constitutive_relations/thermal_richards_model.hh @@ -48,8 +48,12 @@ class ThermalRichardsModel : public EWCModel { ThermalRichardsModel() {} virtual void InitializeModel(const Teuchos::Ptr& S); virtual void UpdateModel(const Teuchos::Ptr& S, int c); - virtual int - Evaluate(double T, double p, double base_poro, double& energy, double& wc, bool verbose = false); + virtual int Evaluate(double T, + double p, + double base_poro, + double& energy, + double& wc, + bool verbose = false); virtual int InverseEvaluate(double energy, double wc, double base_poro, double& T, double& p); protected: diff --git a/src/pks/mpc/mpc.hh b/src/pks/mpc/mpc.hh index 48d9be853..e9d1c0201 100644 --- a/src/pks/mpc/mpc.hh +++ b/src/pks/mpc/mpc.hh @@ -7,30 +7,30 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Multi process coupler base class. +// Multi process coupler base class. /*! -A multi process coupler is a PK (process kernel) which coordinates and couples -several PKs. Each of these coordinated PKs may be MPCs themselves, or physical -PKs. Note this does NOT provide a full implementation of PK -- it does not -supply the AdvanceStep() method. Therefore this class cannot be instantiated, but -must be inherited by derived classes which finish supplying the functionality. +A multi process coupler is a PK which coordinates and couples several PKs. +Each of these coordinated PKs may be MPCs themselves, or physical PKs. Note +this does NOT provide a full implementation of PK -- it does not supply the +AdvanceStep() method. Therefore this class cannot be instantiated, but must be +inherited by derived classes which finish supplying the functionality. Instead, this provides the data structures and methods (which may be overridden by derived classes) for managing multiple PKs. Most of these methods simply loop through the coordinated PKs, calling their respective methods. -.. _mpc-spec: -.. admonition:: mpc-spec +.. _pk-mpc-spec: +.. admonition:: pk-mpc-spec - * `"PKs order`" ``[Array(string)]`` Provide a specific order to the - sub-PKs; most methods loop over all sub-PKs, and will call the sub-PK - method in this order. + * `"PKs order`" ``[Array(string)]`` Provide a specific order to the + sub-PKs; most methods loop over all sub-PKs, and will call the sub-PK + method in this order. - INCLUDES: + INCLUDES: - - ``[pk-spec]`` *Is a* PK_. + - ``[pk-spec]`` *Is a* :ref:`PK`. */ @@ -50,7 +50,7 @@ respective methods. namespace Amanzi { -template +template class MPC : virtual public PK { public: MPC(Teuchos::ParameterList& pk_tree, @@ -117,7 +117,7 @@ class MPC : virtual public PK { }; -template +template void MPC::parseParameterList() { @@ -128,7 +128,7 @@ MPC::parseParameterList() // ----------------------------------------------------------------------------- // Setup of PK hierarchy from PList // ----------------------------------------------------------------------------- -template +template void MPC::Setup() { @@ -139,7 +139,7 @@ MPC::Setup() // ----------------------------------------------------------------------------- // loop over sub-PKs, calling their initialization methods // ----------------------------------------------------------------------------- -template +template void MPC::Initialize() { @@ -150,7 +150,7 @@ MPC::Initialize() // ----------------------------------------------------------------------------- // loop over sub-PKs, calling set_tags // ----------------------------------------------------------------------------- -template +template void MPC::set_tags(const Tag& current, const Tag& next) { @@ -162,7 +162,7 @@ MPC::set_tags(const Tag& current, const Tag& next) // ----------------------------------------------------------------------------- // loop over sub-PKs, calling their state_to_solution method // ----------------------------------------------------------------------------- -template +template void MPC::State_to_Solution(const Tag& tag, TreeVector& soln) { @@ -180,7 +180,7 @@ MPC::State_to_Solution(const Tag& tag, TreeVector& soln) // ----------------------------------------------------------------------------- // loop over sub-PKs, calling their solution_to_state method // ----------------------------------------------------------------------------- -template +template void MPC::Solution_to_State(const TreeVector& soln, const Tag& tag) { @@ -198,25 +198,27 @@ MPC::Solution_to_State(const TreeVector& soln, const Tag& tag) // ----------------------------------------------------------------------------- // loop over sub-PKs, calling their commit_state method // ----------------------------------------------------------------------------- -template +template void MPC::CommitStep(double t_old, double t_new, const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "commiting step @ " << tag << std::endl; - for (auto& pk : sub_pks_) { pk->CommitStep(t_old, t_new, tag); } + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "commiting step @ " << tag << std::endl; + for (auto& pk : sub_pks_) { + pk->CommitStep(t_old, t_new, tag); + } }; // ----------------------------------------------------------------------------- // loop over sub-PKs, calling their fail step method // ----------------------------------------------------------------------------- -template +template void MPC::FailStep(double t_old, double t_new, const Tag& tag) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "failing step @ " << tag << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "failing step @ " << tag << std::endl; for (auto& pk : sub_pks_) pk->FailStep(t_old, t_new, tag); }; @@ -224,7 +226,7 @@ MPC::FailStep(double t_old, double t_new, const Tag& tag) // ----------------------------------------------------------------------------- // loop over sub-PKs, calling their calculate_diagnostics method // ----------------------------------------------------------------------------- -template +template void MPC::CalculateDiagnostics(const Tag& tag) { @@ -238,7 +240,7 @@ MPC::CalculateDiagnostics(const Tag& tag) // ----------------------------------------------------------------------------- // Marks sub-PKs as changed. // ----------------------------------------------------------------------------- -template +template void MPC::ChangedSolutionPK(const Tag& tag) { @@ -246,7 +248,7 @@ MPC::ChangedSolutionPK(const Tag& tag) }; -template +template Teuchos::RCP MPC::get_subpk(int i) { @@ -259,7 +261,7 @@ MPC::get_subpk(int i) // protected constructor of subpks -template +template void MPC::init_(Comm_ptr_type comm) { @@ -282,7 +284,7 @@ MPC::init_(Comm_ptr_type comm) }; -template +template Teuchos::RCP MPC::getSubPKPlist_(int i) { @@ -291,7 +293,7 @@ MPC::getSubPKPlist_(int i) } -template +template Teuchos::RCP MPC::getSubPKPlist_(const std::string& name) { diff --git a/src/pks/mpc/mpc_coupled_cells.hh b/src/pks/mpc/mpc_coupled_cells.hh index af3379dc1..15c2d3c0c 100644 --- a/src/pks/mpc/mpc_coupled_cells.hh +++ b/src/pks/mpc/mpc_coupled_cells.hh @@ -7,29 +7,35 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! A coupler which solves two PDEs on the same domain. /*! -This is a StrongMPC which uses a preconditioner in which the +This is a :ref:`Strong MPC` which uses a preconditioner in which the block-diagonal cell-local matrix is dense. If the system looks something like: -A( y1, y2, x, t ) = 0 -B( y1, y2, x, t ) = 0 +.. math:: + + A( y_1, y_2, x, t ) = 0 + B( y_1, y_2, x, t ) = 0 -where y1,y2 are spatially varying unknowns that are discretized using the MFD -method (and therefore have both cell and face unknowns), an approximation to -the Jacobian is written as +where :math:`y_1, y_2` are spatially varying unknowns that are discretized +using the MFD method (and therefore have both cell and face unknowns), an +approximation to the Jacobian is written as -[ dA_c/dy1_c dA_c/dy1_f dA_c/dy2_c 0 ] -[ dA_f/dy1_c dA_f/dy1_f 0 0 ] -[ dB_c/dy1_c 0 dB_c/dy2_c dB_c/dy2_f ] -[ 0 0 dB_f/dy2_c dB_f/dy2_f ] +.. math:: + \begin{bmatrix} + \frac{dA^c}{dy_1^c} & \frac{dA^c}{dy_1^f} & \frac{dA^c}{dy_2^c} & 0 \\ + \frac{dA^f}{dy_1^c} & \frac{dA^f}{dy_1^f} & 0 & 0 \\ + \frac{dB^c}{dy_1^c} & 0 & \frac{dB^c}{dy_2^c} & \frac{dB^c}{dy_2^f} \\ + 0 & 0 & \frac{dB^f}{dy_2^c} & \frac{dB^f}{dy_2^f} + \end{bmatrix} -Note that the upper left block is the standard preconditioner for the A -system, and the lower right block is the standard precon for the B system, -and we have simply added cell-based couplings, dA_c/dy2_c and dB_c/dy1_c. + +Note that the upper left block is the standard preconditioner for the A system, +and the lower right block is the standard precon for the B system, and we have +simply added cell-based couplings, :math:`\frac{dA^c}{dy_2^c}` and +:math:`\frac{dB^c}{dy_1^c}`. Most commonly this is used to couple flow and energy equations on the same mesh. In the temperature/pressure system, these extra blocks correspond to @@ -37,20 +43,22 @@ mesh. In the temperature/pressure system, these extra blocks correspond to .. math:: \frac{\partial \Theta}{\partial T} \; , \; \frac{\partial E}{\partial p} -.. _mpc-coupled-cells-spec: -.. admonition:: mpc-coupled-cells-spec +`"PK type`" = `"mpc coupled cells`" + +.. _pk-mpc-coupled-cells-spec: +.. admonition:: pk-mpc-coupled-cells-spec - * `"domain name`" ``[string]`` Domain of simulation - * `"conserved quantity A`" ``[string]`` Key of the first sub-PK's conserved quantity. - * `"conserved quantity B`" ``[string]`` Key of the second sub-PK's conserved quantity. - * `"primary variable A`" ``[string]`` Key of the first sub-PK's primary variable. - * `"primary variable B`" ``[string]`` Key of the second sub-PK's primary variable. - * `"no dA/dy2 block`" ``[bool]`` **false** Excludes the dA_c/dy2_c block above. - * `"no dB/dy1 block`" ``[bool]`` **false** Excludes the dB_c/dy1_c block above. + * `"domain name`" ``[string]`` Domain of simulation + * `"conserved quantity A`" ``[string]`` Key of the first sub-PK's conserved quantity. + * `"conserved quantity B`" ``[string]`` Key of the second sub-PK's conserved quantity. + * `"primary variable A`" ``[string]`` Key of the first sub-PK's primary variable. + * `"primary variable B`" ``[string]`` Key of the second sub-PK's primary variable. + * `"no dA/dy2 block`" ``[bool]`` **false** Excludes the dA^c/dy_2^c block above. + * `"no dB/dy1 block`" ``[bool]`` **false** Excludes the dB^c/dy1^c block above. - INCLUDES: + INCLUDES: - - ``[strong-mpc-spec]`` *Is a* StrongMPC_. + - ``[strong-mpc-spec]`` *Is a* :ref:`Strong MPC`. */ @@ -80,8 +88,8 @@ class MPCCoupledCells : public StrongMPC { virtual void Setup() override; // applies preconditioner to u and returns the result in Pu - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; // updates the preconditioner virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; diff --git a/src/pks/mpc/mpc_coupled_cells_reg.hh b/src/pks/mpc/mpc_coupled_cells_reg.hh index 0b2f5a9dd..0894b2d04 100644 --- a/src/pks/mpc/mpc_coupled_cells_reg.hh +++ b/src/pks/mpc/mpc_coupled_cells_reg.hh @@ -8,5 +8,5 @@ */ #include "mpc_coupled_cells.hh" -Amanzi::RegisteredPKFactory - Amanzi::MPCCoupledCells::reg_("mpc coupled cells"); +Amanzi::RegisteredPKFactory Amanzi::MPCCoupledCells::reg_( + "mpc coupled cells"); diff --git a/src/pks/mpc/mpc_coupled_dualmedia_water.cc b/src/pks/mpc/mpc_coupled_dualmedia_water.cc index 3c8b419e8..c73659f0d 100644 --- a/src/pks/mpc/mpc_coupled_dualmedia_water.cc +++ b/src/pks/mpc/mpc_coupled_dualmedia_water.cc @@ -175,7 +175,7 @@ MPCCoupledDualMediaWater::UpdatePreconditioner(double t, double h) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon update at t = " << t << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon update at t = " << t << std::endl; } diff --git a/src/pks/mpc/mpc_coupled_dualmedia_water.hh b/src/pks/mpc/mpc_coupled_dualmedia_water.hh index 9fcfceff6..02024ece1 100644 --- a/src/pks/mpc/mpc_coupled_dualmedia_water.hh +++ b/src/pks/mpc/mpc_coupled_dualmedia_water.hh @@ -10,7 +10,7 @@ //! A coupler which integrates surface, richards and preferantial flows implicitly. /*! - +TODO: @dasvyat document me */ diff --git a/src/pks/mpc/mpc_coupled_dualmedia_water_reg.hh b/src/pks/mpc/mpc_coupled_dualmedia_water_reg.hh index 51d76cf02..d63b95117 100644 --- a/src/pks/mpc/mpc_coupled_dualmedia_water_reg.hh +++ b/src/pks/mpc/mpc_coupled_dualmedia_water_reg.hh @@ -11,7 +11,7 @@ namespace Amanzi { -RegisteredPKFactory - MPCCoupledDualMediaWater::reg_("coupled dualmedia water"); +RegisteredPKFactory MPCCoupledDualMediaWater::reg_( + "coupled dualmedia water"); } diff --git a/src/pks/mpc/mpc_coupled_reactivetransport.cc b/src/pks/mpc/mpc_coupled_reactivetransport.cc index e369f19f3..97b0ad1e7 100644 --- a/src/pks/mpc/mpc_coupled_reactivetransport.cc +++ b/src/pks/mpc/mpc_coupled_reactivetransport.cc @@ -14,7 +14,8 @@ */ #include "mpc_coupled_reactivetransport.hh" -#include "pk_helpers.hh" +#include "chem_pk_helpers.hh" +#include "PK_Helpers.hh" namespace Amanzi { @@ -27,66 +28,88 @@ MPCCoupledReactiveTransport::MPCCoupledReactiveTransport( const Teuchos::RCP& S, const Teuchos::RCP& soln) : PK(pk_tree, global_list, S, soln), WeakMPC(pk_tree, global_list, S, soln) -{ - chem_step_succeeded_ = true; - - alquimia_timer_ = Teuchos::TimeMonitor::getNewCounter("alquimia " + name()); - alquimia_surf_timer_ = Teuchos::TimeMonitor::getNewCounter("alquimia surface " + name()); -} +{} void MPCCoupledReactiveTransport::parseParameterList() { - WeakMPC::parseParameterList(); - - domain_ = Keys::readDomain(*plist_, "domain", "domain"); - domain_surf_ = Keys::readDomainHint(*plist_, domain_, "domain", "surface"); - - tcc_key_ = Keys::readKey( - *plist_, domain_, "total component concentration", "total_component_concentration"); - tcc_surf_key_ = Keys::readKey(*plist_, + // tweak the sub-PK parameter lists + auto coupled_pk_names = plist_->get>("PKs order"); + auto chem_names = getSubPKPlist_(0)->get>("PKs order"); + auto transport_names = getSubPKPlist_(1)->get>("PKs order"); + + domain_ = pks_list_->sublist(transport_names[0]).get("domain name", "domain"); + domain_surf_ = pks_list_->sublist(transport_names[1]).get("domain name", "surface"); + + mol_frac_key_ = Keys::readKey( + pks_list_->sublist(transport_names[0]), domain_, "primary variable", "mole_fraction"); + mol_frac_surf_key_ = Keys::readKey( + pks_list_->sublist(transport_names[1]), domain_surf_, "primary variable", "mole_fraction"); + + tcc_key_ = Keys::readKey(pks_list_->sublist(chem_names[0]), + domain_, + "primary variable", + "total_component_concentration"); + tcc_surf_key_ = Keys::readKey(pks_list_->sublist(chem_names[1]), domain_surf_, - "surface total component concentration", + "primary variable", "total_component_concentration"); + mol_dens_key_ = Keys::readKey(*plist_, domain_, "molar density liquid", "molar_density_liquid"); mol_dens_surf_key_ = Keys::readKey(*plist_, domain_surf_, "surface molar density liquid", "molar_density_liquid"); + + if (tcc_key_ == mol_frac_key_) { + Errors::Message msg; + msg << "Chemistry and Transport may not be given the same primary variable name (\"" << tcc_key_ + << "\") -- rename one or the other."; + Exceptions::amanzi_throw(msg); + } + if (tcc_surf_key_ == mol_frac_surf_key_) { + Errors::Message msg; + msg << "Chemistry and Transport may not be given the same primary variable name (\"" + << tcc_surf_key_ << "\") -- rename one or the other."; + Exceptions::amanzi_throw(msg); + } + + // this MPC accesses chemistry and transport primary variables + pks_list_->sublist(chem_names[0]).set("primary variable password", name_); + pks_list_->sublist(chem_names[1]).set("primary variable password", name_); + pks_list_->sublist(transport_names[0]).set("primary variable password", name_); + pks_list_->sublist(transport_names[1]).set("primary variable password", name_); + + // Only reaction PKs set IC, but all need the list to be present in all PK_Physical_Default. + pks_list_->sublist(transport_names[0]).sublist("initial conditions"); + pks_list_->sublist(transport_names[1]).sublist("initial conditions"); + + cast_sub_pks_(); + + coupled_chemistry_pk_->parseParameterList(); +#ifdef ALQUIMIA_ENABLED + transport_pk_->setChemEngine( + Teuchos::rcp_static_cast(chemistry_pk_)); + transport_pk_surf_->setChemEngine( + Teuchos::rcp_static_cast(chemistry_pk_surf_)); +#endif + coupled_transport_pk_->parseParameterList(); } void MPCCoupledReactiveTransport::Setup() { - cast_sub_pks_(); - // must Setup transport first to get alias for saturation, etc set up correctly coupled_transport_pk_->Setup(); coupled_chemistry_pk_->Setup(); - S_->Require(tcc_key_, tag_next_, "state") - .SetMesh(S_->GetMesh(domain_)) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, chemistry_pk_->num_aqueous_components()); - S_->RequireEvaluator(tcc_key_, tag_next_); - - S_->Require(tcc_surf_key_, tag_next_, "state") - .SetMesh(S_->GetMesh(domain_surf_)) - ->SetGhosted() - ->AddComponent( - "cell", AmanziMesh::Entity_kind::CELL, chemistry_pk_surf_->num_aqueous_components()); - S_->RequireEvaluator(tcc_surf_key_, tag_next_); - - S_->Require(mol_dens_key_, tag_next_) + requireEvaluatorAtNext(mol_dens_key_, tag_next_, *S_) .SetMesh(S_->GetMesh(domain_)) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S_->RequireEvaluator(mol_dens_key_, tag_next_); - - S_->Require(mol_dens_surf_key_, tag_next_) + requireEvaluatorAtNext(mol_dens_surf_key_, tag_next_, *S_) .SetMesh(S_->GetMesh(domain_surf_)) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S_->RequireEvaluator(mol_dens_surf_key_, tag_next_); } @@ -115,74 +138,41 @@ MPCCoupledReactiveTransport::cast_sub_pks_() AMANZI_ASSERT(transport_pk_->domain() == chemistry_pk_->domain()); AMANZI_ASSERT(transport_pk_surf_->domain() == chemistry_pk_surf_->domain()); - -// communicate chemistry engine to transport. -#ifdef ALQUIMIA_ENABLED - transport_pk_->SetupAlquimia( - Teuchos::rcp_static_cast(chemistry_pk_), - chemistry_pk_->chem_engine()); - transport_pk_surf_->SetupAlquimia( - Teuchos::rcp_static_cast(chemistry_pk_surf_), - chemistry_pk_surf_->chem_engine()); -#endif } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MPCCoupledReactiveTransport::Initialize() { + // initialize chemistry, including geochemical ICs + coupled_chemistry_pk_->Initialize(); + AMANZI_ASSERT(S_->GetRecord(tcc_key_, tag_next_).initialized()); + AMANZI_ASSERT(S_->GetRecord(tcc_surf_key_, tag_next_).initialized()); + + // Compute mol frac from concentration + // // NOTE: this requires that Reactive-Transport is done last, or at least // after the density of water can be evaluated. This could be problematic // for, e.g., salinity intrusion problems where water density is a function // of concentration itself, but should work for all other problems? - Teuchos::RCP tcc_surf = - S_->GetW(tcc_surf_key_, tag_next_, "state").ViewComponent("cell", true); - S_->GetEvaluator(mol_dens_surf_key_, tag_next_).Update(*S_, name_); - Teuchos::RCP mol_dens_surf = - S_->Get(mol_dens_surf_key_, tag_next_).ViewComponent("cell", true); - - Teuchos::RCP tcc = - S_->GetW(tcc_key_, tag_next_, "state").ViewComponent("cell", true); - S_->GetEvaluator(mol_dens_key_, tag_next_).Update(*S_, name_); - Teuchos::RCP mol_dens = - S_->Get(mol_dens_key_, tag_next_).ViewComponent("cell", true); - - int num_aqueous = chemistry_pk_surf_->num_aqueous_components(); - convertConcentrationToAmanzi(*mol_dens_surf, num_aqueous, *tcc_surf, *tcc_surf); - convertConcentrationToAmanzi(*mol_dens, num_aqueous, *tcc, *tcc); - - chemistry_pk_surf_->set_aqueous_components(tcc_surf); - chemistry_pk_surf_->Initialize(); - //*tcc_surf = *chemistry_pk_surf_->aqueous_components(); - - chemistry_pk_->set_aqueous_components(tcc); - chemistry_pk_->Initialize(); - //*tcc = *chemistry_pk_->aqueous_components(); - - convertConcentrationToATS(*mol_dens_surf, num_aqueous, *tcc_surf, *tcc_surf); - convertConcentrationToATS(*mol_dens, num_aqueous, *tcc, *tcc); - - transport_pk_surf_->Initialize(); - transport_pk_->Initialize(); -} - - -// ----------------------------------------------------------------------------- -// Calculate the min of sub PKs timestep sizes. -// ----------------------------------------------------------------------------- -double -MPCCoupledReactiveTransport::get_dt() -{ - double dTtran = coupled_transport_pk_->get_dt(); - double dTchem = coupled_chemistry_pk_->get_dt(); - - if (!chem_step_succeeded_ && (dTchem / dTtran > 0.99)) { dTchem *= 0.5; } - - if (dTtran > dTchem) dTtran = dTchem; - - return dTtran; + convertConcentrationToMolFrac(*S_, + { tcc_key_, tag_next_ }, + { mol_frac_key_, tag_next_ }, + { mol_dens_key_, tag_next_ }, + name()); + S_->GetRecordW(mol_frac_key_, tag_next_, name()).set_initialized(); + + convertConcentrationToMolFrac(*S_, + { tcc_surf_key_, tag_next_ }, + { mol_frac_surf_key_, tag_next_ }, + { mol_dens_surf_key_, tag_next_ }, + name()); + S_->GetRecordW(mol_frac_surf_key_, tag_next_, name()).set_initialized(); + + coupled_transport_pk_->Initialize(); } @@ -193,56 +183,38 @@ bool MPCCoupledReactiveTransport::AdvanceStep(double t_old, double t_new, bool reinit) { Teuchos::OSTab tab = vo_->getOSTab(); - chem_step_succeeded_ = false; // First we do a transport step. bool fail = coupled_transport_pk_->AdvanceStep(t_old, t_new, reinit); - if (fail) { - if (vo_->os_OK(Teuchos::VERB_MEDIUM)) - *vo_->os() << coupled_transport_pk_->name() << " failed." << std::endl; - return fail; - } - - // Chemistry on the surface - Teuchos::RCP tcc_surf = - S_->GetW(tcc_surf_key_, tag_next_, "state").ViewComponent("cell", true); - S_->GetEvaluator(mol_dens_surf_key_, tag_next_).Update(*S_, name_); - Teuchos::RCP mol_dens_surf = - S_->Get(mol_dens_surf_key_, tag_next_).ViewComponent("cell", true); - fail = advanceChemistry( - chemistry_pk_surf_, t_old, t_new, reinit, *mol_dens_surf, tcc_surf, *alquimia_surf_timer_); - changedEvaluatorPrimary(tcc_surf_key_, tag_next_, *S_); - if (fail) { - if (vo_->os_OK(Teuchos::VERB_MEDIUM)) - *vo_->os() << chemistry_pk_surf_->name() << " failed." << std::endl; - return fail; - } else { - transport_pk_surf_->debugger()->WriteCellVector("tcc (chem)", *tcc_surf); - transport_pk_surf_->PrintSoluteExtrema(*tcc_surf, t_new - t_old); - } - - // Chemistry in the subsurface - Teuchos::RCP tcc = - S_->GetW(tcc_key_, tag_next_, "state").ViewComponent("cell", true); - S_->GetEvaluator(mol_dens_key_, tag_next_).Update(*S_, name_); - Teuchos::RCP mol_dens = - S_->Get(mol_dens_key_, tag_next_).ViewComponent("cell", true); - try { - fail = advanceChemistry(chemistry_pk_, t_old, t_new, reinit, *mol_dens, tcc, *alquimia_timer_); - changedEvaluatorPrimary(tcc_key_, tag_next_, *S_); - } catch (const Errors::Message& chem_error) { - fail = true; - } - if (fail) { - if (vo_->os_OK(Teuchos::VERB_MEDIUM)) - *vo_->os() << chemistry_pk_->name() << " failed." << std::endl; - return fail; - } else { - transport_pk_->debugger()->WriteCellVector("tcc (chem)", *tcc); - transport_pk_->PrintSoluteExtrema(*tcc, t_new - t_old); - } - - chem_step_succeeded_ = true; + if (fail) return fail; + + // move from mol_frac@next to tcc@current + convertMolFracToConcentration(*S_, + { mol_frac_key_, tag_next_ }, + { tcc_key_, tag_current_ }, + { mol_dens_key_, tag_next_ }, + name()); + convertMolFracToConcentration(*S_, + { mol_frac_surf_key_, tag_next_ }, + { tcc_surf_key_, tag_current_ }, + { mol_dens_surf_key_, tag_next_ }, + name()); + + // Next to chemistry step + fail = coupled_chemistry_pk_->AdvanceStep(t_old, t_new, reinit); + if (fail) return fail; + + // move from tcc@next to mol_frac@next + convertConcentrationToMolFrac(*S_, + { tcc_key_, tag_next_ }, + { mol_frac_key_, tag_next_ }, + { mol_dens_key_, tag_next_ }, + name()); + convertConcentrationToMolFrac(*S_, + { tcc_surf_key_, tag_next_ }, + { mol_frac_surf_key_, tag_next_ }, + { mol_dens_surf_key_, tag_next_ }, + name()); return fail; }; diff --git a/src/pks/mpc/mpc_coupled_reactivetransport.hh b/src/pks/mpc/mpc_coupled_reactivetransport.hh index 5c4a3d617..cd7ab67d2 100644 --- a/src/pks/mpc/mpc_coupled_reactivetransport.hh +++ b/src/pks/mpc/mpc_coupled_reactivetransport.hh @@ -7,10 +7,37 @@ Authors: Daniil Svyatskiy */ -/* - This is the mpc_pk component of the Amanzi code. +/*! + +This couples integrated (surface + subsurface) transport MPC with an integrated +chemistry MPC. + +Transport must be tightly coupled in order to correctly pass surface-subsurface +advective fluxes between the two domains. Chemistry is just a weak MPC. The +two are then coupled to form an integrated reactive-transport PK. + +This performs operatoring splitting between transport and chemistry in each +domain. Note that transport's primary variable is "molar_fraction", which is +in units of [mol-C mol-H2O^-1]. Chemistry is in +"total_component_concentration", which is in units of [mol-C L^-1]. Therefore, +between steps, we convert between the two. + +`"PK type`" = `"surface subsurface reactive transport`" + +.. _pk-surface-subsurface-reactive-transport-spec: +.. admonition:: pk-surface-subsurface-reactive-transport-spec + + * `"PKs order`" ``[Array(string)]`` Order must be {chemistry_mpc, + transport_mpc}. The chemistry MPC is likely just a :ref:`Weak MPC` + coupling to chemistry PKs, while the transport MPC is likely a + :ref:`Integrated Transport` MPC. + + KEYS: + + - `"molar density liquid`" + - `"surface molar density liquid`" + - Process kernel for coupling of Transport_PK and Chemistry_PK. */ @@ -38,7 +65,6 @@ class MPCCoupledReactiveTransport : public WeakMPC { void parseParameterList() override; // PK methods - virtual double get_dt() override; virtual void Setup() override; virtual void Initialize() override; virtual bool AdvanceStep(double t_old, double t_new, bool reinit = false) override; @@ -47,14 +73,11 @@ class MPCCoupledReactiveTransport : public WeakMPC { virtual void cast_sub_pks_(); protected: - bool chem_step_succeeded_; - Key domain_, domain_surf_; Key tcc_key_, tcc_surf_key_; + Key mol_frac_key_, mol_frac_surf_key_; Key mol_dens_key_, mol_dens_surf_key_; - Teuchos::RCP alquimia_timer_, alquimia_surf_timer_; - // storage for the component concentration intermediate values Teuchos::RCP coupled_transport_pk_; Teuchos::RCP coupled_chemistry_pk_; diff --git a/src/pks/mpc/mpc_coupled_reactivetransport_reg.hh b/src/pks/mpc/mpc_coupled_reactivetransport_reg.hh index 7f0607e25..f330725fc 100644 --- a/src/pks/mpc/mpc_coupled_reactivetransport_reg.hh +++ b/src/pks/mpc/mpc_coupled_reactivetransport_reg.hh @@ -12,7 +12,7 @@ namespace Amanzi { -RegisteredPKFactory - MPCCoupledReactiveTransport::reg_("coupled reactive transport"); +RegisteredPKFactory MPCCoupledReactiveTransport::reg_( + "surface subsurface reactive transport"); } // namespace Amanzi diff --git a/src/pks/mpc/mpc_coupled_transport.cc b/src/pks/mpc/mpc_coupled_transport.cc index 8a2d039f9..35e12c0c6 100644 --- a/src/pks/mpc/mpc_coupled_transport.cc +++ b/src/pks/mpc/mpc_coupled_transport.cc @@ -7,11 +7,6 @@ Authors: */ -/* - This is the mpc_pk component of the Amanzi code. - -*/ - #include "mpc_coupled_transport.hh" namespace Amanzi { @@ -33,20 +28,36 @@ MPCCoupledTransport::parseParameterList() Key domain_ss = pks_list_->sublist(name_ss_).get("domain name", "domain"); Key domain_surf = pks_list_->sublist(name_surf_).get("domain name", "surface"); + // first make sure predictor-corrector scheme is turned off -- this isn't valid for coupled transport + for (const auto& name : std::vector{ name_ss_, name_surf_ }) { + if (pks_list_->sublist(name).isParameter("temporal discretization order")) { + int order = pks_list_->sublist(name).get("temporal discretization order"); + if (order != 1) { + if (vo_->os_OK(Teuchos::VERB_LOW)) + *vo_->os() << vo_->color("yellow") << "Transport PK \"" << name + << "\" prescribes \"temporal discretization order\" " << order + << ", but this is not valid for integrated transport. " + << "Using \"temporal discretization order\" 1 instead." << vo_->reset() + << std::endl; + } + pks_list_->sublist(name).set("temporal discretization order", 1); + } + } + Key ss_flux_key = Keys::readKey(pks_list_->sublist(name_ss_), domain_ss, "water flux", "water_flux"); Key surf_flux_key = Keys::readKey(pks_list_->sublist(name_surf_), domain_surf, "water flux", "water_flux"); - Key ss_tcc_key = Keys::readKey( - pks_list_->sublist(name_ss_), domain_ss, "concentration", "total_component_concentration"); - Key surf_tcc_key = Keys::readKey( - pks_list_->sublist(name_surf_), domain_surf, "concentration", "total_component_concentration"); + Key ss_tcc_key = + Keys::readKey(pks_list_->sublist(name_ss_), domain_ss, "primary variable", "mole_fraction"); + Key surf_tcc_key = + Keys::readKey(pks_list_->sublist(name_surf_), domain_surf, "primary variable", "mole_fraction"); Key surf_tcq_key = Keys::readKey( pks_list_->sublist(name_surf_), domain_surf, "conserved quantity", "total_component_quantity"); auto& bc_list = - pks_list_->sublist(name_ss_).sublist("boundary conditions").sublist("concentration"); + pks_list_->sublist(name_ss_).sublist("boundary conditions").sublist("mole fraction"); if (!bc_list.isSublist("BC coupling")) { Teuchos::ParameterList& bc_coupling = bc_list.sublist("BC coupling"); bc_coupling.set("spatial distribution method", "domain coupling"); @@ -56,9 +67,9 @@ MPCCoupledTransport::parseParameterList() bc_coupling.set>("regions", regs); Teuchos::ParameterList& tmp = bc_coupling.sublist("fields"); tmp.set("conserved quantity key", surf_tcq_key); - tmp.set("conserved quantity copy key", tag_next_.get()); + tmp.set("conserved quantity tag", tag_next_.get()); tmp.set("external field key", surf_tcc_key); - tmp.set("external field copy key", tag_next_.get()); + tmp.set("external field tag", tag_next_.get()); } auto& src_list = @@ -74,11 +85,11 @@ MPCCoupledTransport::parseParameterList() tmp.set("flux key", ss_flux_key); // NOTE: FIXME --ETC amanzi/amanzi#646 Currently flux field is hard-coded // as NEXT both here and as transport PK's flow_tag - tmp.set("flux copy key", Tags::NEXT.get()); + tmp.set("flux tag", Tags::NEXT.get()); tmp.set("conserved quantity key", surf_tcc_key); - tmp.set("conserved quantity copy key", tag_next_.get()); + tmp.set("conserved quantity tag", tag_next_.get()); tmp.set("external field key", ss_tcc_key); - tmp.set("external field copy key", tag_next_.get()); + tmp.set("external field tag", tag_next_.get()); } WeakMPC::parseParameterList(); @@ -126,7 +137,6 @@ MPCCoupledTransport::get_num_aqueous_component() void MPCCoupledTransport::SetupCouplingConditions_() -{ -} +{} } // namespace Amanzi diff --git a/src/pks/mpc/mpc_coupled_transport.hh b/src/pks/mpc/mpc_coupled_transport.hh index 953aa29f6..709f09946 100644 --- a/src/pks/mpc/mpc_coupled_transport.hh +++ b/src/pks/mpc/mpc_coupled_transport.hh @@ -6,11 +6,21 @@ Authors: Daniil Svyatskiy */ +/*! -/* - This is the mpc_pk component of the Amanzi code. +This MPC couples surface and subsurface transport. It is implemented as +described in `Molins et al WRR 2022 `_, +and deals with the conservation of advected fluxes as they are transported +laterally, infiltrate, etc, including wetting and drying of surface cells. + +`"PK type`" = `"surface subsurface transport`" + +.. _pk-surface-subsurface-transport-spec: +.. admonition:: pk-surface-subsurface-transport-spec + + * `"PKs order`" ``[Array(string)]`` Order must be {subsurface transport, + surface transport}. - PK for coupling of surface and subsurface transport PKs */ #pragma once diff --git a/src/pks/mpc/mpc_coupled_water.cc b/src/pks/mpc/mpc_coupled_water.cc index 937175853..6eb2644ab 100644 --- a/src/pks/mpc/mpc_coupled_water.cc +++ b/src/pks/mpc/mpc_coupled_water.cc @@ -11,7 +11,7 @@ #include "Teuchos_XMLParameterListHelpers.hpp" #include "EpetraExt_RowMatrixOut.h" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "mpc_surface_subsurface_helpers.hh" #include "mpc_coupled_water.hh" @@ -64,10 +64,9 @@ MPCCoupledWater::Setup() StrongMPC::Setup(); // require the coupling fields, claim ownership - S_->Require(exfilt_key_, tag_next_, exfilt_key_) + requireEvaluatorAtNext(exfilt_key_, tag_next_, *S_, name_) .SetMesh(surf_mesh_) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireEvaluatorPrimary(exfilt_key_, tag_next_, *S_); // Create the preconditioner. // -- collect the preconditioners @@ -81,7 +80,7 @@ MPCCoupledWater::Setup() precon_->set_inverse_parameters(inv_list); // -- push the surface local ops into the subsurface global operator - for (Operators::Operator::op_iterator op = precon_surf_->begin(); op != precon_surf_->end(); + for (Operators::Operator::op_iterator op = precon_surf_->begin() ; op != precon_surf_->end(); ++op) { precon_->OpPushBack(*op); } @@ -129,8 +128,8 @@ void MPCCoupledWater::Initialize() { // initialize coupling terms - S_->GetPtrW(exfilt_key_, tag_next_, exfilt_key_)->PutScalar(0.); - S_->GetRecordW(exfilt_key_, tag_next_, exfilt_key_).set_initialized(); + S_->GetPtrW(exfilt_key_, tag_next_, name_)->PutScalar(0.); + S_->GetRecordW(exfilt_key_, tag_next_, name_).set_initialized(); changedEvaluatorPrimary(exfilt_key_, tag_next_, *S_); // Initialize all sub PKs. @@ -166,7 +165,7 @@ MPCCoupledWater::FunctionalResidual(double t_old, // The residual of the surface flow equation provides the water flux from // subsurface to surface. Epetra_MultiVector& source = - *S_->GetW(exfilt_key_, tag_next_, exfilt_key_).ViewComponent("cell", false); + *S_->GetW(exfilt_key_, tag_next_, name_).ViewComponent("cell", false); source = *g->SubVector(1)->Data()->ViewComponent("cell", false); changedEvaluatorPrimary(exfilt_key_, tag_next_, *S_); @@ -184,7 +183,7 @@ int MPCCoupledWater::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Precon application:" << std::endl; // call the precon's inverse if (vo_->os_OK(Teuchos::VERB_EXTREME)) @@ -379,7 +378,7 @@ double MPCCoupledWater::ErrorNorm(Teuchos::RCP u, Teuchos::RCP res) { // move the surface face residual onto the surface cell. - auto res2 = Teuchos::rcp(new TreeVector(*res, INIT_MODE_COPY)); + auto res2 = Teuchos::rcp(new TreeVector(*res)); auto& res_face = *res2->SubVector(0)->Data()->ViewComponent("face", false); auto& res_surf_cell = *res2->SubVector(1)->Data()->ViewComponent("cell", false); const auto& u_surf_cell = *u->SubVector(1)->Data()->ViewComponent("cell", false); diff --git a/src/pks/mpc/mpc_coupled_water.hh b/src/pks/mpc/mpc_coupled_water.hh index 4f0b937cb..f504d3408 100644 --- a/src/pks/mpc/mpc_coupled_water.hh +++ b/src/pks/mpc/mpc_coupled_water.hh @@ -5,35 +5,59 @@ provided in the top-level COPYRIGHT file. Authors: Ethan Coon (ecoon@lanl.gov) -*/ -//! A coupler which integrates surface and subsurface flow implicitly. + \frac{\partial \Theta_s(p_s^*)}{\partial t} &= \nabla k_s \cdot \nabla (z+h(p_s^*)) + Q_{ext} + q_{ss} \\ + \frac{\partial \Theta(p)}{\partial t} &= \nabla \cdot k K (\nabla p + \rho g \hat{z}) \\ + & -k K (\nabla p + \rho g \hat{z}) \cdot \hat{n} |_{\Gamma} = q_{ss} \\ + & p|_{\Gamma} = p_s +*/ /*! -Couples Richards equation to surface water through continuity of both pressure -and fluxes. This leverages subsurface discretizations that include face-based -unknowns, and notes that those face unknowns that correspond to surface faces -are co-located with the surface cell pressure, and therefore are equivalent. -In this approach (described in detail in a paper that is in review), the -surface equations are directly assembled into the subsurface discrete operator. +This MPC couples Richards equation (subsurface flow) to the diffusion wave +equation (surface flow) through continuity of both pressure and fluxes. In its +standard form, it couples pressure at a the surface of the domain, +:math:`\Gamma`, by solving: + +.. math:: + + \frac{\partial \Theta_s(p_s^*)}{\partial t} &= \nabla k_s \cdot \nabla (z+h(p_s^*)) + Q_{ext} + q_{ss} \\ + \frac{\partial \Theta(p)}{\partial t} &= \nabla \cdot k K (\nabla p + \rho g \hat{z}) \\ + -k K (\nabla p + \rho g \hat{z}) \cdot \hat{n} |_{\Gamma} &= q_{ss} \\ + p|_{\Gamma} &= p_s + +:math:`q_{ss}`, the "exfiltration" of water from subsurface to surface, is +eliminated discretely (enforcing flux continuity) and the pressure equality +condition (the last equation) is enforced by elimintating the surface unknowns +discretely. + +This leverages subsurface discretizations that include face-based unknowns, and +notes that those face unknowns that correspond to surface faces are co-located +with the surface cell pressure, and therefore are equivalent. In this approach +(see `Coon et al WRR 2020 `_), +the surface equations are directly assembled into the subsurface discrete +operator. + +As a result, this requires a subsurface discretization that uses face-based +unknowns, e.g. any of the `"mfd: *`" class of methods. + +`"PK type`" = `"coupled water`" -.. _mpc-coupled-water-spec: -.. admonition:: mpc-coupled-water-spec +.. _pk-coupled-water-spec: +.. admonition:: pk-coupled-water-spec - * `"PKs order`" ``[Array(string)]`` The use supplies the names of the - coupled PKs. The order must be {subsurface_flow_pk, surface_flow_pk} - (subsurface first). + * `"PKs order`" ``[Array(string)]`` Order must be {subsurface_flow_pk, + surface_flow_pk}. * `"subsurface domain name`" ``[string]`` **domain** * `"surface domain name`" ``[string]`` **surface** - * `"water delegate`" ``[mpc-delegate-water-spec]`` A `Coupled Water - Globalization Delegate`_ spec. + * `"water delegate`" ``[mpc-delegate-water-spec]`` A :ref:`Coupled Water + Globalization Delegate` spec. INCLUDES: - - ``[strong-mpc-spec]`` *Is a* StrongMPC_ + - ``[strong-mpc-spec]`` *Is a* :ref:`Strong MPC`. */ @@ -70,22 +94,23 @@ class MPCCoupledWater : public StrongMPC { Teuchos::RCP g) override; // -- Apply preconditioner to u and returns the result in Pu. - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; // -- Modify the predictor. - virtual bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + virtual bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; // -- Modify the correction. - virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult - ModifyCorrection(double h, - Teuchos::RCP res, - Teuchos::RCP u, - Teuchos::RCP du) override; - - virtual double - ErrorNorm(Teuchos::RCP u, Teuchos::RCP res) override; + virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult ModifyCorrection( + double h, + Teuchos::RCP res, + Teuchos::RCP u, + Teuchos::RCP du) override; + + virtual double ErrorNorm(Teuchos::RCP u, + Teuchos::RCP res) override; Teuchos::RCP preconditioner() { return precon_; } diff --git a/src/pks/mpc/mpc_coupled_water_split_flux.cc b/src/pks/mpc/mpc_coupled_water_split_flux.cc index 95c6f4348..736426ba7 100644 --- a/src/pks/mpc/mpc_coupled_water_split_flux.cc +++ b/src/pks/mpc/mpc_coupled_water_split_flux.cc @@ -9,7 +9,7 @@ #include "mpc_coupled_water_split_flux.hh" #include "mpc_surface_subsurface_helpers.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" namespace Amanzi { @@ -33,10 +33,8 @@ MPCCoupledWaterSplitFlux::parseParameterList() // determine whether we are coupling subdomains or coupling 3D domains is_domain_set_ = S_->HasDomainSet(domain_set_); - if (is_domain_set_) - domain_ = Keys::getDomainInSet(domain_set_, "*"); - else - domain_ = domain_set_; + if (is_domain_set_) domain_ = Keys::getDomainInSet(domain_set_, "*"); + else domain_ = domain_set_; domain_sub_ = Keys::readDomainHint(*plist_, domain_set_, "surface", "subsurface"); @@ -93,27 +91,24 @@ MPCCoupledWaterSplitFlux::Setup() for (const auto& domain : *domain_set) { auto p_key = Keys::getKey(domain, p_lateral_flow_source_suffix_); Tag ds_tag_next = get_ds_tag_next_(domain); - S_->Require(p_key, ds_tag_next, p_key) + requireEvaluatorAtNext(p_key, ds_tag_next, *S_, name_) .SetMesh(S_->GetMesh(domain)) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireEvaluatorPrimary(p_key, ds_tag_next, *S_); } } else { - S_->Require( - p_lateral_flow_source_, tags_[1].second, p_lateral_flow_source_) + requireEvaluatorAtNext(p_lateral_flow_source_, tags_[1].second, *S_, name_) .SetMesh(S_->GetMesh(Keys::getDomain(p_lateral_flow_source_))) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireEvaluatorPrimary(p_lateral_flow_source_, tags_[1].second, *S_); } // also need conserved quantities at old and new times - S_->Require(p_conserved_variable_star_, tags_[0].second) + requireEvaluatorAtNext(p_conserved_variable_star_, tags_[0].second, *S_) .SetMesh(S_->GetMesh(domain_star_)) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + S_->Require(p_conserved_variable_star_, tags_[0].first) .SetMesh(S_->GetMesh(domain_star_)) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S_->RequireEvaluator(p_conserved_variable_star_, tags_[0].second); //S_->RequireEvaluator(p_conserved_variable_star_, tags_[0].first); } } @@ -155,8 +150,7 @@ MPCCoupledWaterSplitFlux::Initialize() S_->GetRecordW(pkey, ds_tag_next, p_owner).set_initialized(); } } else { - S_->GetRecordW(p_lateral_flow_source_, tags_[1].second, p_lateral_flow_source_) - .set_initialized(); + S_->GetRecordW(p_lateral_flow_source_, tags_[1].second, name_).set_initialized(); } } @@ -211,23 +205,15 @@ void MPCCoupledWaterSplitFlux::CopyStarToPrimary_() { if (is_domain_set_) { - if (coupling_ == "pressure") - CopyStarToPrimary_DomainSet_Pressure_(); - else if (coupling_ == "flux") - CopyStarToPrimary_DomainSet_Flux_(); - else if (coupling_ == "hybrid") - CopyStarToPrimary_DomainSet_Hybrid_(); - else - AMANZI_ASSERT(false); + if (coupling_ == "pressure") CopyStarToPrimary_DomainSet_Pressure_(); + else if (coupling_ == "flux") CopyStarToPrimary_DomainSet_Flux_(); + else if (coupling_ == "hybrid") CopyStarToPrimary_DomainSet_Hybrid_(); + else AMANZI_ASSERT(false); } else { - if (coupling_ == "pressure") - CopyStarToPrimary_Standard_Pressure_(); - else if (coupling_ == "flux") - CopyStarToPrimary_Standard_Flux_(); - else if (coupling_ == "hybrid") - CopyStarToPrimary_Standard_Hybrid_(); - else - AMANZI_ASSERT(false); + if (coupling_ == "pressure") CopyStarToPrimary_Standard_Pressure_(); + else if (coupling_ == "flux") CopyStarToPrimary_Standard_Flux_(); + else if (coupling_ == "hybrid") CopyStarToPrimary_Standard_Hybrid_(); + else AMANZI_ASSERT(false); } } @@ -299,9 +285,8 @@ MPCCoupledWaterSplitFlux::CopyStarToPrimary_Standard_Pressure_() auto p_owner = S_->GetRecord(p_primary_variable_, tags_[1].first).owner(); auto& p = *S_->GetW(p_primary_variable_, tags_[1].first, p_owner) .ViewComponent("cell", false); - auto& WC = - *S_->GetW(p_conserved_variable_, tags_[1].first, p_conserved_variable_) - .ViewComponent("cell", false); + auto& WC = *S_->GetW(p_conserved_variable_, tags_[1].first, name_) + .ViewComponent("cell", false); double p_atm_plus_eps = 101325. + 1.e-7; for (int c = 0; c != p_star.MyLength(); ++c) { @@ -336,9 +321,8 @@ MPCCoupledWaterSplitFlux::CopyStarToPrimary_Standard_Flux_() // mass // -- grab the data, difference - auto& q_div = - *S_->GetW(p_lateral_flow_source_, tags_[1].second, p_lateral_flow_source_) - .ViewComponent("cell", false); + auto& q_div = *S_->GetW(p_lateral_flow_source_, tags_[1].second, name_) + .ViewComponent("cell", false); q_div.Update(1.0 / dt, *S_->Get(p_conserved_variable_star_, tags_[0].second) .ViewComponent("cell", false), @@ -369,9 +353,8 @@ MPCCoupledWaterSplitFlux::CopyStarToPrimary_Standard_Hybrid_() // mass // -- grab the data, difference - auto& q_div = - *S_->GetW(p_lateral_flow_source_, tags_[1].second, p_lateral_flow_source_) - .ViewComponent("cell", false); + auto& q_div = *S_->GetW(p_lateral_flow_source_, tags_[1].second, name_) + .ViewComponent("cell", false); q_div.Update(1.0 / dt, *S_->Get(p_conserved_variable_star_, tags_[0].second) .ViewComponent("cell", false), @@ -560,7 +543,7 @@ MPCCoupledWaterSplitFlux::CopyStarToPrimary_DomainSet_Hybrid_() // set the lateral flux to 0 Key p_lf_key = Keys::getKey(*ds_iter, p_lateral_flow_source_suffix_); - (*S_->GetW(p_lf_key, ds_tag_next, p_lf_key) + (*S_->GetW(p_lf_key, ds_tag_next, name_) .ViewComponent("cell", false))[0][0] = 0.; changedEvaluatorPrimary(p_lf_key, ds_tag_next, *S_); diff --git a/src/pks/mpc/mpc_coupled_water_split_flux.hh b/src/pks/mpc/mpc_coupled_water_split_flux.hh index 207a6bffa..b5213b16b 100644 --- a/src/pks/mpc/mpc_coupled_water_split_flux.hh +++ b/src/pks/mpc/mpc_coupled_water_split_flux.hh @@ -6,45 +6,110 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! An operator-split coupled_water coupler, splitting overland flow from subsurface. /*! -solve: -(dTheta_s / dt)^* = div k_s grad (z+h) +This MPC implements an operator-split coupled water, which splits the lateral +overland fluxes from surface sources and subsurface flow. + +To advance the coupled flow problem from :math:`t^n` to :math:`t^{n + 1}`, we +perform two steps. First, solve the diffusion wave equation: + +.. math:: + + \frac{\partial \Theta_s(p_s^*)}{\partial t} = \nabla k_s \cdot \nabla (z+h(p_s^*)) + +for surface pressure :math:`p_s^*`. This is colloquially called the "star" +system. Then, one of three algorithms is performed for the "primary" system, +which is a variation on :ref:`Integrated Hydrology` without lateral surface +fluxes and with extra coupling to the star system. + +**Pressure Coupling** + +`"pressure`" coupling is a standard operator splitting. :math:`p_s^*` becomes +the initial value for the coupled surface sources and subsurface equations: + +.. math:: + + \frac{\partial \Theta_s(p_s)}{\partial t} &= Q_ext + q_{ss} \\ + \frac{\partial \Theta(p)}{\partial t} &= \nabla \cdot k K (\nabla p + \rho g \hat{z}) \\ + -k K (\nabla p + \rho g \hat{z}) \cdot \hat{n} |_\Gamma &= q_{ss} \\ + p|_\Gamma &= p_s \\ + p_s(t^n) &= p_s^* + +Note the lack of a lateral flow term in the overland equation (relative to the +standard diffusion wave equation shown in `Integrated Hydrology`_). This +system is coupled and solved in the same discrete way as `Integrated +Hydrology`_. -then solve: +**Flux Coupling** -dTheta_s / dt = (dTheta_s / dt)^* + Q_ext + q_ss -dTheta / dt = div k (grad p + rho*g*\hat{z}) -k (grad p + rho*g*\hat{z}) |_s = q_ss +`"flux`" coupling, rather than setting the initial pressure from the +:math:`p_s^*`, instead provides the divergence of fluxes in the lateral flow +system as a source to the surface system: -This effectively does an operator splitting on the surface flow equation, -passing some combination of pressure and divergence of fluxes to the -subsurface. +.. math:: -Note that this can be used with either a 3D subsurface solve, by setting the -2nd sub-PK to be a 3D permafrost MPC, or a bunch of columns, but setting the -2nd sub-PK to be a DomainSetMPC. + \frac{\partial \Theta_s(p_s)}{\partial t} &= \frac{\partial \Theta_s(p_s^*)}{\partial t} + Q_ext + q_{ss} \\ + \frac{\partial \Theta(p)}{\partial t} &= \nabla \cdot k K (\nabla p + \rho g \hat{z}) \\ + -k K (\nabla p + \rho g \hat{z}) \cdot \hat{n} |_\Gamma &= q_{ss} \\ + p|_\Gamma &= p_s +The advantage of this approach is that it more stably handles the case of +wetting up -- when a dry surface cell first gets overland flow into that cell, +it requires that :math:`p_s > p_{atm}`. But if the subsurface below it is +unsaturated, this can create a large gradient in pressure that will immediately +be eliminated in the subsurface solve once "run-on" infiltrates. This jump +between a :math:`p_s^* > p_atm` and :math:`p_s < p_atm` is unstable, and hard +on the nonlinear solver. -.. _mpc-permafrost-split-flux-spec -.. admonition:: mpc-permafrost-split-flux-spec +Imposing the run-on as a source of water rather than as a initial pressure is +much more stable for run-on. - * `"domain name`" ``[string]`` The subsurface domain, e.g. "domain" (for a - 3D subsurface ) or "column:*" (for the intermediate scale model. + +**Hybrid Coupling** + +While the `"flux`" approach is more stable than `'pressure`" in cells +experiencing run-on, it is not necessary, and potentially problematic in the +case of run-off. In those cases the `"pressure`" case is more stable. +Therefore, a `"hybrid`" coupling approach is used most frequently; this uses +the `"pressure`' algorithm where the divergence of lateral surface fluxes is +negative (e.g. run-off) and the `"flux`" algorithm elsewhere. + +All three algorithms should result in the same (converged) solution. The +`"hybrid`" algorithm is the most robust for numerical performance. + + +Additionally, the subsurface domain may be treated as either a 3D domain +(solving 3D Richards equations) or as a domain-set of many 1D, vertical +columns. In this case, the second system of equations is implemented on each +subsurface column individually -- there is nothing coupling these columns in +the second system. Lateral subsurface flow is ignored in this case. This +allows subcycling of individual columns, and a much more efficient solve. This +is most appropriate at larger or "intermediate" scales, where lateral flow in +the subsurface is small. + +`"PK type`" = `"operator split coupled water`" + +.. _pk-operator-split-coupled-water-spec: +.. admonition:: pk-operator-split-coupled-water-spec + + * `"PKs order`" ``[Array(string)]`` Order is {star_system, primary_system}. + Note that the sub-PKs are likely a :ref:`Overland Flow PK` for the "star" + system and a :ref:`Integrated Hydrology` MPC for the "primary" system. + + * `"domain name`" ``[string]`` The subsurface domain, e.g. `"domain`" (for a + 3D subsurface) or `"column:*`" (for the intermediate scale, columnar model). * `"star domain name`" ``[string]`` The surface domain, typically `"surface_star`" by convention. - * `"coupling type`" ``[string]`` **hybrid** One of: `"pressure`" (pass the - pressure field when coupling flow in the operator splitting), `"flux`" - (pass the divergence of fluxes as a source), or `"hybrid`" a mixture of - the two that seems the most robust. + * `"coupling type`" ``[string]`` **"hybrid"** One of: `"pressure`", `"flux`", + or `"hybrid`" (see above). INCLUDES: - - ``[mpc-spec]`` *Is an* MPC_. - - ``[mpc-subcycled-spec]`` *Is a* MPCSubcycled_ + + - ``[mpc-spec]`` *Is an* :ref:`MPC`. + - ``[mpc-subcycled-spec]`` *Is a* :ref:`Subcycling MPC`. */ @@ -92,16 +157,14 @@ class MPCCoupledWaterSplitFlux : public MPCSubcycled { if (subcycling_[1]) return Tag{ Keys::cleanName(tags_[1].second.get() + "_" + Keys::getDomainSetIndex(subdomain)) }; - else - return Tag{ tags_[1].second }; + else return Tag{ tags_[1].second }; } Tag get_ds_tag_current_(const std::string& subdomain) { if (subcycling_[1]) return Tag{ Keys::cleanName(tags_[1].first.get() + "_" + Keys::getDomainSetIndex(subdomain)) }; - else - return Tag{ tags_[1].first }; + else return Tag{ tags_[1].first }; } diff --git a/src/pks/mpc/mpc_coupled_water_split_flux_reg.hh b/src/pks/mpc/mpc_coupled_water_split_flux_reg.hh index 7abe09251..e21b34c29 100644 --- a/src/pks/mpc/mpc_coupled_water_split_flux_reg.hh +++ b/src/pks/mpc/mpc_coupled_water_split_flux_reg.hh @@ -11,7 +11,7 @@ namespace Amanzi { -RegisteredPKFactory - MPCCoupledWaterSplitFlux::reg_("operator split coupled water"); +RegisteredPKFactory MPCCoupledWaterSplitFlux::reg_( + "operator split coupled water"); } // namespace Amanzi diff --git a/src/pks/mpc/mpc_delegate_ewc.cc b/src/pks/mpc/mpc_delegate_ewc.cc index c70d2dc73..0265c00c5 100644 --- a/src/pks/mpc/mpc_delegate_ewc.cc +++ b/src/pks/mpc/mpc_delegate_ewc.cc @@ -182,7 +182,9 @@ MPCDelegateEWC::ModifyPredictor(double h, Teuchos::RCP up) // modified = modify_predictor_ewc_(h,up); } } else if (predictor_type_ == PREDICTOR_SMART_EWC) { - if (dt_prev > 0.) { modified = modify_predictor_smart_ewc_(h, up); } + if (dt_prev > 0.) { + modified = modify_predictor_smart_ewc_(h, up); + } } return modified; } @@ -209,8 +211,7 @@ MPCDelegateEWC::ApplyPreconditioner(Teuchos::RCP u, Teuchos::R int ierr = 0; if ((precon_type_ == PRECON_EWC) || (precon_type_ == PRECON_SMART_EWC)) { precon_ewc_(u, Pu); - } else - ierr = 1; + } else ierr = 1; return ierr; } diff --git a/src/pks/mpc/mpc_delegate_ewc.hh b/src/pks/mpc/mpc_delegate_ewc.hh index 2400d97cf..d83cf255e 100644 --- a/src/pks/mpc/mpc_delegate_ewc.hh +++ b/src/pks/mpc/mpc_delegate_ewc.hh @@ -6,8 +6,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Globalization for nonlinearity associated with phase change and latent heat. /*! The EWC delegate works to deal with strong nonlinearities associated with @@ -33,49 +31,53 @@ provides the initial guess to the nonlinear solve. .. _mpc-delegate-ewc-spec: .. admonition:: mpc-delegate-ewc-spec - * `"verbose object`" ``[verbose-object-spec]`` See `Verbose Object`_. + * `"verbose object`" ``[verbose-object-spec]`` See :ref:`Verbose Object`. + + * `"PK name`" ``[string]`` **optional** Name of the owning PK -- simply for + logging and debugging. Typically set by the owning PK, not by the user. + + * `"domain name`" ``[string]`` **"domain"** The mesh. - * `"PK name`" ``[string]`` Name of the owning PK -- simply for logging and - debugging. - * `"domain name`" ``[string]`` **"domain"** The mesh. + * `"preconditioner type`" ``[string]`` When to use EWC on the nonlinear + iterate's correction. One of: - * `"preconditioner type`" ``[string]`` When to use EWC on the nonlinear - iterate's correction. One of: + - `"none`" Never do EWC + - `"ewc`" Always do EWC + - `"smart ewc`" Attempt EWC when it seems likely it will be useful and + take the EWC correction if it is smaller than the standard correction. - - `"none`" Never do EWC - - `"ewc`" Always do EWC - - `"smart ewc`" Attempt EWC when it seems likely it will be useful and - take the EWC correction if it is smaller than the standard correction. + * `"predictor type`" ``[string]`` When to use EWC on the predictor. One + of: - * `"predictor type`" ``[string]`` When to use EWC on the predictor. One - of: + - `"none`" Never do EWC + - `"ewc`" Always do EWC + - `"smart ewc`" Attempt EWC when it seems likely it will be useful and + take the EWC correction if it is smaller than the standard correction. - - `"none`" Never do EWC - - `"ewc`" Always do EWC - - `"smart ewc`" Attempt EWC when it seems likely it will be useful and - take the EWC correction if it is smaller than the standard correction. + * `"freeze-thaw cusp width [K]`" ``[double]`` **optional** Controls a width + over which to assume we are close to the latent heat cliff, and begins + applying the EWC algorithm in `"ewc smarter`". Note that this overrides + the following two parameters with this value. - * `"freeze-thaw cusp width [K]`" ``[double]`` Controls a width over which - to assume we are close to the latent heat cliff, and begins applying the - EWC algorithm in `"ewc smarter`". + * `"freeze-thaw cusp width (freezing) [K]`" ``[double]`` **0.** Controls a width + over which to assume we are close to the latent heat cliff as we get + colder, and begins applying the EWC algorithm in `"ewc smarter`". - * `"freeze-thaw cusp width (freezing) [K]`" ``[double]`` Controls a width - over which to assume we are close to the latent heat cliff as we get - colder, and begins applying the EWC algorithm in `"ewc smarter`". + * `"freeze-thaw cusp width (thawing) [K]`" ``[double]`` **0.** Controls a width + over which to assume we are close to the latent heat cliff as we get + warmer, and begins applying the EWC algorithm in `"ewc smarter`". - * `"freeze-thaw cusp width (thawing) [K]`" ``[double]`` Controls a width - over which to assume we are close to the latent heat cliff as we get - warmer, and begins applying the EWC algorithm in `"ewc smarter`". + KEYS - * `"pressure key`" ``[string]`` **DOMAIN-pressure** - * `"temperature key`" ``[string]`` **DOMAIN-temperature** - * `"water content key`" ``[string]`` **DOMAIN-water_content** - * `"energy key`" ``[string]`` **DOMAIN-energy** - * `"cell volume key`" ``[string]`` **DOMAIN-cell_volume** + - `"pressure`" + - `"temperature`" + - `"water content`" + - `"energy`" + - `"cell volume`" - INCLUDES + INCLUDES - - ``[debugger-spec]`` Uses a Debugger_ + - ``[debugger-spec]`` Uses a :ref:`Debugger` */ diff --git a/src/pks/mpc/mpc_delegate_ewc_subsurface.cc b/src/pks/mpc/mpc_delegate_ewc_subsurface.cc index 7b008b6e6..0623035b1 100644 --- a/src/pks/mpc/mpc_delegate_ewc_subsurface.cc +++ b/src/pks/mpc/mpc_delegate_ewc_subsurface.cc @@ -97,7 +97,7 @@ MPCDelegateEWCSubsurface::modify_predictor_smart_ewc_(double h, Teuchos::RCP dcvo = Teuchos::null; - if (vo_->os_OK(Teuchos::VERB_EXTREME)) dcvo = db_->GetVerboseObject(c, rank); + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) dcvo = db_->GetVerboseObject(c, rank); Teuchos::OSTab dctab = dcvo == Teuchos::null ? vo_->getOSTab() : dcvo->getOSTab(); AmanziGeometry::Point result(2); @@ -265,7 +265,7 @@ MPCDelegateEWCSubsurface::modify_predictor_smart_ewc_(double h, Teuchos::RCPos_OK(Teuchos::VERB_EXTREME)) *dcvo->os() << " increasing pressures..." << std::endl; @@ -306,7 +306,7 @@ MPCDelegateEWCSubsurface::modify_predictor_smart_ewc_(double h, Teuchos::RCP u, Teuchos: for (int c = 0; c != ncells; ++c) { // debugger Teuchos::RCP dcvo = Teuchos::null; - if (vo_->os_OK(Teuchos::VERB_EXTREME)) dcvo = db_->GetVerboseObject(c, rank); + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) dcvo = db_->GetVerboseObject(c, rank); Teuchos::OSTab dctab = dcvo == Teuchos::null ? vo_->getOSTab() : dcvo->getOSTab(); double T_prev = T_old[0][c]; @@ -586,7 +586,7 @@ MPCDelegateEWCSubsurface::precon_ewc_(Teuchos::RCP u, Teuchos: } } -# if EWC_PC_INCREASING_PRESSURE +#if EWC_PC_INCREASING_PRESSURE } else { // increasing, thawing if (dcvo != Teuchos::null && dcvo->os_OK(Teuchos::VERB_EXTREME)) *dcvo->os() << " increasing pressures..." << std::endl; @@ -655,7 +655,7 @@ MPCDelegateEWCSubsurface::precon_ewc_(Teuchos::RCP u, Teuchos: } } } -# endif +#endif } } #endif diff --git a/src/pks/mpc/mpc_delegate_ewc_surface.cc b/src/pks/mpc/mpc_delegate_ewc_surface.cc index 41b77194a..bf8584b2e 100644 --- a/src/pks/mpc/mpc_delegate_ewc_surface.cc +++ b/src/pks/mpc/mpc_delegate_ewc_surface.cc @@ -58,7 +58,9 @@ MPCDelegateEWCSurface::modify_predictor_smart_ewc_(double h, Teuchos::RCPget_time(tag_next_) - S_->get_time(tag_current_); @@ -92,7 +94,7 @@ MPCDelegateEWCSurface::modify_predictor_smart_ewc_(double h, Teuchos::RCP dcvo = Teuchos::null; - if (vo_->os_OK(Teuchos::VERB_EXTREME)) dcvo = db_->GetVerboseObject(c, rank); + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) dcvo = db_->GetVerboseObject(c, rank); Teuchos::OSTab dctab = dcvo == Teuchos::null ? vo_->getOSTab() : dcvo->getOSTab(); AmanziGeometry::Point result(2); @@ -227,7 +229,7 @@ MPCDelegateEWCSurface::precon_ewc_(Teuchos::RCP u, Teuchos::RC for (int c = 0; c != ncells; ++c) { // debugger Teuchos::RCP dcvo = Teuchos::null; - if (vo_->os_OK(Teuchos::VERB_EXTREME)) dcvo = db_->GetVerboseObject(c, rank); + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) dcvo = db_->GetVerboseObject(c, rank); Teuchos::OSTab dctab = dcvo == Teuchos::null ? vo_->getOSTab() : dcvo->getOSTab(); double T_prev = T_old[0][c]; diff --git a/src/pks/mpc/mpc_delegate_water_decl.hh b/src/pks/mpc/mpc_delegate_water_decl.hh index c29d815eb..287668b70 100644 --- a/src/pks/mpc/mpc_delegate_water_decl.hh +++ b/src/pks/mpc/mpc_delegate_water_decl.hh @@ -6,23 +6,9 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Globalization for nonlinearity around the appearance/disappearance of surface water. -#ifndef AMANZI_MPC_DELEGATE_WATER_HH_ -#define AMANZI_MPC_DELEGATE_WATER_HH_ - -#include "Teuchos_RCP.hpp" -#include "Teuchos_ParameterList.hpp" - -#include "VerboseObject.hh" -#include "Debugger.hh" -#include "TreeVector.hh" -#include "CompositeVector.hh" -#include "State.hh" - /*! -The water delegate works to deal with discontinuities/strong nonlinearities +The water delegate works to deal with discontinuities and strong nonlinearities when surface cells shift from dry to wet (i.e. the surface pressure goes from < atmospheric pressure to > atmospheric pressure. @@ -31,49 +17,60 @@ These methods work to alter the predictor around this nonlinearity. .. _mpc-delegate-water-spec: .. admonition:: mpc-delegate-water-spec - * `"modify predictor with heuristic`" ``[bool]`` **false** This simply - limits the prediction to backtrack to just above atmospheric on both the - first and second timesteps that take us over atmospheric. + * `"modify predictor with heuristic`" ``[bool]`` **false** This simply + limits the prediction to backtrack to just above atmospheric on both the + first and second timesteps that take us over atmospheric. - * `"modify predictor damp and cap the water spurt`" ``[bool]`` **false** The - second both limits (caps) and damps all surface cells to ensure that all - nearby cells are also not overshooting. This is the preferred method. + * `"modify predictor damp and cap the water spurt`" ``[bool]`` **false** The + second both limits (caps) and damps all surface cells to ensure that all + nearby cells are also not overshooting. This is the preferred method. - These methods work to alter the preconditioned correction for the same - reasons described above. + These methods work to alter the preconditioned correction for the same + reasons described above. - * `"global water face limiter`" ``[double]`` **1.e99** This is simply a limit - to the maximum allowed size of the correction (in [Pa]) on all faces. Any - correction larger than this is set to this. + * `"global water face limiter`" ``[double]`` **1.e99** This is simply a limit + to the maximum allowed size of the correction (in [Pa]) on all faces. Any + correction larger than this is set to this. - * `"cap the water spurt`" ``[bool]`` **false** If a correction takes the - pressure on a surface cell from below atmospheric (dry) to above (wet), - the correction is set to a value which results in the new iterate to being - CAP_SIZE over atmospheric. + * `"cap the water spurt`" ``[bool]`` **false** If a correction takes the + pressure on a surface cell from below atmospheric (dry) to above (wet), + the correction is set to a value which results in the new iterate to being + CAP_SIZE over atmospheric. - * `"damp the water spurt`" ``[bool]`` **false** A damping factor (less than - one) is calculated to multiply the correction such that the largest - correction takes a cell to just above atmospheric. All faces (globally) - are affected. + * `"damp the water spurt`" ``[bool]`` **false** A damping factor (less than + one) is calculated to multiply the correction such that the largest + correction takes a cell to just above atmospheric. All faces (globally) + are affected. - * `"damp and cap the water spurt`" ``[bool]`` **false** None of the above - should really be used. Capping, when the cap is particularly severe, - results in faces whose values are very out of equilibrium with their - neighboring cells which are not capped. Damping results in a tiny - timestep in which, globally, at MOST one face can go from wet to dry. - This looks to do a combination, in which all things are damped, but faces - that are initially expected to go from dry to wet are pre-scaled to - ensure that, when damped, they are also (like the biggest change) allowed - to go from dry to wet (so that multiple cells can wet in the same step). - This is the preferred method. + * `"damp and cap the water spurt`" ``[bool]`` **false** None of the above + should really be used. Capping, when the cap is particularly severe, + results in faces whose values are very out of equilibrium with their + neighboring cells which are not capped. Damping results in a tiny + timestep in which, globally, at MOST one face can go from wet to dry. + This looks to do a combination, in which all things are damped, but faces + that are initially expected to go from dry to wet are pre-scaled to + ensure that, when damped, they are also (like the biggest change) allowed + to go from dry to wet (so that multiple cells can wet in the same step). + This is the preferred method. - In these methods, the following parameters are useful: + In these methods, the following parameters are useful: - * `"cap over atmospheric`" ``[double]`` **100** This sets the max size over - atmospheric to which things are capped or damped. `[Pa]` + * `"cap over atmospheric`" ``[double]`` **100** This sets the max size over + atmospheric to which things are capped or damped. `[Pa]` */ +#ifndef AMANZI_MPC_DELEGATE_WATER_HH_ +#define AMANZI_MPC_DELEGATE_WATER_HH_ + +#include "Teuchos_RCP.hpp" +#include "Teuchos_ParameterList.hpp" + +#include "VerboseObject.hh" +#include "Debugger.hh" +#include "TreeVector.hh" +#include "CompositeVector.hh" +#include "State.hh" namespace Amanzi { @@ -112,54 +109,54 @@ class MPCDelegateWater { i_Tsurf_ = i_Tsurf; } - template + template bool ModifyPredictor_Heuristic(double h, const Teuchos::RCP& u); - template + template bool ModifyPredictor_WaterSpurtDamp(double h, const Teuchos::RCP& u); - template + template bool ModifyPredictor_TempFromSource(double h, const Teuchos::RCP& u); - template + template int ModifyCorrection_WaterFaceLimiter(double h, Teuchos::RCP res, Teuchos::RCP u, Teuchos::RCP du); - template + template double ModifyCorrection_WaterSpurtDamp(double h, Teuchos::RCP res, Teuchos::RCP u, Teuchos::RCP du); - template + template int ModifyCorrection_WaterSpurtCap(double h, Teuchos::RCP res, Teuchos::RCP u, Teuchos::RCP du, double damping); - template + template double ModifyCorrection_DesaturatedSpurtDamp(double h, Teuchos::RCP res, Teuchos::RCP u, Teuchos::RCP du); - template + template int ModifyCorrection_DesaturatedSpurtCap(double h, Teuchos::RCP res, Teuchos::RCP u, Teuchos::RCP du, double damping); - template + template double ModifyCorrection_SaturatedSpurtDamp(double h, Teuchos::RCP res, Teuchos::RCP u, Teuchos::RCP du); - template + template int ModifyCorrection_SaturatedSpurtCap(double h, Teuchos::RCP res, Teuchos::RCP u, diff --git a/src/pks/mpc/mpc_delegate_water_impl.hh b/src/pks/mpc/mpc_delegate_water_impl.hh index baa680f13..88e0fd3a5 100644 --- a/src/pks/mpc/mpc_delegate_water_impl.hh +++ b/src/pks/mpc/mpc_delegate_water_impl.hh @@ -17,7 +17,7 @@ namespace Amanzi { // Approach 1: global face limiter on the correction size -template +template int MPCDelegateWater::ModifyCorrection_WaterFaceLimiter(double h, Teuchos::RCP res, @@ -46,7 +46,7 @@ MPCDelegateWater::ModifyCorrection_WaterFaceLimiter(double h, // Approach 2: damping of the spurt -- limit the max oversaturated pressure // using a global damping term. -template +template double MPCDelegateWater::ModifyCorrection_WaterSpurtDamp(double h, Teuchos::RCP res, @@ -98,7 +98,7 @@ MPCDelegateWater::ModifyCorrection_WaterSpurtDamp(double h, // Approach 3: capping of the spurt -- limit the max oversaturated pressure // if coming from undersaturated. -template +template int MPCDelegateWater::ModifyCorrection_WaterSpurtCap(double h, Teuchos::RCP res, @@ -159,7 +159,7 @@ MPCDelegateWater::ModifyCorrection_WaterSpurtCap(double h, // Approach 2: damping of the spurt -- limit the max oversaturated pressure // using a global damping term. -template +template double MPCDelegateWater::ModifyCorrection_SaturatedSpurtDamp(double h, Teuchos::RCP res, @@ -206,7 +206,7 @@ MPCDelegateWater::ModifyCorrection_SaturatedSpurtDamp(double h, // Approach 3: capping of the spurt -- limit the max oversaturated pressure // if coming from undersaturated. -template +template int MPCDelegateWater::ModifyCorrection_SaturatedSpurtCap(double h, Teuchos::RCP res, @@ -246,7 +246,7 @@ MPCDelegateWater::ModifyCorrection_SaturatedSpurtCap(double h, // Approach 2: damping of the spurt -- limit the max oversaturated pressure // using a global damping term. -template +template double MPCDelegateWater::ModifyCorrection_DesaturatedSpurtDamp(double h, Teuchos::RCP res, @@ -293,7 +293,7 @@ MPCDelegateWater::ModifyCorrection_DesaturatedSpurtDamp(double h, // Approach 3: capping of the spurt -- limit the max oversaturated pressure // if coming from undersaturated. -template +template int MPCDelegateWater::ModifyCorrection_DesaturatedSpurtCap(double h, Teuchos::RCP res, @@ -332,7 +332,7 @@ MPCDelegateWater::ModifyCorrection_DesaturatedSpurtCap(double h, // modify predictor via heuristic stops spurting in the surface flow -template +template bool MPCDelegateWater::ModifyPredictor_Heuristic(double h, const Teuchos::RCP& u) { @@ -391,7 +391,7 @@ MPCDelegateWater::ModifyPredictor_Heuristic(double h, const Teuchos::RCP +template bool MPCDelegateWater::ModifyPredictor_WaterSpurtDamp(double h, const Teuchos::RCP& u) { @@ -493,7 +493,7 @@ MPCDelegateWater::ModifyPredictor_WaterSpurtDamp(double h, const Teuchos::RCP +template bool MPCDelegateWater::ModifyPredictor_TempFromSource(double h, const Teuchos::RCP& u) { diff --git a/src/pks/mpc/mpc_flow_transport.cc b/src/pks/mpc/mpc_flow_transport.cc new file mode 100644 index 000000000..a67d51b0d --- /dev/null +++ b/src/pks/mpc/mpc_flow_transport.cc @@ -0,0 +1,282 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon +*/ + +#include "PK_Helpers.hh" +#include "mpc_flow_transport.hh" + +namespace Amanzi { + +void +MPCFlowTransport::parseParameterList() +{ + // are we doing surface, subsurface, or integrated transport? + auto flow_plist = getSubPKPlist_(0); + Key surf_lwc_key, sub_lwc_key; + + if (flow_plist->isParameter("domain name")) { + std::string domain = Keys::readDomain(*flow_plist); + if (Keys::in(domain, "surface")) { + surface_ = true; + surf_lwc_key = Keys::readKey(*getSubPKPlist_(1), domain, "water content", "water_content"); + } else { + subsurface_ = true; + sub_lwc_key = Keys::readKey(*getSubPKPlist_(1), domain, "water content", "water_content"); + } + } else { + // no domain name means it is an MPC, likely coupled water, but maybe permafrost + surface_ = true; + subsurface_ = true; + auto transport_names = getSubPKPlist_(1)->get>("PKs order"); + + // if reactive_transport_names[0] has a domain, it is transport only. + // otherwise it is reactive transport, and we have to go another level down + AMANZI_ASSERT(transport_names.size() == 2); + + if (!pks_list_->sublist(transport_names[0]).isParameter("domain name")) { + chemistry_ = true; + + // chemistry first + transport_names = + pks_list_->sublist(transport_names[1]).get>("PKs order"); + } + + // now we have the actual transport names! + auto subsurf_domain = Keys::readDomain(pks_list_->sublist(transport_names[0])); + sub_lwc_key = Keys::readKey(pks_list_->sublist(transport_names[0]), + subsurf_domain, + "liquid water content", + "water_content"); + + auto surf_domain = Keys::readDomain(pks_list_->sublist(transport_names[1])); + surf_lwc_key = Keys::readKey( + pks_list_->sublist(transport_names[1]), surf_domain, "liquid water content", "water_content"); + } + + auto [flow_current_tag, flow_next_tag] = tags_[0]; + auto [transport_current_tag, transport_next_tag] = tags_[1]; + + if (subsurface_) { + if (transport_next_tag != flow_next_tag) { + // set the flow field evaluator as the flow's NEXT tag + // + // Note, we could be more careful here and readKey() the flow field's name + // from the flow PK's sublist (which may be nested two deep). Instead we + // hard-code this as the default. If this breaks in the future it can be + // fixed. --ETC + Teuchos::ParameterList& flux_list = + S_->GetEvaluatorList(Keys::getKey("water_flux", transport_next_tag)); + if (!flux_list.isParameter("evaluator type")) { + flux_list.set("evaluator type", "alias"); + flux_list.set("target", Keys::getKey("water_flux", flow_next_tag, true)); + } + + // velocity for dispersivity + Teuchos::ParameterList& velo_list = + S_->GetEvaluatorList(Keys::getKey("darcy_velocity", transport_next_tag)); + if (!velo_list.isParameter("evaluator type")) { + velo_list.set("evaluator type", "alias"); + velo_list.set("target", Keys::getKey("darcy_velocity", flow_next_tag, true)); + } + + // now set the liquid water content as an interpolated field at next + // note that flow_current copy is kept by flow PK, and transport_current copy is kept by transport PK + Teuchos::ParameterList& lwc_list_next = + S_->GetEvaluatorList(Keys::getKey(sub_lwc_key, transport_next_tag)); + if (!lwc_list_next.isParameter("evaluator type")) { + lwc_list_next.set("evaluator type", "temporal interpolation"); + lwc_list_next.set("current tag", flow_current_tag.get()); + lwc_list_next.set("next tag", flow_next_tag.get()); + } + + // porosity used with velocity to compute particle velocity when dispersion is on + // -- and an interpolation at transport's next + Teuchos::ParameterList& poro_list_next = + S_->GetEvaluatorList(Keys::getKey("porosity", transport_next_tag)); + if (!poro_list_next.isParameter("evaluator type")) { + poro_list_next.set("evaluator type", "temporal interpolation"); + poro_list_next.set("current tag", flow_current_tag.get()); + poro_list_next.set("next tag", flow_next_tag.get()); + } + + // chemistry uses (independently) density, saturation, and porosity + if (chemistry_) { + // mass density used by Alquimia + // -- transport next is an interpolation + Teuchos::ParameterList& dens_list_current = + S_->GetEvaluatorList(Keys::getKey("mass_density_liquid", transport_current_tag)); + if (!dens_list_current.isParameter("evaluator type")) { + dens_list_current.set("evaluator type", "temporal interpolation"); + dens_list_current.set("current tag", flow_current_tag.get()); + dens_list_current.set("next tag", flow_next_tag.get()); + } + + // saturation + // -- flow's current is done by flow + // -- transport's next is an interoplation + Teuchos::ParameterList& sat_list_current = + S_->GetEvaluatorList(Keys::getKey("saturation_liquid", transport_current_tag)); + if (!sat_list_current.isParameter("evaluator type")) { + sat_list_current.set("evaluator type", "temporal interpolation"); + sat_list_current.set("current tag", flow_current_tag.get()); + sat_list_current.set("next tag", flow_next_tag.get()); + } + + // -- porosity at transport's current is an interpolation (could also be a copy of transport's next?) + Teuchos::ParameterList& poro_list_current = + S_->GetEvaluatorList(Keys::getKey("porosity", transport_current_tag)); + if (!poro_list_current.isParameter("evaluator type")) { + poro_list_current.set("evaluator type", "temporal interpolation"); + poro_list_current.set("current tag", flow_current_tag.get()); + poro_list_current.set("next tag", flow_next_tag.get()); + } + } + } + } + + if (surface_) { + if (transport_next_tag != flow_next_tag) { + // set the flow field evaluator as the flow's NEXT tag + // + // Note, we could be more careful here and readKey() the flow field's name + // from the flow PK's sublist (which may be nested two deep). Instead we + // hard-code this as the default. If this breaks in the future it can be + // fixed. --ETC + Teuchos::ParameterList& flux_list = + S_->GetEvaluatorList(Keys::getKey("surface-water_flux", transport_next_tag)); + if (!flux_list.isParameter("evaluator type")) { + flux_list.set("evaluator type", "alias"); + flux_list.set("target", + Keys::getKey("surface-water_flux", flow_next_tag, true)); + } + + // velocity for evaluators + Teuchos::ParameterList& velo_list = + S_->GetEvaluatorList(Keys::getKey("surface-velocity", transport_next_tag)); + if (!velo_list.isParameter("evaluator type")) { + velo_list.set("evaluator type", "alias"); + velo_list.set("target", Keys::getKey("surface-velocity", flow_next_tag, true)); + } + + // set the liquid water content as an interpolated field + // -- flow's current is a kept by flow + // -- transport's next is an interpolation + Teuchos::ParameterList& lwc_list_next = + S_->GetEvaluatorList(Keys::getKey(surf_lwc_key, transport_next_tag)); + if (!lwc_list_next.isParameter("evaluator type")) { + lwc_list_next.set("evaluator type", "temporal interpolation"); + lwc_list_next.set("current tag", flow_current_tag.get()); + lwc_list_next.set("next tag", flow_next_tag.get()); + } + + // chemistry uses (independently) density & ponded depth at the current tag + if (chemistry_) { + // density used by Alquimia + // -- transport's next is an interpolation + Teuchos::ParameterList& dens_list_current = + S_->GetEvaluatorList(Keys::getKey("surface-mass_density_liquid", transport_current_tag)); + if (!dens_list_current.isParameter("evaluator type")) { + dens_list_current.set("evaluator type", "temporal interpolation"); + dens_list_current.set("current tag", flow_current_tag.get()); + dens_list_current.set("next tag", flow_next_tag.get()); + } + + // ponded depth + // -- flow's current is kept by flow + // -- transport's next is an interpolation + Teuchos::ParameterList& pd_list_current = + S_->GetEvaluatorList(Keys::getKey("surface-ponded_depth", transport_current_tag)); + if (!pd_list_current.isParameter("evaluator type")) { + pd_list_current.set("evaluator type", "temporal interpolation"); + pd_list_current.set("current tag", flow_current_tag.get()); + pd_list_current.set("next tag", flow_next_tag.get()); + } + } + } + } + + MPCSubcycled::parseParameterList(); + if (subcycling_[0]) { + Errors::Message msg; + msg << "In MPCFlowTransport PK \"" << name_ << "\", cannot subcycle flow PK, only transport PK"; + Exceptions::amanzi_throw(msg); + } + + if (subsurface_) { + // for interpolated evaluators, we must first require key@NEXT -- otherwise + // it will get called to be an alias key@TRANSPORT_NEXT, which is an + // interpolator that depends upon this. + requireEvaluatorAtNext(sub_lwc_key, flow_next_tag, *S_); + requireEvaluatorAtNext("porosity", flow_next_tag, *S_); + requireEvaluatorAtCurrent("porosity", flow_current_tag, *S_, name_); + + if (chemistry_) { + requireEvaluatorAtNext("mass_density_liquid", flow_next_tag, *S_); + requireEvaluatorAtCurrent("mass_density_liquid", flow_current_tag, *S_, name_); + + requireEvaluatorAtNext("saturation_liquid", flow_next_tag, *S_); + } + + // now require key@transport_next, which will be the interpolant + requireEvaluatorAtNext(sub_lwc_key, transport_next_tag, *S_); + requireEvaluatorAtNext("porosity", transport_next_tag, *S_); + if (chemistry_) { + requireEvaluatorAtCurrent("mass_density_liquid", transport_current_tag, *S_); + requireEvaluatorAtCurrent("saturation_liquid", transport_current_tag, *S_); + requireEvaluatorAtCurrent("porosity", transport_current_tag, *S_); + } + } + + if (surface_) { + // for interpolated evaluators, we must first require key@NEXT -- otherwise + // it will get called to be an alias key@TRANSPORT_NEXT, which is an + // interpolator that depends upon this. + requireEvaluatorAtNext(surf_lwc_key, flow_next_tag, *S_); + if (chemistry_) { + requireEvaluatorAtNext("surface-mass_density_liquid", flow_next_tag, *S_); + requireEvaluatorAtCurrent("surface-mass_density_liquid", flow_current_tag, *S_, name_); + + requireEvaluatorAtNext("surface-ponded_depth", flow_next_tag, *S_); + } + + // now require key@transport_next, which will be the interpolant + requireEvaluatorAtNext(surf_lwc_key, transport_next_tag, *S_); + if (chemistry_) { + requireEvaluatorAtCurrent("surface-mass_density_liquid", transport_current_tag, *S_); + requireEvaluatorAtCurrent("surface-ponded_depth", transport_current_tag, *S_); + requireEvaluatorAtCurrent("surface-porosity", transport_current_tag, *S_); + } + } +} + + +// ----------------------------------------------------------------------------- +// Advance each sub-PK individually, returning a failure as soon as possible. +// ----------------------------------------------------------------------------- +void +MPCFlowTransport::CommitStep(double t_old, double t_new, const Tag& tag) +{ + MPCSubcycled::CommitStep(t_old, t_new, tag); + + // also save our flow quantities, needed for interpolation + auto [flow_current_tag, flow_next_tag] = tags_[0]; + + if (subsurface_) { + assign("porosity", flow_current_tag, flow_next_tag, *S_); + if (chemistry_) { + assign("mass_density_liquid", flow_current_tag, flow_next_tag, *S_); + } + } + + if (surface_ && chemistry_) { + assign("surface-mass_density_liquid", flow_current_tag, flow_next_tag, *S_); + } +} + + +} // namespace Amanzi diff --git a/src/pks/mpc/mpc_flow_transport.hh b/src/pks/mpc/mpc_flow_transport.hh new file mode 100644 index 000000000..63c76243b --- /dev/null +++ b/src/pks/mpc/mpc_flow_transport.hh @@ -0,0 +1,79 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Ethan Coon +*/ + +/*! + +An MPC that coordinates the coupling of flow and transport, or of integrated +flow an integrated transport. + +This MPC simply sets a few default evaluators used in coupling (e.g. alias and +time-interpolated evaluators) based upon the knonw temporal discretizations and +coupling strategies of flow and transport. Nothing done here couldn't also be +done in the input file by the user, but this shifts some of the burden away +from the user. + +Specifically, this sets (as appropriate for surface-only, subsurface-only, or +integrated cases): + +- Ensures that flow is not subcycled. +- Transport's flux field is given by flow's water_flux field, and is temporally + piecewise constant throughout the flow interval using the value at flow's + NEXT tag. + +If transport is subcycled, then this additionally sets that: + +- porosity is an ALIASED evaluator pointing to flow's NEXT tag (this likely + will change, but for now changing it will break tests) +- saturation & molar density are temporally interpolated evaluators between + flow's CURRENT and NEXT tags. + +Note this always assumes that Flow is the _first_ PK in the `"PKs order`" list. + +`"PK type`" = `"coupled flow and transport`" + +.. _pk-coupled-flow-and-transport-spec: +.. admonition:: pk-coupled-flow-and-transport-spec + + INCLUDES: + + - ``[mpc-subcycled-spec]`` + +*/ + +#pragma once + +#include "mpc_subcycled.hh" + +namespace Amanzi { + +class MPCFlowTransport : public MPCSubcycled { + public: + MPCFlowTransport(Teuchos::ParameterList& pk_tree, + const Teuchos::RCP& global_list, + const Teuchos::RCP& S, + const Teuchos::RCP& soln) + : PK(pk_tree, global_list, S, soln), + MPCSubcycled(pk_tree, global_list, S, soln), + chemistry_(false), + surface_(false), + subsurface_(false) + {} + + void parseParameterList() override; + void CommitStep(double t_old, double t_new, const Tag& tag) override; + + protected: + bool chemistry_, surface_, subsurface_; + + private: + // factory registration + static RegisteredPKFactory reg_; +}; + +} // namespace Amanzi diff --git a/src/pks/mpc/mpc_morphology_pk.cc b/src/pks/mpc/mpc_morphology_pk.cc index 34b8b42a4..f15ddeef2 100644 --- a/src/pks/mpc/mpc_morphology_pk.cc +++ b/src/pks/mpc/mpc_morphology_pk.cc @@ -13,6 +13,7 @@ */ #include "mpc_morphology_pk.hh" +#include "PK_Helpers.hh" #include "Mesh.hh" namespace Amanzi { @@ -22,196 +23,89 @@ Morphology_PK::Morphology_PK(Teuchos::ParameterList& pk_tree_or_fe_list, const Teuchos::RCP& S, const Teuchos::RCP& soln) : PK(pk_tree_or_fe_list, global_list, S, soln), - PK_MPCSubcycled_ATS(pk_tree_or_fe_list, global_list, S, soln) -{ - // Create verbosity object. - vo_ = Teuchos::null; - Teuchos::ParameterList vlist; - vlist.sublist("verbose object") = plist_->sublist("verbose object"); - vo_ = Teuchos::rcp(new VerboseObject("Morphology_PK", vlist)); - domain_ = plist_->get("domain name", "domain"); - name_ = "morphology pk"; - - Teuchos::Array pk_order = plist_->get>("PKs order"); -} - -// ----------------------------------------------------------------------------- -// Calculate the min of sub PKs timestep sizes. -// ----------------------------------------------------------------------------- -double -Morphology_PK::get_dt() -{ - if (dt_MPC_ < 0) { - double dt = Amanzi::PK_MPCSubcycled_ATS::get_dt(); - set_dt(dt); - return dt; - } else { - return dt_MPC_; - } -} + MPCFlowTransport(pk_tree_or_fe_list, global_list, S, soln) +{} void -Morphology_PK::Setup(const Teuchos::Ptr& S) +Morphology_PK::parseParameterList() { - //passwd_ = "coupled_transport"; // owner's password - //passwd_ = "state"; // owner's password - - - dt_MPC_ = plist_->get("dt MPC", 31557600); - MSF_ = plist_->get("morphological scaling factor", 1); + MPCFlowTransport::parseParameterList(); - Amanzi::PK_MPCSubcycled_ATS::Setup(S); - - mesh_ = S->GetDeformableMesh(domain_); - vertex_coord_key_ = Keys::getKey(domain_, "vertex_coordinate"); - if (domain_ == "surface") { - domain_3d_ = "surface_3d"; - domain_ss_ = "domain"; - vertex_coord_key_3d_ = Keys::getKey(domain_3d_, "vertex_coordinate"); - vertex_coord_key_ss_ = Keys::getKey(domain_ss_, "vertex_coordinate"); - mesh_3d_ = S->GetDeformableMesh(domain_ + "_3d"); - mesh_ss_ = S->GetDeformableMesh(domain_ss_); - } - - // create storage for the vertex coordinates - // we need to checkpoint those to be able to create - // the deformed mesh after restart - std::vector location(1); - std::vector num_dofs(1); - std::vector name(1); - - if (!S->HasField(vertex_coord_key_)) { - int dim = mesh_->getSpaceDimension(); - location[0] = AmanziMesh::Entity_kind::NODE; - num_dofs[0] = dim; - name[0] = "node"; - - S->Require(vertex_coord_key_, Tags::NEXT, "state") - .SetMesh(mesh_) - ->SetGhosted() - ->SetComponents(name, location, num_dofs); - } - - if (S->HasMesh(domain_3d_) && (!S->HasField(vertex_coord_key_3d_))) { - int dim = mesh_3d_->getSpaceDimension(); - location[0] = AmanziMesh::Entity_kind::NODE; - num_dofs[0] = dim; - name[0] = "node"; - - S->Require(vertex_coord_key_3d_, Tags::NEXT, "state") - .SetMesh(mesh_3d_) - ->SetGhosted() - ->SetComponents(name, location, num_dofs); - } + domain_ = plist_->get("domain name"); + elevation_increase_key_ = Keys::readKey(*plist_, domain_, "deformation", "deformation"); - if (S->HasMesh(domain_ss_) && (!S->HasField(vertex_coord_key_ss_))) { - int dim = mesh_ss_->getSpaceDimension(); - location[0] = AmanziMesh::Entity_kind::NODE; - num_dofs[0] = dim; - name[0] = "node"; - - S->Require(vertex_coord_key_ss_, Tags::NEXT, "state") - .SetMesh(mesh_ss_) - ->SetGhosted() - ->SetComponents(name, location, num_dofs); + Key elev_key = Keys::readKey(*plist_, domain_, "elevation", "elevation"); + if (!S_->HasEvaluatorList(elev_key)) { + Teuchos::ParameterList& elev_list = S_->GetEvaluatorList(elev_key); + elev_list.set("evaluator type", "meshed elevation"); + elev_list.set("dynamic mesh", true); + elev_list.set("deformation indicator", elevation_increase_key_); } - elevation_increase_key_ = Keys::getKey(domain_, "deformation"); - if (!S->HasField(elevation_increase_key_)) { - S->Require(elevation_increase_key_, Tags::NEXT, "state") - .SetMesh(mesh_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - Teuchos::ParameterList deform_plist; - deform_plist.set("evaluator name", elevation_increase_key_); - deform_eval_ = Teuchos::rcp(new EvaluatorPrimary(deform_plist)); - S->SetEvaluator(elevation_increase_key_, deform_eval_); + auto [flow_current_tag, flow_next_tag] = tags_[0]; + auto [transport_current_tag, transport_next_tag] = tags_[1]; + + dens_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); + pd_key_ = Keys::readKey(*plist_, domain_, "ponded depth", "ponded_depth"); + // if subcycling transport, need an interpolation eval for density + if (flow_next_tag != transport_next_tag) { + // flow's current is a copy + requireEvaluatorAtCurrent(dens_key_, flow_current_tag, *S_, name_); + requireEvaluatorAtCurrent(pd_key_, flow_current_tag, *S_, name_); + + // transport's next is an interpolation + Teuchos::ParameterList& dens_list_next = + S_->GetEvaluatorList(Keys::getKey(dens_key_, transport_next_tag)); + if (!dens_list_next.isParameter("evaluator type")) { + dens_list_next.set("evaluator type", "temporal interpolation"); + dens_list_next.set("current tag", flow_current_tag.get()); + dens_list_next.set("next tag", flow_next_tag.get()); + } + Teuchos::ParameterList& pd_list_next = + S_->GetEvaluatorList(Keys::getKey(pd_key_, transport_next_tag)); + if (!pd_list_next.isParameter("evaluator type")) { + pd_list_next.set("evaluator type", "temporal interpolation"); + pd_list_next.set("current tag", flow_current_tag.get()); + pd_list_next.set("next tag", flow_next_tag.get()); + } } - int num_veg_species = plist_->get("number of vegitation species", 1); - - - Key biomass_key = Keys::getKey(domain_, "biomass"); - Key stem_density_key = Keys::getKey(domain_, "stem_density"); - Key stem_height_key = Keys::getKey(domain_, "stem_height"); - Key stem_diameter_key = Keys::getKey(domain_, "stem_diameter"); - Key plant_area_key = Keys::getKey(domain_, "plant_area"); + MSF_ = plist_->get("morphological scaling factor", 1); - location[0] = AmanziMesh::Entity_kind::CELL; - num_dofs[0] = num_veg_species; - name[0] = "cell"; + domain_3d_ = Keys::readDomainHint(*plist_, domain_, "surface", "surface_3d"); + domain_ss_ = Keys::readDomainHint(*plist_, domain_, "surface", "domain"); - if (!S->HasField(biomass_key)) { - S->Require(biomass_key, Tags::NEXT, biomass_key) - .SetMesh(mesh_) - ->SetGhosted() - ->SetComponents(name, location, num_dofs); - S->RequireEvaluator(biomass_key); - } + vertex_coord_key_ = + Keys::readKey(*plist_, domain_3d_, "vertex coordinates", "vertex_coordinates"); - if (!S->HasField("msl")) S->RequireScalar("msl"); + mesh_ = S_->GetDeformableMesh(domain_); + mesh_3d_ = S_->GetDeformableMesh(domain_3d_); + mesh_ss_ = S_->GetDeformableMesh(domain_ss_); } -void -Morphology_PK::Initialize(const Teuchos::Ptr& S) -{ - Amanzi::PK_MPCSubcycled_ATS::Initialize(S); - - // initialize the vertex coordinate of existing meshes - - if (S->HasField(vertex_coord_key_)) Initialize_MeshVertices_(S, mesh_, vertex_coord_key_); - - if (S->HasField(vertex_coord_key_3d_)) - Initialize_MeshVertices_(S, mesh_3d_, vertex_coord_key_3d_); - - if (S->HasField(vertex_coord_key_ss_)) - Initialize_MeshVertices_(S, mesh_ss_, vertex_coord_key_ss_); - - if (S->HasField(elevation_increase_key_)) { - S->GetW(elevation_increase_key_, "state").PutScalar(0.); - S->GetField(elevation_increase_key_, "state")->set_initialized(); - } - - flow_pk_ = Teuchos::rcp_dynamic_cast(sub_pks_[0]); - sed_transport_pk_ = sub_pks_[1]; - - - const Epetra_MultiVector& dz = - *S->Get(elevation_increase_key_).ViewComponent("cell", false); - - dz_accumul_ = Teuchos::rcp(new Epetra_MultiVector(dz)); - dz_accumul_->PutScalar(0.); -} void -Morphology_PK::CommitStep(double t_old, double t_new, const Teuchos::RCP& S) +Morphology_PK::Setup() { - sed_transport_pk_->CommitStep(t_old, t_new, S); + auto [flow_current_tag, flow_next_tag] = tags_[0]; + auto [transport_current_tag, transport_next_tag] = tags_[1]; - S->set_time(t_new); + Amanzi::MPCFlowTransport::Setup(); - Key elev_key = Keys::readKey(*plist_, domain_, "elevation", "elevation"); - Key slope_key = Keys::readKey(*plist_, domain_, "slope magnitude", "slope_magnitude"); - - bool chg = S_->GetEvaluator(elev_key)->HasFieldChanged(S_.ptr(), elev_key); - if (chg) { - Teuchos::RCP elev = S->GetPtrW(elev_key, elev_key); - Teuchos::RCP slope = S->GetPtrW(slope_key, slope_key); - Teuchos::RCP vc = S->GetPtrW(vertex_coord_key_ss_, "state"); - Teuchos::RCP dz = - S->GetPtrW(elevation_increase_key_, "state"); - - *elev = *S_->GetPtrW(elev_key, elev_key); - *slope = *S_->GetPtrW(slope_key, slope_key); - *vc = *S_->GetPtrW(vertex_coord_key_ss_, "state"); - } + requireEvaluatorAtNext(elevation_increase_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - Key biomass_key = Keys::getKey(domain_, "biomass"); - chg = S_->GetEvaluator(biomass_key)->HasFieldChanged(S_.ptr(), biomass_key); - // if (chg) + S_->Require( + vertex_coord_key_, tag_next_, vertex_coord_key_) + .SetMesh(mesh_3d_) + ->SetGhosted() + ->SetComponent("node", AmanziMesh::Entity_kind::NODE, mesh_3d_->getSpaceDimension()); } + // ----------------------------------------------------------------------------- // Advance each sub-PK individually, returning a failure as soon as possible. // ----------------------------------------------------------------------------- @@ -221,233 +115,95 @@ Morphology_PK::AdvanceStep(double t_old, double t_new, bool reinit) bool fail = false; Teuchos::OSTab tab = vo_->getOSTab(); - double dt_step; - dt_step = S_inter_->final_time() - S_inter_->initial_time(); + // zero out the dz field to reset for the next step + S_->GetW(elevation_increase_key_, tag_next_, sub_pks_[1]->name()).PutScalar(0.); - if (dt_step < dt_MPC_) { - std::stringstream messagestream; - messagestream << "Actual step is less than prescribed MPC timestep."; - Errors::Message message(messagestream.str()); - Exceptions::amanzi_throw(message); - } + fail = Amanzi::MPCFlowTransport::AdvanceStep(t_old, t_new, reinit); + if (!fail) { + const Epetra_MultiVector& dz = + *S_->Get(elevation_increase_key_, tag_next_).ViewComponent("cell", false); + double max_dz, min_dz; + dz.MinValue(&min_dz); + dz.MaxValue(&max_dz); - Teuchos::RCP msl_rcp = - Teuchos::rcp_dynamic_cast(S_inter_->GetField("msl", "state")); - msl_rcp->Compute(t_old); + if (vo_->os_OK(Teuchos::VERB_HIGH)) + *vo_->os() << "Deformation min " << min_dz << " max " << max_dz << "\n"; - Key elev_key = Keys::readKey(*plist_, domain_, "elevation", "elevation"); - Epetra_MultiVector& dz = - *S_next_->GetW(elevation_increase_key_, "state").ViewComponent("cell", false); - dz.PutScalar(0.); - - flow_pk_->ResetTimeStepper(t_old); - - S_inter_->set_intermediate_time(t_old); - S_next_->set_intermediate_time(t_old); - double dt_done = 0; - double dt_next = flow_pk_->get_dt(); - double t_DNS_end = t_old + dt_step / MSF_; // end of direct numerical simulation - - bool done = false; - int ncycles = 0; - - while (!done) { - dt_next = flow_pk_->get_dt(); - if (t_old + dt_done + dt_next > t_DNS_end) { dt_next = t_DNS_end - t_old - dt_done; } - - fail = true; - while (fail) { - S_next_->set_time(t_old + dt_done + dt_next); - S_inter_->set_time(t_old + dt_done); - fail = flow_pk_->AdvanceStep(t_old + dt_done, t_old + dt_done + dt_next, reinit); - - if (fail) { - if (vo_->getVerbLevel() >= Teuchos::VERB_HIGH) *vo_->os() << "Master step is failed\n"; - dt_next = flow_pk_->get_dt(); - } - } - - master_dt_ = dt_next; - - flow_pk_->CalculateDiagnostics(S_next_); - flow_pk_->CommitStep(t_old + dt_done, t_old + dt_done + dt_next, S_next_); - - //S_next_->WriteStatistics(vo_); - slave_dt_ = sed_transport_pk_->get_dt(); - if (slave_dt_ > master_dt_) slave_dt_ = master_dt_; - if (vo_->getVerbLevel() >= Teuchos::VERB_HIGH) - *vo_->os() << "Slave dt=" << slave_dt_ << " Master dt=" << master_dt_ << "\n"; - - fail = sed_transport_pk_->AdvanceStep(t_old + dt_done, t_old + dt_done + dt_next, reinit); - - if (fail) { - dt_next /= 2; - } else { - S_inter_->set_intermediate_time(t_old + dt_done + dt_next); - sed_transport_pk_->CommitStep(t_old + dt_done, t_old + dt_done + dt_next, S_next_); - dt_done += dt_next; - - // we're done with this timestep, copy the state - *S_inter_ = *S_next_; - } - ncycles++; - - - // check for done condition - done = (std::abs(t_old + dt_done - t_DNS_end) / (t_DNS_end - t_old) < - 0.1 * min_dt_) || // finished the step - (dt_next < min_dt_); // failed + Update_MeshVertices_(S_.ptr(), tag_next_); } - - double max_dz, min_dz; - dz.MinValue(&min_dz); - dz.MaxValue(&max_dz); - if (vo_->getVerbLevel() >= Teuchos::VERB_HIGH) - *vo_->os() << "min " << min_dz << " max " << max_dz << "\n"; - - dz.Scale(MSF_); - - dz_accumul_->Update(1, dz, 1); - Update_MeshVertices_(S_next_.ptr()); - - - bool chg = S_next_->GetEvaluator(elev_key)->HasFieldChanged(S_next_.ptr(), elev_key); - Epetra_MultiVector& elev_cell = - *S_next_->GetW(elev_key, elev_key).ViewComponent("cell", false); - //S_next_ -> GetEvaluator("surface-slope)->HasFieldChanged(S_next_.ptr(), elev_key); - - - return fail; - - - // // advance the slave, subcycling if needed - // S_next_->set_intermediate_time(t_old); - // bool done = false; - // double dt_next = slave_dt_; - // double dt_done = 0.; - // int ncycles = 0; - - // while (!done) { - // // do not overstep - // if (t_old + dt_done + dt_next > t_new) { - // dt_next = t_new - t_old - dt_done; - // } - // // take the step - // fail = sed_transport_pk_->AdvanceStep(t_old + dt_done, t_old + dt_done + dt_next, reinit); - // ncycles ++; - // if (fail) { - // // if fail, cut the step and try again - // dt_next /= 2; - // } else { - // // if success, commit the state and increment to next intermediate - // // -- etc: unclear if state should be commited or not? - // // set the intermediate time - // S_next_ -> set_intermediate_time(t_old + dt_done + dt_next); - // //S_next_ -> set_intermediate_time(t_old + dt_done + dt_next); - // sed_transport_pk_->CommitStep(t_old + dt_done, t_old + dt_done + dt_next, S_next_); - // //sed_transport_pk_->CommitStep(t_old + dt_done, t_old + dt_done + dt_next, S_next_); - // dt_done += dt_next; - // } - // // check for done condition - // done = (std::abs(t_old + dt_done - t_new) / (t_new - t_old) < 0.1*min_dt_) || // finished the step - // (dt_next < min_dt_); // failed - // } - - - // if (std::abs(t_old + dt_done - t_new) / (t_new - t_old) < 0.1*min_dt_) { - // // done, success - // if (vo_->getVerbLevel() >= Teuchos::VERB_HIGH) *vo_->os()<<"Slave step is successful after " - // <getVerbLevel() >= Teuchos::VERB_HIGH) *vo_->os()<<"Slave step is failed after " - // <& S, - Teuchos::RCP mesh, - Key vert_field_key) +Morphology_PK::Update_MeshVertices_(const Teuchos::Ptr& S, const Tag& tag) { - // spatial dimension - int dim = mesh->getSpaceDimension(); - Amanzi::AmanziGeometry::Point coords(dim); - // number of vertices - int nV = mesh->getNumEntities(Amanzi::AmanziMesh::Entity_kind::NODE, - Amanzi::AmanziMesh::Parallel_kind::OWNED); - - Epetra_MultiVector& vc = - *S->GetPtrW(vert_field_key, "state")->ViewComponent("node", false); - - // search the id of the mid point on the top - for (int iV = 0; iV < nV; iV++) { - // get the coords of the node - coords = mesh->getNodeCoordinate(iV); - for (int s = 0; s < dim; ++s) { vc[s][iV] = coords[s]; } + S->Get(elevation_increase_key_, tag).ScatterMasterToGhosted("cell"); + { // This is done in a context to avoid problems with the scatter and views + const Epetra_MultiVector& dz = + *S->Get(elevation_increase_key_, tag).ViewComponent("cell", true); + + // NOTE: this will get much cleaner in Tpetra, where the view and the + // vector can share the same memory! For now we need the view for the + // deform() call, and the vector for the scatter. + // + // NOTE that this only needs to exist on the surface mesh, but needs to be + // the 3d coordinates. + Epetra_MultiVector& vc = *S->GetW(vertex_coord_key_, tag, vertex_coord_key_) + .ViewComponent("node", false); + + for (int c = 0; c != dz.MyLength(); ++c) { + auto surf_nodes = mesh_->getCellNodes(c); + for (auto& n : surf_nodes) { + if (n < vc.MyLength()) { + int ncells = mesh_->getNodeCells(n, AmanziMesh::Parallel_kind::ALL).size(); + vc[2][n] += MSF_ * dz[0][c] / ncells; + } + } + } } - S->GetPtrW(vert_field_key, "state")->ScatterMasterToGhosted("node"); - S->GetField(vert_field_key, "state")->set_initialized(); -} - -void -Morphology_PK::Update_MeshVertices_(const Teuchos::Ptr& S) -{ - // spatial dimension - int dim = mesh_ss_->getSpaceDimension(); - Amanzi::AmanziGeometry::Point coords(dim); - // number of vertices - - Epetra_MultiVector& vc = - *S->GetPtrW(vertex_coord_key_ss_, "state")->ViewComponent("node", true); - - - const auto& dz_cv = S->Get(elevation_increase_key_); - dz_cv.ScatterMasterToGhosted(); - const Epetra_MultiVector& dz = *dz_cv.ViewComponent("cell", true); - - int ncells = dz.MyLength(); - - AmanziMesh::Entity_ID_List nodes, cells; - double xyz[3]; - - for (int c = 0; c < ncells; c++) { - AmanziMesh::Entity_ID domain_face; - domain_face = mesh_->getEntityParent(AmanziMesh::Entity_kind::CELL, c); - - nodes = mesh_ss_->getFaceNodes(domain_face); - int nnodes = nodes.size(); - for (int i = 0; i < nnodes; i++) { - coords = mesh_ss_->getNodeCoordinate(nodes[i]); - cells = mesh_ss_->getNodeCells(nodes[i], Amanzi::AmanziMesh::Parallel_kind::ALL); - int nsize = cells.size(); - double old = coords[2]; - - coords[2] += dz[0][c] / nsize; - vc[2][nodes[i]] += dz[0][c] / nsize; - - // coords[2] += 0.1 / nsize; - // vc[2][nodes[i]] += 0.1 / nsize; + S_->Get(vertex_coord_key_, tag).ScatterMasterToGhosted("node"); + + { // now that we have scattered, move the coordinates to a view and deform + // + // NOTE: must deform the ghost nodes as well as owned nodes! + const Epetra_MultiVector& vc = + *S->Get(vertex_coord_key_, tag).ViewComponent("node", true); + + // NOTE: nodeids will be subsurface mesh node ids! + AmanziMesh::Entity_ID_View nodeids("nodeids", vc.MyLength()); + AmanziMesh::Entity_ID_View nodeids_surf("nodeids_surf", vc.MyLength()); + AmanziMesh::Mesh::Point_View newpos("newpos", vc.MyLength()); + + AmanziMesh::cEntity_ID_View parent_ids = mesh_->getEntityParents(AmanziMesh::Entity_kind::NODE); + for (int n = 0; n != vc.MyLength(); ++n) { + AmanziMesh::Entity_ID ss_node = parent_ids[n]; + nodeids_surf[n] = n; + nodeids[n] = ss_node; + AmanziGeometry::Point p(vc[0][n], vc[1][n], vc[2][n]); + newpos[n] = p; + } - // if (c==0){ - // std::cout<<"COORDS "<node_set_coordinates(nodes[i], coords); - } + // mark the indicator field as changed now to force recomputation of + // dependencies on deformed mesh + changedEvaluatorPrimary(elevation_increase_key_, tag_next_, *S_); } +} - deform_eval_ = - Teuchos::rcp_dynamic_cast(S->GetEvaluator(elevation_increase_key_)); - deform_eval_->SetChanged(S.ptr()); +void +Morphology_PK::CommitStep(double t_old, double t_new, const Tag& tag) +{ + MPCFlowTransport::CommitStep(t_old, t_new, tag); - S->GetPtrW(vertex_coord_key_, "state")->ScatterMasterToGhosted("node"); + // also save our flow quantities, needed for interpolation + auto [flow_current_tag, flow_next_tag] = tags_[0]; + assign(dens_key_, flow_current_tag, flow_next_tag, *S_); + assign(pd_key_, flow_current_tag, flow_next_tag, *S_); } diff --git a/src/pks/mpc/mpc_morphology_pk.hh b/src/pks/mpc/mpc_morphology_pk.hh index ed9260a4d..a0ba6738d 100644 --- a/src/pks/mpc/mpc_morphology_pk.hh +++ b/src/pks/mpc/mpc_morphology_pk.hh @@ -8,9 +8,22 @@ */ /* - This is the mpc_pk component of the Amanzi code. + This PK couples surface flow and sediment transport and provides capability to model + geomorphological changes of the surface elevation and slopes. + The elevation change is defined as follows: + + .. math:: + + \Delta Z = \frac{\delta t}{(1-\phi_s)\rho_s} (Q_t + Q_s - Q_e + Q_db) + + + where :math:'\phi_s' is soil porosity and :math:'\rho_s' - sediment density + + The surface and subsurface meshes has to be defined as 'deformable mesh' + + + - PK for coupling of surface and subsurface transport PKs */ #ifndef ATS_AMANZI_MORPHOLOGY_PK_HH_ @@ -18,65 +31,40 @@ #include "Teuchos_RCP.hpp" -#include "pk_mpcsubcycled_ats.hh" +#include "mpc_flow_transport.hh" #include "pk_physical_bdf_default.hh" #include "PK.hh" #include "Debugger.hh" namespace Amanzi { -class Morphology_PK : public PK_MPCSubcycled_ATS { +class Morphology_PK : public MPCFlowTransport { public: Morphology_PK(Teuchos::ParameterList& pk_tree_or_fe_list, const Teuchos::RCP& global_list, const Teuchos::RCP& S, const Teuchos::RCP& soln); - ~Morphology_PK() {} // PK methods - // -- dt is the minimum of the sub pks - virtual double get_dt(); - //virtual void set_dt(double dt); - virtual void Setup(const Teuchos::Ptr& S); - virtual void Initialize(const Teuchos::Ptr& S); + void parseParameterList() override; + void Setup() override; + void CommitStep(double t_old, double t_new, const Tag& tag) override; // -- advance each sub pk from t_old to t_new. - virtual bool AdvanceStep(double t_old, double t_new, bool reinit = false); - - virtual void CommitStep(double t_old, double t_new, const Teuchos::RCP& S); - - std::string name() { return name_; } + virtual bool AdvanceStep(double t_old, double t_new, bool reinit = false) override; protected: - void Initialize_MeshVertices_(const Teuchos::Ptr& S, - Teuchos::RCP mesh, - Key vert_field_key); - - void Update_MeshVertices_(const Teuchos::Ptr& S); - - void FlowAnalyticalSolution_(const Teuchos::Ptr& S, double time); + void Update_MeshVertices_(const Teuchos::Ptr& S, const Tag& tag); Key domain_, domain_3d_, domain_ss_; - Key vertex_coord_key_, vertex_coord_key_3d_, vertex_coord_key_ss_; - Key elevation_increase_key_; - - Teuchos::RCP dz_accumul_; + Teuchos::RCP mesh_, mesh_3d_, mesh_ss_; - Teuchos::RCP flow_pk_; - Teuchos::RCP sed_transport_pk_; + Key vertex_coord_key_; + Key elevation_increase_key_; + Key dens_key_, pd_key_; // used in transport's subcycled quantites, need interpolations - double master_dt_, slave_dt_; - double dt_MPC_, dt_sample_; double MSF_; // morphology scaling factor - Teuchos::RCP mesh_, mesh_3d_, mesh_ss_; - Teuchos::RCP deform_eval_; - Key erosion_rate_; - - // debugger for dumping vectors - Teuchos::RCP flow_db_; - Teuchos::RCP trans_db_; - // factory registration static RegisteredPKFactory reg_; }; diff --git a/src/pks/mpc/mpc_permafrost.cc b/src/pks/mpc/mpc_permafrost.cc index cfdc1a0b5..b9563adf6 100644 --- a/src/pks/mpc/mpc_permafrost.cc +++ b/src/pks/mpc/mpc_permafrost.cc @@ -20,7 +20,7 @@ #include "surface_ice_model.hh" #include "energy_base.hh" #include "advection.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "mpc_permafrost.hh" @@ -65,11 +65,11 @@ MPCPermafrost::parseParameterList() // -- primary exchange flux keys and evaluators mass_exchange_key_ = Keys::readKey(*plist_, domain_surf_, "mass exchange flux", "surface_subsurface_flux"); - requireAtNext(mass_exchange_key_, tag_next_, *S_, name_); + requireEvaluatorAtNext(mass_exchange_key_, tag_next_, *S_, name_); energy_exchange_key_ = Keys::readKey(*plist_, domain_surf_, "energy exchange flux", "surface_subsurface_energy_flux"); - requireAtNext(energy_exchange_key_, tag_next_, *S_, name_); + requireEvaluatorAtNext(energy_exchange_key_, tag_next_, *S_, name_); // parse keys surf_temp_key_ = Keys::readKey(*plist_, domain_surf_, "surface temperature", "temperature"); @@ -143,18 +143,18 @@ MPCPermafrost::Setup() MPCSubsurface::Setup(); // require the coupling fields, claim ownership - requireAtNext(mass_exchange_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(mass_exchange_key_, tag_next_, *S_, name_) .SetMesh(surf_mesh_) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtNext(energy_exchange_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(energy_exchange_key_, tag_next_, *S_, name_) .SetMesh(surf_mesh_) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // require in case the PK did not do so already - requireAtNext(surf_pd_key_, tag_next_, *S_) + requireEvaluatorAtNext(surf_pd_key_, tag_next_, *S_) .SetMesh(surf_mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(surf_pd_key_, tag_current_, *S_, surf_pd_key_); + requireEvaluatorAtCurrent(surf_pd_key_, tag_current_, *S_, surf_pd_key_); // require surface derivatives S_->RequireDerivative( @@ -174,7 +174,7 @@ MPCPermafrost::Setup() if (precon_type_ != PRECON_NO_FLOW_COUPLING) { Teuchos::RCP surf_flow_pc = surf_flow_pk_->preconditioner(); Teuchos::RCP domain_flow_pc = domain_flow_pk_->preconditioner(); - for (Operators::Operator::op_iterator op = surf_flow_pc->begin(); op != surf_flow_pc->end(); + for (Operators::Operator::op_iterator op = surf_flow_pc->begin() ; op != surf_flow_pc->end(); ++op) { domain_flow_pc->OpPushBack(*op); } @@ -183,7 +183,8 @@ MPCPermafrost::Setup() // -- surface energy Teuchos::RCP surf_energy_pc = surf_energy_pk_->preconditioner(); Teuchos::RCP domain_energy_pc = domain_energy_pk_->preconditioner(); - for (Operators::Operator::op_iterator op = surf_energy_pc->begin(); op != surf_energy_pc->end(); + for (Operators::Operator::op_iterator op = surf_energy_pc->begin() + ; op != surf_energy_pc->end(); ++op) { domain_energy_pc->OpPushBack(*op); } @@ -239,7 +240,7 @@ MPCPermafrost::Setup() dE_dp_plist.set("entity kind", "cell"); dE_dp_surf_ = Teuchos::rcp(new Operators::PDE_Accumulation(dE_dp_plist, surf_mesh_)); - for (Operators::Operator::op_iterator op = dE_dp_surf_->global_operator()->begin(); + for (Operators::Operator::op_iterator op = dE_dp_surf_->global_operator() ->begin(); op != dE_dp_surf_->global_operator()->end(); ++op) { dE_dp_block_->OpPushBack(*op); @@ -346,8 +347,7 @@ MPCPermafrost::Initialize() S_->GetRecordW(mass_exchange_key_, tag_next_, name_).set_initialized(); changedEvaluatorPrimary(mass_exchange_key_, tag_next_, *S_); - S_->GetPtrW(energy_exchange_key_, tag_next_, name_) - ->PutScalar(0.0); + S_->GetPtrW(energy_exchange_key_, tag_next_, name_)->PutScalar(0.0); S_->GetRecordW(energy_exchange_key_, tag_next_, name_).set_initialized(); changedEvaluatorPrimary(energy_exchange_key_, tag_next_, *S_); @@ -389,7 +389,7 @@ void MPCPermafrost::set_tags(const Tag& tag_current, const Tag& tag_next) { MPCSubsurface::set_tags(tag_current, tag_next); - if (water_.get()) water_->set_tags(tag_current, tag_next); + if (water_.get() ) water_->set_tags(tag_current, tag_next); if (surf_ewc_ != Teuchos::null) surf_ewc_->set_tags(tag_current, tag_next); } @@ -426,8 +426,7 @@ MPCPermafrost::FunctionalResidual(double t_old, // The residual of the surface flow equation provides the water flux from // subsurface to surface. Epetra_MultiVector& source = - *S_->GetW(mass_exchange_key_, tag_next_, name_) - .ViewComponent("cell", false); + *S_->GetW(mass_exchange_key_, tag_next_, name_).ViewComponent("cell", false); source = *g->SubVector(2)->Data()->ViewComponent("cell", false); changedEvaluatorPrimary(mass_exchange_key_, tag_next_, *S_); @@ -446,8 +445,7 @@ MPCPermafrost::FunctionalResidual(double t_old, // The residual of the surface energy equation provides the diffusive energy // flux from subsurface to surface. Epetra_MultiVector& esource = - *S_->GetW(energy_exchange_key_, tag_next_, name_) - .ViewComponent("cell", false); + *S_->GetW(energy_exchange_key_, tag_next_, name_).ViewComponent("cell", false); esource = *g->SubVector(3)->Data()->ViewComponent("cell", false); changedEvaluatorPrimary(energy_exchange_key_, tag_next_, *S_); @@ -464,7 +462,7 @@ int MPCPermafrost::ApplyPreconditioner(Teuchos::RCP r, Teuchos::RCP Pr) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Precon application:" << std::endl; // write residuals if (vo_->os_OK(Teuchos::VERB_HIGH)) { @@ -530,7 +528,7 @@ void MPCPermafrost::UpdatePreconditioner(double t, Teuchos::RCP up, double h) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon update at t = " << t << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon update at t = " << t << std::endl; // update the various components -- note it is important that subsurface are // done first (which is handled as they are listed first) diff --git a/src/pks/mpc/mpc_permafrost.hh b/src/pks/mpc/mpc_permafrost.hh index 9fa4958a8..6dc1b5679 100644 --- a/src/pks/mpc/mpc_permafrost.hh +++ b/src/pks/mpc/mpc_permafrost.hh @@ -7,18 +7,29 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! A coupler which solves flow and energy both surface and subsurface. /*! This MPC handles the coupling of surface energy and flow to subsurface energy -and flow for integrated hydrology with freeze/thaw processes. +and flow for integrated thermal hydrology with freeze/thaw processes. -.. _mpc-permafrost-spec: -.. admonition:: mpc-permafrost-spec +Coupling for flow is identical to that in :ref:`Integrated Hydrology`. +Coupling between surface flow and energy is identical to that of :ref:`Surface +Flow & Energy`, while coupling between subsurface flow and energy is identical +to that of :ref:`Subsurface Flow & Energy`. Coupling of energy between the +surface and subsurface is similar to flow; both continuity of temperature and +the diffusive flux of energy are enforced, while advected fluxes of energy are +passed with mass (exfiltration) flux. - * `"PKs order`" ``[Array(string)]`` The user supplies the names of the - coupled PKs. The order must be {subsurface_flow_pk, subsurface_energy_pk, - surface_flow_pk, surface_energy_pk}. +This is the implementation of the model described in `Painter et al WRR 2016 +`_. + +`"PK type`" = `"permafrost model`" + +.. _pk-permafrost-model-spec: +.. admonition:: pk-permafrost-model-spec + + * `"PKs order`" ``[Array(string)]`` Order must be {subsurface_flow_pk, + subsurface_energy_pk, surface_flow_pk, surface_energy_pk}. * `"subsurface domain name`" ``[string]`` **domain** @@ -28,12 +39,19 @@ and flow for integrated hydrology with freeze/thaw processes. * `"energy exchange flux key`" ``[string]`` **SURFACE_DOMAIN-surface_subsurface_energy_flux** - * `"water delegate`" ``[mpc-delegate-water-spec]`` A `Coupled Water - Globalization Delegate`_ spec. + * `"supress Jacobian terms: d div surface q / dT`" ``[bool]`` **false** Turn + off the Jacobian term associated with the derivative of overland + conductivity with respect to temperature. + + * `"water delegate`" ``[mpc-delegate-water-spec]`` A :ref:`Coupled Water + Globalization Delegate` spec. + + * `"surface ewc delegate`" ``[mpc-delegate-ewc-spec]`` A :ref:`EWC + Globalization Delegate` spec. INCLUDES: - - ``[mpc-subsurface-spec]`` *Is a* `Subsurface MPC`_ + - ``[mpc-subsurface-spec]`` *Is a* :ref:`Subsurface Flow & Energy` */ @@ -73,22 +91,23 @@ class MPCPermafrost : public MPCSubsurface { Teuchos::RCP g) override; // -- Apply preconditioner to r and returns the result in Pr. - virtual int - ApplyPreconditioner(Teuchos::RCP r, Teuchos::RCP Pr) override; + virtual int ApplyPreconditioner(Teuchos::RCP r, + Teuchos::RCP Pr) override; // -- Update the preconditioner. virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; // -- Modify the predictor. - virtual bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + virtual bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; // -- Modify the correction. - virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult - ModifyCorrection(double h, - Teuchos::RCP r, - Teuchos::RCP u, - Teuchos::RCP du) override; + virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult ModifyCorrection( + double h, + Teuchos::RCP r, + Teuchos::RCP u, + Teuchos::RCP du) override; protected: // sub PKs diff --git a/src/pks/mpc/mpc_permafrost_split_flux.cc b/src/pks/mpc/mpc_permafrost_split_flux.cc index 49cbd6ea2..c4975e3a2 100644 --- a/src/pks/mpc/mpc_permafrost_split_flux.cc +++ b/src/pks/mpc/mpc_permafrost_split_flux.cc @@ -9,7 +9,7 @@ #include "mpc_permafrost_split_flux.hh" #include "mpc_surface_subsurface_helpers.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" namespace Amanzi { @@ -69,14 +69,14 @@ MPCPermafrostSplitFlux::parseParameterList() for (const auto& domain : *domain_set) { auto p_key = Keys::getKey(domain, p_lateral_flow_source_suffix_); Tag ds_tag_next = get_ds_tag_next_(domain); - requireAtNext(p_key, ds_tag_next, *S_, name_); + requireEvaluatorAtNext(p_key, ds_tag_next, *S_, name_); auto T_key = Keys::getKey(domain, T_lateral_flow_source_suffix_); - requireAtNext(T_key, ds_tag_next, *S_, name_); + requireEvaluatorAtNext(T_key, ds_tag_next, *S_, name_); } } else { - requireAtNext(p_lateral_flow_source_, tags_[1].second, *S_, name_); - requireAtNext(T_lateral_flow_source_, tags_[1].second, *S_, name_); + requireEvaluatorAtNext(p_lateral_flow_source_, tags_[1].second, *S_, name_); + requireEvaluatorAtNext(T_lateral_flow_source_, tags_[1].second, *S_, name_); } } @@ -116,6 +116,38 @@ MPCPermafrostSplitFlux::parseParameterList() "temperature primary variable star", Keys::getVarName(T_primary_variable_)); + // alias porosity for use in the subcycled elevation evaluator for surface_star + if (subcycling_[0]) { + auto [star_current_tag, star_next_tag] = tags_[0]; + + if (is_domain_set_) { + auto domain_set = S_->GetDomainSet(domain_set_); + for (const auto& domain : *domain_set) { + AMANZI_ASSERT(Keys::starts_with(domain, "surface_")); + std::string domain_sub = domain.substr(8, std::string::npos); + auto base_poro_key = Keys::getKey(domain_sub, "base_porosity"); + Tag ds_tag_next = get_ds_tag_next_(domain); + + Teuchos::ParameterList& base_poro_list = + S_->GetEvaluatorList(Keys::getKey(base_poro_key, star_next_tag)); + if (!base_poro_list.isParameter("evaluator type")) { + base_poro_list.set("evaluator type", "alias"); + base_poro_list.set("target", Keys::getKey(base_poro_key, ds_tag_next, true)); + } + } + } else { + auto [column_current_tag, column_next_tag] = tags_[1]; + + Teuchos::ParameterList& base_poro_list = + S_->GetEvaluatorList(Keys::getKey("base_porosity", star_next_tag)); + if (!base_poro_list.isParameter("evaluator type")) { + base_poro_list.set("evaluator type", "alias"); + base_poro_list.set("target", + Keys::getKey("base_porosity", column_next_tag, true)); + } + } + } + MPCSubcycled::parseParameterList(); }; @@ -131,37 +163,37 @@ MPCPermafrostSplitFlux::Setup() for (const auto& domain : *domain_set) { auto p_key = Keys::getKey(domain, p_lateral_flow_source_suffix_); Tag ds_tag_next = get_ds_tag_next_(domain); - requireAtNext(p_key, ds_tag_next, *S_, name_) + requireEvaluatorAtNext(p_key, ds_tag_next, *S_, name_) .SetMesh(S_->GetMesh(domain)) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); auto T_key = Keys::getKey(domain, T_lateral_flow_source_suffix_); - requireAtNext(T_key, ds_tag_next, *S_, name_) + requireEvaluatorAtNext(T_key, ds_tag_next, *S_, name_) .SetMesh(S_->GetMesh(domain)) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } } else { - requireAtNext(p_lateral_flow_source_, tags_[1].second, *S_, name_) + requireEvaluatorAtNext(p_lateral_flow_source_, tags_[1].second, *S_, name_) .SetMesh(S_->GetMesh(Keys::getDomain(p_lateral_flow_source_))) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtNext(T_lateral_flow_source_, tags_[1].second, *S_, name_) + requireEvaluatorAtNext(T_lateral_flow_source_, tags_[1].second, *S_, name_) .SetMesh(S_->GetMesh(Keys::getDomain(T_lateral_flow_source_))) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } // also need conserved quantities at old and new times - requireAtNext(p_conserved_variable_star_, tags_[0].second, *S_) + requireEvaluatorAtNext(p_conserved_variable_star_, tags_[0].second, *S_) .SetMesh(S_->GetMesh(domain_star_)) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(p_conserved_variable_star_, tags_[0].first, *S_) + requireEvaluatorAtCurrent(p_conserved_variable_star_, tags_[0].first, *S_) .SetMesh(S_->GetMesh(domain_star_)) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtNext(T_conserved_variable_star_, tags_[0].second, *S_) + requireEvaluatorAtNext(T_conserved_variable_star_, tags_[0].second, *S_) .SetMesh(S_->GetMesh(domain_star_)) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(T_conserved_variable_star_, tags_[0].first, *S_) + requireEvaluatorAtCurrent(T_conserved_variable_star_, tags_[0].first, *S_) .SetMesh(S_->GetMesh(domain_star_)) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } @@ -271,23 +303,15 @@ void MPCPermafrostSplitFlux::CopyStarToPrimary_() { if (is_domain_set_) { - if (coupling_ == "pressure") - CopyStarToPrimary_DomainSet_Pressure_(); - else if (coupling_ == "flux") - CopyStarToPrimary_DomainSet_Flux_(); - else if (coupling_ == "hybrid") - CopyStarToPrimary_DomainSet_Hybrid_(); - else - AMANZI_ASSERT(false); + if (coupling_ == "pressure") CopyStarToPrimary_DomainSet_Pressure_(); + else if (coupling_ == "flux") CopyStarToPrimary_DomainSet_Flux_(); + else if (coupling_ == "hybrid") CopyStarToPrimary_DomainSet_Hybrid_(); + else AMANZI_ASSERT(false); } else { - if (coupling_ == "pressure") - CopyStarToPrimary_Standard_Pressure_(); - else if (coupling_ == "flux") - CopyStarToPrimary_Standard_Flux_(); - else if (coupling_ == "hybrid") - CopyStarToPrimary_Standard_Hybrid_(); - else - AMANZI_ASSERT(false); + if (coupling_ == "pressure") CopyStarToPrimary_Standard_Pressure_(); + else if (coupling_ == "flux") CopyStarToPrimary_Standard_Flux_(); + else if (coupling_ == "hybrid") CopyStarToPrimary_Standard_Hybrid_(); + else AMANZI_ASSERT(false); } } diff --git a/src/pks/mpc/mpc_permafrost_split_flux.hh b/src/pks/mpc/mpc_permafrost_split_flux.hh index 343f60180..cd8e6012b 100644 --- a/src/pks/mpc/mpc_permafrost_split_flux.hh +++ b/src/pks/mpc/mpc_permafrost_split_flux.hh @@ -6,42 +6,35 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! An operator-split permafrost coupler, splitting overland flow from subsurface. /*! -solve: - -(dTheta_s / dt)^* = div k_s grad (z+h) - -then solve: - -dTheta_s / dt = (dTheta_s / dt)^* + Q_ext + q_ss -dTheta / dt = div k (grad p + rho*g*\hat{z}) -k (grad p + rho*g*\hat{z}) |_s = q_ss - -This effectively does an operator splitting on the surface flow equation, -passing some combination of pressure and divergence of fluxes to the -subsurface. - -This is the permafrost analog, so deals with energy as well in a similar -strategy. In this case advection and diffusion of energy are handled in the -first solve: -(dE_s / dt)^* = div ( kappa_s grad T + hq ) +This MPC solves the thermal equivalent of :ref:`Operator Split Integrated +Hydrology`. This is the permafrost analog, so deals with energy as well in a +similar strategy. In this case advection and diffusion of energy are handled +in the "star" system, then the "primary" system solves the :ref:`Integrated +Thermal Hydrology` system without lateral fluxes and with extra coupling terms +equivalent to those for flow from :ref:`Operaor Split Integrated Hydrology`. -then: +Like the flow-only case, this can be used with either a 3D subsurface solve, by +setting the 2nd sub-PK to be a 3D permafrost MPC, or a bunch of columns, but +setting the 2nd sub-PK to be a DomainSetMPC. -dE_s / dt = (dE_s / dt)^* + QE_ext + h * Q_ext + qE_ss + h * q_ss -dE / dt = div ( kappa grad T) + hq ) -kappa grad T |_s = qE_ss +This is the model from `Jan et al Comp. Geosci. 2018 +`_ -Note that this can be used with either a 3D subsurface solve, by setting the -2nd sub-PK to be a 3D permafrost MPC, or a bunch of columns, but setting the -2nd sub-PK to be a DomainSetMPC. +`"PK type`" = `"operator split permafrost`" +.. _pk-operator-split-permafrost: +.. admonition:: pk-operator-split-permafrost -.. _mpc-permafrost-split-flux-spec -.. admonition:: mpc-permafrost-split-flux-spec + * `"PKs order`" ``[Array(string)]`` Order is {star_system, primary_system}. + Note that the sub-PKs are likely a :ref:`Surface Flow & Energy` MPC for + the star system and a :ref:`Integrated Thermal Hydrology` MPC for the + primary system. Because the latter does not include lateral fluxes in the + surface, the sub-PKs of the primary system may be :ref:`General Surface + Balance` equations rather than :ref:`Overland Flow PK` and :ref:`Overland + Energy with Ice` (thereby removing the lateral flow and energy transport + components). * `"domain name`" ``[string]`` The subsurface domain, e.g. "domain" (for a 3D subsurface ) or "column:*" (for the intermediate scale model. @@ -55,8 +48,8 @@ Note that this can be used with either a 3D subsurface solve, by setting the the two that seems the most robust. INCLUDES: - - ``[mpc-spec]`` *Is an* MPC_. - - ``[mpc-subcycled-spec]`` *Is a* MPCSubcycled_ + - ``[pk-mpc-spec]`` *Is an* :ref:`MPC`. + - ``[pk-subcycling-mpc-spec]`` *Is a* :ref:`Subcycling MPC` */ diff --git a/src/pks/mpc/mpc_permafrost_split_flux_reg.hh b/src/pks/mpc/mpc_permafrost_split_flux_reg.hh index fa809491b..61d65028b 100644 --- a/src/pks/mpc/mpc_permafrost_split_flux_reg.hh +++ b/src/pks/mpc/mpc_permafrost_split_flux_reg.hh @@ -11,7 +11,7 @@ namespace Amanzi { -RegisteredPKFactory - MPCPermafrostSplitFlux::reg_("operator split permafrost"); +RegisteredPKFactory MPCPermafrostSplitFlux::reg_( + "operator split permafrost"); } // namespace Amanzi diff --git a/src/pks/mpc/mpc_reactivetransport.cc b/src/pks/mpc/mpc_reactivetransport.cc index 76096ffc2..67b43eb35 100644 --- a/src/pks/mpc/mpc_reactivetransport.cc +++ b/src/pks/mpc/mpc_reactivetransport.cc @@ -14,7 +14,8 @@ */ #include "mpc_reactivetransport.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" +#include "chem_pk_helpers.hh" namespace Amanzi { @@ -26,55 +27,73 @@ MPCReactiveTransport::MPCReactiveTransport(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& S, const Teuchos::RCP& soln) : PK(pk_tree, global_list, S, soln), WeakMPC(pk_tree, global_list, S, soln) +{} + + +void +MPCReactiveTransport::parseParameterList() { - chem_step_succeeded_ = true; + // 0 is chem, 1 is transport + cast_sub_pks_(); - alquimia_timer_ = Teuchos::TimeMonitor::getNewCounter("alquimia " + name()); + domain_ = getSubPKPlist_(1)->get("domain name", "domain"); + tcc_key_ = + Keys::readKey(*getSubPKPlist_(0), domain_, "primary variable", "total_component_concentration"); + mol_frac_key_ = Keys::readKey(*getSubPKPlist_(1), domain_, "primary variable", "mole_fraction"); + if (tcc_key_ == mol_frac_key_) { + Errors::Message msg; + msg << "Chemistry and Transport may not be given the same primary variable name (\"" << tcc_key_ + << "\") -- rename one or the other."; + Exceptions::amanzi_throw(msg); + } - domain_ = Keys::readDomain(*plist_, "domain", "domain"); - tcc_key_ = Keys::readKey( - *plist_, domain_, "total component concentration", "total_component_concentration"); mol_dens_key_ = Keys::readKey(*plist_, domain_, "molar density liquid", "molar_density_liquid"); + + // Only chemistry PK needs to set the IC -- we use chemistry to process geochemical + // initial conditions -- but the "initial conditions" list must be present + // for all PK_Physical PKs, so just touch it here to make sure it exists. + getSubPKPlist_(1)->sublist("initial conditions"); + + // this MPC need access to both primary variables + getSubPKPlist_(0)->set("primary variable password", name_); + getSubPKPlist_(1)->set("primary variable password", name_); + + WeakMPC::parseParameterList(); } void MPCReactiveTransport::Setup() { - cast_sub_pks_(); - + // must Setup transport first to get alias for saturation, etc set up correctly transport_pk_->Setup(); chemistry_pk_->Setup(); - - S_->Require(tcc_key_, tag_next_, "state") - .SetMesh(S_->GetMesh(domain_)) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, chemistry_pk_->num_aqueous_components()); - S_->RequireEvaluator(tcc_key_, tag_next_); - - - S_->Require(mol_dens_key_, tag_next_) + requireEvaluatorAtNext(mol_dens_key_, tag_next_, *S_) .SetMesh(S_->GetMesh(domain_)) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S_->RequireEvaluator(mol_dens_key_, tag_next_); } void MPCReactiveTransport::cast_sub_pks_() { + // cast transport PK transport_pk_ = Teuchos::rcp_dynamic_cast(sub_pks_[1]); AMANZI_ASSERT(transport_pk_ != Teuchos::null); + +#ifdef ALQUIMIA_ENABLED + chemistry_pk_ = Teuchos::rcp_dynamic_cast(sub_pks_[0]); + AMANZI_ASSERT(chemistry_pk_ != Teuchos::null); + + // now chem engine is set and we can hand it to transport + transport_pk_->setChemEngine(chemistry_pk_); + +#else chemistry_pk_ = Teuchos::rcp_dynamic_cast(sub_pks_[0]); AMANZI_ASSERT(chemistry_pk_ != Teuchos::null); - // communicate chemistry engine to transport. -#ifdef ALQUIMIA_ENABLED - transport_pk_->SetupAlquimia( - Teuchos::rcp_static_cast(chemistry_pk_), - chemistry_pk_->chem_engine()); #endif } @@ -84,67 +103,55 @@ MPCReactiveTransport::cast_sub_pks_() void MPCReactiveTransport::Initialize() { + // initialize chemistry, including geochemical ICs + chemistry_pk_->Initialize(); + AMANZI_ASSERT(S_->GetRecord(tcc_key_, tag_next_).initialized()); + + // Compute mol frac from concentration + // // NOTE: this requires that Reactive-Transport is done last, or at least // after the density of water can be evaluated. This could be problematic // for, e.g., salinity intrusion problems where water density is a function // of concentration itself, but should work for all other problems? - Teuchos::RCP tcc = - S_->GetW(tcc_key_, tag_next_, "state").ViewComponent("cell", true); - S_->GetEvaluator(mol_dens_key_, tag_next_).Update(*S_, name_); - Teuchos::RCP mol_dens = - S_->Get(mol_dens_key_, tag_next_).ViewComponent("cell", true); - - int num_aqueous = chemistry_pk_->num_aqueous_components(); - convertConcentrationToAmanzi(*mol_dens, num_aqueous, *tcc, *tcc); - chemistry_pk_->set_aqueous_components(tcc); - chemistry_pk_->Initialize(); - //*tcc = *chemistry_pk_->aqueous_components(); - convertConcentrationToATS(*mol_dens, num_aqueous, *tcc, *tcc); - + convertConcentrationToMolFrac(*S_, + { tcc_key_, tag_next_ }, + { mol_frac_key_, tag_next_ }, + { mol_dens_key_, tag_next_ }, + name()); + S_->GetRecordW(mol_frac_key_, tag_next_, name()).set_initialized(); + + // initialize transport transport_pk_->Initialize(); } -// ----------------------------------------------------------------------------- -// Calculate the min of sub PKs timestep sizes. -// ----------------------------------------------------------------------------- -double -MPCReactiveTransport::get_dt() -{ - double dTtran = transport_pk_->get_dt(); - double dTchem = chemistry_pk_->get_dt(); - - if (!chem_step_succeeded_ && (dTchem / dTtran > 0.99)) { dTchem *= 0.5; } - return dTchem; -} - - // ----------------------------------------------------------------------------- // Advance each sub-PK individually, returning a failure as soon as possible. // ----------------------------------------------------------------------------- bool MPCReactiveTransport::AdvanceStep(double t_old, double t_new, bool reinit) { - chem_step_succeeded_ = false; - // First we do a transport step. bool fail = transport_pk_->AdvanceStep(t_old, t_new, reinit); if (fail) return fail; - // Second, we do a chemistry step. - int num_aq_componets = transport_pk_->get_num_aqueous_component(); + // move from mol_frac@next to tcc@current + convertMolFracToConcentration(*S_, + { mol_frac_key_, tag_next_ }, + { tcc_key_, tag_current_ }, + { mol_dens_key_, tag_next_ }, + name()); - Teuchos::RCP tcc_copy = - S_->GetW(tcc_key_, tag_next_, "state").ViewComponent("cell", true); - - S_->GetEvaluator(mol_dens_key_, tag_next_).Update(*S_, name_); - Teuchos::RCP mol_dens = - S_->Get(mol_dens_key_, tag_next_).ViewComponent("cell", true); + // Next to chemistry step + fail = chemistry_pk_->AdvanceStep(t_old, t_new, reinit); + if (fail) return fail; - fail |= - advanceChemistry(chemistry_pk_, t_old, t_new, reinit, *mol_dens, tcc_copy, *alquimia_timer_); - changedEvaluatorPrimary(tcc_key_, tag_next_, *S_); - if (!fail) chem_step_succeeded_ = true; + // move from tcc@next to mol_frac@next + convertConcentrationToMolFrac(*S_, + { tcc_key_, tag_next_ }, + { mol_frac_key_, tag_next_ }, + { mol_dens_key_, tag_next_ }, + name()); return fail; }; diff --git a/src/pks/mpc/mpc_reactivetransport.hh b/src/pks/mpc/mpc_reactivetransport.hh index ad4745eb4..75948074b 100644 --- a/src/pks/mpc/mpc_reactivetransport.hh +++ b/src/pks/mpc/mpc_reactivetransport.hh @@ -6,11 +6,27 @@ Authors: Daniil Svyatskiy */ +/*! + +This MPC couples transport and chemistry through an operator split strategy. + +Note that transport's primary variable is `"mole_fraction`", which is in units +of [mol C mol liquid^-1]. Chemistry is in "total_component_concentration", which +is in units of [mol-C L^-1]. Therefore, between steps, we convert between the +two. + +`"PK type`" = `"reactive transport`" + +.. _pk-reactive-transport-spec: +.. admonition:: pk-reactive-transport-spec + + * `"domain name`" ``[string]`` Domain of simulation + + KEYS: + + - `"molar density liquid`" -/* - This is the mpc_pk component of the Amanzi code. - Process kernel for coupling of Transport_PK and Chemistry_PK. */ @@ -33,8 +49,8 @@ class MPCReactiveTransport : public WeakMPC { const Teuchos::RCP& S, const Teuchos::RCP& soln); - // PK methods - virtual double get_dt() override; + virtual void parseParameterList() override; + virtual void Setup() override; virtual void Initialize() override; virtual bool AdvanceStep(double t_old, double t_new, bool reinit = false) override; @@ -43,17 +59,21 @@ class MPCReactiveTransport : public WeakMPC { virtual void cast_sub_pks_(); protected: - bool chem_step_succeeded_; - Key domain_; Key tcc_key_; + Key mol_frac_key_; Key mol_dens_key_; Teuchos::RCP alquimia_timer_; // storage for the component concentration intermediate values Teuchos::RCP transport_pk_; + +#ifdef ALQUIMIA_ENABLED + Teuchos::RCP chemistry_pk_; +#else Teuchos::RCP chemistry_pk_; +#endif // factory registration static RegisteredPKFactory reg_; diff --git a/src/pks/mpc/mpc_subcycled.cc b/src/pks/mpc/mpc_subcycled.cc index ca7c21df9..e0f0fe7c0 100644 --- a/src/pks/mpc/mpc_subcycled.cc +++ b/src/pks/mpc/mpc_subcycled.cc @@ -11,9 +11,9 @@ MPC for subcycling one PK relative to another. */ -#include "Event.hh" +#include "TimeStepManager.hh" #include "mpc_subcycled.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" namespace Amanzi { @@ -29,8 +29,6 @@ MPCSubcycled::MPCSubcycled(Teuchos::ParameterList& pk_tree, init_(); // NOTE: this must be done prior to set_tags(), therefore before even parseParameterList() - // - // Master PK is the PK whose timestep size sets the size, the subcycled is subcycled. subcycling_ = plist_->get>("subcycle"); if (subcycling_.size() != sub_pks_.size()) { Errors::Message msg( @@ -38,11 +36,23 @@ MPCSubcycled::MPCSubcycled(Teuchos::ParameterList& pk_tree, Exceptions::amanzi_throw(msg); } dts_.resize(sub_pks_.size(), -1); + tsms_.resize(sub_pks_.size(), Teuchos::null); } void MPCSubcycled::parseParameterList() { + for (int i = 0; i != tsms_.size(); ++i) { + if (subcycling_[i]) { + Teuchos::ParameterList tsm_plist(std::string("TSM: ") + sub_pks_[i]->name()); + tsms_[i] = Teuchos::rcp(new Utils::TimeStepManager(tsm_plist)); + + const auto& tag = tags_[i]; + S_->require_time(tag.first); + S_->require_time(tag.second); + } + } + MPC::parseParameterList(); // min dt allowed in subcycling @@ -76,8 +86,6 @@ MPCSubcycled::Setup() { int i = 0; for (const auto& tag : tags_) { - S_->require_time(tag.first); - S_->require_time(tag.second); S_->require_cycle(tag.second); if (subcycling_[i]) S_->Require("dt", tag.first, name()); ++i; @@ -149,28 +157,26 @@ MPCSubcycled::AdvanceStep_i_(std::size_t i, double t_old, double t_new, bool rei bool done = false; double t_inner = t_old; double dt_inner = dts_[i]; + bool fail_inner = false; Tag tag_subcycle_current = tags_[i].first; Tag tag_subcycle_next = tags_[i].second; + tsms_[i]->RegisterTimeEvent(t_new); S_->set_time(tag_subcycle_current, t_old); - while (!done) { - if (Utils::isNearEqual(t_new, t_inner + dt_inner) || (t_inner + dt_inner) > t_new) { - dt_inner = t_new - t_inner; - } + while (!done) { + dt_inner = tsms_[i]->TimeStep(t_inner, dt_inner, fail_inner); S_->Assign("dt", tag_subcycle_current, name(), dt_inner); S_->set_time(tag_subcycle_next, t_inner + dt_inner); - bool fail_inner = sub_pks_[i]->AdvanceStep(t_inner, t_inner + dt_inner, false); + fail_inner = sub_pks_[i]->AdvanceStep(t_inner, t_inner + dt_inner, false); if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " step failed? " << fail_inner << std::endl; if (fail_inner) { sub_pks_[i]->FailStep(t_old, t_new, tag_subcycle_next); - dt_inner = sub_pks_[i]->get_dt(); - S_->set_time(tag_subcycle_next, S_->get_time(tag_subcycle_current)); if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << " failed, new timestep is " << dt_inner << std::endl; @@ -225,7 +231,9 @@ MPCSubcycled::CommitStep(double t_old, double t_new, const Tag& tag) // initial commit, also do the substep commits int i = 0; for (auto& pk : sub_pks_) { - if (subcycling_[i]) { pk->CommitStep(t_old, t_new, tags_[i].second); } + if (subcycling_[i]) { + pk->CommitStep(t_old, t_new, tags_[i].second); + } ++i; } } diff --git a/src/pks/mpc/mpc_subcycled.hh b/src/pks/mpc/mpc_subcycled.hh index e010db1a7..cf5ccc184 100644 --- a/src/pks/mpc/mpc_subcycled.hh +++ b/src/pks/mpc/mpc_subcycled.hh @@ -6,17 +6,25 @@ Authors: Ethan Coon */ +/*! -/* - Weakly coupled N PKs, potentially subcycling any of them. +A generic MPC that weakly couples N PKs, potentially subcycling any of them. + +`"PK type`" = `"subcycling MPC`" + +.. _pk-subcycling-mpc-spec: +.. admonition:: pk-subcycling-mpc-spec + + * `"subcycle`" ``[Array(bool)]`` Array of the same length as sub_pks. + * `"subcycling target timestep [s]`" ``[double]`` **optional** If provided, + this target dt is included, setting a ceiling on the largest timestep size + and therefore setting a max dt over which we let the sub-PKs step + independently without synchronization. This is required if all sub-PKs are + being subcycled. - * `"subcycle`" ``[Array(bool)]`` Array of the same length as sub_pks. - * `"minimum subcycled relative dt`" ``[double]`` **1.e-5** Sets the minimum - timestep size of the subcycled PKs, as a multiple of the minimum of the - non-subcycled PKs' timestep sizes. + INCLUDES: - INCLUDES: - - ``[mpc-spec]`` + - ``[mpc-spec]`` *Is a* :ref:`MPC`. */ @@ -58,6 +66,7 @@ class MPCSubcycled : public MPC { double dt_, target_dt_; std::vector dts_; std::vector> tags_; + std::vector> tsms_; private: // factory registration diff --git a/src/pks/mpc/mpc_subcycled_reg.hh b/src/pks/mpc/mpc_subcycled_reg.hh index 670a0e2b9..3282c0472 100644 --- a/src/pks/mpc/mpc_subcycled_reg.hh +++ b/src/pks/mpc/mpc_subcycled_reg.hh @@ -18,9 +18,11 @@ See additional documentation in the base class src/pks/mpc/MPC.hh ------------------------------------------------------------------------- */ #include "mpc_subcycled.hh" +#include "mpc_flow_transport.hh" namespace Amanzi { RegisteredPKFactory MPCSubcycled::reg_("subcycling MPC"); +RegisteredPKFactory MPCFlowTransport::reg_("coupled flow and transport"); } // namespace Amanzi diff --git a/src/pks/mpc/mpc_subsurface.cc b/src/pks/mpc/mpc_subsurface.cc index 740cf391a..377b4136d 100644 --- a/src/pks/mpc/mpc_subsurface.cc +++ b/src/pks/mpc/mpc_subsurface.cc @@ -16,6 +16,7 @@ with freezing. ------------------------------------------------------------------------- */ #include "EpetraExt_RowMatrixOut.h" +#include "TensorVector.hh" #include "MultiplicativeEvaluator.hh" #include "TreeOperator.hh" #include "PDE_DiffusionFactory.hh" @@ -77,6 +78,8 @@ MPCSubsurface::parseParameterList() water_flux_dir_key_ = Keys::readKey(*plist_, domain_name_, "water flux direction", "water_flux_direction"); rho_key_ = Keys::readKey(*plist_, domain_name_, "mass density liquid", "mass_density_liquid"); + + perm_key_ = Keys::readKey(*plist_, domain_name_, "permeability", "permeability"); } // -- Initialize owned (dependent) variables. @@ -198,10 +201,8 @@ MPCSubsurface::Setup() Teuchos::ParameterList divq_plist( pks_list_->sublist(pk_order[0]).sublist("diffusion preconditioner")); - if (is_fv_) - divq_plist.set("Newton correction", "true Jacobian"); - else - divq_plist.set("Newton correction", "approximate Jacobian"); + if (is_fv_) divq_plist.set("Newton correction", "true Jacobian"); + else divq_plist.set("Newton correction", "approximate Jacobian"); divq_plist.set("exclude primary terms", true); @@ -214,11 +215,12 @@ MPCSubsurface::Setup() // -- derivatives of water content with respect to temperature if (S_->GetEvaluator(wc_key_, tag_next_).IsDifferentiableWRT(*S_, temp_key_, tag_next_)) { if (dWC_dT_block_ == Teuchos::null) { - dWC_dT_ = Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, mesh_)); + dWC_dT_ = + Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, mesh_)); dWC_dT_block_ = dWC_dT_->global_operator(); } else { - dWC_dT_ = - Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, dWC_dT_block_)); + dWC_dT_ = Teuchos::rcp( + new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, dWC_dT_block_)); } } @@ -246,10 +248,8 @@ MPCSubsurface::Setup() // set up the operator Teuchos::ParameterList ddivKgT_dp_plist( pks_list_->sublist(pk_order[1]).sublist("diffusion preconditioner")); - if (is_fv_) - ddivKgT_dp_plist.set("Newton correction", "true Jacobian"); - else - ddivKgT_dp_plist.set("Newton correction", "approximate Jacobian"); + if (is_fv_) ddivKgT_dp_plist.set("Newton correction", "true Jacobian"); + else ddivKgT_dp_plist.set("Newton correction", "approximate Jacobian"); ddivKgT_dp_plist.set("exclude primary terms", true); @@ -272,10 +272,8 @@ MPCSubsurface::Setup() Teuchos::ParameterList divhq_dp_plist( pks_list_->sublist(pk_order[0]).sublist("diffusion preconditioner")); - if (is_fv_) - divhq_dp_plist.set("Newton correction", "true Jacobian"); - else - divhq_dp_plist.set("Newton correction", "approximate Jacobian"); + if (is_fv_) divhq_dp_plist.set("Newton correction", "true Jacobian"); + else divhq_dp_plist.set("Newton correction", "approximate Jacobian"); Operators::PDE_DiffusionFactory opfactory; if (dE_dp_block_ == Teuchos::null) { @@ -290,10 +288,8 @@ MPCSubsurface::Setup() pks_list_->sublist(pk_order[0]).sublist("diffusion preconditioner")); divhq_dT_plist.set("exclude primary terms", true); - if (is_fv_) - divhq_dT_plist.set("Newton correction", "true Jacobian"); - else - divhq_dT_plist.set("Newton correction", "approximate Jacobian"); + if (is_fv_) divhq_dT_plist.set("Newton correction", "true Jacobian"); + else divhq_dT_plist.set("Newton correction", "approximate Jacobian"); ddivhq_dT_ = opfactory.CreateWithGravity(divhq_dT_plist, pcB); @@ -373,11 +369,12 @@ MPCSubsurface::Setup() // -- derivatives of energy with respect to pressure if (S_->GetEvaluator(wc_key_, tag_next_).IsDifferentiableWRT(*S_, temp_key_, tag_next_)) { if (dE_dp_block_ == Teuchos::null) { - dE_dp_ = Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, mesh_)); + dE_dp_ = + Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, mesh_)); dE_dp_block_ = dE_dp_->global_operator(); } else { - dE_dp_ = - Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, dE_dp_block_)); + dE_dp_ = Teuchos::rcp( + new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, dE_dp_block_)); } } @@ -442,7 +439,8 @@ MPCSubsurface::Initialize() const AmanziGeometry::Point& g = S_->Get("gravity", Tags::DEFAULT); ddivq_dT_->SetGravity(g); ddivq_dT_->SetBCs(sub_pks_[0]->BCs(), sub_pks_[1]->BCs()); - ddivq_dT_->SetTensorCoefficient(richards_pk->K_); + ddivq_dT_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); } if (ddivKgT_dp_ != Teuchos::null) { @@ -475,11 +473,13 @@ MPCSubsurface::Initialize() const AmanziGeometry::Point& g = S_->Get("gravity", Tags::DEFAULT); ddivhq_dp_->SetGravity(g); ddivhq_dp_->SetBCs(sub_pks_[1]->BCs(), sub_pks_[0]->BCs()); - ddivhq_dp_->SetTensorCoefficient(richards_pk->K_); + ddivhq_dp_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); ddivhq_dT_->SetGravity(g); ddivhq_dT_->SetBCs(sub_pks_[1]->BCs(), sub_pks_[1]->BCs()); - ddivhq_dT_->SetTensorCoefficient(richards_pk->K_); + ddivhq_dT_->SetTensorCoefficient( + Teuchos::rcpFromRef(S_->Get(perm_key_, tag_next_).data)); } } @@ -495,7 +495,9 @@ MPCSubsurface::set_tags(const Tag& tag_current, const Tag& tag_next) void MPCSubsurface::CommitStep(double t_old, double t_new, const Tag& tag) { - if (ewc_ != Teuchos::null) { ewc_->commit_state(); } + if (ewc_ != Teuchos::null) { + ewc_->commit_state(); + } update_pcs_ = 0; StrongMPC::CommitStep(t_old, t_new, tag); @@ -685,7 +687,7 @@ MPCSubsurface::UpdatePreconditioner(double t, Teuchos::RCP up, // -- update the local matrices, div h * kr grad ddivhq_dp_->UpdateMatrices(Teuchos::null, Teuchos::null); // -- determine the advective fluxes, q_a = h * kr grad p - CompositeVector adv_flux(*flux, INIT_MODE_ZERO); + CompositeVector adv_flux(flux->Map(), init_mode_default); Teuchos::Ptr adv_flux_ptr(&adv_flux); ddivhq_dp_->UpdateFlux(up->SubVector(0)->Data().ptr(), adv_flux_ptr); // -- add in components div (d h*kr / dp) grad q_a / (h*kr) @@ -723,7 +725,9 @@ MPCSubsurface::UpdatePreconditioner(double t, Teuchos::RCP up, if (vecs.size() > 0) db_->WriteVectors(vnames, vecs, false); } - if (precon_type_ == PRECON_EWC) { ewc_->UpdatePreconditioner(t, up, h); } + if (precon_type_ == PRECON_EWC) { + ewc_->UpdatePreconditioner(t, up, h); + } update_pcs_++; } @@ -735,7 +739,7 @@ int MPCSubsurface::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Precon application:" << std::endl; // write residuals if (vo_->os_OK(Teuchos::VERB_HIGH)) { diff --git a/src/pks/mpc/mpc_subsurface.hh b/src/pks/mpc/mpc_subsurface.hh index b7c7d36c2..68c271f81 100644 --- a/src/pks/mpc/mpc_subsurface.hh +++ b/src/pks/mpc/mpc_subsurface.hh @@ -6,21 +6,19 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! A coupler which solves flow and energy in the subsurface. /*! This MPC provides most nearly all terms for an approximate Jacobian for -coupling three-phase Richards equation (the `Permafrost Flow PK`_) to the -three-phase Energy equation (the `Three-Phase subsurface Energy PK`_). +coupling three-phase Richards equation (the :ref:`Permafrost Flow PK`) to the +three-phase Energy equation (the :ref:`Three-Phase Energy PK`). Many options are provided for turning on and off various aspects of this Jacobian, so it is useful to mathematically write out these terms. The equations are: .. math:: - \frac{\partial \Theta}{\partial t} - \nabla \frac{k_r n_l}{\mu} K ( \nabla p + \rho g \cdot \hat{z} ) = Q_w \\ - \frac{\partial E}{\partial t} - \nabla \cdot \kappa \nabla T + \nabla \cdot \mathbf{q} e(T) = Q_w e(T) + Q_e + \frac{\partial \Theta}{\partial t} - \nabla \frac{k_r n_l}{\mu} K ( \nabla p + \rho g \cdot \hat{z} ) &= Q_w \\ + \frac{\partial E}{\partial t} - \nabla \cdot \kappa \nabla T + \nabla \cdot \mathbf{q} e(T) &= Q_w e(T) + Q_e Note that all of the following are dependent on :math:`p` and/or :math:`T`: @@ -58,7 +56,8 @@ Differentiating these two equations in their two unknowns gives the following fo result in large changes to thermal conductivity. This is referred to as the "div K grad T / dp" term. -:math:`\frac{\partial F_2}{\partial T}`: this is the energy equation diagonal block, and is controlled inside that PK. +:math:`\frac{\partial F_2}{\partial T}`: this is the energy equation diagonal +block, and is controlled inside that PK. Also, at this level, where we know more about the flux used in the energy equation (it is the Darcy flux), we can do a better approximation of the @@ -80,28 +79,28 @@ except in expert cases or for comparison's sake, but the options are: - `"none`" No preconditioner never works. -- `"block diagonal`" This is what one would get from the default StrongMPC_. This probably never works. +- `"block diagonal`" This is what one would get from the default StrongMPC_. + This probably never works. - `"no flow coupling`" This keeps the accumulation terms, but turns off all the non-local blocks. This is equivalent to `Coupled Cells MPC`_. -- `"ewc`" **CURRENTLY DEPRECATED/BROKEN/DISABLED** In addition to the - `"picard`" coupling, this also *always* does a change of variables, whereby - we first invert to calculate primary variable corrections, then do a change - of variables to calculate the linearized corrections in energy and water - content space. We then apply those corrections, and invert to find the - primary variable changes that would have made those corrections. This is - called the "energy and water content" algorithm, and is related to similar - variable changing approaches by Krabbenhoft (for flow) and Knoll (for - energy), but in the multivariate approach. This is somewhat bad, becuase - while it fixes some corrections, it breaks others. - -- `"smart ewc`" **CURRENTLY DEPRECATED/BROKEN/DISABLED** Does the `"ewc`" - algorithm above, but tries to be smart about when to do it. This algorithm - helps when we are about to fall off of the latent heat cliff. If we can - guess when to do it, we have a better chance of not breaking things. This - seems like it ought to be helpful, but often doesn't do as much as one might - hope. +- `"ewc`" **CURRENTLY DISABLED** In addition to the `"picard`" coupling, this + also *always* does a change of variables, whereby we first invert to + calculate primary variable corrections, then do a change of variables to + calculate the linearized corrections in energy and water content space. We + then apply those corrections, and invert to find the primary variable changes + that would have made those corrections. This is called the "energy and water + content" algorithm, and is related to similar variable changing approaches by + Krabbenhoft (for flow) and Knoll (for energy), but in the multivariate + approach. This is somewhat bad, becuase while it fixes some corrections, it + breaks others. + +- `"smart ewc`" **CURRENTLY DISABLED** Does the `"ewc`" algorithm above, but + tries to be smart about when to do it. This algorithm helps when we are + about to fall off of the latent heat cliff. If we can guess when to do it, + we have a better chance of not breaking things. This seems like it ought to + be helpful, but often doesn't do as much as one might hope. Note this "ewc" algorithm is just as valid, and more useful, in the predictor @@ -109,26 +108,32 @@ Note this "ewc" algorithm is just as valid, and more useful, in the predictor pressure and temperature, but often do better to extrapolate in water content and energy space, then invert (locally) for pressure and temperature corrections that meet that extrapolation. Both of these globalization -algorithms are supported by the `EWC Globalization Delegate`_ object. +algorithms are supported by the :ref:`EWC Globalization Delegate` object. + +`"PK type`" = `"subsurface permafrost`" -.. _mpc-subsurface-spec: -.. admonition:: mpc-subsurface-spec +.. _pk-subsurface-permafrost-spec: +.. admonition:: pk-subsurface-permafrost-spec - * `"domain name`" ``[string]`` Domain of simulation + * `"domain name`" ``[string]`` Domain of simulation - * `"preconditioner type`" ``[string]`` **picard** See the above for - detailed descriptions of the choices. One of: `"none`", `"block - diagonal`", `"no flow coupling`", `"picard`", `"ewc`", and `"smart ewc`". + * `"preconditioner type`" ``[string]`` **picard** See the above for detailed + descriptions of the choices. One of: `"none`", `"block diagonal`", `"no + flow coupling`", `"picard`", `"ewc`", and `"smart ewc`". - * `"supress Jacobian terms: div hq / dp,T`" ``[bool]`` **false** If using picard or ewc, do not include this block in the preconditioner. - * `"supress Jacobian terms: d div q / dT`" ``[bool]`` **false** If using picard or ewc, do not include this block in the preconditioner. - * `"supress Jacobian terms: d div K grad T / dp`" ``[bool]`` **false** If using picard or ewc, do not include this block in the preconditioner. + * `"supress Jacobian terms: div hq / dp,T`" ``[bool]`` **false** If using + picard or ewc, do not include this block in the preconditioner. + * `"supress Jacobian terms: d div q / dT`" ``[bool]`` **false** If using + picard or ewc, do not include this block in the preconditioner. + * `"supress Jacobian terms: d div K grad T / dp`" ``[bool]`` **false** If + using picard or ewc, do not include this block in the preconditioner. - * `"ewc delegate`" ``[mpc-delegate-ewc-spec]`` A `EWC Globalization Delegate`_ spec. + * `"ewc delegate`" ``[mpc-delegate-ewc-spec]`` A :ref:`EWC Globalization + Delegate` spec. - INCLUDES: + INCLUDES: - - ``[strong-mpc-spec]`` *Is a* StrongMPC_. + - ``[strong-mpc-spec]`` *Is a* :ref:`Strong MPC`. */ @@ -185,8 +190,8 @@ class MPCSubsurface : public StrongMPC { virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; // -- Apply preconditioner to u and returns the result in Pu. - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; Teuchos::RCP preconditioner() { return preconditioner_; } @@ -256,6 +261,7 @@ class MPCSubsurface : public StrongMPC { Key rho_key_; Key duw_krdT_key_; Key duw_tcdp_key_; + Key perm_key_; bool is_fv_; diff --git a/src/pks/mpc/mpc_subsurface_reg.hh b/src/pks/mpc/mpc_subsurface_reg.hh index d14391b63..35da9cd66 100644 --- a/src/pks/mpc/mpc_subsurface_reg.hh +++ b/src/pks/mpc/mpc_subsurface_reg.hh @@ -8,5 +8,5 @@ */ #include "mpc_subsurface.hh" -Amanzi::RegisteredPKFactory - Amanzi::MPCSubsurface::reg_("subsurface permafrost"); +Amanzi::RegisteredPKFactory Amanzi::MPCSubsurface::reg_( + "subsurface permafrost"); diff --git a/src/pks/mpc/mpc_surface.cc b/src/pks/mpc/mpc_surface.cc index 52b29a2a7..2123480fc 100644 --- a/src/pks/mpc/mpc_surface.cc +++ b/src/pks/mpc/mpc_surface.cc @@ -207,7 +207,9 @@ MPCSurface::Initialize() void MPCSurface::CommitStep(double t_old, double t_new, const Tag& tag) { - if (ewc_ != Teuchos::null) { ewc_->commit_state(); } + if (ewc_ != Teuchos::null) { + ewc_->commit_state(); + } StrongMPC::CommitStep(t_old, t_new, tag); } @@ -297,7 +299,7 @@ int MPCSurface::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Precon application:" << std::endl; // write residuals if (vo_->os_OK(Teuchos::VERB_HIGH)) { @@ -338,7 +340,9 @@ MPCSurface::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCPViewComponent("cell", false); Epetra_MultiVector& Pu_c = *Pu->SubVector(0)->Data()->ViewComponent("cell", false); - for (unsigned int c = 0; c != Pu_c.MyLength(); ++c) { Pu_c[0][c] /= dh_dp[0][c]; } + for (unsigned int c = 0; c != Pu_c.MyLength(); ++c) { + Pu_c[0][c] /= dh_dp[0][c]; + } } } diff --git a/src/pks/mpc/mpc_surface.hh b/src/pks/mpc/mpc_surface.hh index 906f545cd..9e7ae29cd 100644 --- a/src/pks/mpc/mpc_surface.hh +++ b/src/pks/mpc/mpc_surface.hh @@ -6,14 +6,45 @@ Authors: Ethan Coon */ +/*! -/* ------------------------------------------------------------------------- -ATS +This MPC provides terms for an approximate Jacobian for coupling the two-phase +diffusion wave equation (the :ref:`Overland Flow with Ice`) to the two-phase +surface energy equation (the :ref:`Overland Energy with Ice`). -Interface for the derived MPC for coupling energy and water in the subsurface, -with freezing. +`"PK type`" = `"icy surface`" -------------------------------------------------------------------------- */ +.. _pk-icy-surface-spec: +.. admonition:: pk-icy-surface-spec + + * `"domain name`" ``[string]`` Domain of simulation + + * `"preconditioner type`" ``[string]`` **picard** See the above for detailed + descriptions of the choices. One of: `"none`", `"block diagonal`", `"no + flow coupling`", `"picard`", `"ewc`", and `"smart ewc`". Note that the + `"ewc`" preconditioners are rarely helpful in integrated problems, but may + be helpful in surface-only problems. + + * `"supress Jacobian terms: d div surface q / dT`" ``[bool]`` **false** Turn + off the Jacobian term associated with the derivative of overland + conductivity with respect to temperature. + + * `"surface ewc delegate`" ``[mpc-delegate-ewc-spec]`` A :ref:`EWC Globalization + Delegate` spec. + + KEYS + + - `"temperature`" + - `"pressure`" + - `"energy`" + - `"water content`" + - `"overland conductivity`" + - `"upwind overland conductivity`" + - `"potential`" + - `"ponded depth, negative`" + - `"water flux`" + +*/ #ifndef MPC_SURFACE_HH_ #define MPC_SURFACE_HH_ @@ -57,8 +88,8 @@ class MPCSurface : public StrongMPC { virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; // -- Apply preconditioner to u and returns the result in Pu. - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; Teuchos::RCP preconditioner() { return preconditioner_; } diff --git a/src/pks/mpc/mpc_surface_subsurface_helpers.hh b/src/pks/mpc/mpc_surface_subsurface_helpers.hh index 4ec0f8c2a..79b4ea10d 100644 --- a/src/pks/mpc/mpc_surface_subsurface_helpers.hh +++ b/src/pks/mpc/mpc_surface_subsurface_helpers.hh @@ -15,16 +15,13 @@ namespace Amanzi { -void -CopySurfaceToSubsurface(const CompositeVector& surf, CompositeVector& sub); +void CopySurfaceToSubsurface(const CompositeVector& surf, CompositeVector& sub); -void -CopySubsurfaceToSurface(const CompositeVector& sub, CompositeVector& surf); +void CopySubsurfaceToSurface(const CompositeVector& sub, CompositeVector& surf); -void -MergeSubsurfaceAndSurfacePressure(const CompositeVector& kr_surf, - CompositeVector& sub_p, - CompositeVector& surf_p); +void MergeSubsurfaceAndSurfacePressure(const CompositeVector& kr_surf, + CompositeVector& sub_p, + CompositeVector& surf_p); // // The next two helpers are getters and setters that can be used to get/set a @@ -42,7 +39,7 @@ struct DomainFaceGetter { : domain_mesh_(domain_mesh), vec_(vec) {} - template + template double get(const AmanziMesh::Entity_ID& f) { return vec_[0][f]; @@ -54,7 +51,7 @@ struct DomainFaceGetter { }; -template <> +template<> inline double DomainFaceGetter::get(const AmanziMesh::Entity_ID& f) { @@ -68,13 +65,13 @@ struct DomainFaceSetter { : domain_mesh_(domain_mesh), vec_(vec) {} - template + template double get(const AmanziMesh::Entity_ID& f) { return vec_[0][f]; } - template + template void set(const AmanziMesh::Entity_ID& f, const double& val) { vec_[0][f] = val; @@ -85,7 +82,7 @@ struct DomainFaceSetter { Epetra_MultiVector& vec_; }; -template <> +template<> inline double DomainFaceSetter::get(const AmanziMesh::Entity_ID& f) { @@ -93,7 +90,7 @@ DomainFaceSetter::get(const AmanziMesh::Entity_ID& f) return vec_[0][bf]; } -template <> +template<> inline void DomainFaceSetter::set(const AmanziMesh::Entity_ID& f, const double& val) { diff --git a/src/pks/mpc/mpc_weak_subdomain.cc b/src/pks/mpc/mpc_weak_subdomain.cc index 23079fa45..e233a85c3 100644 --- a/src/pks/mpc/mpc_weak_subdomain.cc +++ b/src/pks/mpc/mpc_weak_subdomain.cc @@ -47,8 +47,7 @@ MPCWeakSubdomain::parseParameterList() MPC::parseParameterList(); if (internal_subcycling_) { - internal_subcycling_target_dt_ = - plist_->template get("subcycling target timestep [s]"); + internal_subcycling_target_dt_ = plist_->template get("subcycling target timestep [s]"); } }; @@ -127,10 +126,8 @@ MPCWeakSubdomain::get_ds_tag_next_(const std::string& subdomain) Tag MPCWeakSubdomain::get_ds_tag_current_(const std::string& subdomain) { - if (internal_subcycling_) - return Tag(Keys::getKey(subdomain, tag_current_.get())); - else - return tag_current_; + if (internal_subcycling_) return Tag(Keys::getKey(subdomain, tag_current_.get())); + else return tag_current_; } @@ -173,10 +170,8 @@ MPCWeakSubdomain::Initialize() bool MPCWeakSubdomain::AdvanceStep(double t_old, double t_new, bool reinit) { - if (internal_subcycling_) - return AdvanceStep_InternalSubcycling_(t_old, t_new, reinit); - else - return AdvanceStep_Standard_(t_old, t_new, reinit); + if (internal_subcycling_) return AdvanceStep_InternalSubcycling_(t_old, t_new, reinit); + else return AdvanceStep_Standard_(t_old, t_new, reinit); } // ----------------------------------------------------------------------------- @@ -309,7 +304,9 @@ MPCWeakSubdomain::CommitStep(double t_old, double t_new, const Tag& tag_next) << "MPCWeakSubdomain, but not both."; Exceptions::amanzi_throw(msg); } - for (const auto& pk : sub_pks_) { pk->CommitStep(t_old, t_new, tag_next); } + for (const auto& pk : sub_pks_) { + pk->CommitStep(t_old, t_new, tag_next); + } } diff --git a/src/pks/mpc/mpc_weak_subdomain.hh b/src/pks/mpc/mpc_weak_subdomain.hh index c7847fc4c..81b898f8f 100644 --- a/src/pks/mpc/mpc_weak_subdomain.hh +++ b/src/pks/mpc/mpc_weak_subdomain.hh @@ -7,12 +7,33 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Weak MPC for subdomain model MPCs. /*! - A weak MPC that couples the same PK across many subdomains. Note that this - means that the number of PKs is not known a priori -- it depends on a domain - set. +A weak MPC that couples the same PK across many subdomains. Note that this +means that the number of PKs is not known a priori -- it depends on a domain +set. It may also subcycle all or none of its child PKs. + +`"PK type`" = `"domain set weak MPC`" + +.. _pk-domain-set-weak-mpc-spec: +.. admonition:: pk-domain-set-weak-mpc-spec + + IF + + * `"subcycle`" ``[bool]`` **false** Subcycle the sub PKs or not. + + THEN + + * `"subcycling target timestep [s]`" ``[double]`` timestep over which to + syncronize the sub PKs. + + END + + INCLUDES + + - ``[mpc-spec]`` *Is a* MPC_. + + */ diff --git a/src/pks/mpc/strong_mpc.hh b/src/pks/mpc/strong_mpc.hh index 4e3cb5987..4b08f2ffa 100644 --- a/src/pks/mpc/strong_mpc.hh +++ b/src/pks/mpc/strong_mpc.hh @@ -7,18 +7,22 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Multi process coupler for globally implicit (strong) coupling. /*! -Globally implicit coupling solves all sub-PKs as a single system of equations. This can be completely automated when all PKs are also `PK: BDF`_ PKs, using a block-diagonal preconditioner where each diagonal block is provided by its own sub-PK. +Globally implicit coupling solves all sub-PKs as a single system of equations. +This can be completely automated when all PKs are also :ref:`PK: BDF` PKs, +using a block-diagonal preconditioner where each diagonal block is provided by +its own sub-PK. -.. _strong-mpc-spec: -.. admonition:: strong-mpc-spec +`"PK type`" = `"strong MPC`" - INCLUDES: +.. _pk-strong-mpc-spec: +.. admonition:: pk-strong-mpc-spec - - ``[mpc-spec]`` *Is a* MPC_. - - ``[pk-bdf-default-spec]`` *Is a* `PK: BDF`_. + INCLUDES: + + - ``[mpc-spec]`` *Is a* :ref:`MPC`. + - ``[pk-bdf-default-spec]`` *Is a* :ref:`PK: BDF`. */ @@ -34,8 +38,10 @@ namespace Amanzi { // note this looks odd, but StrongMPC is both a MPC within a hierarchy of BDF // PKs, but it also IS a BDF PK itself, in that it implements the BDF // interface and can be implicitly integrated. -template -class StrongMPC : public MPC, public PK_BDF_Default { +template +class StrongMPC + : public MPC + , public PK_BDF_Default { public: StrongMPC(Teuchos::ParameterList& pk_list, const Teuchos::RCP& global_plist, @@ -67,14 +73,14 @@ class StrongMPC : public MPC, public PK_BDF_Default { Teuchos::RCP g) override; // -- enorm for the coupled system - virtual double - ErrorNorm(Teuchos::RCP u, Teuchos::RCP du) override; + virtual double ErrorNorm(Teuchos::RCP u, + Teuchos::RCP du) override; // StrongMPC's preconditioner is, by default, just the block-diagonal // operator formed by placing the sub PK's preconditioners on the diagonal. // -- Apply preconditioner to u and returns the result in Pu. - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; // -- Update the preconditioner. virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; @@ -93,15 +99,16 @@ class StrongMPC : public MPC, public PK_BDF_Default { virtual bool IsValid(const Teuchos::RCP& u) override; // -- Modify the predictor. - virtual bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + virtual bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; // -- Modify the correction. - virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult - ModifyCorrection(double h, - Teuchos::RCP res, - Teuchos::RCP u, - Teuchos::RCP du) override; + virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult ModifyCorrection( + double h, + Teuchos::RCP res, + Teuchos::RCP u, + Teuchos::RCP du) override; protected: using MPC::sub_pks_; @@ -121,7 +128,7 @@ class StrongMPC : public MPC, public PK_BDF_Default { // ----------------------------------------------------------------------------- // Constructor // ----------------------------------------------------------------------------- -template +template StrongMPC::StrongMPC(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& global_list, const Teuchos::RCP& S, @@ -134,8 +141,7 @@ StrongMPC::StrongMPC(Teuchos::ParameterList& pk_tree, } - -template +template void StrongMPC::parseParameterList() { @@ -153,7 +159,7 @@ StrongMPC::parseParameterList() // ----------------------------------------------------------------------------- // Setup // ----------------------------------------------------------------------------- -template +template void StrongMPC::Setup() { @@ -173,7 +179,7 @@ StrongMPC::Setup() // Required unique initialize(), just calls both of its base class // initialize() methods. // ----------------------------------------------------------------------------- -template +template void StrongMPC::Initialize() { @@ -193,7 +199,7 @@ StrongMPC::Initialize() // ----------------------------------------------------------------------------- // Calls both parts // ----------------------------------------------------------------------------- -template +template void StrongMPC::CommitStep(double t_old, double t_new, const Tag& tag) { @@ -201,7 +207,7 @@ StrongMPC::CommitStep(double t_old, double t_new, const Tag& tag) PK_BDF_Default::CommitStep(t_old, t_new, tag); } -template +template void StrongMPC::FailStep(double t_old, double t_new, const Tag& tag) { @@ -213,7 +219,7 @@ StrongMPC::FailStep(double t_old, double t_new, const Tag& tag) // ----------------------------------------------------------------------------- // Compute the non-linear functional g = g(t,u,udot). // ----------------------------------------------------------------------------- -template +template void StrongMPC::FunctionalResidual(double t_old, double t_new, @@ -258,7 +264,7 @@ StrongMPC::FunctionalResidual(double t_old, // ----------------------------------------------------------------------------- // Applies preconditioner to u and returns the result in Pu. // ----------------------------------------------------------------------------- -template +template int StrongMPC::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) { @@ -291,7 +297,7 @@ StrongMPC::ApplyPreconditioner(Teuchos::RCP u, Teuchos:: // Compute a norm on u-du and returns the result. // For a Strong MPC, the enorm is just the max of the sub PKs enorms. // ----------------------------------------------------------------------------- -template +template double StrongMPC::ErrorNorm(Teuchos::RCP u, Teuchos::RCP du) { @@ -324,7 +330,7 @@ StrongMPC::ErrorNorm(Teuchos::RCP u, Teuchos::RCP +template void StrongMPC::UpdatePreconditioner(double t, Teuchos::RCP up, double h) { @@ -349,7 +355,7 @@ StrongMPC::UpdatePreconditioner(double t, Teuchos::RCP u // Experimental approach -- calling this indicates that the time integration // scheme is changing the value of the solution in state. // ----------------------------------------------------------------------------- -template +template void StrongMPC::ChangedSolution(const Tag& tag) { @@ -362,7 +368,7 @@ StrongMPC::ChangedSolution(const Tag& tag) // Calling this indicates that the time integration scheme is changing // the value of the solution in state. // ----------------------------------------------------------------------------- -template +template void StrongMPC::ChangedSolution() { @@ -373,7 +379,7 @@ StrongMPC::ChangedSolution() // ----------------------------------------------------------------------------- // Check admissibility of each sub-pk // ----------------------------------------------------------------------------- -template +template bool StrongMPC::IsAdmissible(Teuchos::RCP u) { @@ -398,7 +404,7 @@ StrongMPC::IsAdmissible(Teuchos::RCP u) // ----------------------------------------------------------------------------- // Check validity of each sub-pk // ----------------------------------------------------------------------------- -template +template bool StrongMPC::IsValid(const Teuchos::RCP& u) { @@ -423,7 +429,7 @@ StrongMPC::IsValid(const Teuchos::RCP& u) // ----------------------------------------------------------------------------- // Modify predictor from each sub pk. // ----------------------------------------------------------------------------- -template +template bool StrongMPC::ModifyPredictor(double h, Teuchos::RCP u0, @@ -449,7 +455,7 @@ StrongMPC::ModifyPredictor(double h, // ----------------------------------------------------------------------------- // Modify correction from each sub pk. // ----------------------------------------------------------------------------- -template +template AmanziSolvers::FnBaseDefs::ModifyCorrectionResult StrongMPC::ModifyCorrection(double h, Teuchos::RCP res, diff --git a/src/pks/mpc/strong_mpc_reg.hh b/src/pks/mpc/strong_mpc_reg.hh index a034f1ee8..27a0053ab 100644 --- a/src/pks/mpc/strong_mpc_reg.hh +++ b/src/pks/mpc/strong_mpc_reg.hh @@ -25,7 +25,7 @@ See additional documentation in the base class src/pks/mpc/MPC.hh namespace Amanzi { -template <> +template<> RegisteredPKFactory> StrongMPC::reg_("strong MPC"); } // namespace Amanzi diff --git a/src/pks/mpc/weak_mpc.hh b/src/pks/mpc/weak_mpc.hh index 552114335..cd6fd013b 100644 --- a/src/pks/mpc/weak_mpc.hh +++ b/src/pks/mpc/weak_mpc.hh @@ -7,18 +7,19 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Multi process coupler for sequential coupling. /*! Noniterative sequential coupling simply calls each PK's AdvanceStep() method in order. -.. _weak-mpc-spec: -.. admonition:: weak-mpc-spec +`"PK type`" = `"weak MPC`" - INCLUDES: +.. _pk-weak-mpc-spec: +.. admonition:: pk-weak-mpc-spec - - ``[mpc-spec]`` *Is a* MPC_. + INCLUDES: + + - ``[mpc-spec]`` *Is a* :ref:`MPC`. */ diff --git a/src/pks/pk_bdf_default.cc b/src/pks/pk_bdf_default.cc index 7986e5157..b414edc77 100644 --- a/src/pks/pk_bdf_default.cc +++ b/src/pks/pk_bdf_default.cc @@ -15,9 +15,11 @@ BDF. ------------------------------------------------------------------------- */ #include "Teuchos_TimeMonitor.hpp" + +#include "Event.hh" +#include "State.hh" #include "BDF1_TI.hh" #include "pk_bdf_default.hh" -#include "State.hh" namespace Amanzi { @@ -39,7 +41,8 @@ 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(Keys::cleanName(name_, true) + "_continuation_parameter", Tags::DEFAULT, name_); + S_->Require( + Keys::cleanName(name_, true) + "_continuation_parameter", Tags::DEFAULT, name_); } } }; @@ -68,8 +71,8 @@ PK_BDF_Default::Initialize() // solution space is not known until after Setup() is complete. // -- construct the time integrator Teuchos::ParameterList& bdf_plist = plist_->sublist("time integrator"); - time_stepper_ = - Teuchos::rcp(new BDF1_TI(name()+"_TI", bdf_plist, *this, solution_->get_map(), S_)); + time_stepper_ = Teuchos::rcp(new BDF1_TI( + name() + "_TI", bdf_plist, *this, solution_->get_map(), S_)); // -- set initial state time_stepper_->SetInitialState(S_->get_time(), solution_, solution_dot); @@ -117,10 +120,11 @@ PK_BDF_Default::AdvanceStep(double t_old, double t_new, bool reinit) if (vo_->os_OK(Teuchos::VERB_LOW)) *vo_->os() << "----------------------------------------------------------------" << std::endl - << "Advancing: t0 = " << S_->get_time(tag_current_) - << " t1 = " << S_->get_time(tag_next_) << " h = " << dt << std::endl + << "Advancing: t0 = " << t_old << " t1 = " << t_new << " h = " << dt << std::endl << "----------------------------------------------------------------" << std::endl; + AMANZI_ASSERT(std::abs(S_->get_time(tag_current_) - t_old) < 1.e-4); + AMANZI_ASSERT(std::abs(S_->get_time(tag_next_) - t_new) < 1.e-4); State_to_Solution(Tags::NEXT, *solution_); // take a bdf timestep @@ -147,7 +151,8 @@ PK_BDF_Default::AdvanceStep(double t_old, double t_new, bool reinit) void PK_BDF_Default::UpdateContinuationParameter(double lambda) { - S_->Assign(Keys::cleanName(name_, true) + "_continuation_parameter", Tags::DEFAULT, name_, lambda); + S_->Assign( + Keys::cleanName(name_, true) + "_continuation_parameter", Tags::DEFAULT, name_, lambda); ChangedSolution(); } diff --git a/src/pks/pk_bdf_default.hh b/src/pks/pk_bdf_default.hh index a31de4d13..71dc1f66d 100644 --- a/src/pks/pk_bdf_default.hh +++ b/src/pks/pk_bdf_default.hh @@ -6,33 +6,35 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! A base class with default implementations of methods for a PK that can be implicitly integrated in time. /*! -`PKBDFBase` is a base class from which PKs that want to use the `BDF` -series of implicit time integrators must derive. It specifies both the -`BDFFnBase` interface and implements some basic functionality for `BDF` -PKs. +A BDF or Backward Difference Formula a process kernel that is integrated in +time using an "implicit" or "backwards difference" method. Both Physical PKs +and MPCs may be BDF PKs -- when an MPC is integrated using a BDF method we say +it is coupled through a "globally implicit" method (as opposed to sequential or +operator split method). .. _pk-bdf-default-spec: .. admonition:: pk-bdf-default-spec - * `"initial timestep [s]`" ``[double]`` **1.** Initial timestep size [s] + * `"initial timestep [s]`" ``[double]`` **1.** Initial timestep size used + for the first timestep. After this, the `"timestep controller`" may + change the step size. - * `"assemble preconditioner`" ``[bool]`` **true** A flag, typically not set - by user but by an MPC. + * `"time integrator`" ``[bdf1-ti-spec]`` **optional** + A TimeIntegrator_. Note that this is only required if this PK is not + strongly coupled to other PKs. - * `"time integrator`" ``[bdf1-ti-spec]`` **optional** - A TimeIntegrator_. Note that this is only required if this PK is not - strongly coupled to other PKs. + * `"assemble preconditioner`" ``[bool]`` **true** A flag, typically not set + by user but by an MPC. - * `"inverse`" ``[inverse-typed-spec]`` **optional** A Preconditioner_. - Note that this is only used if this PK is not strongly coupled to other PKs. + * `"inverse`" ``[inverse-typed-spec]`` **optional** A :ref:`Linear Solver` + or :ref:`Preconditioner` provided as an :ref:`Inverse`. Note that this is + only used if this PK is not strongly coupled to other PKs. - INCLUDES: + INCLUDES: - - ``[pk-spec]`` This *is a* PK_. + - ``[pk-spec]`` This *is a* PK_. */ @@ -56,9 +58,7 @@ class PK_BDF_Default : public PK_BDF { const Teuchos::RCP& glist, const Teuchos::RCP& S, const Teuchos::RCP& solution) - : PK(pk_tree, glist, S, solution), - PK_BDF(pk_tree, glist, S, solution), - dt_next_(-1.0) + : PK(pk_tree, glist, S, solution), PK_BDF(pk_tree, glist, S, solution), dt_next_(-1.0) {} // Virtual destructor @@ -90,18 +90,19 @@ class PK_BDF_Default : public PK_BDF { // -- Possibly modify the predictor that is going to be used as a // starting value for the nonlinear solve in the time integrator. - virtual bool - ModifyPredictor(double h, Teuchos::RCP up, Teuchos::RCP u) override + virtual bool ModifyPredictor(double h, + Teuchos::RCP up, + Teuchos::RCP u) override { return false; } // -- Possibly modify the correction before it is applied - virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult - ModifyCorrection(double h, - Teuchos::RCP res, - Teuchos::RCP u, - Teuchos::RCP du) override + virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult ModifyCorrection( + double h, + Teuchos::RCP res, + Teuchos::RCP u, + Teuchos::RCP du) override { return AmanziSolvers::FnBaseDefs::CORRECTION_NOT_MODIFIED; } diff --git a/src/pks/pk_explicit_default.hh b/src/pks/pk_explicit_default.hh index a1b720e2f..10696cde1 100644 --- a/src/pks/pk_explicit_default.hh +++ b/src/pks/pk_explicit_default.hh @@ -36,7 +36,7 @@ class PK_Explicit_Default : public PK_Explicit { {} // Virtual destructor - virtual ~PK_Explicit_Default(){}; + virtual ~PK_Explicit_Default() {}; // Default implementations of PK methods. // -- setup diff --git a/src/pks/pk_factory.hh b/src/pks/pk_factory.hh deleted file mode 100644 index f3586e182..000000000 --- a/src/pks/pk_factory.hh +++ /dev/null @@ -1,119 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: Ethan Coon -*/ - -/* ------------------------------------------------------------------------- - - ATS - - PK factory for self-registering PKs. - - See a more thorough factory discussion in $ATS_DIR/src/factory/factory.hh. - - Simplest usage: - - // pk_implementation.hh - #include "pk.hh" - class DerivedPK : public PK { - DerivedPK(Teuchos::ParameterList& plist, - const Teuchos::RCP& solution); - ... - private: - static RegisteredPKFactory factory_; // my factory entry - ... - }; - - ------------------------------------------------------------------------- */ - -#ifndef ATS_PK_FACTORY_HH_ -#define ATS_PK_FACTORY_HH_ - -#include -#include -#include -#include "Teuchos_ParameterList.hpp" -#include "Teuchos_RCP.hpp" - -#include "errors.hh" -#include "TreeVector.hh" -#include "PK.hh" - -namespace Amanzi { - -class PKFactory { - public: - typedef std::map S, - const Teuchos::RCP&, - Teuchos::ParameterList&, - const Teuchos::RCP&)> - map_type; - - static Teuchos::RCP CreatePK(Teuchos::Ptr S, - const Teuchos::RCP& plist, - Teuchos::ParameterList& FElist, - const Teuchos::RCP& soln) - { - std::string s = plist->get("PK type"); - map_type::iterator iter = GetMap()->find(s); - if (iter == GetMap()->end()) { - std::stringstream errmsg; - errmsg << "PK Factory: cannot find PK type \"" << s << "\""; - for (map_type::iterator iter = GetMap()->begin(); iter != GetMap()->end(); ++iter) { - errmsg << std::endl << " option: " << iter->first; - } - Errors::Message message(errmsg.str()); - Exceptions::amanzi_throw(message); - } - - return Teuchos::rcp(iter->second(S, plist, FElist, soln)); - } - - protected: - static map_type* GetMap() - { - if (!map_) { map_ = new map_type; } - return map_; - } - - private: - static map_type* map_; -}; - - -template -PK* -CreateT(Teuchos::Ptr S, - const Teuchos::RCP& plist, - Teuchos::ParameterList& FElist, - const Teuchos::RCP& soln) -{ - return new T(S, plist, FElist, soln); -} - - -template -class RegisteredPKFactory : public PKFactory { - public: - // Constructor for the registered factory. Needs some error checking in - // case a name s is already in the map? (i.e. two implementations trying to - // call themselves the same thing) --etc - RegisteredPKFactory(const std::string& s) - { - GetMap()->insert(std::pair, - const Teuchos::RCP&, - Teuchos::ParameterList&, - const Teuchos::RCP&)>(s, &CreateT)); - } -}; - -} // namespace Amanzi - -#endif diff --git a/src/pks/pk_helpers.cc b/src/pks/pk_helpers.cc deleted file mode 100644 index 8dd5e6f59..000000000 --- a/src/pks/pk_helpers.cc +++ /dev/null @@ -1,341 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: Ethan Coon (ecoon@ornl.gov) -*/ - -//! A set of helper functions for doing common things in PKs. -#include "MeshAlgorithms.hh" -#include "Chemistry_PK.hh" -#include "pk_helpers.hh" - -namespace Amanzi { - -bool -aliasVector(State& S, const Key& key, const Tag& target, const Tag& alias) -{ - if (S.HasEvaluator(key, target) && !S.HasEvaluator(key, alias)) { - S.SetEvaluator(key, alias, S.GetEvaluatorPtr(key, target)); - S.GetRecordSetW(key).AliasRecord(target, alias); - return true; - } - return false; -} - - -// ----------------------------------------------------------------------------- -// Given a vector, apply the Dirichlet data to that vector. -// ----------------------------------------------------------------------------- -void -applyDirichletBCs(const Operators::BCs& bcs, CompositeVector& u) -{ - if (u.HasComponent("face")) { - Epetra_MultiVector& u_f = *u.ViewComponent("face", false); - for (unsigned int f = 0; f != u_f.MyLength(); ++f) { - if (bcs.bc_model()[f] == Operators::OPERATOR_BC_DIRICHLET) { u_f[0][f] = bcs.bc_value()[f]; } - } - - } else if (u.HasComponent("boundary_face")) { - Epetra_MultiVector& u_bf = *u.ViewComponent("boundary_face", false); - const Epetra_MultiVector& u_c = *u.ViewComponent("cell", false); - const Epetra_Map& vandalay_map = - u.Mesh()->getMap(AmanziMesh::Entity_kind::BOUNDARY_FACE, false); - const Epetra_Map& face_map = u.Mesh()->getMap(AmanziMesh::Entity_kind::FACE, false); - - for (int bf = 0; bf != u_bf.MyLength(); ++bf) { - AmanziMesh::Entity_ID f = face_map.LID(vandalay_map.GID(bf)); - if (bcs.bc_model()[f] == Operators::OPERATOR_BC_DIRICHLET) { - u_bf[0][bf] = bcs.bc_value()[f]; - } - } - } -} - - -// ----------------------------------------------------------------------------- -// Given a vector and a face ID, get the value at that location. -// -// Looks in the following order: -// -- face component -// -- boundary Dirichlet data -// -- boundary_face value -// -- internal cell -// ----------------------------------------------------------------------------- -double -getFaceOnBoundaryValue(AmanziMesh::Entity_ID f, const CompositeVector& u, const Operators::BCs& bcs) -{ - if (u.HasComponent("face")) { - return (*u.ViewComponent("face", false))[0][f]; - } else if (bcs.bc_model()[f] == Operators::OPERATOR_BC_DIRICHLET) { - return bcs.bc_value()[f]; - // } else if (u.HasComponent("boundary_face")) { - // AmanziMesh::Entity_ID bf = getFaceOnBoundaryBoundaryFace(*u.Mesh(), f); - // return (*u.ViewComponent("boundary_face",false))[0][bf]; - } else { - auto c = getFaceOnBoundaryInternalCell(*u.Mesh(), f); - return (*u.ViewComponent("cell", false))[0][c]; - } - return -1; -} - - -// ----------------------------------------------------------------------------- -// Get the directional int for a face that is on the boundary. -// ----------------------------------------------------------------------------- -int -getBoundaryDirection(const AmanziMesh::Mesh& mesh, AmanziMesh::Entity_ID f) -{ - auto cells = mesh.getFaceCells(f); - AMANZI_ASSERT(cells.size() == 1); - const auto& [faces, dirs] = mesh.getCellFacesAndDirections(cells[0]); - return dirs[std::find(faces.begin(), faces.end(), f) - faces.begin()]; -} - - -// ----------------------------------------------------------------------------- -// Get a primary variable evaluator for a key at tag -// ----------------------------------------------------------------------------- -Teuchos::RCP -requireEvaluatorPrimary(const Key& key, const Tag& tag, State& S, bool or_die) -{ - // first check, is there one already - if (S.HasEvaluator(key, tag)) { - // if so, make sure it is primary - Teuchos::RCP eval = S.GetEvaluatorPtr(key, tag); - Teuchos::RCP eval_pv = Teuchos::rcp_dynamic_cast(eval); - if (or_die && eval_pv == Teuchos::null) { - Errors::Message msg; - msg << "Expected primary variable evaluator for " << key << " @ " << tag.get(); - Exceptions::amanzi_throw(msg); - } - return eval_pv; - } - - // if not, create one, only at this tag, not to be shared across tags. By - // this, we mean we don't stick the "type" = "primary" back into the - // evaluator list -- this allows "copy evaluators" e.g. "water content at the - // old tag" to differ from the standard evalulator, e.g. "water content at - // the new tag" which is likely a secondary variable evaluator. - Teuchos::ParameterList plist(key); - plist.set("evaluator type", "primary variable"); - plist.set("tag", tag.get()); - auto eval_pv = Teuchos::rcp(new EvaluatorPrimaryCV(plist)); - S.SetEvaluator(key, tag, eval_pv); - return eval_pv; -} - - -// ----------------------------------------------------------------------------- -// Marks a primary evaluator as changed. -// ----------------------------------------------------------------------------- -bool -changedEvaluatorPrimary(const Key& key, const Tag& tag, State& S, bool or_die) -{ - bool changed = false; - Teuchos::RCP eval = S.GetEvaluatorPtr(key, tag); - Teuchos::RCP eval_pv = Teuchos::rcp_dynamic_cast(eval); - if (eval_pv == Teuchos::null) { - if (or_die) { - Errors::Message msg; - msg << "Expected primary variable evaluator for " << key << " @ " << tag.get(); - Exceptions::amanzi_throw(msg); - } - } else { - eval_pv->SetChanged(); - changed = true; - } - return changed; -} - - -// ----------------------------------------------------------------------------- -// Require a vector and a primary variable evaluator at current tag(s). -// ----------------------------------------------------------------------------- -CompositeVectorSpace& -requireAtCurrent(const Key& key, const Tag& tag, State& S, const Key& name, bool is_eval) -{ - CompositeVectorSpace& cvs = S.Require(key, tag); - if (!name.empty()) { - Key owner = S.GetRecord(key, tag).owner(); - if (owner.empty()) { - S.Require(key, tag, name); - if (is_eval) requireEvaluatorAssign(key, tag, S); - } - - if (tag != Tags::CURRENT) { - S.Require(key, Tags::CURRENT); - Key current_owner = S.GetRecord(key, Tags::CURRENT).owner(); - if (owner.empty()) { - S.Require(key, Tags::CURRENT, name); - if (is_eval) requireEvaluatorAssign(key, Tags::CURRENT, S); - } - } - } else { - if (is_eval) S.RequireEvaluator(key, tag); - } - return cvs; -} - - -// ----------------------------------------------------------------------------- -// Require a vector and a primary variable evaluator at next tag(s). -// ----------------------------------------------------------------------------- -CompositeVectorSpace& -requireAtNext(const Key& key, const Tag& tag, State& S, const Key& name) -{ - CompositeVectorSpace& cvs = S.Require(key, tag); - if (!name.empty()) { - S.Require(key, tag, name); - requireEvaluatorPrimary(key, tag, S); - } else { - S.RequireEvaluator(key, tag); - } - - if (tag != Tags::NEXT) { aliasVector(S, key, tag, Tags::NEXT); } - return cvs; -} - - -// ----------------------------------------------------------------------------- -// Require assignment evaluator, which allows tracking old data. -// ----------------------------------------------------------------------------- -Teuchos::RCP -requireEvaluatorAssign(const Key& key, const Tag& tag, State& S) -{ - // in the future, this will likely derive from primary instead of just being - // primary. This will allow confirming that the times are the same. - return requireEvaluatorPrimary(key, tag, S, false); -} - -// ----------------------------------------------------------------------------- -// Assign if it is an assignment evaluator. -// ----------------------------------------------------------------------------- -void -assign(const Key& key, const Tag& tag_dest, const Tag& tag_source, State& S) -{ - S.GetEvaluator(key, tag_source).Update(S, Keys::getKey(key, tag_dest)); - bool changed = changedEvaluatorPrimary(key, tag_dest, S, false); - if (changed) S.Assign(key, tag_dest, tag_source); -} - - -// ----------------------------------------------------------------------------- -// Helper functions for working with Amanzi's Chemistry PK -// ----------------------------------------------------------------------------- -void -convertConcentrationToAmanzi(const Epetra_MultiVector& mol_dens, - int num_aqueous, - const Epetra_MultiVector& tcc_ats, - Epetra_MultiVector& tcc_amanzi) -{ - // convert from mole fraction [mol C / mol H20] to [mol C / L] - for (int k = 0; k != num_aqueous; ++k) { - for (int c = 0; c != tcc_ats.MyLength(); ++c) { - // 1.e-3 converts L to m^3 - tcc_amanzi[k][c] = tcc_ats[k][c] * mol_dens[0][c] * 1.e-3; - } - } -} - - -void -convertConcentrationToATS(const Epetra_MultiVector& mol_dens, - int num_aqueous, - const Epetra_MultiVector& tcc_amanzi, - Epetra_MultiVector& tcc_ats) -{ - // convert from [mol C / L] to mol fraction [mol C / mol H20] - for (int k = 0; k != num_aqueous; ++k) { - for (int c = 0; c != tcc_amanzi.MyLength(); ++c) { - tcc_ats[k][c] = tcc_amanzi[k][c] / (mol_dens[0][c] * 1.e-3); - } - } -} - - -bool -advanceChemistry(Teuchos::RCP chem_pk, - double t_old, - double t_new, - bool reinit, - const Epetra_MultiVector& mol_dens, - Teuchos::RCP tcc, - Teuchos::Time& timer) -{ - bool fail = false; - int num_aqueous = chem_pk->num_aqueous_components(); - convertConcentrationToAmanzi(mol_dens, num_aqueous, *tcc, *tcc); - chem_pk->set_aqueous_components(tcc); - - { - auto monitor = Teuchos::rcp(new Teuchos::TimeMonitor(timer)); - fail = chem_pk->AdvanceStep(t_old, t_new, reinit); - } - if (fail) return fail; - - *tcc = *chem_pk->aqueous_components(); - convertConcentrationToATS(mol_dens, num_aqueous, *tcc, *tcc); - return fail; -} - - -void -copyMeshCoordinatesToVector(const AmanziMesh::Mesh& mesh, CompositeVector& vec) -{ - Epetra_MultiVector& nodes = *vec.ViewComponent("node", true); - - int ndim = mesh.getSpaceDimension(); - AmanziGeometry::Point nc; - for (int i = 0; i != nodes.MyLength(); ++i) { - nc = mesh.getNodeCoordinate(i); - for (int j = 0; j != ndim; ++j) nodes[j][i] = nc[j]; - } -} - -void -copyVectorToMeshCoordinates(const CompositeVector& vec, AmanziMesh::Mesh& mesh) -{ - const Epetra_MultiVector& nodes = *vec.ViewComponent("node", true); - int ndim = mesh.getSpaceDimension(); - - Amanzi::AmanziMesh::Entity_ID_View node_ids("node_ids", nodes.MyLength()); - Amanzi::AmanziMesh::Point_View new_positions("new_positions", nodes.MyLength()); - for (int n = 0; n != nodes.MyLength(); ++n) { - node_ids[n] = n; - if (mesh.getSpaceDimension() == 2) { - new_positions[n] = Amanzi::AmanziGeometry::Point{ nodes[0][n], nodes[1][n] }; - } else { - new_positions[n] = Amanzi::AmanziGeometry::Point{ nodes[0][n], nodes[1][n], nodes[2][n] }; - } - } - Amanzi::AmanziMesh::deform(mesh, node_ids, new_positions); -} - -int -commMaxValLoc(const Comm_type& comm, const ValLoc& local, ValLoc& global) -{ - MpiComm_type const* mpi_comm = dynamic_cast(&comm); - const MPI_Comm& mpi_comm_raw = mpi_comm->Comm(); - return MPI_Allreduce(&local, &global, 1, MPI_DOUBLE_INT, MPI_MAXLOC, mpi_comm_raw); -} - -ValLoc -maxValLoc(const Epetra_Vector& vec) -{ - ValLoc local{ 0., 0 }; - for (int i = 0; i != vec.MyLength(); ++i) { - if (vec[i] > local.value) { - local.value = vec[i]; - local.gid = vec.Map().GID(i); - } - } - ValLoc global{ 0., 0 }; - int ierr = commMaxValLoc(vec.Comm(), local, global); - AMANZI_ASSERT(!ierr); - return global; -} - -} // namespace Amanzi diff --git a/src/pks/pk_helpers.hh b/src/pks/pk_helpers.hh deleted file mode 100644 index fcc7a26e2..000000000 --- a/src/pks/pk_helpers.hh +++ /dev/null @@ -1,144 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: Ethan Coon (ecoon@ornl.gov) -*/ - -//! A set of helper functions for doing common things in PKs. -#pragma once - -#include "Teuchos_TimeMonitor.hpp" - -#include "Mesh.hh" -#include "CompositeVector.hh" -#include "BCs.hh" - -#include "EvaluatorPrimary.hh" -#include "State.hh" -#include "Chemistry_PK.hh" - -namespace Amanzi { - -bool -aliasVector(State& S, const Key& key, const Tag& target, const Tag& alias); - -// ----------------------------------------------------------------------------- -// Given a vector, apply the Dirichlet data to that vector's boundary_face -// component. -// ----------------------------------------------------------------------------- -void -applyDirichletBCs(const Operators::BCs& bcs, CompositeVector& u); - - -// ----------------------------------------------------------------------------- -// Given a vector and a face ID, get the value at that location. -// -// Looks in the following order: -// -- face component -// -- boundary Dirichlet data -// -- boundary_face value (currently not used -- fix me --etc) -// -- internal cell -// ----------------------------------------------------------------------------- -double -getFaceOnBoundaryValue(AmanziMesh::Entity_ID f, - const CompositeVector& u, - const Operators::BCs& bcs); - - -// ----------------------------------------------------------------------------- -// Get the directional int for a face that is on the boundary. -// ----------------------------------------------------------------------------- -int -getBoundaryDirection(const AmanziMesh::Mesh& mesh, AmanziMesh::Entity_ID f); - - -// ----------------------------------------------------------------------------- -// Get a primary variable evaluator for a key at tag -// ----------------------------------------------------------------------------- -Teuchos::RCP -requireEvaluatorPrimary(const Key& key, const Tag& tag, State& S, bool or_die = true); - - -// ----------------------------------------------------------------------------- -// Mark primary variable evaluator as changed. -// ----------------------------------------------------------------------------- -bool -changedEvaluatorPrimary(const Key& key, const Tag& tag, State& S, bool or_die = true); - - -// ----------------------------------------------------------------------------- -// Require a vector and a primary variable evaluator at current tag(s). -// ----------------------------------------------------------------------------- -CompositeVectorSpace& -requireAtCurrent(const Key& key, - const Tag& tag, - State& S, - const Key& name = "", - bool is_eval = true); - - -// ----------------------------------------------------------------------------- -// Require a vector and a primary variable evaluator at next tag(s). -// ----------------------------------------------------------------------------- -CompositeVectorSpace& -requireAtNext(const Key& key, const Tag& tag, State& S, const Key& name = ""); - -// ----------------------------------------------------------------------------- -// Require assignment evaluator, which allows tracking old data. -// ----------------------------------------------------------------------------- -Teuchos::RCP -requireEvaluatorAssign(const Key& key, const Tag& tag, State& S); - -// ----------------------------------------------------------------------------- -// Assign if it is an assignment evaluator. -// ----------------------------------------------------------------------------- -void -assign(const Key& key, const Tag& tag_dest, const Tag& tag_source, State& S); - - -// ----------------------------------------------------------------------------- -// Helper functions for working with Amanzi's Chemistry PK -// ----------------------------------------------------------------------------- -void -convertConcentrationToAmanzi(const Epetra_MultiVector& mol_den, - int num_aqueous, - const Epetra_MultiVector& tcc_ats, - Epetra_MultiVector& tcc_amanzi); - -void -convertConcentrationToATS(const Epetra_MultiVector& mol_den, - int num_aqueous, - const Epetra_MultiVector& tcc_ats, - Epetra_MultiVector& tcc_amanzi); - -bool -advanceChemistry(Teuchos::RCP chem_pk, - double t_old, - double t_new, - bool reinit, - const Epetra_MultiVector& mol_dens, - Teuchos::RCP tcc, - Teuchos::Time& timer); - - -void -copyMeshCoordinatesToVector(const AmanziMesh::Mesh& mesh, CompositeVector& vec); -void -copyVectorToMeshCoordinates(const CompositeVector& vec, AmanziMesh::Mesh& mesh); - - -// Compute pairs of value + location -typedef struct ValLoc { - double value; - AmanziMesh::Entity_ID gid; -} ENorm_t; - -int -commMaxValLoc(const Comm_type& comm, const ValLoc& local, ValLoc& global); -ValLoc -maxValLoc(const Epetra_Vector& vec); - -} // namespace Amanzi diff --git a/src/pks/pk_physical_bdf_default.cc b/src/pks/pk_physical_bdf_default.cc index 9edabf57a..abb111d6f 100644 --- a/src/pks/pk_physical_bdf_default.cc +++ b/src/pks/pk_physical_bdf_default.cc @@ -14,7 +14,9 @@ Standard base for most PKs, this combines both domains/meshes of PKPhysicalBase and BDF methods of PK_BDF_Default. ------------------------------------------------------------------------- */ -#include "pk_helpers.hh" +#include "AmanziComm.hh" +#include "Reductions.hh" +#include "PK_Helpers.hh" #include "pk_physical_bdf_default.hh" namespace Amanzi { @@ -28,6 +30,8 @@ PK_PhysicalBDF_Default::parseParameterList() max_valid_change_ = plist_->get("max valid change", -1.0); conserved_key_ = Keys::readKey(*plist_, domain_, "conserved quantity"); + requireEvaluatorAtCurrent(conserved_key_, tag_current_, *S_, name_); + atol_ = plist_->get("absolute error tolerance", 1.0); rtol_ = plist_->get("relative error tolerance", 1.0); fluxtol_ = plist_->get("flux error tolerance", 1.0); @@ -50,15 +54,15 @@ PK_PhysicalBDF_Default::Setup() new Operators::BCs(mesh_, AmanziMesh::Entity_kind::FACE, WhetStone::DOF_Type::SCALAR)); // convergence criteria is based on a conserved quantity - requireAtNext(conserved_key_, tag_next_, *S_) + requireEvaluatorAtNext(conserved_key_, tag_next_, *S_, true) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, true); // we also use a copy of the conserved quantity, as this is a better choice in the error norm - requireAtCurrent(conserved_key_, tag_current_, *S_, name_, true); + requireEvaluatorAtCurrent(conserved_key_, tag_current_, *S_, name_); // cell volume used throughout - requireAtNext(cell_vol_key_, tag_next_, *S_) + requireEvaluatorAtNext(cell_vol_key_, tag_next_, *S_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, true); }; @@ -112,15 +116,9 @@ PK_PhysicalBDF_Default::ErrorNorm(Teuchos::RCP u, Teuchos::RCP dvec = res->Data(); double h = S_->get_time(tag_next_) - S_->get_time(tag_current_); - Teuchos::RCP comm_p = mesh_->getComm(); - Teuchos::RCP mpi_comm_p = - Teuchos::rcp_dynamic_cast(comm_p); - const MPI_Comm& comm = mpi_comm_p->Comm(); - double enorm_val = 0.0; for (CompositeVector::name_iterator comp = dvec->begin(); comp != dvec->end(); ++comp) { - double enorm_comp = 0.0; - int enorm_loc = -1; + Reductions::MaxLoc enorm_comp = Reductions::createEmptyMaxLoc(); const Epetra_MultiVector& dvec_v = *dvec->ViewComponent(*comp, false); if (*comp == "cell") { @@ -131,9 +129,9 @@ PK_PhysicalBDF_Default::ErrorNorm(Teuchos::RCP u, std::abs(h * dvec_v[0][c]) / (atol_ * cv[0][c] + rtol_ * std::abs(conserved[0][c])); AMANZI_ASSERT((atol_ * cv[0][c] + rtol_ * std::abs(conserved[0][c])) > 0.); - if (enorm_c > enorm_comp) { - enorm_comp = enorm_c; - enorm_loc = c; + if (enorm_c > enorm_comp.value) { + enorm_comp.value = enorm_c; + enorm_comp.gid = dvec_v.Map().GID(c); } } @@ -152,44 +150,26 @@ PK_PhysicalBDF_Default::ErrorNorm(Teuchos::RCP u, double enorm_f = fluxtol_ * h * std::abs(dvec_v[0][f]) / (atol_ * cv_min + rtol_ * std::abs(conserved_min)); AMANZI_ASSERT((atol_ * cv_min + rtol_ * std::abs(conserved_min)) > 0.); - if (enorm_f > enorm_comp) { - enorm_comp = enorm_f; - enorm_loc = f; + if (enorm_f > enorm_comp.value) { + enorm_comp.value = enorm_f; + enorm_comp.gid = dvec_v.Map().GID(f); } } - - } else { - // double norm; - // dvec_v.Norm2(&norm); - // AMANZI_ASSERT(norm < 1.e-15); } + enorm_comp = Reductions::reduceAllMaxLoc(*mesh_->getComm(), enorm_comp); + // Write out Inf norms too. if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { double infnorm(0.); dvec_v.NormInf(&infnorm); - ENorm_t err; - ENorm_t l_err; - l_err.value = enorm_comp; - l_err.gid = dvec_v.Map().GID(enorm_loc); - - int ierr; - - ierr = MPI_Allreduce(&l_err, &err, 1, MPI_DOUBLE_INT, MPI_MAXLOC, comm); - AMANZI_ASSERT(!ierr); - *vo_->os() << " ENorm (" << *comp << ") = " << err.value << "[" << err.gid << "] (" - << infnorm << ")" << std::endl; + *vo_->os() << " ENorm (" << *comp << ") = " << enorm_comp << " (" << infnorm << ")" + << std::endl; } - enorm_val = std::max(enorm_val, enorm_comp); + enorm_val = std::max(enorm_val, enorm_comp.value); } - - double enorm_val_l = enorm_val; - - int ierr; - ierr = MPI_Allreduce(&enorm_val_l, &enorm_val, 1, MPI_DOUBLE, MPI_MAX, comm); - AMANZI_ASSERT(!ierr); return enorm_val; }; @@ -201,7 +181,7 @@ bool PK_PhysicalBDF_Default::IsValid(const Teuchos::RCP& up) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Validating timestep." << std::endl; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) *vo_->os() << "Validating timestep." << std::endl; if (max_valid_change_ > 0.0) { const CompositeVector& var_new = S_->Get(key_, tag_next_); diff --git a/src/pks/pk_physical_bdf_default.hh b/src/pks/pk_physical_bdf_default.hh index 1195a65cd..922b1abad 100644 --- a/src/pks/pk_physical_bdf_default.hh +++ b/src/pks/pk_physical_bdf_default.hh @@ -6,19 +6,16 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Default implementation of both BDF and Physical PKs. /*! -A base class for all PKs that are both physical, in the sense that they -implement an equation and are not couplers, and BDF, in the sense that they -support the implicit integration interface. This largely just supplies a -default error norm based on error in conservation relative to the extent of the -conserved quantity. +PKs that are both Physical and BDF are likely conservation equations. Given a +conserved quantity, we can supply a default error norm for conservation. By +default, the error norm used by solvers is given by: -By default, the error norm used by solvers is given by: +:math:`ENORM(u, du) = |du| / ( a_{tol} + r_{tol} * |u| )` -:math:`ENORM(u, du) = |du| / ( a_tol + r_tol * |u| )` +where :math:`u` is the conserved quantity and :math:`du` is the error in +conservation. The defaults here are typically good, or else good defaults are set in the code, so usually are not supplied by the user. @@ -27,33 +24,28 @@ code, so usually are not supplied by the user. .. _pk-physical-bdf-default-spec: .. admonition:: pk-physical-bdf-default-spec - * `"conserved quantity key`" ``[string]`` Name of the conserved quantity. - Usually a sane default is set by the PK. - - * `"max valid change`" ``[double]`` **-1** Sets a limiter on what is a - valid change in a single timestep. Changes larger than this are declared - invalid and the timestep shrinks. By default, any change is valid. - Units are the same as the primary variable. - - * `"absolute error tolerance`" ``[double]`` **1.0** Absolute tolerance, - :math:`a_tol` in the equation above. Unit are the same as the conserved - quantity. Note that this default is often overridden by PKs with more - physical values, and very rarely are these set by the user. + * `"conserved quantity key`" ``[string]`` Name of the conserved quantity. + Usually a sane default is set by the PK. - * `"relative error tolerance`" ``[double]`` **1.0** Relative tolerance, - :math:`r_tol` in the equation above. ``[-]`` Note that this default can - be overridden by PKs with more physical values, and very rarely are these - set by the user. + * `"absolute error tolerance`" ``[double]`` **1.0** Absolute tolerance, + :math:`a_{tol}` in the equation above. Unit are the same as the conserved + quantity. Note that this default is often overridden by PKs with more + physical values, and very rarely are these set by the user. - * `"flux error tolerance`" ``[double]`` **1.0** Relative tolerance on the - flux. Note that this default is often overridden by PKs with more physical - values, and very rarely are these set by the user. + * `"relative error tolerance`" ``[double]`` **1.0** Relative tolerance, + :math:`r_{tol}` in the equation above. ``[-]`` Note that this default can + be overridden by PKs with more physical values, and very rarely are these + set by the user. - INCLUDES: + * `"flux error tolerance`" ``[double]`` **1.0** Relative tolerance on the + flux, or face-based error caused by a mismatch in flux from either side of + the face. Note that this default is often overridden by PKs with more + physical values, and very rarely are these set by the user. - - ``[pk-bdf-default-spec]`` *Is a* `PK: BDF`_ - - ``[pk-physical-default-spec]`` *Is a* `PK: Physical`_ + INCLUDES: + - ``[pk-bdf-default-spec]`` *Is a* `PK: BDF`_ + - ``[pk-physical-default-spec]`` *Is a* `PK: Physical`_ */ @@ -62,14 +54,16 @@ code, so usually are not supplied by the user. #include "errors.hh" #include "pk_bdf_default.hh" -#include "pk_physical_default.hh" +#include "PK_Physical_Default.hh" #include "BCs.hh" #include "Operator.hh" namespace Amanzi { -class PK_PhysicalBDF_Default : public PK_BDF_Default, public PK_Physical_Default { +class PK_PhysicalBDF_Default + : public PK_BDF_Default + , public PK_Physical_Default { public: PK_PhysicalBDF_Default(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& glist, @@ -90,8 +84,8 @@ class PK_PhysicalBDF_Default : public PK_BDF_Default, public PK_Physical_Default virtual void Initialize() override; // Default preconditioner is Picard - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; // updates the preconditioner, default does nothing virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override @@ -99,8 +93,8 @@ class PK_PhysicalBDF_Default : public PK_BDF_Default, public PK_Physical_Default // Default implementations of BDFFnBase methods. // -- Compute a norm on u-du and return the result. - virtual double - ErrorNorm(Teuchos::RCP u, Teuchos::RCP du) override; + virtual double ErrorNorm(Teuchos::RCP u, + Teuchos::RCP du) override; bool IsValid(const Teuchos::RCP& up) override; diff --git a/src/pks/pk_physical_default.cc b/src/pks/pk_physical_default.cc deleted file mode 100644 index 1178d90b9..000000000 --- a/src/pks/pk_physical_default.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: Ethan Coon -*/ - -/* ------------------------------------------------------------------------- - ATS - - Default base with default implementations of methods for a physical PK. - ------------------------------------------------------------------------- */ - -#include "EvaluatorPrimary.hh" -#include "StateDefs.hh" -#include "pk_helpers.hh" -#include "pk_physical_default.hh" - -namespace Amanzi { - -PK_Physical_Default::PK_Physical_Default(Teuchos::ParameterList& pk_tree, - const Teuchos::RCP& glist, - const Teuchos::RCP& S, - const Teuchos::RCP& solution) - : PK(pk_tree, glist, S, solution), - PK_Physical(pk_tree, glist, S, solution) -{} - -void -PK_Physical_Default::parseParameterList() -{ - // require primary variable evaluators - key_ = Keys::readKey(*plist_, domain_, "primary variable"); - requireAtNext(key_, tag_next_, *S_, name_); - requireAtCurrent(key_, tag_current_, *S_, name_); -} - - -// ----------------------------------------------------------------------------- -// Construction of data. -// ----------------------------------------------------------------------------- - -void -PK_Physical_Default::Setup() -{ - // set up the debugger - Teuchos::RCP vo_plist = plist_; - if (plist_->isSublist(name_ + " verbose object")) { - vo_plist = Teuchos::rcp(new Teuchos::ParameterList(*plist_)); - vo_plist->set("verbose object", plist_->sublist(name_ + " verbose object")); - } - - db_ = Teuchos::rcp(new Debugger(mesh_, name_, *vo_plist)); -}; - - -void -PK_Physical_Default::CommitStep(double t_old, double t_new, const Tag& tag_next) -{ - Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_EXTREME)) - *vo_->os() << "Commiting state @ " << tag_next << std::endl; - - AMANZI_ASSERT(tag_next == tag_next_ || tag_next == Tags::NEXT); - Tag tag_current = tag_next == tag_next_ ? tag_current_ : Tags::CURRENT; - assign(key_, tag_current, tag_next, *S_); -} - - -void -PK_Physical_Default::FailStep(double t_old, double t_new, const Tag& tag_next) -{ - AMANZI_ASSERT(tag_next == tag_next_ || tag_next == Tags::NEXT); - Tag tag_current = tag_next == tag_next_ ? tag_current_ : Tags::CURRENT; - assign(key_, tag_next, tag_current, *S_); -} - - -// ----------------------------------------------------------------------------- -// Marks as changed -// ----------------------------------------------------------------------------- -void -PK_Physical_Default::ChangedSolutionPK(const Tag& tag) -{ - changedEvaluatorPrimary(key_, tag, *S_); -} - - -// ----------------------------------------------------------------------------- -// Initialization of the PK data. -// ----------------------------------------------------------------------------- -void -PK_Physical_Default::Initialize() -{ - // Get the record - Record& record = S_->GetRecordW(key_, tag_next_, name()); - - // Initialize the data - if (!record.initialized()) { - // initial conditions - // -- Get the IC function plist. - if (!plist_->isSublist("initial condition")) { - Errors::Message message; - message << name() << " has no initial condition parameter list."; - Exceptions::amanzi_throw(message); - } - - // -- Calculate the IC. - Teuchos::ParameterList ic_plist = plist_->sublist("initial condition"); - record.Initialize(ic_plist); - - // communicate just to make sure values are initialized for valgrind's sake - if (record.Get().Ghosted()) - record.Get().ScatterMasterToGhosted(); - ChangedSolutionPK(tag_next_); - } - - // Push the data into the solution. - solution_->SetData(record.GetPtrW(name())); -}; - - -} // namespace Amanzi diff --git a/src/pks/pk_physical_default.hh b/src/pks/pk_physical_default.hh deleted file mode 100644 index 1e2259ef4..000000000 --- a/src/pks/pk_physical_default.hh +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -//! A base class with default implementations of methods for a leaf of the PK tree (a conservation equation, or similar). -/*! - -`PKPhysicalBase` is a base class providing some functionality for PKs which -are defined on a single mesh, and represent a single process model. Typically -all leaves of the PK tree will inherit from `PKPhysicalBase`. - -.. _pk-physical-default-spec: -.. admonition:: pk-physical-default-spec - - * `"domain name`" ``[string]`` Name from the Mesh_ list on which this PK is defined. - - * `"primary variable key`" ``[string]`` The primary variable - e.g. `"pressure`", or `"temperature`". Most PKs supply sane defaults. - - * `"initial condition`" ``[initial-conditions-spec]`` See InitialConditions_. - - INCLUDES: - - - ``[pk-spec]`` This *is a* PK_. - - ``[debugger-spec]`` Uses a Debugger_ - -*/ -#ifndef ATS_PK_PHYSICAL_BASE_HH_ -#define ATS_PK_PHYSICAL_BASE_HH_ - -#include "Teuchos_ParameterList.hpp" -#include "TreeVector.hh" - -#include "Debugger.hh" - -#include "EvaluatorPrimary.hh" -#include "PK.hh" -#include "PK_Physical.hh" - -namespace Amanzi { - -class PK_Physical_Default : public PK_Physical { - public: - PK_Physical_Default(Teuchos::ParameterList& pk_tree, - const Teuchos::RCP& glist, - const Teuchos::RCP& S, - const Teuchos::RCP& solution); - - // Virtual destructor - virtual ~PK_Physical_Default() = default; - - virtual void parseParameterList() override; - - // Tag the primary variable as changed in the DAG - virtual void ChangedSolutionPK(const Tag& tag) override; - - virtual void Setup() override; - virtual void Initialize() override; - - virtual void CommitStep(double t_old, double t_new, const Tag& tag) override; - virtual void FailStep(double t_old, double t_new, const Tag& tag) override; - - protected: - // ENORM struct - typedef struct ENorm_t { - double value; - int gid; - } ENorm_t; -}; - -} // namespace Amanzi - -#endif diff --git a/src/pks/pk_physical_explicit_default.hh b/src/pks/pk_physical_explicit_default.hh index 57c6eeac9..eec802af8 100644 --- a/src/pks/pk_physical_explicit_default.hh +++ b/src/pks/pk_physical_explicit_default.hh @@ -20,18 +20,20 @@ domains/meshes of PKPhysicalBase and Explicit methods of PKExplicitBase. #include "errors.hh" #include "PK.hh" #include "pk_explicit_default.hh" -#include "pk_physical_default.hh" +#include "PK_Physical_Default.hh" namespace Amanzi { -class PK_Physical_Explicit_Default : public PK_Explicit_Default, public PK_Physical_Default { +class PK_Physical_Default_Explicit_Default + : public PK_Explicit_Default + , public PK_Physical_Default { public: - PK_Physical_Explicit_Default(Teuchos::ParameterList& pk_tree, - const Teuchos::RCP& glist, - const Teuchos::RCP& S, - const Teuchos::RCP& solution) + PK_Physical_Default_Explicit_Default(Teuchos::ParameterList& pk_tree, + const Teuchos::RCP& glist, + const Teuchos::RCP& S, + const Teuchos::RCP& solution) : PK(pk_tree, glist, S, solution), PK_Explicit_Default(pk_tree, glist, S, solution), PK_Physical_Default(pk_tree, glist, S, solution) diff --git a/src/pks/surface_balance/CLM/ats_clm_interface.hh b/src/pks/surface_balance/CLM/ats_clm_interface.hh index 13139527a..e428b6c55 100644 --- a/src/pks/surface_balance/CLM/ats_clm_interface.hh +++ b/src/pks/surface_balance/CLM/ats_clm_interface.hh @@ -83,8 +83,7 @@ namespace CLM { // rank | rank (for logging purposes only) // verbosity | 0 (None) - 1 (Low) - 2 (High) - 3 (Extreme) // -int -init(int ncells, int ncolumns, int startcode, int rank, int verbosity); +int init(int ncells, int ncolumns, int startcode, int rank, int verbosity); // @@ -99,8 +98,7 @@ init(int ncells, int ncolumns, int startcode, int rank, int verbosity); // | by incoming radiation. So what incoming met data // | temporal resolution does CLM expect? --etc // -int -set_zero_time(double zero_time); +int set_zero_time(double zero_time); // // Sets the initial, assumed uniform, state. @@ -109,8 +107,7 @@ set_zero_time(double zero_time); // temperature| Soil, snow, and water temperature [K] // snow depth | Initial snow depth [m] // -int -set_initial_state(double temperature, double snow_depth); +int set_initial_state(double temperature, double snow_depth); // @@ -128,19 +125,17 @@ set_initial_state(double temperature, double snow_depth); // | Note only the dominant land type is used, as maxt is // | hard-coded 1 and this assumption is used in a few places in drv. // -int -set_ground_properties(double* latlon, - const Epetra_MultiVector& sand, - const Epetra_MultiVector& clay, - const std::vector& color_index, - double* fractional_ground); +int set_ground_properties(double* latlon, + const Epetra_MultiVector& sand, + const Epetra_MultiVector& clay, + const std::vector& color_index, + double* fractional_ground); // // Begin setup. Sets the tiles and pushes info from driver into grid/tile // ------------------------------------------------------------------ // -int -setup_begin(); +int setup_begin(); // @@ -149,8 +144,7 @@ setup_begin(); // Input: // dz | vector of cell dz [m] Size ncells. // -int -set_dz(const Epetra_MultiVector& dz); +int set_dz(const Epetra_MultiVector& dz); // @@ -165,19 +159,17 @@ set_dz(const Epetra_MultiVector& dz); // res_sat | residual saturation [-] // | make this variable across columns? cells? FIXME // -int -set_et_controls(int beta_type, - int veg_water_stress_type, - double wilting_point, - double field_capacity, - double res_sat); +int set_et_controls(int beta_type, + int veg_water_stress_type, + double wilting_point, + double field_capacity, + double res_sat); // // End setup. Pushes grid, tile, drv info into clm1d column instances. // ------------------------------------------------------------------ // -int -setup_end(); +int setup_end(); // @@ -187,8 +179,7 @@ setup_end(); // porosity | [-] Size ncells. // saturation | [-] Size ncells. // -int -set_wc(const Epetra_MultiVector& porosity, const Epetra_MultiVector& saturation); +int set_wc(const Epetra_MultiVector& porosity, const Epetra_MultiVector& saturation); // @@ -201,8 +192,7 @@ set_wc(const Epetra_MultiVector& porosity, const Epetra_MultiVector& saturation) // Input: // porosity | [-] Size ncells. // -int -set_tksat_from_porosity(const Epetra_MultiVector& porosity); +int set_tksat_from_porosity(const Epetra_MultiVector& porosity); // @@ -215,8 +205,7 @@ set_tksat_from_porosity(const Epetra_MultiVector& porosity); // | isn't obvious that this is a good idea in cases of // | frozen water? FIXME // -int -set_pressure(const Epetra_MultiVector& pressure, double patm); +int set_pressure(const Epetra_MultiVector& pressure, double patm); // @@ -238,15 +227,14 @@ set_pressure(const Epetra_MultiVector& pressure, double patm); // wind_u | Windspeed velocity [m/s] // p_atm | Atmospheric pressure [Pa] // -int -set_met_data(const Epetra_MultiVector& qSW, - const Epetra_MultiVector& qLW, - const Epetra_MultiVector& pRain, - const Epetra_MultiVector& pSnow, - const Epetra_MultiVector& air_temp, - const Epetra_MultiVector& vp_air, - const Epetra_MultiVector& wind_u, - double p_atm); +int set_met_data(const Epetra_MultiVector& qSW, + const Epetra_MultiVector& qLW, + const Epetra_MultiVector& pRain, + const Epetra_MultiVector& pSnow, + const Epetra_MultiVector& air_temp, + const Epetra_MultiVector& vp_air, + const Epetra_MultiVector& wind_u, + double p_atm); // @@ -256,8 +244,7 @@ set_met_data(const Epetra_MultiVector& qSW, // step | integer cycle number (logging only?) // time | time at start of step (relative to zero time) [s] // dt | step size [s] -int -advance_time(int step, double time, double dt); +int advance_time(int step, double time, double dt); // @@ -267,8 +254,7 @@ advance_time(int step, double time, double dt); // qW_surf | water source/sink surface (sign?) [m/s] Size ncolumns. // qW_subsurf | water source/sink surface (sign?) [1/s] Size ncells. // -int -get_total_mass_fluxes(Epetra_MultiVector& qW_surf, Epetra_MultiVector& qW_subsurf); +int get_total_mass_fluxes(Epetra_MultiVector& qW_surf, Epetra_MultiVector& qW_subsurf); // @@ -284,16 +270,14 @@ get_total_mass_fluxes(Epetra_MultiVector& qW_surf, Epetra_MultiVector& qW_subsur // // The total variant includes canopy latent and sensible heat terms. The // ground variant does not. -int -get_total_energy_fluxes(Epetra_MultiVector& latent_heat, - Epetra_MultiVector& sensible_heat, - Epetra_MultiVector& lw_out, - Epetra_MultiVector& conducted_e); -int -get_ground_energy_fluxes(Epetra_MultiVector& latent_heat, - Epetra_MultiVector& sensible_heat, - Epetra_MultiVector& lw_out, - Epetra_MultiVector& conducted_e); +int get_total_energy_fluxes(Epetra_MultiVector& latent_heat, + Epetra_MultiVector& sensible_heat, + Epetra_MultiVector& lw_out, + Epetra_MultiVector& conducted_e); +int get_ground_energy_fluxes(Epetra_MultiVector& latent_heat, + Epetra_MultiVector& sensible_heat, + Epetra_MultiVector& lw_out, + Epetra_MultiVector& conducted_e); // // Mass fluxes for mass balance and diagnostics/visualization @@ -312,17 +296,16 @@ get_ground_energy_fluxes(Epetra_MultiVector& latent_heat, // irrigation_flag | ??? // tran_soil | Transpiration distributed to soil via rooting curve [1/s] (Size ncells) // -int -get_mass_fluxes(Epetra_MultiVector& evap_total, - Epetra_MultiVector& evap_ground, - Epetra_MultiVector& evap_soil, - Epetra_MultiVector& evap_canopy, - Epetra_MultiVector& tran_veg, - Epetra_MultiVector& influx, - Epetra_MultiVector& irrigation, - Epetra_MultiVector& inst_irrigation, - Epetra_MultiVector& irrigation_flag, - Epetra_MultiVector& tran_soil); +int get_mass_fluxes(Epetra_MultiVector& evap_total, + Epetra_MultiVector& evap_ground, + Epetra_MultiVector& evap_soil, + Epetra_MultiVector& evap_canopy, + Epetra_MultiVector& tran_veg, + Epetra_MultiVector& influx, + Epetra_MultiVector& irrigation, + Epetra_MultiVector& inst_irrigation, + Epetra_MultiVector& irrigation_flag, + Epetra_MultiVector& tran_soil); // @@ -339,13 +322,12 @@ get_mass_fluxes(Epetra_MultiVector& evap_total, // T_veg | Leaf temperature [K] // T_soil | Soil temperature [K] (size ncells) // -int -get_diagnostics(Epetra_MultiVector& swe, - Epetra_MultiVector& snow_depth, - Epetra_MultiVector& canopy_storage, - Epetra_MultiVector& Tskin, - Epetra_MultiVector& Tveg, - Epetra_MultiVector& Tsoil); +int get_diagnostics(Epetra_MultiVector& swe, + Epetra_MultiVector& snow_depth, + Epetra_MultiVector& canopy_storage, + Epetra_MultiVector& Tskin, + Epetra_MultiVector& Tveg, + Epetra_MultiVector& Tsoil); } // namespace CLM diff --git a/src/pks/surface_balance/CLM/surface_balance_CLM.cc b/src/pks/surface_balance/CLM/surface_balance_CLM.cc index 943f951f6..f2a2f4880 100644 --- a/src/pks/surface_balance/CLM/surface_balance_CLM.cc +++ b/src/pks/surface_balance/CLM/surface_balance_CLM.cc @@ -28,7 +28,7 @@ water sources, etc. #include -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "ats_clm_interface.hh" #include "surface_balance_CLM.hh" @@ -109,16 +109,14 @@ SurfaceBalanceCLM::Setup() // requirements: other primary variables // -- surface water source -- note we keep old and new in case of Crank-Nicholson Richards PK - S_->Require(surf_water_src_key_, tag_next_, name_) + requireEvaluatorAtNext(surf_water_src_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireEvaluatorPrimary(surf_water_src_key_, tag_next_, *S_); // -- subsurface water source -- note we keep old and new in case of Crank-Nicholson Richards PK - S_->Require(ss_water_src_key_, tag_next_, name_) + requireEvaluatorPrimary(ss_water_src_key_, tag_next_, *S_, name_) .SetMesh(subsurf_mesh) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireEvaluatorPrimary(ss_water_src_key_, tag_next_, *S_); // set requirements on dependencies SetupDependencies_(tag_next_); @@ -281,7 +279,7 @@ void SurfaceBalanceCLM::InitializeCLM_(const Tag& tag) { // Initialize the CLM instance - Teuchos::ParameterList& ic_list = plist_->sublist("initial condition"); + Teuchos::ParameterList& ic_list = plist_->sublist("initial conditions"); double snow_depth = ic_list.get("initial snow depth [m]"); double temp = ic_list.get("initial temperature [K]"); double year = ic_list.get("initial time [yr]"); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/LandCover.cc b/src/pks/surface_balance/constitutive_relations/land_cover/LandCover.cc index 7254a4497..57920c337 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/LandCover.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/LandCover.cc @@ -91,11 +91,13 @@ LandCover::LandCover(Teuchos::ParameterList& plist) LandCoverMap -getLandCover(Teuchos::ParameterList& plist, const std::vector& required_pars) +getLandCover(Teuchos::ParameterList plist, const std::vector& required_pars) { LandCoverMap lcm = Impl::getLandCover(plist); for (const auto& lc : lcm) { - for (const auto& par : required_pars) { Impl::checkValid(lc.first, lc.second, par); } + for (const auto& par : required_pars) { + Impl::checkValid(lc.first, lc.second, par); + } } return lcm; } @@ -158,7 +160,8 @@ checkValid(const std::string& region, const LandCover& lc, const std::string& pa if (parname == "pt_alpha_transpiration" && std::isnan(lc.pt_alpha_transpiration)) throwInvalid(region, "Priestley-Taylor alpha of transpiration [-]"); - if (parname == "mannings_n" && std::isnan(lc.mannings_n)) throwInvalid(region, "Manning's n [?]"); + if (parname == "mannings_n" && std::isnan(lc.mannings_n) + ) throwInvalid(region, "Manning's n [?]"); if (parname == "leaf_on_doy" && std::isnan(lc.leaf_on_doy)) throwInvalid(region, "leaf off time [doy]"); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/LandCover.hh b/src/pks/surface_balance/constitutive_relations/land_cover/LandCover.hh index 71372e07e..79b1f55ac 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/LandCover.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/LandCover.hh @@ -38,77 +38,88 @@ same region-based partitioning. .. _land-cover-spec: .. admonition:: land-cover-spec - * `"rooting depth max [m]`" ``[double]`` **NaN** Below this the rooting fraction is - set to 0. [m] - * `"rooting profile alpha [-]`" ``[double]`` **NaN** alpha in the rooting profile - function [-] - * `"rooting profile beta [-]`" ``[double]`` **NaN** beta in the rooting profile - function [-] Note that these are from the CLM 4.5 Technical Note. - - * `"capillary pressure at fully closed stomata [Pa]`" ``[double]`` **NaN** - * `"capillary pressure at fully open stomata [Pa]`" ``[double]`` **NaN** - Transpiration is typically downregulated by a limiter that is empirically - modeling stomata closure. Typically it varies linearly from 0 to 1 as a - function of capillary pressure, between these two values. Note that - these should be positive! [Pa] - - * `"maximum xylem capillary pressure [Pa]`" ``[double]`` **NaN** - Maximum capillary pressure at the plant collar before the plant starts to close stomata. - - * `"leaf on time [doy]`" ``[double]`` **NaN** Day of year, relative to time 0, when leaves - begin transpiring. Note that -1 implies evergreen. [doy] - * `"leaf off time [doy]`" ``[double]`` **NaN** Day of year, relative to time 0, when leaves - stop transpiring. Note that -1 implies evergreen. [doy] - - * `"Priestley-Taylor alpha of snow [-]`" ``[double]`` **NaN** Evaporation coefficient - in the Priestley-Taylor model, used in sublimation of snow. - * `"Priestley-Taylor alpha of bare ground [-]`" ``[double]`` **NaN** Evaporation coefficient - in the Priestley-Taylor model, used in bare soil - * `"Priestley-Taylor alpha of canopy [-]`" ``[double]`` **NaN** Evaporation coefficient - in the Priestley-Taylor model, used in sublimation of snow. - * `"Priestley-Taylor alpha of transpiration [-]`" ``[double]`` **NaN** Evaporation coefficient - in the Priestley-Taylor model, used in transpiration. - - * `"interception coefficient [-]`" ``[double]`` **NaN** Fraction, per unit LAI, of - water intercepted by the canopy. - - * `"albedo of bare ground [-]`" ``[double]`` **NaN** Albedo of the land cover - type, ranging from [0,1] - * `"emissivity of bare ground [-]`" ``[double]`` **NaN** Emissivity of the land - cover type's bare ground, ranging from [0,1] - * `"albedo of canopy [-]`" ``[double]`` **NaN** Albedo of the land cover type's - canopy, ranging from [0,1] - - * `"Beer's law extinction coefficient, shortwave [-]`" ``[double]`` **NaN** - * `"Beer's law extinction coefficient, longwave [-]`" ``[double]`` **NaN** - Beer's law provides the attenuation of light through a diffuse medium (in - this case leaves) as a function of concentration/density (in this case - LAI) and an extinction coefficient, sometimes called the absorptivity, - which is usually a function of wavelength, but here is split into long - and shortwave constants. - - * `"snow transition depth [m]`" ``[double]`` **NaN** See below. - * `"water transition depth [m]`" ``[double]`` **NaN** Due to the need for smooth - transitions (numerically) between various surface balance conditions, - frequently a subgrid-scale model is used that, rather than trying to - smooth each model, varies an area fraction between 1 and 0 for multiple - components (e.g. snow-covered, water-covered, bare-ground) of the surface - cell. These area fractions are determined by a model, but most - frequently are a linear variation from 1 (e.g. fully covered by water) at - this ponded depth and above, and 0 (e.g. no area covered by water) at 0 - ponded depth. Then, multiple surface energy balances (SEBs) are - calculated, one assuming the ponded depth is this thick, and the various - components of the SEB are averaged by that area fraction. - - * `"roughness length of bare ground [m]`" ``[double]`` **NaN** Roughness length of - the bare soil, used in calculating sensible/latent heat in the - physics-based SEB model. A typical value is 0.04. - * `"roughness length of snow [m]`" ``[double]`` **NaN** Roughness - length of the snow-covered soil, used in calculating sensible/latent heat - in the physics-based SEB model. A typical value is 0.004. - - - - `"Manning's n [?]`" ``[double]`` **NaN** Manning's n [??] THIS IS NOT CURRENTLY USED. + * `"rooting depth max [m]`" ``[double]`` **NaN** Below this the rooting + fraction is set to 0. [m] + * `"rooting profile alpha [-]`" ``[double]`` **NaN** alpha in the rooting + profile function [-] + * `"rooting profile beta [-]`" ``[double]`` **NaN** beta in the rooting + profile function [-] Note that these are from the CLM 4.5 Technical Note. + + * `"capillary pressure at fully closed stomata [Pa]`" ``[double]`` **NaN** + * `"capillary pressure at fully open stomata [Pa]`" ``[double]`` **NaN** + Transpiration is typically downregulated by a limiter that is empirically + modeling stomata closure. Typically it varies linearly from 0 to 1 as a + function of capillary pressure, between these two values. Note that + these should be positive! [Pa] + + * `"maximum xylem capillary pressure [Pa]`" ``[double]`` **NaN** + Maximum capillary pressure at the plant collar before the plant starts to close stomata. + + * `"leaf on time [doy]`" ``[double]`` **NaN** Day of year, relative to time + 0, when leaves begin transpiring. Note that -1 implies evergreen. [doy] + * `"leaf off time [doy]`" ``[double]`` **NaN** Day of year, relative to + time 0, when leaves stop transpiring. Note that -1 implies + evergreen. [doy] + + Note that `"leaf on doy`" and `"leaf off doy`" are relative to the + simulation's zero time, not the start time. Typically these are Julian + day of the year, but this assumes that the 0 time of the simulation (not + the "start time", but time 0!) is Jan 1. This leaf on/off cycle is modulo + the `"year duration`" (typically 1 noleap). Note if `"leaf off doy`" < + `"leaf on time`" is ok too -- this is the case if simulation time zero is + mid-summer. + + * `"Priestley-Taylor alpha of snow [-]`" ``[double]`` **NaN** Evaporation + coefficient in the Priestley-Taylor model, used in sublimation of snow. + * `"Priestley-Taylor alpha of bare ground [-]`" ``[double]`` **NaN** + Evaporation coefficient in the Priestley-Taylor model, used in bare soil + * `"Priestley-Taylor alpha of canopy [-]`" ``[double]`` **NaN** Evaporation + coefficient in the Priestley-Taylor model, used in sublimation of snow. + * `"Priestley-Taylor alpha of transpiration [-]`" ``[double]`` **NaN** + Evaporation coefficient in the Priestley-Taylor model, used in + transpiration. + + * `"interception coefficient [-]`" ``[double]`` **NaN** Fraction, per unit + LAI, of water intercepted by the canopy. + + * `"albedo of bare ground [-]`" ``[double]`` **NaN** Albedo of the land + cover type, ranging from [0,1] + * `"emissivity of bare ground [-]`" ``[double]`` **NaN** Emissivity of the + land cover type's bare ground, ranging from [0,1] + * `"albedo of canopy [-]`" ``[double]`` **NaN** Albedo of the land cover + type's canopy, ranging from [0,1] + + * `"Beer's law extinction coefficient, shortwave [-]`" ``[double]`` **NaN** + * `"Beer's law extinction coefficient, longwave [-]`" ``[double]`` **NaN** + Beer's law provides the attenuation of light through a diffuse medium (in + this case leaves) as a function of concentration/density (in this case + LAI) and an extinction coefficient, sometimes called the absorptivity, + which is usually a function of wavelength, but here is split into long + and shortwave constants. + + * `"snow transition depth [m]`" ``[double]`` **NaN** See below. + * `"water transition depth [m]`" ``[double]`` **NaN** Due to the need for + smooth transitions (numerically) between various surface balance + conditions, frequently a subgrid-scale model is used that, rather than + trying to smooth each model, varies an area fraction between 1 and 0 for + multiple components (e.g. snow-covered, water-covered, bare-ground) of + the surface cell. These area fractions are determined by a model, but + most frequently are a linear variation from 1 (e.g. fully covered by + water) at this ponded depth and above, and 0 (e.g. no area covered by + water) at 0 ponded depth. Then, multiple surface energy balances (SEBs) + are calculated, one assuming the ponded depth is this thick, and the + various components of the SEB are averaged by that area fraction. + + * `"roughness length of bare ground [m]`" ``[double]`` **NaN** Roughness + length of the bare soil, used in calculating sensible/latent heat in the + physics-based SEB model. A typical value is 0.04. + * `"roughness length of snow [m]`" ``[double]`` **NaN** Roughness length of + the snow-covered soil, used in calculating sensible/latent heat in the + physics-based SEB model. A typical value is 0.004. + + + - `"Manning's n [?]`" ``[double]`` **NaN** Manning's n [??] THIS IS NOT + CURRENTLY USED. */ @@ -154,7 +165,6 @@ struct LandCover { double albedo_ground; double albedo_canopy; double emissivity_ground; - double emissivity_canopy; double beers_k_sw; double beers_k_lw; @@ -171,15 +181,13 @@ struct LandCover { // this one includes error checking for NaNs using LandCoverMap = std::map; -LandCoverMap -getLandCover(Teuchos::ParameterList& plist, const std::vector& required_pars); +LandCoverMap getLandCover(Teuchos::ParameterList plist, + const std::vector& required_pars); namespace Impl { -void -checkValid(const std::string& region, const LandCover& lc, const std::string& parname); -LandCoverMap -getLandCover(Teuchos::ParameterList& plist); +void checkValid(const std::string& region, const LandCover& lc, const std::string& parname); +LandCoverMap getLandCover(Teuchos::ParameterList& plist); } // namespace Impl diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/albedo_threecomponent_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/albedo_threecomponent_evaluator.cc index 6089f2e25..4e7e273dd 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/albedo_threecomponent_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/albedo_threecomponent_evaluator.cc @@ -24,7 +24,9 @@ AlbedoThreeComponentEvaluator::AlbedoThreeComponentEvaluator(Teuchos::ParameterL a_ice_ = plist_.get("albedo ice [-]", 0.44); a_water_ = plist_.get("albedo water [-]", 0.1168); is_constant_snow_albedo_ = plist_.isParameter("albedo snow [-]"); - if (is_constant_snow_albedo_) { a_snow_ = plist_.get("albedo snow [-]"); } + if (is_constant_snow_albedo_) { + a_snow_ = plist_.get("albedo snow [-]"); + } e_ice_ = plist_.get("emissivity ice [-]", 0.98); e_water_ = plist_.get("emissivity water [-]", 0.995); @@ -127,7 +129,7 @@ AlbedoThreeComponentEvaluator::EnsureCompatibility_ToDeps_(State& S) { // new state! if (land_cover_.size() == 0) - land_cover_ = getLandCover(S.ICList().sublist("land cover types"), + land_cover_ = getLandCover(S.GetModelParameters("land cover types"), { "albedo_ground", "emissivity_ground" }); for (auto dep : dependencies_) { diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/albedo_threecomponent_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/albedo_threecomponent_evaluator.hh index 3ac72ce21..92f1aed92 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/albedo_threecomponent_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/albedo_threecomponent_evaluator.hh @@ -6,8 +6,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Evaluates albedos and emissivities in a three-component subgrid model. /*! Evaluates the albedo and emissivity as an interpolation on the surface @@ -16,10 +14,10 @@ snow. Note this internally calculates albedo of snow based upon snow density. Components are: 0 = land, 1 = ice/water, 2 = snow. -Requires the use of LandCover types, for ground albedo and emissivity. +`"evaluator type`" = `"subgrid albedos, three components`" -.. _albedo-evaluator-subgrid-spec: -.. admonition:: albedo-evaluator-subgrid-spec +.. _evaluator-subgrid-albedos-three-components-spec: +.. admonition:: evaluator-subgrid-albedos-three-components-spec * `"albedo ice [-]`" ``[double]`` **0.44** * `"albedo water [-]`" ``[double]`` **0.1168** @@ -38,6 +36,15 @@ Requires the use of LandCover types, for ground albedo and emissivity. - `"snow density`" **SNOW_DOMAIN-density** - `"unfrozen fraction`" **DOMAIN-unfrozen_fraction** + +.. note:: + + This evaluator also uses the :ref:`Land Cover` types. From that struct, it + requires the value of the following parameters: + + - `"emissivity of bare ground [-]`" + - `"albedo of bare ground [-]`" + */ #pragma once diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/albedo_twocomponent_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/albedo_twocomponent_evaluator.cc index 7cf9878e2..63692d169 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/albedo_twocomponent_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/albedo_twocomponent_evaluator.cc @@ -24,7 +24,9 @@ AlbedoTwoComponentEvaluator::AlbedoTwoComponentEvaluator(Teuchos::ParameterList& a_ice_ = plist_.get("albedo ice [-]", 0.44); a_water_ = plist_.get("albedo water [-]", 0.1168); is_constant_snow_albedo_ = plist_.isParameter("albedo snow [-]"); - if (is_constant_snow_albedo_) { a_snow_ = plist_.get("albedo snow [-]"); } + if (is_constant_snow_albedo_) { + a_snow_ = plist_.get("albedo snow [-]"); + } e_ice_ = plist_.get("emissivity ice [-]", 0.98); e_water_ = plist_.get("emissivity water [-]", 0.995); @@ -140,7 +142,7 @@ AlbedoTwoComponentEvaluator::EnsureCompatibility_ToDeps_(State& S) { // new state! if (land_cover_.size() == 0) - land_cover_ = getLandCover(S.ICList().sublist("land cover types"), + land_cover_ = getLandCover(S.GetModelParameters("land cover types"), { "emissivity_ground", "albedo_ground" }); for (auto dep : dependencies_) { diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/albedo_twocomponent_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/albedo_twocomponent_evaluator.hh index be231a72e..320108804 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/albedo_twocomponent_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/albedo_twocomponent_evaluator.hh @@ -6,8 +6,6 @@ Authors: Ethan Coon (coonet@ornl.gov) */ - -//! Evaluates albedos and emissivities in a two-component subgrid model. /*! Evaluates the albedo and emissivity as an interpolation on the surface @@ -17,10 +15,10 @@ snow density. Components are indexed by: 0 = land/ice/water, 1 = snow. -Requires the use of LandCover types, for ground albedo and emissivity. +`"evaluator type`" = `"subgrid albedos, two components`" -.. _albedo-evaluator-spec: -.. admonition:: albedo-evaluator-spec +.. _evaluator-subgrid-albedos-two-components-spec: +.. admonition:: evaluator-subgrid-albedos-two-components-spec * `"albedo ice [-]`" ``[double]`` **0.44** * `"albedo water [-]`" ``[double]`` **0.1168** @@ -40,6 +38,15 @@ Requires the use of LandCover types, for ground albedo and emissivity. - `"ponded depth`" **DOMAIN-ponded_depth** - `"unfrozen fraction`" **DOMAIN-unfrozen_fraction** + +.. note:: + + This evaluator also uses the :ref:`Land Cover` types. From that struct, it + requires the value of the following parameters: + + - `"emissivity of bare ground [-]`" + - `"albedo of bare ground [-]`" + */ #pragma once diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_evaluator.cc index 4bdcd31ce..14bdf7d63 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_evaluator.cc @@ -150,7 +150,7 @@ void AreaFractionsThreeComponentEvaluator::EnsureCompatibility_ToDeps_(State& S) { if (land_cover_.size() == 0) - land_cover_ = getLandCover(S.ICList().sublist("land cover types"), + land_cover_ = getLandCover(S.GetModelParameters("land cover types"), { "snow_transition_depth", "water_transition_depth" }); auto tag = my_keys_.front().second; diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_evaluator.hh index 5123723a3..e66638e81 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_evaluator.hh @@ -15,36 +15,33 @@ another linear transition to vary between snow-covered and not-snow-covered. Ordering of the area fractions calculated are: [bare ground, water, snow]. +This evaluator simplifies the situation by assuming constant water density. +This make it so that ice and water see the same geometry per unit pressure, +which isn't quite true thanks to density differences. However, we hypothesize +that these differences, on the surface (unlike in the subsurface) really don't +affect the solution. + + `"evaluator type`" = `"area fractions, three components`" -.. _area-fractions-threecomponent-evaluator-spec: -.. admonition:: area-fractions-threecomponent-evaluator-spec: +.. _evaluator-area-fractions-three-components-spec: +.. admonition:: evaluator-area-fractions-three-components-spec: - * `"minimum fractional area [-]`" ``[double]`` **1.e-5** - Mimimum area fraction allowed, less than this is rebalanced as zero. + * `"minimum fractional area [-]`" ``[double]`` **1.e-5** Mimimum area + fraction allowed, less than this is rebalanced as zero. DEPENDENCIES: - `"snow depth`" **DOMAIN_SNOW-depth** - `"ponded depth`" **DOMAIN-ponded_depth** -.. note: +.. note:: - This evaluator also uses the LandCover_ types. From that struct, it + This evaluator also uses the :ref:`Land Cover` types. From that struct, it requires the value of the following parameters: - - `"snow transition height [m]`" ``[double]`` **0.02** - Minimum thickness for specifying the snow gradient. - - `"water transition height [m]`" ``[double]`` **0.02** - Minimum thickness for specifying the water gradient. - -.. note: - - This evaluator simplifies the situation by assuming constant density. This - make it so that ice and water see the same geometry per unit pressure, which - isn't quite true thanks to density differences. However, we hypothesize - that these differences, on the surface (unlike in the subsurface) really - don't affect the solution. + - `"snow transition height [m]`" + - `"water transition height [m]`" */ diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_microtopography_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_microtopography_evaluator.hh index f430f2a5b..3406a8fe9 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_microtopography_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_threecomponent_microtopography_evaluator.hh @@ -16,8 +16,8 @@ top of that surface. `"evaluator type`" = `"area fractions, three components with microtopography`" -.. _area-fractions-threecomponent-microtopography-evaluator-spec: -.. admonition:: area-fractions-threecomponent-microtopography-evaluator-spec +.. _evaluator-area-fractions-three-components-with-microtopography-spec: +.. admonition:: evaluator-area-fractions-three-components-with-microtopography-spec * `"snow transitional height [m]`" ``[double]`` **0.02** Minimum thickness for specifying the snow gradient. @@ -39,13 +39,6 @@ top of that surface. - `"volumetric snow depth`" **DOMAIN_SNOW-volumetric_depth** The name of the snow depth. - -NOTE: this evaluator simplifies the situation by assuming constant density. -This make it so that ice and water see the same geometry per unit pressure, -which isn't quite true thanks to density differences. However, we hypothesize -that these differences, on the surface (unlike in the subsurface) really don't -matter much. --etc - */ #pragma once diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_twocomponent_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_twocomponent_evaluator.cc index d2af81d3e..0867dbaac 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_twocomponent_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_twocomponent_evaluator.cc @@ -113,7 +113,8 @@ void AreaFractionsTwoComponentEvaluator::EnsureCompatibility_ToDeps_(State& S) { if (land_cover_.size() == 0) - land_cover_ = getLandCover(S.ICList().sublist("land cover types"), { "snow_transition_depth" }); + land_cover_ = + getLandCover(S.GetModelParameters("land cover types"), { "snow_transition_depth" }); for (auto dep : dependencies_) { auto& fac = S.Require(dep.first, dep.second); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_twocomponent_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_twocomponent_evaluator.hh index 72bee617e..4d853a2c3 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_twocomponent_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/area_fractions_twocomponent_evaluator.hh @@ -15,33 +15,31 @@ another linear transition to vary between snow-covered and not-snow-covered. Ordering of the area fractions calculated are: [bare ground/water, snow]. +This evaluator simplifies the situation by assuming constant water density. +This make it so that ice and water see the same geometry per unit pressure, +which isn't quite true thanks to density differences. However, we hypothesize +that these differences, on the surface (unlike in the subsurface) really don't +affect the solution. + + `"evaluator type`" = `"area fractions, two components`" -.. _area-fractions-twocomponent-evaluator-spec: -.. admonition:: area-fractions-twocomponent-evaluator-spec: +.. _evaluator-area-fractions-two-components-spec: +.. admonition:: evaluator-area-fractions-two-components-spec: - * `"minimum fractional area [-]`" ``[double]`` **1.e-5** - Mimimum area fraction allowed, less than this is rebalanced as zero. + * `"minimum fractional area [-]`" ``[double]`` **1.e-5** Minimum area + fraction allowed, less than this is rebalanced as zero. DEPENDENCIES: - `"snow depth`" ``[string]`` -.. note: +.. note:: - This evaluator also uses the LandCover_ types. From that struct, it + This evaluator also uses the :ref:`Land Cover` types. From that struct, it requires the value of the following parameters: - - `"snow transition height [m]`" ``[double]`` **0.02** - Minimum thickness for specifying the snow gradient. - -.. note: - - This evaluator simplifies the situation by assuming constant density. This - make it so that ice and water see the same geometry per unit pressure, which - isn't quite true thanks to density differences. However, we hypothesize - that these differences, on the surface (unlike in the subsurface) really - don't affect the solution. + - `"snow transition height [m]`" */ diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/canopy_radiation_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/canopy_radiation_evaluator.cc index ff589ac6a..d7b6c1562 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/canopy_radiation_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/canopy_radiation_evaluator.cc @@ -73,9 +73,8 @@ void CanopyRadiationEvaluator::EnsureCompatibility_ToDeps_(State& S) { if (!compatible_) { - land_cover_ = - getLandCover(S.ICList().sublist("land cover types"), - { "beers_k_lw", "beers_k_sw", "emissivity_canopy", "albedo_canopy" }); + land_cover_ = getLandCover(S.GetModelParameters("land cover types"), + { "beers_k_lw", "beers_k_sw", "albedo_canopy" }); for (const auto& dep : dependencies_) { S.Require(dep.first, dep.second) diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/canopy_radiation_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/canopy_radiation_evaluator.hh index 489e3443c..eb5e6ce44 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/canopy_radiation_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/canopy_radiation_evaluator.hh @@ -6,16 +6,11 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Evaluates the canopy radiation balance, providing canopy net and radiation to the snow/surface. /*! Computes and sums the downward radiation terms, determining the total radiation sent down to the surface from the canopy and above. -Requires the use of LandCover types, for albedo and emissivity of the canopy -itself, along with Beer's law coefficients. - Computes: 1. canopy-downward_shortwave_radiation -- transmitted shortwave. Note that @@ -49,16 +44,33 @@ solve all of these balances to convergence simultaneously. `"evaluator type`" = `"canopy radiation balance from above`" -.. _canopy-radiation-evaluator-spec: -.. admonition:: canopy-radiation-evaluator-spec +.. _evaluator-canopy-radiation-balance-from-above-spec: +.. admonition:: evaluator-canopy-radiation-balance-from-above-spec: KEYS: + + - `"canopy downward shortwave radiation`" **CANOPY_DOMAIN-downward_shortwave_radiation** + - `"canopy downward longwave radiation`" **CANOPY_DOMAIN-downward_longwave_radiation** + - `"canopy radiation balance`" **CANOPY_DOMAIN-radiation_balance** + + DEPENDENCIES: + - `"incoming shortwave radiation`" **SURFACE_DOMAIN-incoming_shortwave_radiation** - `"incoming longwave radiation`" **SURFACE_DOMAIN-incoming_longwave_radiation** - `"canopy temperature`" **CANOPY_DOMAIN-temperature** - `"leaf area index`" **CANOPY_DOMAIN-leaf_area_index** -Note that this is a subset of the physics in the "radiation balance evaluator," +.. note:: + + This evaluator also uses the :ref:`Land Cover` types. From that struct, it + requires the value of the following parameters: + + - `"Beer's law extinction coefficient, shortwave [-]`" + - `"Beer's law extinction coefficient, longwave [-]`" + - `"albedo of canopy [-]`" + + +Note that this is a *subset* of the physics in the "radiation balance evaluator," and is therefore mutually exclusive with that model. */ @@ -85,7 +97,8 @@ class CanopyRadiationEvaluator : public EvaluatorSecondaryMonotypeCV { protected: virtual void EnsureCompatibility_ToDeps_(State& S) override; - virtual void EnsureCompatibility_Structure_(State& S) override { + virtual void EnsureCompatibility_Structure_(State& S) override + { EnsureCompatibility_StructureSame_(S); } diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/drainage_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/drainage_evaluator.hh index 171a864d5..62e383618 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/drainage_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/drainage_evaluator.hh @@ -34,8 +34,8 @@ Drainage is given by: .. math:: D = max(0, \frac{(\Theta - \Theta_sat)}{\tau}) -.. _drainage-evaluator-spec: -.. admonition:: drainage-evaluator-spec +.. _evaluator-drainage-spec: +.. admonition:: evaluator-drainage-spec * `"drainage timescale [s]`" ``[double]`` **864** Timescale over which drainage occurs. * `"saturated specific water content [m^3 H2O / m^2 leaf area]`" ``[double]`` **1e-4** @@ -72,7 +72,8 @@ class DrainageEvaluator : public EvaluatorSecondaryMonotypeCV { const Tag& wrt_tag, const std::vector& results) override; - virtual void EnsureCompatibility_Structure_(State& S) override { + virtual void EnsureCompatibility_Structure_(State& S) override + { EnsureCompatibility_StructureSame_(S); } diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/evaporation_downregulation_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/evaporation_downregulation_evaluator.hh index f7c5030bc..3a346aef9 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/evaporation_downregulation_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/evaporation_downregulation_evaluator.hh @@ -8,9 +8,23 @@ */ /*! -Downregulates evaporation through a dessicated zone via soil resistance. -Currently support two soil resistance methods: Sakagucki-Zeng and Sellers. -This will call soil resistance evaluator. + +This evaluator computes actual evaporation from potential evaporation due to a +dessicated zone via soil resistance. + +.. math:: + + E = \frac{E_{potential}}{1 + R_{soil}} + +`"evaluator type`" = `"evaporation downregulation, soil resistance`" + +.. _evaluator-evaporation-downregulation-soil-resistance: +.. admonition:: evaluator-evaporation-downregulation-soil-resistance + + DEPENDENCIES: + + - `"potential evaporation`" + - `"soil resistance`" */ @@ -30,8 +44,9 @@ class EvaporationDownregulationEvaluator : public EvaluatorSecondaryMonotypeCV { EvaporationDownregulationEvaluator(const EvaporationDownregulationEvaluator& other) = default; virtual Teuchos::RCP Clone() const override; - virtual bool - IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override { // this will mostly be differentiated with respect to pressure for flow // Jacobians, but none of the terms that _really_ depend on p are actually diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_evaluator.cc index 3c43fe82f..7f26abb18 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_evaluator.cc @@ -128,7 +128,7 @@ IncidentShortwaveRadiationEvaluator::EvaluatePartialDerivative_( double time = S.get_time(); if (wrt_key == slope_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& slope_v = *slope->ViewComponent(*comp, false); const Epetra_MultiVector& aspect_v = *aspect->ViewComponent(*comp, false); @@ -143,7 +143,7 @@ IncidentShortwaveRadiationEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == aspect_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& slope_v = *slope->ViewComponent(*comp, false); const Epetra_MultiVector& aspect_v = *aspect->ViewComponent(*comp, false); @@ -158,7 +158,7 @@ IncidentShortwaveRadiationEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == qSWin_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& slope_v = *slope->ViewComponent(*comp, false); const Epetra_MultiVector& aspect_v = *aspect->ViewComponent(*comp, false); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_evaluator.hh index 39c87de74..08494766f 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_evaluator.hh @@ -7,9 +7,10 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Evaluates the radiation incident on a non-flat surface. /*! +Evaluates the radiation incident on a non-flat surface. + Aspect modified shortwave radiation is determined by a factor which is multiplied by the 'incoming radiation incident on a flat surface' to determine the 'incoming radiation incident on a sloping surface of a given aspect' as a @@ -28,16 +29,18 @@ This implementation is derived from `LandLab code `_, which is released under the MIT license. +`"evaluator type`" = `"incident shortwave radiation`" + +.. _evaluator-incident_shortwave_radiation-spec: +.. admonition:: evaluator-incident_shortwave_radiation-spec -.. _incident_shortwave_radiation_evaluator-spec: -.. admonition:: incident_shortwave_radiation_evaluator-spec + * `"incident shortwave radiation parameters`" ``[incident-shortwave-radiation-model-spec]`` - * `"incident shortwave radiation parameters`" ``[incident_shortwave_radiation_model-spec]`` + DEPENDENCIES: - KEYS: - - `"slope`" **DOMAIN-slope_magnitude** - - `"aspect`" **DOMAIN-aspect** - - `"incoming shortwave radiation`" **DOMAIN-incoming_shortwave_radiation** + - `"slope`" + - `"aspect`" + - `"incoming shortwave radiation`" */ diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_model.cc b/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_model.cc index f462a34d1..121abca27 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_model.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_model.cc @@ -74,13 +74,15 @@ IncidentShortwaveRadiationModel::IncidentShortwaveRadiation(double slope, int doy_ii = doy_i + 1; if (doy_ii > 364) doy_ii = 0; double rad_ii = Impl::Radiation(slope, aspect, doy_ii, hour, lat_, qSWin); - rad = rad_i + (doy - doy_i) * rad_ii; + double ddoy = (doy - doy_i); + rad = (1 - ddoy) * rad_i + ddoy * rad_ii; } else { double rad_i = Impl::Radiation(slope, aspect, doy_i, hour, lat_, qSWin); int doy_ii = doy_i - 1; if (doy_ii < 0) doy_ii = 364; double rad_ii = Impl::Radiation(slope, aspect, doy_ii, hour, lat_, qSWin); - rad = rad_i + (doy_i - doy) * rad_ii; + double ddoy = (doy - doy_i); + rad = (1 - ddoy) * rad_i + ddoy * rad_ii; } } else { double hour = 12.0 + 24 * (doy - doy_i); @@ -335,10 +337,8 @@ Radiation(double slope, double aspect, int doy, double hour, double lat, double { auto facs = GeometricRadiationFactors(slope, aspect, doy, hour, lat); double fac = facs.first / facs.second; - if (fac > 6.) - fac = 6.; - else if (fac < 0.) - fac = 0.; + if (fac > 6.) fac = 6.; + else if (fac < 0.) fac = 0.; return qSWin * fac; } diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_model.hh b/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_model.hh index 11655b145..2a9d8eb11 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_model.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/incident_shortwave_radiation_model.hh @@ -10,8 +10,8 @@ //! Evaluates shortwave as a function of slope/aspect/etc. /*! -.. _incident_shortwave_radiation_model-spec: -.. admonition:: incident_shortwave_radiation_model-spec +.. _incident-shortwave-radiation-model-spec: +.. admonition:: incident-shortwave-radiation-model-spec * `"latitude [degrees]`" ``[double]`` Latitude of the site. A single typical value is fine for most domains, even relatively large ones @@ -34,22 +34,18 @@ namespace SurfaceBalance { namespace Relations { namespace Impl { -double -DeclinationAngle(double doy); -double -HourAngle(double hour); -double -SolarAltitude(double delta, double phi, double tau); -double -SolarAzhimuth(double delta, double phi, double tau); -double -FlatGeometry(double alpha, double phi_sun); -double -SlopeGeometry(double slope, double aspect, double alpha, double phi_sun); -std::pair -GeometricRadiationFactors(double slope, double aspect, int doy, double hour, double lat); -double -Radiation(double slope, double aspect, int doy, double hr, double lat, double qSWin); +double DeclinationAngle(double doy); +double HourAngle(double hour); +double SolarAltitude(double delta, double phi, double tau); +double SolarAzhimuth(double delta, double phi, double tau); +double FlatGeometry(double alpha, double phi_sun); +double SlopeGeometry(double slope, double aspect, double alpha, double phi_sun); +std::pair GeometricRadiationFactors(double slope, + double aspect, + int doy, + double hour, + double lat); +double Radiation(double slope, double aspect, int doy, double hr, double lat, double qSWin); } // namespace Impl @@ -59,10 +55,14 @@ class IncidentShortwaveRadiationModel { double IncidentShortwaveRadiation(double slope, double aspect, double qSWin, double time) const; - double - DIncidentShortwaveRadiationDSlope(double slope, double aspect, double qSWin, double time) const; - double - DIncidentShortwaveRadiationDAspect(double slope, double aspect, double qSWin, double time) const; + double DIncidentShortwaveRadiationDSlope(double slope, + double aspect, + double qSWin, + double time) const; + double DIncidentShortwaveRadiationDAspect(double slope, + double aspect, + double qSWin, + double time) const; double DIncidentShortwaveRadiationDIncomingShortwaveRadiation(double slope, double aspect, double qSWin, diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/interception_fraction_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/interception_fraction_evaluator.cc index 8cdc3e973..d2e9ce84f 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/interception_fraction_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/interception_fraction_evaluator.cc @@ -88,7 +88,7 @@ InterceptionFractionEvaluator::Evaluate_(const State& S, Teuchos::RCP drainage = S.GetPtr(drainage_key_, tag); Teuchos::RCP air_temp = S.GetPtr(air_temp_key_, tag); - for (CompositeVector::name_iterator comp = results[0]->begin(); comp != results[0]->end(); + for (CompositeVector::name_iterator comp = results[0]->begin() ; comp != results[0]->end(); ++comp) { const Epetra_MultiVector& ai_v = *ai->ViewComponent(*comp, false); const Epetra_MultiVector& rain_v = *rain->ViewComponent(*comp, false); @@ -129,7 +129,7 @@ InterceptionFractionEvaluator::EvaluatePartialDerivative_( Teuchos::RCP drainage = S.GetPtr(drainage_key_, tag); Teuchos::RCP air_temp = S.GetPtr(air_temp_key_, tag); - for (CompositeVector::name_iterator comp = results[0]->begin(); comp != results[0]->end(); + for (CompositeVector::name_iterator comp = results[0]->begin() ; comp != results[0]->end(); ++comp) { const Epetra_MultiVector& ai_v = *ai->ViewComponent(*comp, false); const Epetra_MultiVector& rain_v = *rain->ViewComponent(*comp, false); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/interception_fraction_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/interception_fraction_evaluator.hh index 100d81497..c9de444e3 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/interception_fraction_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/interception_fraction_evaluator.hh @@ -29,8 +29,8 @@ all snow). This evaluator partitions the drainage and sums it with throughfall to compute the total source, in each phase, to the layer below the canopy (snow and/or ground surface). -.. _interception-fraction-evaluator-spec: -.. admonition:: interception-fraction-evaluator-spec +.. _evaluator-interception-fraction-spec: +.. admonition:: evaluator-interception-fraction-spec * `"interception fraction parameters`" ``[interception-fraction-model-spec]`` @@ -74,7 +74,8 @@ class InterceptionFractionEvaluator : public EvaluatorSecondaryMonotypeCV { const Key& wrt_key, const Tag& wrt_tag, const std::vector& results) override; - virtual void EnsureCompatibility_Structure_(State& S) override { + virtual void EnsureCompatibility_Structure_(State& S) override + { EnsureCompatibility_StructureSame_(S); } diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/land_cover_evaluator_reg.hh b/src/pks/surface_balance/constitutive_relations/land_cover/land_cover_evaluator_reg.hh index 275d04c2e..333641250 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/land_cover_evaluator_reg.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/land_cover_evaluator_reg.hh @@ -32,8 +32,8 @@ namespace Amanzi { namespace SurfaceBalance { namespace Relations { -Utils::RegisteredFactory - AlbedoTwoComponentEvaluator::reg_("subgrid albedos, two components"); +Utils::RegisteredFactory AlbedoTwoComponentEvaluator::reg_( + "subgrid albedos, two components"); Utils::RegisteredFactory AlbedoThreeComponentEvaluator::reg_("subgrid albedos, three components"); @@ -51,22 +51,22 @@ Utils::RegisteredFactory IncidentShortwaveRadiationEvaluator::reg_("incident shortwave radiation"); -Utils::RegisteredFactory - LongwaveEvaluator::reg_("incoming longwave radiation"); +Utils::RegisteredFactory LongwaveEvaluator::reg_( + "incoming longwave radiation"); Utils::RegisteredFactory InterceptionFractionEvaluator::reg_("interception fraction"); Utils::RegisteredFactory DrainageEvaluator::reg_("canopy drainage"); -Utils::RegisteredFactory - PETPriestleyTaylorEvaluator::reg_("potential evapotranspiration, Priestley-Taylor"); +Utils::RegisteredFactory PETPriestleyTaylorEvaluator::reg_( + "potential evapotranspiration, Priestley-Taylor"); Utils::RegisteredFactory EvaporationDownregulationEvaluator::reg_("evaporation downregulation, soil resistance"); -Utils::RegisteredFactory - PlantWiltingFactorEvaluator::reg_("plant wilting factor"); +Utils::RegisteredFactory PlantWiltingFactorEvaluator::reg_( + "plant wilting factor"); Utils::RegisteredFactory RootingDepthFractionEvaluator::reg_("root fraction"); @@ -77,20 +77,20 @@ Utils::RegisteredFactory TranspirationDistributionRelPermEvaluator::reg_( "transpiration distribution, relative permeability"); -Utils::RegisteredFactory - SnowMeltRateEvaluator::reg_("snow melt rate"); +Utils::RegisteredFactory SnowMeltRateEvaluator::reg_( + "snow melt rate"); -Utils::RegisteredFactory - RadiationBalanceEvaluator::reg_("radiation balance, surface and canopy"); +Utils::RegisteredFactory RadiationBalanceEvaluator::reg_( + "radiation balance, surface and canopy"); -Utils::RegisteredFactory - CanopyRadiationEvaluator::reg_("canopy radiation balance from above"); +Utils::RegisteredFactory CanopyRadiationEvaluator::reg_( + "canopy radiation balance from above"); -Utils::RegisteredFactory - SEBTwoComponentEvaluator::reg_("surface energy balance, two components"); +Utils::RegisteredFactory SEBTwoComponentEvaluator::reg_( + "surface energy balance, two components"); -Utils::RegisteredFactory - SEBThreeComponentEvaluator::reg_("surface energy balance, three components"); +Utils::RegisteredFactory SEBThreeComponentEvaluator::reg_( + "surface energy balance, three components"); } // namespace Relations } // namespace SurfaceBalance diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/longwave_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/longwave_evaluator.cc index 37cb4ea55..636e7777d 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/longwave_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/longwave_evaluator.cc @@ -7,20 +7,6 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Evaluates incoming longwave radiation from vapor pressure and air temperature. -/*! - -.. _longwave_evaluator-spec: -.. admonition:: longwave_evaluator-spec - - - DEPENDENCIES: - - * `"air temperature key`" ``[string]`` **DOMAIN-air_temperature** - * `"vapor pressure air key`" ``[string]`` **DOMAIN-vapor_pressure_air** - -*/ - #include "Key.hh" #include "seb_physics_defs.hh" #include "seb_physics_funcs.hh" diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/longwave_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/longwave_evaluator.hh index ab2e14b1c..f136fc3cc 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/longwave_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/longwave_evaluator.hh @@ -7,17 +7,17 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! Evaluates incoming longwave radiation from vapor pressure and air temperature. /*! -.. _longwave_evaluator-spec: -.. admonition:: longwave_evaluator-spec +Estimates incoming longwave radiation from vapor pressure and air temperature. +.. _evaluator-incoming-longwave-radiation-spec: +.. admonition:: evaluator-incoming-longwave-radiation-spec - DEPENDENCIES: + DEPENDENCIES: - * `"air temperature key`" ``[string]`` **DOMAIN-air_temperature** - * `"vapor pressure air key`" ``[string]`` **DOMAIN-vapor_pressure_air** + * `"air temperature key`" + * `"vapor pressure air key`" */ diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/pet_priestley_taylor_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/pet_priestley_taylor_evaluator.cc index 7b4707f33..20a51b61b 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/pet_priestley_taylor_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/pet_priestley_taylor_evaluator.cc @@ -146,10 +146,8 @@ PETPriestleyTaylorEvaluator::Evaluate_(const State& S, const std::vectorViewComponent("cell", false))(0); res_c.ReciprocalMultiply(1, *limiter(limiter_dof_), *evap_val(0), 0); for (int c = 0; c != res_c.MyLength(); ++c) { - if (limiter[limiter_dof_][c] < 1.e-5) { res_c[c] = 0.; } + if (limiter[limiter_dof_][c] < 1.e-5) { + res_c[c] = 0.; + } } } else if (one_minus_limiter_ && wrt_key == one_minus_limiter_key_) { const auto& limiter = @@ -216,7 +216,9 @@ PETPriestleyTaylorEvaluator::EvaluatePartialDerivative_(const State& S, auto& res_c = *(*result[0]->ViewComponent("cell", false))(0); res_c.ReciprocalMultiply(-1, *limiter(one_minus_limiter_dof_), *evap_val(0), 0); for (int c = 0; c != res_c.MyLength(); ++c) { - if (limiter[one_minus_limiter_dof_][c] < 1.e-5) { res_c[c] = 0.; } + if (limiter[one_minus_limiter_dof_][c] < 1.e-5) { + res_c[c] = 0.; + } } } } @@ -227,7 +229,7 @@ PETPriestleyTaylorEvaluator::EnsureCompatibility_ToDeps_(State& S) { if (!compatible_) { land_cover_ = - getLandCover(S.ICList().sublist("land cover types"), { "pt_alpha_" + evap_type_ }); + getLandCover(S.GetModelParameters("land cover types"), { "pt_alpha_" + evap_type_ }); Tag tag = my_keys_.front().second; for (auto& dep : dependencies_) { diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/pet_priestley_taylor_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/pet_priestley_taylor_evaluator.hh index fec0076b3..c6d469ff8 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/pet_priestley_taylor_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/pet_priestley_taylor_evaluator.hh @@ -16,8 +16,8 @@ pages 90-93, Equations 1-57 to 1-60 Requires the following dependencies: -.. _pet-priestley-taylor-evaluator-spec: -.. admonition:: pet-priestley-taylor-evaluator-spec: +.. _evaluator-pet-priestley-taylor-spec: +.. admonition:: evaluator-pet-priestley-taylor-spec: * `"include limiter`" ``[bool]`` **false** If true, multiply potential ET by a limiter to get an actual ET. @@ -33,15 +33,16 @@ Requires the following dependencies: * `"1 - limiter dof`" ``[int]`` **0** Area fractions are often used as limiters, and these have multiple dofs. This provides which one to use. * `"sublimate snow`" ``[bool]`` **false** If true, use latent heat of - vaporization of snow, not water. + vaporization of snow, not water. KEYS: - `"air temperature`" **DOMAIN-air_temperature** Air temp, in [K] - - `"surface temperature`" **DOMAIN-temperature** Ground or leaf temp, in [K]. Note this may be the - same as air temperature. + - `"surface temperature`" **DOMAIN-temperature** Ground or leaf temp, in + [K]. Note this may be the same as air temperature. - `"elevation`" **DOMAIN-elevation** Elevation [m] - - `"net radiation`" **DOMAIN-net_radiation** [W m^-2] Net radiation balance, positive to the ground. + - `"net radiation`" **DOMAIN-net_radiation** [W m^-2] Net radiation balance, + positive to the ground. - `"limiter`" [-] See `"include limiter`" above. - `"1 - limiter`" [-] See `"include 1 - limiter`" above. @@ -64,38 +65,33 @@ namespace PriestleyTaylor { // [MJ m^-2 d^-1] given a daily-averaged ground and air temperature // (in C or K). We convert to W/m^2 // -double -groundHeatFlux(double temp_ground, double temp_air); +double groundHeatFlux(double temp_ground, double temp_air); // // PRMS-IV eqn 1-58, calculates the slope of vapor pressure as a function of // daily averaged air temperature [K], in [KPa C^-1] // -double -vaporPressureSlope(double temp_air); +double vaporPressureSlope(double temp_air); // // PRMS-IV eqn 1-57, calculates the psychrometric constant in [KPa C^-1] as a // function of an elevation (lapse rate fixed) and a latent heat of // vaporization in [cal gm^-1]. // -double -psychrometricConstant(double lh_vap, double evel); +double psychrometricConstant(double lh_vap, double evel); // // PRMS-IV eqn 1-51, calculates the latent heat of vaporization [cal g^-1] as a // function of the daily averaged air temperature [K] for liquid water // -double -latentHeatVaporization_water(double temp_air); +double latentHeatVaporization_water(double temp_air); // // PRMS-IV eqn 1-51, calculates the latent heat of vaporization [cal g^-1] as a // function of the daily averaged air temperature [K] for snow -- note this is // currently the same as the water value, but should get modified for snow! // -double -latentHeatVaporization_snow(double temp_air); +double latentHeatVaporization_snow(double temp_air); } // namespace PriestleyTaylor diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_evaluator.cc index 4e3d9c0b1..40f07fc3e 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_evaluator.cc @@ -100,7 +100,7 @@ PlantWiltingFactorEvaluator::EnsureCompatibility_ToDeps_(State& S) { if (models_.size() == 0) { land_cover_ = - getLandCover(S.ICList().sublist("land cover types"), + getLandCover(S.GetModelParameters("land cover types"), { "stomata_closed_capillary_pressure", "stomata_open_capillary_pressure" }); for (const auto& lc : land_cover_) { models_[lc.first] = Teuchos::rcp(new PlantWiltingFactorModel(lc.second)); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_evaluator.hh index 9bb5ee28f..99839c3ba 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_evaluator.hh @@ -14,27 +14,33 @@ Also known as Beta, or the water availability factor, or the plant wilting factor, or the transpiration reduction function. .. math:: - Beta = (p_closed - p) / (p_closed - p_open) + + \beta = \frac{p_{closed} - p}{p_{closed} - p_{open}} where p is the capillary pressure or water potential, and closed and open indicate the values at which stomates are fully open or fully closed (the wilting point). -Note this makes use of LandCover objects for water potential of fully open and -fully closed stomata. - Note the challenges of using this model with arbitrary van Genuchten WRMs. See -Verhoef & Egea, Ag. & Forest Meteorology, 2014 -https://doi.org/10.1016/j.agrformet.2014.02.009 +`Verhoef & Egea, Ag. & Forest Meteorology, 2014 +`_ -.. _plant-wilting-factor-evaluator-spec: -.. admonition:: plant-wilting-factor-evaluator-spec +.. _evaluator-plant-wilting-factor-spec: +.. admonition:: evaluator-plant-wilting-factor-spec KEYS: - `"capillary pressure`" **DOMAIN-capillary_pressure_gas_liq** +.. note:: + + This evaluator also uses the :ref:`Land Cover` types. From that struct, it + requires the value of the following parameters: + + - `"capillary pressure at fully closed stomata [Pa]`" + - `"capillary pressure at fully open stomata [Pa]`" + */ diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_model.cc b/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_model.cc index 21846e9da..4766c322a 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_model.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/plant_wilting_factor_model.cc @@ -17,7 +17,9 @@ namespace SurfaceBalance { namespace Relations { // Constructor from ParameterList -PlantWiltingFactorModel::PlantWiltingFactorModel(const LandCover& lc) : lc_(lc) {} +PlantWiltingFactorModel::PlantWiltingFactorModel(const LandCover& lc) + : lc_(lc) +{} // main method double diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/radiation_balance_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/radiation_balance_evaluator.cc index 535f37786..a51614846 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/radiation_balance_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/radiation_balance_evaluator.cc @@ -82,7 +82,7 @@ void RadiationBalanceEvaluator::EnsureCompatibility_ToDeps_(State& S) { if (!compatible_) { - land_cover_ = getLandCover(S.ICList().sublist("land cover types"), + land_cover_ = getLandCover(S.GetModelParameters("land cover types"), { "beers_k_lw", "beers_k_sw", "albedo_canopy" }); for (const auto& dep : dependencies_) { @@ -177,15 +177,6 @@ RadiationBalanceEvaluator::Evaluate_(const State& S, const std::vector& results) -{ - for (const auto& res : results) res->PutScalar(0.); -} - } // namespace Relations } // namespace SurfaceBalance diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/radiation_balance_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/radiation_balance_evaluator.hh index b098e6065..7a152c60f 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/radiation_balance_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/radiation_balance_evaluator.hh @@ -6,10 +6,10 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! Evaluates a net radiation balance for ground and canopy. /*! +This evaluates a net radiation balance for ground and canopy. + Here the net radiation is positive for energy inputs to the layer. Note that ground is based on the two-channel (land + snow) while canopy is assumed to be a simple, single layer. @@ -17,8 +17,6 @@ a simple, single layer. This evaluator requires that the surface temperature, snow temperature, and canopy temperature are known, or at least being solved for. -Requires the use of LandCover types, for albedo and Beer's law coefficients. - This is combination of CLM v4.5 Tech Note and Beer's law for attenuation of radiation absorption. In particular, long-wave is exactly as Figure 4.1c in CLM 4.5 Tech Note. The main difference comes in how absorptivity (which is equal @@ -47,15 +45,19 @@ Computes: bounces (e.g. reflected atmosphere->canopy->cloud->back to canopy, or transmitted by the canopy, reflected by snow/surface. -Requires the use of LandCover types, for canopy albedo and Beer's law -coefficients. - `"evaluator type`" = `"radiation balance, surface and canopy`" -.. _radiation-balance-evaluator-spec: -.. admonition:: radiation-balance-evaluator-spec +.. _evaluator-radiation-balance-spec: +.. admonition:: evaluator-radiation-balance-spec KEYS: + + - `"surface radiation balance`" + - `"snow radiation balance`" + - `"canopy radiation balance`" + + DEPENDENCIES: + - `"surface albedos`" **SURFACE_DOMAIN-albedos** - `"surface emissivities`" **SURFACE_DOMAIN-emissivities** - `"incoming shortwave radiation`" **SURFACE_DOMAIN-incoming_shortwave_radiation** @@ -66,7 +68,18 @@ coefficients. - `"leaf area index`" **CANOPY_DOMAIN-leaf_area_index** - `"area fractions`" **SURFACE_DOMAIN-area_fractions** -Note that this is a superset of the physics in the "canopy radiation + +.. note:: + + This evaluator also uses the :ref:`Land Cover` types. From that struct, it + requires the value of the following parameters: + + - `"Beer's law extinction coefficient, shortwave [-]`" + - `"Beer's law extinction coefficient, longwave [-]`" + - `"albedo of canopy [-]`" + + +Note that this is a *superset* of the physics in the "canopy radiation evaluator," and is therefore mutually exclusive with that model. */ @@ -91,9 +104,16 @@ class RadiationBalanceEvaluator : public EvaluatorSecondaryMonotypeCV { return Teuchos::rcp(new RadiationBalanceEvaluator(*this)); } + bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override { + return false; + } + protected: virtual void EnsureCompatibility_ToDeps_(State& S) override; - virtual void EnsureCompatibility_Structure_(State& S) override { + virtual void EnsureCompatibility_Structure_(State& S) override + { EnsureCompatibility_StructureSame_(S); } @@ -101,9 +121,9 @@ class RadiationBalanceEvaluator : public EvaluatorSecondaryMonotypeCV { virtual void Evaluate_(const State& S, const std::vector& results) override; virtual void EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, - const Tag& wrt_tag, - const std::vector& results) override; + const Key& wrt_key, + const Tag& wrt_tag, + const std::vector& results) override {} protected: Key domain_surf_; diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/rooting_depth_fraction_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/rooting_depth_fraction_evaluator.cc index 835f37271..5a7490115 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/rooting_depth_fraction_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/rooting_depth_fraction_evaluator.cc @@ -137,7 +137,7 @@ RootingDepthFractionEvaluator::EnsureCompatibility_ToDeps_(State& S) { if (land_cover_.size() == 0) { land_cover_ = - getLandCover(S.ICList().sublist("land cover types"), + getLandCover(S.GetModelParameters("land cover types"), { "rooting_depth_max", "rooting_profile_alpha", "rooting_profile_beta" }); } diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/rooting_depth_fraction_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/rooting_depth_fraction_evaluator.hh index a2bc8b32d..568cb936f 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/rooting_depth_fraction_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/rooting_depth_fraction_evaluator.hh @@ -21,20 +21,27 @@ computing this over the vertical corridor is done by integrating this function between the depth of the face above and below for each grid cell, with the bottom-most grid cell integrating to infinity. -Note that the two parameters, :math:`\alpha` and :math:`\beta` are provided in -the Land Cover class as `"rooting profile alpha`" and `"rooting profile beta`" -respectively. +.. _evaluator-rooting-depth-fraction-spec: +.. admonition:: evaluator-rooting-depth-fraction-spec -.. _rooting-depth-fraction-evaluator-spec: -.. admonition:: rooting-depth-fraction-evaluator-spec - - * `"surface domain name`" ``[string]`` **SURFACE_DOMAIN** Sane default provided for most domain names. + * `"surface domain name`" ``[string]`` **SURFACE_DOMAIN** Sane default + provided for most domain names. KEYS: - `"cell volume`" **DOMAIN-cell_volume** - `"surface area`" **SURFACE_DOMAIN-cell_volume** + +.. note:: + + This evaluator also uses the :ref:`Land Cover` types. From that struct, it + requires the value of the following parameters: + + - `"rooting profile alpha [-]`" + - `"rooting profile beta [-]`" + - `"rooting depth max [m]`" + */ #pragma once @@ -61,8 +68,9 @@ class RootingDepthFractionEvaluator : public EvaluatorSecondaryMonotypeCV { const Tag& wrt_tag, const std::vector& result) override; - virtual bool - IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override { return false; } diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_defs.hh b/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_defs.hh index ea92d3846..3d9715ea9 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_defs.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_defs.hh @@ -72,7 +72,8 @@ struct ModelParams { Cd0_d(0.) {} - ModelParams(Teuchos::ParameterList& plist) : ModelParams() + ModelParams(Teuchos::ParameterList& plist) + : ModelParams() { thermalK_freshsnow = plist.get("thermal conductivity of fresh snow [W m^-1 K^-1]", thermalK_freshsnow); @@ -196,7 +197,9 @@ struct MassBalance { // all are in [m/s] of WATER, i.e. snow are in SWE double Mm; // melt rate (positive indicates increasing water, decreasing snow) double dt; // max dt that may be taken to conserve snow swe - MassBalance() : Me(NaN), Mm(NaN) {} + MassBalance() + : Me(NaN), Mm(NaN) + {} }; @@ -208,7 +211,9 @@ struct FluxBalance { double E_subsurf; // [W/m^2], energy to/from subsurface system double M_snow; // [m/s], mass swe to snow system - FluxBalance() : M_surf(0.), E_surf(0.), M_subsurf(0.), E_subsurf(0.), M_snow(0.) {} + FluxBalance() + : M_surf(0.), E_surf(0.), M_subsurf(0.), E_subsurf(0.), M_snow(0.) + {} }; diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_funcs.cc b/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_funcs.cc index 9c62385c5..44dbe61a4 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_funcs.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_funcs.cc @@ -133,10 +133,8 @@ SaturatedVaporPressureELM(double temp) double coef_i[9] = { 6.11213467, 4.44007856e-1, 1.43064234e-2, 2.64461437e-4, 3.05903558e-6, 1.96237241e-8, 8.92344772e-11, -3.73208410e-13, 2.09339997e-16 }; double* coef; - if (T >= 0) - coef = coef_w; - else - coef = coef_i; + if (T >= 0) coef = coef_w; + else coef = coef_i; double res = coef[0]; double Tn = T; @@ -473,10 +471,9 @@ UpdateFluxesWithoutSnow(const GroundProperties& surf, // Energy to surface. double Train = std::max(0., met.air_temp - 273.15); - flux.E_surf = eb.fQswIn + eb.fQlwIn - eb.fQlwOut + eb.fQh // purely energy fluxes - - eb.fQm // energy put into melting snow - + - surf.density_w * met.Pr * Train * params.Cv_water; // energy advected in by rainfall + flux.E_surf = eb.fQswIn + eb.fQlwIn - eb.fQlwOut + eb.fQh // purely energy fluxes + - eb.fQm // energy put into melting snow + + surf.density_w * met.Pr * Train * params.Cv_water; // energy advected in by rainfall // zero subsurf values flux.M_subsurf = 0.; @@ -545,8 +542,8 @@ UpdateFluxesWithSnow(const GroundProperties& surf, // Energy to surface. double Train = std::max(0., met.air_temp - 273.15); - flux.E_surf = eb.fQc // conducted to ground - + surf.density_w * met.Pr * Train * params.Cv_water; // rain enthalpy + flux.E_surf = eb.fQc // conducted to ground + + surf.density_w * met.Pr * Train * params.Cv_water; // rain enthalpy // + 0 // enthalpy of meltwater at 0C. return flux; } diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_funcs.hh b/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_funcs.hh index 49250e6e2..96c29b539 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_funcs.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_physics_funcs.hh @@ -47,63 +47,56 @@ namespace Relations { // // Determine the albedo of snow as a function of density. // ------------------------------------------------------------------------------------------ -double -CalcAlbedoSnow(double density_snow); +double CalcAlbedoSnow(double density_snow); // // Determine the surface roughness // ------------------------------------------------------------------------------------------ -double -CalcRoughnessFactor(double snow_height, double Z_rough_bare, double Z_rough_snow); +double CalcRoughnessFactor(double snow_height, double Z_rough_bare, double Z_rough_snow); // // Calculate longwave from air temp and vapor pressure // ------------------------------------------------------------------------------------------ -double -IncomingLongwaveRadiation(double air_temp, double vapor_pressure_air); +double IncomingLongwaveRadiation(double air_temp, double vapor_pressure_air); // // Calculates incoming shortwave and longwave radiation incident on surface // ------------------------------------------------------------------------------------------ -std::pair -IncomingRadiation(const MetData& met, double albedo); +std::pair IncomingRadiation(const MetData& met, double albedo); // // Calculates outgoing longwave radiation // ------------------------------------------------------------------------------------------ -double -OutgoingLongwaveRadiation(double temp, double emissivity); +double OutgoingLongwaveRadiation(double temp, double emissivity); // // Beer's law for radiation attenuation through a single-layer canopy // ------------------------------------------------------------------------------------------ -double -BeersLawAbsorptivity(double k_extinction, double lai); +double BeersLawAbsorptivity(double k_extinction, double lai); // // Wind speed term D_he // ------------------------------------------------------------------------------------------ -double -WindFactor(double Us, double Z_Us, double Z_rough, double KB); +double WindFactor(double Us, double Z_Us, double Z_rough, double KB); // // Stability of convective overturning term Zeta AKA Sqig // ------------------------------------------------------------------------------------------ -double -StabilityFunction(double air_temp, double skin_temp, double Us, double Z_Us, double c_gravity); +double StabilityFunction(double air_temp, + double skin_temp, + double Us, + double Z_Us, + double c_gravity); // // Westermann 2016, saturated vapor pressure over water/ice // In [Pa] // ------------------------------------------------------------------------------------------ -double -SaturatedVaporPressure(double temp); -double -SaturatedVaporPressureELM(double temp); -double -SaturatedSpecificHumidityELM(double temp); +double SaturatedVaporPressure(double temp); +double SaturatedVaporPressureELM(double temp); +double SaturatedSpecificHumidityELM(double temp); // @@ -111,46 +104,41 @@ SaturatedSpecificHumidityELM(double temp); // After Ho & Webb 2006 // In [Pa] // ------------------------------------------------------------------------------------------ -double -VaporPressureGround(const GroundProperties& surf, const ModelParams& params); +double VaporPressureGround(const GroundProperties& surf, const ModelParams& params); // // Diffusion of vapor pressure limiter on evaporation. // After Sakagucki and Zeng 2009 eqaution (10) // ------------------------------------------------------------------------------------------ -double -EvaporativeResistanceGround(const GroundProperties& surf, - const MetData& met, - double vapor_pressure_ground); +double EvaporativeResistanceGround(const GroundProperties& surf, + const MetData& met, + double vapor_pressure_ground); // // Basic sensible heat. // ------------------------------------------------------------------------------------------ -double -SensibleHeat(double resistance_coef, - double density_air, - double Cp_air, - double air_temp, - double skin_temp); +double SensibleHeat(double resistance_coef, + double density_air, + double Cp_air, + double air_temp, + double skin_temp); // // Basic latent heat. // ------------------------------------------------------------------------------------------ -double -LatentHeat(double resistance_coef, - double density_air, /// this should be w? - double latent_heat_fusion, - double vapor_pressure_air, - double vapor_pressure_skin, - double Apa); +double LatentHeat(double resistance_coef, + double density_air, /// this should be w? + double latent_heat_fusion, + double vapor_pressure_air, + double vapor_pressure_skin, + double Apa); // // Heat conducted to ground via simple diffusion model between snow and skin surface. // ------------------------------------------------------------------------------------------ -double -ConductedHeatIfSnow(double ground_temp, const SnowProperties& snow); +double ConductedHeatIfSnow(double ground_temp, const SnowProperties& snow); // // Update the energy balance, solving for the amount of heat available to melt snow. @@ -158,25 +146,23 @@ ConductedHeatIfSnow(double ground_temp, const SnowProperties& snow); // NOTE, this should not be used directly -- instead it is called within the loop solving for // snow temperature. // ------------------------------------------------------------------------------------------ -void -UpdateEnergyBalanceWithSnow_Inner(const GroundProperties& surf, - const SnowProperties& snow, - const MetData& met, - const ModelParams& params, - EnergyBalance& eb); +void UpdateEnergyBalanceWithSnow_Inner(const GroundProperties& surf, + const SnowProperties& snow, + const MetData& met, + const ModelParams& params, + EnergyBalance& eb); // // Determine the snow temperature by solving for energy balance, i.e. the snow // temp at equilibrium. Assumes no melting (and therefore T_snow calculated // can be greater than 0 C. // ------------------------------------------------------------------------------------------ -double -DetermineSnowTemperature(const GroundProperties& surf, - const MetData& met, - const ModelParams& params, - SnowProperties& snow, - EnergyBalance& eb, - std::string method = "brent"); +double DetermineSnowTemperature(const GroundProperties& surf, + const MetData& met, + const ModelParams& params, + SnowProperties& snow, + EnergyBalance& eb, + std::string method = "brent"); // @@ -184,64 +170,58 @@ DetermineSnowTemperature(const GroundProperties& surf, // // NOTE, this CAN be used directly. // ------------------------------------------------------------------------------------------ -EnergyBalance -UpdateEnergyBalanceWithSnow(const GroundProperties& surf, - const MetData& met, - const ModelParams& params, - SnowProperties& snow); +EnergyBalance UpdateEnergyBalanceWithSnow(const GroundProperties& surf, + const MetData& met, + const ModelParams& params, + SnowProperties& snow); // // Update the energy balance, solving for the amount of heat conducted to the ground. // // NOTE, this CAN be used directly. // ------------------------------------------------------------------------------------------ -EnergyBalance -UpdateEnergyBalanceWithoutSnow(const GroundProperties& surf, - const MetData& met, - const ModelParams& params); +EnergyBalance UpdateEnergyBalanceWithoutSnow(const GroundProperties& surf, + const MetData& met, + const ModelParams& params); // // Given an energy balance, determine the resulting mass changes between // precip, evaporation, melt, etc, with snow. // ------------------------------------------------------------------------------------------ -MassBalance -UpdateMassBalanceWithSnow(const GroundProperties& surf, - const ModelParams& params, - const EnergyBalance& eb); +MassBalance UpdateMassBalanceWithSnow(const GroundProperties& surf, + const ModelParams& params, + const EnergyBalance& eb); // // Given an energy balance, determine the resulting mass changes between // precip, evaporation, melt, etc, with snow. // ------------------------------------------------------------------------------------------ -MassBalance -UpdateMassBalanceWithoutSnow(const GroundProperties& surf, - const ModelParams& params, - const EnergyBalance& eb); +MassBalance UpdateMassBalanceWithoutSnow(const GroundProperties& surf, + const ModelParams& params, + const EnergyBalance& eb); // // Given an energy balance and a mass balance, accumulate these into sources // for surf and subsurf. // ------------------------------------------------------------------------------------------ -FluxBalance -UpdateFluxesWithSnow(const GroundProperties& surf, - const MetData& met, - const ModelParams& params, - const SnowProperties& snow, - const EnergyBalance& eb, - const MassBalance& mb); +FluxBalance UpdateFluxesWithSnow(const GroundProperties& surf, + const MetData& met, + const ModelParams& params, + const SnowProperties& snow, + const EnergyBalance& eb, + const MassBalance& mb); // // Given an energy balance and a mass balance, accumulate these into sources // for surf and subsurf. // ------------------------------------------------------------------------------------------ -FluxBalance -UpdateFluxesWithoutSnow(const GroundProperties& surf, - const MetData& met, - const ModelParams& params, - const EnergyBalance& eb, - const MassBalance& mb, - bool model_1p1 = false); +FluxBalance UpdateFluxesWithoutSnow(const GroundProperties& surf, + const MetData& met, + const ModelParams& params, + const EnergyBalance& eb, + const MassBalance& mb, + bool model_1p1 = false); // Calculation of a snow temperature requires a root-finding operation, for diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc index 86949e77a..53bb9cbf4 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc @@ -605,7 +605,7 @@ SEBThreeComponentEvaluator::EvaluatePartialDerivative_(const State& S, const Tag& wrt_tag, const std::vector& results) { - //AMANZI_ASSERT(false); + AMANZI_ASSERT(false); } void @@ -632,7 +632,7 @@ SEBThreeComponentEvaluator::EnsureCompatibility_ToDeps_(State& S) if (land_cover_.size() == 0) land_cover_ = - getLandCover(S.ICList().sublist("land cover types"), + getLandCover(S.GetModelParameters("land cover types"), { "roughness_snow", "roughness_ground", "water_transition_depth" }); // use domain name to set the mesh type diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.hh index 605481d95..49450d3a9 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.hh @@ -22,10 +22,10 @@ approach for water. All snow is assumed to first cover water (likely ice), then cover land, as both water and snow prefer low-lying depressions due to gravity- and wind-driven redistributions, respectively. -`"evaluator type`" = `"surface energy balance, two components`" +`"evaluator type`" = `"surface energy balance, three components`" -.. _seb-threecomponent-evaluator-spec: -.. admonition:: seb-threecomponent-evaluator-spec +.. _evaluator-seb-threecomponent-spec: +.. admonition:: evaluator-seb-threecomponent-spec * `"wind speed reference height [m]`" ``[double]`` **2.0** Reference height at which wind speed is measured. @@ -114,6 +114,14 @@ class SEBThreeComponentEvaluator : public EvaluatorSecondaryMonotypeCV { return Teuchos::rcp(new SEBThreeComponentEvaluator(*this)); } + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override + { + // manually turn off derivatives + return false; + } + protected: virtual void EnsureCompatibility_ToDeps_(State& S) override; diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_twocomponent_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/seb_twocomponent_evaluator.cc index ceca30c32..218809425 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_twocomponent_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_twocomponent_evaluator.cc @@ -287,10 +287,8 @@ SEBTwoComponentEvaluator::Evaluate_(const State& S, const std::vector& results) -{} +{ + AMANZI_ASSERT(false); +} void @@ -557,7 +555,7 @@ SEBTwoComponentEvaluator::EnsureCompatibility_ToDeps_(State& S) } if (land_cover_.size() == 0) - land_cover_ = getLandCover(S.ICList().sublist("land cover types"), + land_cover_ = getLandCover(S.GetModelParameters("land cover types"), { "roughness_snow", "roughness_ground", "water_transition_depth", diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_twocomponent_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/seb_twocomponent_evaluator.hh index b867b2582..bc7a3fdf2 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_twocomponent_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_twocomponent_evaluator.hh @@ -18,8 +18,8 @@ the ground from the atmosphere. `"evaluator type`" = `"surface energy balance, two components`" -.. _seb-twocomponent-evaluator-spec: -.. admonition:: seb-twocomponent-evaluator-spec +.. _evaluator-seb-twocomponent-spec: +.. admonition:: evaluator-seb-twocomponent-spec * `"wind speed reference height [m]`" ``[double]`` **2.0** Reference height at which wind speed is measured. @@ -115,6 +115,14 @@ class SEBTwoComponentEvaluator : public EvaluatorSecondaryMonotypeCV { return Teuchos::rcp(new SEBTwoComponentEvaluator(*this)); } + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override + { + // manually turn off derivatives + return false; + } + protected: // some variables on the surface mesh, others on the subsurface mesh virtual void EnsureCompatibility_ToDeps_(State& S) override; diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/snow_meltrate_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/snow_meltrate_evaluator.cc index 368809c84..5c6fc9bd8 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/snow_meltrate_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/snow_meltrate_evaluator.cc @@ -47,7 +47,7 @@ void SnowMeltRateEvaluator::EnsureCompatibility_ToDeps_(State& S) { // new state! - land_cover_ = getLandCover(S.ICList().sublist("land cover types"), { "snow_transition_depth" }); + land_cover_ = getLandCover(S.GetModelParameters("land cover types"), { "snow_transition_depth" }); EvaluatorSecondaryMonotypeCV::EnsureCompatibility_ToDeps_(S); } diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/snow_meltrate_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/snow_meltrate_evaluator.hh index e476b79ad..5e2494ca0 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/snow_meltrate_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/snow_meltrate_evaluator.hh @@ -32,8 +32,8 @@ the snow SWE goes to zero. That factor is 1 at the snow transition depth, and 0 when snow SWE is 0. This uses LandCover for the snow_ground_transition parameter. -.. _snow-meltrate-evaluator-spec: -.. admonition:: snow-meltrate-evaluator-spec +.. _evaluator-snow-meltrate-spec: +.. admonition:: evaluator-snow-meltrate-spec * `"snow melt rate [mm day^-1 C^-1]`" ``[double]`` **2.74** the melt rate per degree-day, above 0 C, e.g. :math:`R` above. diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_evaluator.cc index ad8acb318..11dd3036a 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_evaluator.cc @@ -136,7 +136,9 @@ TranspirationDistributionEvaluator::Evaluate_(const State& S, for (auto c : subsurf_mesh.columns.getCells(sc)) { result_v[0][c] *= coef; - if (limiter_local_) { result_v[0][c] *= f_wp[0][c]; } + if (limiter_local_) { + result_v[0][c] *= f_wp[0][c]; + } } } } @@ -165,7 +167,7 @@ TranspirationDistributionEvaluator::EnsureCompatibility_ToDeps_(State& S) // new state! if (land_cover_.size() == 0) land_cover_ = - getLandCover(S.ICList().sublist("land cover types"), { "leaf_on_doy", "leaf_off_doy" }); + getLandCover(S.GetModelParameters("land cover types"), { "leaf_on_doy", "leaf_off_doy" }); Key domain = Keys::getDomain(my_keys_.front().first); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_evaluator.hh index dde6d50b7..41718f196 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_evaluator.hh @@ -49,19 +49,13 @@ long. Good choices for those models depend upon the local climate, but may be something like Julian day 101 for leaf on and Julian day 254 for leaf off (PRMS defaults for US temperate forests). -Note that `"leaf on doy`" and `"leaf off doy`" are relative to the simulation's -zero time, not the start time. Typically these are Julian day of the year, but -this assumes that the 0 time of the simulation (not the "start time", but time -0!) is Jan 1. This leaf on/off cycle is modulo the `"year duration`" -(typically 1 noleap). Note if `"leaf off doy`" < `"leaf on time`" is ok too -- -this is the case if simulation time zero is mid-summer. These parameters come -from the LandCover type. - -.. _transpiration-distribution-evaluator-spec: -.. admonition:: transpiration-distribution-evaluator-spec +`"evaluator type`" = `"transpiration distribution, rooting depth`" + +.. _evaluator-transpiration-distribution-rooting-depth-spec: +.. admonition:: evaluator-transpiration-distribution-rooting-depth-spec + * `"year duration`" ``[double]`` **1** * `"year duration units`" ``[string]`` **noleap** - * `"water limiter function`" ``[function-spec]`` **optional** If provided, limit the total water sink as a function of the integral of the water potential * rooting fraction. @@ -74,6 +68,16 @@ from the LandCover type. - `"cell volume`" **DOMAIN-cell_volume** - `"surface cell volume`" **DOMAIN_SURF-cell_volume** + +.. note:: + + This evaluator also uses the :ref:`Land Cover` types. From that struct, it + requires the value of the following parameters: + + - `"leaf on time [doy]`" + - `"leaf off time [doy]`" + + */ #pragma once @@ -95,8 +99,9 @@ class TranspirationDistributionEvaluator : public EvaluatorSecondaryMonotypeCV { TranspirationDistributionEvaluator(const TranspirationDistributionEvaluator& other) = default; virtual Teuchos::RCP Clone() const override; - virtual bool - IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override { // calculate of derivatives of this is a tricky thing to do, with // non-cell-local terms due to rescaling. Just turn off derivatives diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_relperm_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_relperm_evaluator.cc index 09028bcf3..dd9398d63 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_relperm_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_relperm_evaluator.cc @@ -54,7 +54,8 @@ SoilPlantFluxFunctor::SoilPlantFluxFunctor(AmanziMesh::Entity_ID sc_, // increases, soil->plant flux should increase, so total_trans should increase, // so this function is hopefully monotonically decreasing with plant_pc double -SoilPlantFluxFunctor::operator()(double plant_pc) const { +SoilPlantFluxFunctor::operator()(double plant_pc) const +{ double total_trans = computeSoilPlantFluxes(plant_pc); return pet[0][sc] - total_trans; } @@ -218,11 +219,20 @@ TranspirationDistributionRelPermEvaluator::Evaluate_(const State& S, for (int sc : lc_ids) { if (potential_trans[0][sc] > 0. || krp_ > 0.) { SoilPlantFluxFunctor func(sc, - subsurf_mesh.columns.getCells(sc), - region_lc.second, - soil_pc, soil_kr, f_root, potential_trans, - rho, nliq, visc, cv, sa, - K_ * perm_scale, krp_ / perm_scale, g); + subsurf_mesh.columns.getCells(sc), + region_lc.second, + soil_pc, + soil_kr, + f_root, + potential_trans, + rho, + nliq, + visc, + cv, + sa, + K_ * perm_scale, + krp_ / perm_scale, + g); // compute the flux at max pc double pc_plant_max = region_lc.second.maximum_xylem_capillary_pressure; @@ -267,14 +277,17 @@ TranspirationDistributionRelPermEvaluator::Evaluate_(const State& S, // compute the plant capillary pressure using a root-finder int itrs = nits_; - plant_pc_v[0][sc] = Amanzi::Utils::findRootBrent(func, ab.first, ab.second, tol_, &itrs); + plant_pc_v[0][sc] = + Amanzi::Utils::findRootBrent(func, ab.first, ab.second, tol_, &itrs); AMANZI_ASSERT(itrs > 0 && itrs <= nits_); // compute the distributed transpiration fluxes for each grid cell func.computeSoilPlantFluxes(plant_pc_v[0][sc], &trans_v); } } else { - for (auto c : subsurf_mesh.columns.getCells(sc)) { trans_v[0][c] = 0.; } + for (auto c : subsurf_mesh.columns.getCells(sc)) { + trans_v[0][c] = 0.; + } } } } @@ -303,9 +316,8 @@ TranspirationDistributionRelPermEvaluator::EnsureCompatibility_ToDeps_(State& S) // new state! if (land_cover_.size() == 0) { - land_cover_ = - getLandCover(S.ICList().sublist("land cover types"), - { "maximum_xylem_capillary_pressure" }); + land_cover_ = getLandCover(S.GetModelParameters("land cover types"), + { "maximum_xylem_capillary_pressure" }); } // Create an unowned factory to check my dependencies. diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_relperm_evaluator.hh b/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_relperm_evaluator.hh index 367d764d5..467d2ed8f 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_relperm_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/land_cover/transpiration_distribution_relperm_evaluator.hh @@ -60,8 +60,8 @@ from plant to soil, is allowed. If it is set to 1, hydraulic redistribution is the maximal flow rate, e.g. no regulation by the plant is assumed. -.. _transpiration-distribution-relperm-evaluator-spec: -.. admonition:: transpiration-distribution-relperm-evaluator-spec +.. _evaluator-transpiration-distribution-relperm-spec: +.. admonition:: evaluator-transpiration-distribution-relperm-spec * `"plant permeability per m [m]`" ``[double]`` **1.e-12** :math:`K` above, the total plant permeability. @@ -126,7 +126,7 @@ struct SoilPlantFluxFunctor { // right hand side double computeSoilPlantFlux(double root_pc, AmanziMesh::Entity_ID c) const; - double computeSoilPlantFluxes(double root_pc, Epetra_MultiVector* trans=nullptr) const; + double computeSoilPlantFluxes(double root_pc, Epetra_MultiVector* trans = nullptr) const; const LandCover& lc; const Epetra_MultiVector& soil_pc; @@ -152,8 +152,9 @@ class TranspirationDistributionRelPermEvaluator : public EvaluatorSecondaryMonot const TranspirationDistributionRelPermEvaluator& other) = default; virtual Teuchos::RCP Clone() const override; - virtual bool - IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override { // calculate of derivatives of this is a tricky thing to do, with // non-cell-local terms due to rescaling. Just turn off derivatives diff --git a/src/pks/surface_balance/constitutive_relations/litter/evaporative_flux_relaxation_evaluator.cc b/src/pks/surface_balance/constitutive_relations/litter/evaporative_flux_relaxation_evaluator.cc index 7b59a406e..7267d3e58 100644 --- a/src/pks/surface_balance/constitutive_relations/litter/evaporative_flux_relaxation_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/litter/evaporative_flux_relaxation_evaluator.cc @@ -119,7 +119,7 @@ EvaporativeFluxRelaxationEvaluator::EvaluatePartialDerivative_( Teuchos::RCP cv = S.GetPtr(cv_key_, tag); if (wrt_key == wc_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& wc_v = *wc->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); @@ -136,7 +136,7 @@ EvaporativeFluxRelaxationEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == rho_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& wc_v = *wc->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); @@ -152,7 +152,7 @@ EvaporativeFluxRelaxationEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == thickness_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& wc_v = *wc->ViewComponent(*comp, false); const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); diff --git a/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_evaluator.cc b/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_evaluator.cc index 5745eb881..0cd5e22fc 100644 --- a/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_evaluator.cc @@ -25,7 +25,7 @@ pressures, 'n_l' is molar density liquid Note that the expected domain for this is the micropore domain, but may be changed on the input line. -.. _micropore-macropore-flux-evaluator-spec: +.. _evaluator-micropore-macropore-flux-spec: .. admonition:: micropore-micropore-flux-evaluator * `"micropore domain`" ``[string]`` **""** Defaults to the domain of the flux's @@ -152,7 +152,7 @@ MicroporeMacroporeFluxEvaluator::EvaluatePartialDerivative_( Teuchos::RCP den = S.GetPtr(den_key_, tag); if (wrt_key == pm_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& pm_v = *pm->ViewComponent(*comp, false); const Epetra_MultiVector& pM_v = *pM->ViewComponent(*comp, false); @@ -171,7 +171,7 @@ MicroporeMacroporeFluxEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == pM_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& pm_v = *pm->ViewComponent(*comp, false); const Epetra_MultiVector& pM_v = *pM->ViewComponent(*comp, false); @@ -190,7 +190,7 @@ MicroporeMacroporeFluxEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == krM_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& pm_v = *pm->ViewComponent(*comp, false); const Epetra_MultiVector& pM_v = *pM->ViewComponent(*comp, false); @@ -209,7 +209,7 @@ MicroporeMacroporeFluxEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == krm_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& pm_v = *pm->ViewComponent(*comp, false); const Epetra_MultiVector& pM_v = *pM->ViewComponent(*comp, false); @@ -228,7 +228,7 @@ MicroporeMacroporeFluxEvaluator::EvaluatePartialDerivative_( } } else if (wrt_key == K_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& pm_v = *pm->ViewComponent(*comp, false); const Epetra_MultiVector& pM_v = *pM->ViewComponent(*comp, false); @@ -246,7 +246,7 @@ MicroporeMacroporeFluxEvaluator::EvaluatePartialDerivative_( } } } else if (wrt_key == den_key_) { - for (CompositeVector::name_iterator comp = result[0]->begin(); comp != result[0]->end(); + for (CompositeVector::name_iterator comp = result[0]->begin() ; comp != result[0]->end(); ++comp) { const Epetra_MultiVector& pm_v = *pm->ViewComponent(*comp, false); const Epetra_MultiVector& pM_v = *pM->ViewComponent(*comp, false); diff --git a/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_evaluator.hh b/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_evaluator.hh index f37fafad8..25dae93be 100644 --- a/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_evaluator.hh +++ b/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_evaluator.hh @@ -26,8 +26,8 @@ pressures, 'n_l' is molar density liquid Note that the expected domain for this is the micropore domain, but may be changed on the input line. -.. _micropore-macropore-flux-evaluator-spec: -.. admonition:: micropore-macropore-flux-evaluator-spec +.. _evaluator-micropore-macropore-flux-spec: +.. admonition:: evaluator-micropore-macropore-flux-spec * `"micropore domain`" ``[string]`` **DOMAIN** Defaults to the domain of the flux's variable name. diff --git a/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_model.hh b/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_model.hh index 14d75b731..76a2f64ae 100644 --- a/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_model.hh +++ b/src/pks/surface_balance/constitutive_relations/litter/micropore_macropore_flux_model.hh @@ -35,8 +35,11 @@ class MicroporeMacroporeFluxModel { double krM, double krm, double K) const; - double - DMicroporeMacroporeFluxDPressure(double pm, double pM, double krM, double krm, double K) const; + double DMicroporeMacroporeFluxDPressure(double pm, + double pM, + double krM, + double krm, + double K) const; double DMicroporeMacroporeFluxDRelativePermeability(double pm, double pM, double krM, diff --git a/src/pks/surface_balance/surface_balance_base.cc b/src/pks/surface_balance/surface_balance_base.cc index bd7eec3b4..ba2691492 100644 --- a/src/pks/surface_balance/surface_balance_base.cc +++ b/src/pks/surface_balance/surface_balance_base.cc @@ -7,7 +7,7 @@ Authors: Ethan Coon (coonet@ornl.gov) */ -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "surface_balance_base.hh" @@ -41,7 +41,8 @@ SurfaceBalanceBase::parseParameterList() if (is_source_term_ && source_key_.empty()) { source_key_ = Keys::readKey(*plist_, domain_, "source", "source_sink"); - is_source_term_finite_differentiable_ = plist_->get("source term finite difference", false); + is_source_term_finite_differentiable_ = + plist_->get("source term finite difference", false); if (is_source_term_finite_differentiable_) { eps_ = plist_->get("source term finite difference epsilon", 1.e-8); } @@ -77,19 +78,19 @@ SurfaceBalanceBase::Setup() // requirements: source terms from above if (is_source_term_) { if (theta_ > 0) { - requireAtNext(source_key_, tag_next_, *S_) + requireEvaluatorAtNext(source_key_, tag_next_, *S_, true) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - if (!is_source_term_finite_differentiable_ - && S_->GetEvaluator(source_key_, tag_next_).IsDifferentiableWRT(*S_, key_, tag_next_)) { + if (!is_source_term_finite_differentiable_ && + S_->GetEvaluator(source_key_, tag_next_).IsDifferentiableWRT(*S_, key_, tag_next_)) { is_source_term_differentiable_ = true; S_->RequireDerivative( source_key_, tag_next_, key_, tag_next_); } } if (theta_ < 1) { - requireAtCurrent(source_key_, tag_current_, *S_, name_) + requireEvaluatorAtCurrent(source_key_, tag_current_, *S_, name_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } @@ -98,14 +99,14 @@ SurfaceBalanceBase::Setup() // requirements: conserved quantity at current and new times conserved_quantity_ = conserved_key_ != key_; if (conserved_quantity_) { - requireAtNext(conserved_key_, tag_next_, *S_) + requireEvaluatorAtNext(conserved_key_, tag_next_, *S_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); S_->RequireDerivative( conserved_key_, tag_next_, key_, tag_next_); // and at the current time, where it is a copy evaluator - requireAtCurrent(conserved_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(conserved_key_, tag_current_, *S_, name_); } // operator for inverse @@ -149,7 +150,7 @@ SurfaceBalanceBase::FunctionalResidual(double t_old, Solution_to_State(*u_new, tag_next_); bool debug = false; - if (vo_->os_OK(Teuchos::VERB_EXTREME)) debug = true; + if (vo_->os_OK(Teuchos::VERB_EXTREME) ) debug = true; if (vo_->os_OK(Teuchos::VERB_HIGH)) { *vo_->os() << "----------------------------------------------------------------" << std::endl @@ -271,7 +272,7 @@ SurfaceBalanceBase::ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) { Teuchos::OSTab tab = vo_->getOSTab(); - if (vo_->os_OK(Teuchos::VERB_HIGH)) *vo_->os() << "Precon application:" << std::endl; + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Precon application:" << std::endl; if (conserved_quantity_) { db_->WriteVector("seb_res", u->Data().ptr(), true); diff --git a/src/pks/surface_balance/surface_balance_base.hh b/src/pks/surface_balance/surface_balance_base.hh index 71d48219e..1be98c262 100644 --- a/src/pks/surface_balance/surface_balance_base.hh +++ b/src/pks/surface_balance/surface_balance_base.hh @@ -7,9 +7,10 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ -//! A simple conservation ODE. /*! +A simple set of time-evolving ODEs, solving for conservation of some quantity. + This is a very simple vector of ODEs, useful in balance equations, where the time derivative of a conserved quantity is determined by a bunch of sources and sinks. @@ -17,31 +18,48 @@ sinks. .. math:: \frac{\partial \Phi }{\partial t} = \sum_i Q_i -.. _balance-pk-spec: -.. admonition:: balance-pk-spec +`"PK type`" = `"general surface balance`" + +.. _pk-general-surface-balance-spec: +.. admonition:: pk-general-surface-balance-spec + + * `"primary variable key`" ``[string]`` The primary variable associated with + this PK. Note there is no default -- this must be provided by the user. + + * `"conserved quantity key`" ``[string]`` The conserved quantity :math:`\Phi` + + * `"source key`" ``[string]`` **DOMAIN-source_sink** Units are in conserved + quantity per second per cell volume. This default is typically only + appropriate when this is a water balance PK and the domain is sufficient + to identify the balance. E.g. the domain is "canopy" and this equation + solves for a canopy water balance. Otherwise this should also be renamed + to avoid confusion. + + * `"time discretization theta`" ``[double]`` **1.0** :math:`\theta` in a + Crank-Nicholson time integration scheme. 1.0 implies fully implicit, 0.0 + implies explicit, 0.5 implies C-N. - * `"primary variable key`" ``[string]`` The primary variable associated with - this PK. Note there is no default -- this must be provided by the user. + Math and solver algorithm options: - * `"conserved quantity key`" ``[string]`` The conserved quantity :math:`\Phi` + * `"absolute error tolerance`" ``[double]`` **550.0** a_tol in the standard + error norm calculation. Defaults to a small amount of water. Units are + the same as the conserved quantity. - * `"source key`" ``[string]`` **DOMAIN-source_sink** Units are in conserved - quantity per second per cell volume. + * `"inverse`" ``[inverse-spec]`` **optional** The inverse used for + preconditioning in a non-globally coupled problem. See :ref:`Inverse`. - * `"time discretization theta`" ``[double]`` **1.0** :math:`\theta` in a - Crank-Nicholson time integration scheme. 1.0 implies fully implicit, 0.0 - implies explicit, 0.5 implies C-N. + * `"accumulation preconditioner`" ``[pde-accumulation-spec]`` **optional** + The inverse of the accumulation operator. See :ref:`Accumulation`. + Typically not provided by users, as defaults are sufficient. - * `"modify predictor positivity preserving`" ``[bool]`` **false** If true, - predictors are modified to ensure that the conserved quantity is always > 0. + Globalization and other process-based hacks: - * `"absolute error tolerance`" ``[double]`` **550.0** a_tol in the standard - error norm calculation. Defaults to a small amount of water. Units are - the same as the conserved quantity. + * `"modify predictor positivity preserving`" ``[bool]`` **false** If true, + predictors are modified to ensure that the conserved quantity is always > 0. - INCLUDES: + INCLUDES: - - ``[pk-physical-bdf-default-spec]`` + - ``[pk-physical-bdf-default-spec]`` A :ref:`PK: Physical and BDF` spec. */ @@ -84,11 +102,12 @@ class SurfaceBalanceBase : public PK_PhysicalBDF_Default { virtual void UpdatePreconditioner(double t, Teuchos::RCP up, double h) override; // applies preconditioner to u and returns the result in Pu - virtual int - ApplyPreconditioner(Teuchos::RCP u, Teuchos::RCP Pu) override; + virtual int ApplyPreconditioner(Teuchos::RCP u, + Teuchos::RCP Pu) override; - virtual bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + virtual bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; protected: bool conserved_quantity_; diff --git a/src/pks/surface_balance/surface_balance_implicit_subgrid.cc b/src/pks/surface_balance/surface_balance_implicit_subgrid.cc index 4133bf347..64762178f 100644 --- a/src/pks/surface_balance/surface_balance_implicit_subgrid.cc +++ b/src/pks/surface_balance/surface_balance_implicit_subgrid.cc @@ -20,7 +20,7 @@ #include -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "seb_physics_defs.hh" #include "surface_balance_implicit_subgrid.hh" @@ -41,13 +41,13 @@ ImplicitSubgrid::parseParameterList() plist_->set("absolute error tolerance", 0.01); snow_dens_key_ = Keys::readKey(*plist_, domain_, "snow density", "density"); - requireAtNext(snow_dens_key_, tag_next_, *S_, name_); + requireEvaluatorAtNext(snow_dens_key_, tag_next_, *S_, name_); snow_death_rate_key_ = Keys::readKey(*plist_, domain_, "snow death rate", "death_rate"); - requireAtNext(snow_death_rate_key_, tag_next_, *S_, name_); + requireEvaluatorAtNext(snow_death_rate_key_, tag_next_, *S_, name_); snow_age_key_ = Keys::readKey(*plist_, domain_, "snow age", "age"); - requireAtNext(snow_age_key_, tag_next_, *S_, name_); + requireEvaluatorAtNext(snow_age_key_, tag_next_, *S_, name_); new_snow_key_ = Keys::readKey(*plist_, domain_, "new snow source", "source"); density_snow_max_ = plist_->get("max density of snow [kg m^-3]", 600.); @@ -63,25 +63,25 @@ ImplicitSubgrid::Setup() SurfaceBalanceBase::Setup(); // requirements: things I use - requireAtNext(new_snow_key_, tag_next_, *S_) + requireEvaluatorAtNext(new_snow_key_, tag_next_, *S_) .SetMesh(mesh_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); // requirements: other primary variables - requireAtNext(snow_dens_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(snow_dens_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(snow_dens_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(snow_dens_key_, tag_current_, *S_, name_); - requireAtNext(snow_death_rate_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(snow_death_rate_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(snow_death_rate_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(snow_death_rate_key_, tag_current_, *S_, name_); - requireAtNext(snow_age_key_, tag_next_, *S_, name_) + requireEvaluatorAtNext(snow_age_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(snow_age_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(snow_age_key_, tag_current_, *S_, name_); } // -- Initialize owned (dependent) variables. @@ -91,7 +91,7 @@ ImplicitSubgrid::Initialize() SurfaceBalanceBase::Initialize(); // initialize snow density, age - Teuchos::ParameterList& ic_list = plist_->sublist("initial condition"); + Teuchos::ParameterList& ic_list = plist_->sublist("initial conditions"); if (!S_->GetRecord(snow_dens_key_, tag_next_).initialized()) { if (ic_list.isParameter("restart file")) { @@ -134,7 +134,9 @@ ImplicitSubgrid::ModifyPredictor(double h, Teuchos::RCP u) { Epetra_MultiVector& u_vec = *u->Data()->ViewComponent("cell", false); - for (int c = 0; c != u_vec.MyLength(); ++c) { u_vec[0][c] = std::max(0., u_vec[0][c]); } + for (int c = 0; c != u_vec.MyLength(); ++c) { + u_vec[0][c] = std::max(0., u_vec[0][c]); + } return true; } diff --git a/src/pks/surface_balance/surface_balance_implicit_subgrid.hh b/src/pks/surface_balance/surface_balance_implicit_subgrid.hh index 3b12c3895..3ec77d194 100644 --- a/src/pks/surface_balance/surface_balance_implicit_subgrid.hh +++ b/src/pks/surface_balance/surface_balance_implicit_subgrid.hh @@ -6,40 +6,41 @@ Authors: Ethan Coon (ecoon@lanl.gov) */ - -//! An implicit PK for surface balance snow SWE conservation. /*! -This is a balance PK whose conserved quantity is snow SWE. The energy balance -comes in as it provides the energy needed to melt snow. So source terms -include snow precipitation and snowmelt. It also manages snow density, which -should get rethought a bit. +This is a balance PK whose conserved quantity is snow water equivalent. The +energy balance comes in as it provides the energy needed to melt snow. So +source terms include snow precipitation and snowmelt. It also manages snow +density, which should get rethought a bit. There is also some wierd hackiness here about area fractions -- see ATS Issue -#8 +#8. + +`"PK type`" = `"surface balance implicit subgrid`" -.. _subgrid-balance-pk-spec: -.. admonition:: subgrid-balance-pk-spec +.. _pk-surface-balance-implicit-subgrid-spec: +.. admonition:: pk-surface-balance-implicit-subgrid-spec - * `"absolute error tolerance`" ``[double]`` **0.01** ``[m]`` + * `"absolute error tolerance`" ``[double]`` **0.01** ``[m]`` A small amount + of snow. - INCLUDES: + INCLUDES: - - ``[balance-pk-spec]`` This *is a* `Balance Equation`_ + - ``[balance-pk-spec]`` This *is a* `Balance Equation`_ - Not typically set by user, defaults work: + KEYS: - * `"conserved quantity key`" ``[string]`` **DOMAIN-snow_water_equivalent** - Sets the default conserved quantity key, so this is likely not supplied - by the user. `[m]` - * `"snow density key`" ``[string]`` **DOMAIN-density** Default snow density - key. `[kg m^-3]` - * `"snow age key`" ``[string]`` **DOMAIN-age** Default snow age key. `[d]` - * `"new snow key`" ``[string]`` **DOMAIN-source** Default new snow key. `[m SWE s^-1]` - * `"area fractions key`" ``[string]`` **DOMAIN-fractional_areas** Subgrid - model fractional areas, see note above. `[-]` - * `"snow death rate key`" ``[string]`` **DOMAIN-death_rate** Deals with last - tiny bit of snowmelt. + - `"conserved quantity key`" **DOMAIN-snow_water_equivalent** Sets the + default conserved quantity key, so this is likely not supplied by the + user. `[m]` + - `"snow density key`" **DOMAIN-density** Default snow density key. `[kg + m^-3]` + - `"snow age key`" **DOMAIN-age** Default snow age key. `[d]` + - `"new snow key`" **DOMAIN-source** Default new snow key. `[m SWE s^-1]` + - `"area fractions key`" **DOMAIN-fractional_areas** Subgrid model + fractional areas, see note above. `[-]` + - `"snow death rate key`" **DOMAIN-death_rate** Deals with last tiny bit of + snowmelt. */ @@ -71,14 +72,15 @@ class ImplicitSubgrid : public SurfaceBalanceBase { // -- Initialize owned (dependent) variables. virtual void Initialize() override; - virtual bool - ModifyPredictor(double h, Teuchos::RCP u0, Teuchos::RCP u) override; + virtual bool ModifyPredictor(double h, + Teuchos::RCP u0, + Teuchos::RCP u) override; - virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult - ModifyCorrection(double h, - Teuchos::RCP res, - Teuchos::RCP u, - Teuchos::RCP du) override; + virtual AmanziSolvers::FnBaseDefs::ModifyCorrectionResult ModifyCorrection( + double h, + Teuchos::RCP res, + Teuchos::RCP u, + Teuchos::RCP du) override; // computes the non-linear functional g = g(t,u,udot) virtual void FunctionalResidual(double t_old, diff --git a/src/pks/test_pks/divgrad_test/divgrad_test.cc b/src/pks/test_pks/divgrad_test/divgrad_test.cc index ca18503d5..aa2611bd4 100644 --- a/src/pks/test_pks/divgrad_test/divgrad_test.cc +++ b/src/pks/test_pks/divgrad_test/divgrad_test.cc @@ -79,7 +79,7 @@ void DivGradTest::initialize(const Teuchos::Ptr& S) { // Check for PK-specific initialization - if (!plist_->isSublist("initial condition")) { + if (!plist_->isSublist("initial conditions")) { std::stringstream messagestream; messagestream << name_ << " has no initial condition parameter list."; Errors::Message message(messagestream.str()); @@ -87,7 +87,7 @@ DivGradTest::initialize(const Teuchos::Ptr& S) } // make sure the initial condition doesn't set faces in another way - Teuchos::ParameterList ic_plist = plist_->sublist("initial condition"); + Teuchos::ParameterList ic_plist = plist_->sublist("initial conditions"); ic_plist.set("initialize faces from cells", false); // initialize primary variable from the ic_plist condition @@ -169,7 +169,9 @@ DivGradTest::ApplyBoundaryConditions_(const Teuchos::RCP& pres) Epetra_MultiVector& pres_f = *pres->ViewComponent("face", true); int nfaces = pres->size("face"); for (int f = 0; f != nfaces; ++f) { - if (bc_markers_[f] == Operators::OPERATOR_BC_DIRICHLET) { pres_f[0][f] = bc_values_[f]; } + if (bc_markers_[f] == Operators::OPERATOR_BC_DIRICHLET) { + pres_f[0][f] = bc_values_[f]; + } } }; @@ -187,9 +189,11 @@ DivGradTest::TestRegularFaceValues_(const Teuchos::RCP& pres) if (cells.size() == 1) { if (bc_markers_[f] == Operators::OPERATOR_BC_DIRICHLET) { - if (std::abs((*pres)("face", f) - bc_values_[f]) > eps) nfail++; + if (std::abs((*pres) ("face", f) - bc_values_[f]) > eps) nfail++; } else { - if (bc_markers_[f] == Operators::OPERATOR_BC_NONE) { bc_values_[f] = 0.0; } + if (bc_markers_[f] == Operators::OPERATOR_BC_NONE) { + bc_values_[f] = 0.0; + } AmanziGeometry::Point fpoint = mesh_->getFaceCentroid(f); AmanziGeometry::Point cpoint = mesh_->getCellCentroid(cells[0]); @@ -202,11 +206,11 @@ DivGradTest::TestRegularFaceValues_(const Teuchos::RCP& pres) } else { p = p - dp; } - if (std::abs((*pres)("face", f) - p) > eps) nfail++; + if (std::abs((*pres) ("face", f) - p) > eps) nfail++; } } else { double p = ((*pres)("cell", cells[0]) + (*pres)("cell", cells[1])) / 2.0; - if (std::abs((*pres)("face", f) - p) > eps) nfail++; + if (std::abs((*pres) ("face", f) - p) > eps) nfail++; } } diff --git a/src/pks/transport/CMakeLists.txt b/src/pks/transport/CMakeLists.txt index f4dffcedc..27e8d2369 100644 --- a/src/pks/transport/CMakeLists.txt +++ b/src/pks/transport/CMakeLists.txt @@ -11,24 +11,21 @@ add_subdirectory(constitutive_relations) # ATS include directories include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/transport/constitutive_relations/sources) -# include_directories(${ATS_SOURCE_DIR}/src/pks/transport/constitutive_relations/sediment_transport) +include_directories(${ATS_SOURCE_DIR}/src/pks/transport/constitutive_relations/sediment_transport) # Amanzi include directories include_directories(${TRANSPORT_SOURCE_DIR}) set(ats_transport_src_files - transport_ats_dispersion.cc transport_ats_ti.cc - transport_ats_henrylaw.cc - transport_ats_vandv.cc transport_ats_pk.cc - # sediment_transport_pk.cc + sediment_transport_pk.cc ) set(ats_transport_inc_files transport_ats.hh - # sediment_transport_pk.hh + sediment_transport_pk.hh ) @@ -67,11 +64,11 @@ register_evaluator_with_factory( LISTNAME ATS_TRANSPORT_REG ) -# register_evaluator_with_factory( -# HEADERFILE sediment_transport_reg.hh -# LISTNAME ATS_TRANSPORT_REG -# ) - +register_evaluator_with_factory( + HEADERFILE sediment_transport_reg.hh + LISTNAME ATS_TRANSPORT_REG + ) + generate_evaluators_registration_header( HEADERFILE ats_transport_registration.hh LISTNAME ATS_TRANSPORT_REG diff --git a/src/pks/transport/SedimentTransportDefs.hh b/src/pks/transport/SedimentTransportDefs.hh deleted file mode 100644 index 3390fcb73..000000000 --- a/src/pks/transport/SedimentTransportDefs.hh +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright 2010-202x held jointly by participating institutions. - ATS is released under the three-clause BSD License. - The terms of use and "as is" disclaimer for this license are - provided in the top-level COPYRIGHT file. - - Authors: Konstantin Lipnikov (lipnikov@lanl.gov) -*/ - -/* - Transport PK - -*/ - -#ifndef AMANZI_TRANSPORT_CONSTANTS_HH_ -#define AMANZI_TRANSPORT_CONSTANTS_HH_ - -namespace Amanzi { -namespace Transport { - -// const int TRANSPORT_PHASE_LIQUID = 0; // phases from 0 to 1 -// const int TRANSPORT_PHASE_GAS = 1; -// const int TRANSPORT_NUMBER_PHASES = 2; - -const double TRANSPORT_LARGE_TIME_STEP = 1e+99; -const double TRANSPORT_SMALL_TIME_STEP = 1e-12; - -const int TRANSPORT_BC_CONSTANT_TCC = 1; -const int TRANSPORT_BC_DISPERSION_FLUX = 2; -const int TRANSPORT_BC_NULL = 3; - -const int TRANSPORT_FLOW_STEADYSTATE = 1; -const int TRANSPORT_FLOW_TRANSIENT = 2; - -const double TRANSPORT_CONCENTRATION_OVERSHOOT = 1e-6; -const double TRANSPORT_CONCENTRATION_INFINITY = 1e+99; - -const int TRANSPORT_HEX_FACES = 6; // Hexahedron is the common element -const int TRANSPORT_HEX_NODES = 8; -const int TRANSPORT_HEX_EDGES = 12; - -const int TRANSPORT_QUAD_FACES = 4; // Quadrilateral is the common element -const int TRANSPORT_QUAD_NODES = 4; -const int TRANSPORT_QUAD_EDGES = 4; - -const int TRANSPORT_MAX_FACES = 14; // Kelvin's tetrakaidecahedron -const int TRANSPORT_MAX_NODES = 47; // These polyhedron parameters must -const int TRANSPORT_MAX_EDGES = 60; // be calculated in Init(). - -const int TRANSPORT_DISPERSION_METHOD_TPFA = 1; -const int TRANSPORT_DISPERSION_METHOD_NLFV = 2; - -const int TRANSPORT_LIMITER_BARTH_JESPERSEN = 1; -const int TRANSPORT_LIMITER_TENSORIAL = 2; -const int TRANSPORT_LIMITER_KUZMIN = 3; -const double TRANSPORT_LIMITER_TOLERANCE = 1e-14; - -const int TRANSPORT_INTERNAL_ERROR = 911; // contact (lipnikov@lanl.gov) - -} // namespace Transport -} // namespace Amanzi - -#endif diff --git a/src/pks/transport/constitutive_relations/CMakeLists.txt b/src/pks/transport/constitutive_relations/CMakeLists.txt index be897b9ae..c0c3a0ee3 100644 --- a/src/pks/transport/constitutive_relations/CMakeLists.txt +++ b/src/pks/transport/constitutive_relations/CMakeLists.txt @@ -6,8 +6,7 @@ # collect all sources -list(APPEND subdirs sources) -#list(APPEND subdirs sources sediment_transport) +list(APPEND subdirs sources sediment_transport) set(ats_transport_relations_src_files "") set(ats_transport_relations_inc_files "") diff --git a/src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator.cc b/src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator.cc new file mode 100644 index 000000000..941fefade --- /dev/null +++ b/src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator.cc @@ -0,0 +1,131 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: +*/ + +/* + +*/ + +#include "biomass_evaluator.hh" +#include "Teuchos_ParameterList.hpp" + +namespace Amanzi { + +BiomassEvaluator::BiomassEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) +{ + InitializeFromPlist_(); +} + +Teuchos::RCP +BiomassEvaluator::Clone() const +{ + return Teuchos::rcp(new BiomassEvaluator(*this)); +} + +void +BiomassEvaluator::InitializeFromPlist_() +{ + Tag tag = my_keys_.front().second; + Key domain_name = Keys::getDomain(my_keys_.front().first); + my_keys_.clear(); // clear and re-insert to ensure proper order + + biomass_key_ = Keys::getKey(domain_name, "biomass"); + my_keys_.emplace_back(KeyTag{ biomass_key_, tag }); + + stem_density_key_ = Keys::getKey(domain_name, "stem_density"); + my_keys_.emplace_back(KeyTag{ stem_density_key_, tag }); + + stem_height_key_ = Keys::getKey(domain_name, "stem_height"); + my_keys_.emplace_back(KeyTag{ stem_height_key_, tag }); + + stem_diameter_key_ = Keys::getKey(domain_name, "stem_diameter"); + my_keys_.emplace_back(KeyTag{ stem_diameter_key_, tag }); + + plant_area_key_ = Keys::getKey(domain_name, "plant_area"); + my_keys_.emplace_back(KeyTag{ plant_area_key_, tag }); + + nspecies_ = plist_.get("number of vegetation species", 1); + + type_ = plist_.get("type"); + alpha_n = plist_.get>("alpha n").toVector(); + alpha_h = plist_.get>("alpha h").toVector(); + alpha_a = plist_.get>("alpha a").toVector(); + alpha_d = plist_.get>("alpha d").toVector(); + + beta_n = plist_.get>("beta n").toVector(); + beta_h = plist_.get>("beta h").toVector(); + beta_a = plist_.get>("beta a").toVector(); + beta_d = plist_.get>("beta d").toVector(); + + Bmax = plist_.get>("Bmax").toVector(); + zmax = plist_.get>("zmax").toVector(); + zmin = plist_.get>("zmin").toVector(); + + elev_key_ = Keys::readKey(plist_, domain_name, "elevation", "elevation"); + dependencies_.insert(KeyTag{ elev_key_, tag }); + + msl_key_ = Keys::readKey(plist_, domain_name, "mean sea level", "mean_sea_level"); + dependencies_.insert(KeyTag{ msl_key_, tag }); +} + + +void +BiomassEvaluator::Evaluate_(const State& S, const std::vector& results) +{ + Epetra_MultiVector& biomass = *results[0]->ViewComponent("cell"); + Epetra_MultiVector& stem_density = *results[1]->ViewComponent("cell"); + Epetra_MultiVector& stem_height = *results[2]->ViewComponent("cell"); + Epetra_MultiVector& stem_diameter = *results[3]->ViewComponent("cell"); + Epetra_MultiVector& plant_area = *results[4]->ViewComponent("cell"); + Tag tag = my_keys_.front().second; + + const Epetra_MultiVector& elev = + *S.GetPtr(elev_key_, tag)->ViewComponent("cell", false); + const Epetra_MultiVector& msl = + *S.GetPtr(msl_key_, tag)->ViewComponent("cell", false); + + int ncells = biomass.MyLength(); + + for (int n = 0; n < nspecies_; n++) { + AMANZI_ASSERT((zmax[n] - zmin[n]) > 1e-6); + switch (type_) { + case 1: + for (int c = 0; c < ncells; c++) { + double z_b = elev[0][c] - msl[0][c]; + if ((z_b > zmin[n]) && (z_b < zmax[n])) { + biomass[n][c] = Bmax[n] * (zmax[n] - z_b) / (zmax[n] - zmin[n]); + } else { + biomass[n][c] = 0.; + } + } + break; + case 2: + for (int c = 0; c < ncells; c++) { + double z_b = elev[0][c] - msl[0][c]; + if (z_b >= zmax[n]) { + biomass[n][c] = Bmax[n]; + } else if ((z_b > zmin[n]) && (z_b < zmax[n])) { + biomass[n][c] = Bmax[n] * (z_b - zmin[n]) / (zmax[n] - zmin[n]); + } else if (z_b <= zmin[n]) { + biomass[n][c] = 0.; + } + } + break; + } + for (int c = 0; c < ncells; c++) { + stem_diameter[n][c] = alpha_d[n] * std::pow(biomass[n][c], beta_d[n]); + stem_height[n][c] = alpha_h[n] * std::pow(biomass[n][c], beta_h[n]); + stem_density[n][c] = alpha_n[n] * std::pow(biomass[n][c], beta_n[n]); + plant_area[n][c] = alpha_a[n] * std::pow(biomass[n][c], beta_a[n]); + } + } +} + + +} // namespace Amanzi diff --git a/src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator.hh b/src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator.hh new file mode 100644 index 000000000..7e00d8b6e --- /dev/null +++ b/src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator.hh @@ -0,0 +1,101 @@ +/* + Copyright 2010-202x held jointly by participating institutions. + ATS is released under the three-clause BSD License. + The terms of use and "as is" disclaimer for this license are + provided in the top-level COPYRIGHT file. + + Authors: Daniil Svyatsky (dasvyat@lanl.gov) +*/ + +/*! + +This biomass model evaluates evolution of biomass as a function of `"mean sea +level`". There are 2 models implemented. + +Model 1: + +.. math:: + + B = \left\{\begin{array}{ll} + B_{max}\frac{(z_{max} - z_b)}{(z_{max} - z_{min})} &\qquad\mbox{if}\qquad z_{min} Clone() const override; + + protected: + // Required methods from EvaluatorSecondaryMonotypeCV + virtual void Evaluate_(const State& S, const std::vector& results) override; + + virtual void EvaluatePartialDerivative_(const State& S, + const Key& wrt_key, + const Tag& wrt_tag, + const std::vector& results) override + { + AMANZI_ASSERT(0); + } + + virtual void EnsureCompatibility_Structure_(State& S) override { + EnsureCompatibility_StructureSame_(S); + } + + void InitializeFromPlist_(); + + protected: + int nspecies_, type_; + std::vector alpha_n, alpha_h, alpha_d, alpha_a; + std::vector beta_n, beta_h, beta_d, beta_a; + std::vector Bmax, zmax, zmin; + + Key biomass_key_, stem_density_key_, stem_height_key_, stem_diameter_key_, plant_area_key_; + Key elev_key_, msl_key_; + + private: + static Utils::RegisteredFactory factory_; +}; + +} // namespace Amanzi + +#endif diff --git a/src/pks/mpc/biomass_evaluator_reg.hh b/src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator_reg.hh similarity index 100% rename from src/pks/mpc/biomass_evaluator_reg.hh rename to src/pks/transport/constitutive_relations/sediment_transport/biomass_evaluator_reg.hh diff --git a/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator.cc b/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator.cc index 37d3bff1a..b178640b1 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator.cc +++ b/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator.cc @@ -4,11 +4,12 @@ The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. - Authors: Ethan Coon (ecoon@lanl.gov) + Authors: Daniil Svyatsky (dasvyat@lanl.gov) */ /* - Determining the molar fraction of a gas component within a gas mixture. + + Determining erosion rate into sediment transport */ @@ -22,18 +23,16 @@ ErosionRateEvaluator ::ErosionRateEvaluator(Teuchos::ParameterList& plist) Tag tag = my_keys_.front().second; Key domain_name = Keys::getDomain(my_keys_.front().first); - velocity_key_ = plist_.get("velocity key", Keys::getKey(domain_name, "velocity")); + velocity_key_ = Keys::readKey(plist_, domain_name, "velocity", "velocity"); + Key pres_key = Keys::readKey(plist_, domain_name, "pressure", "pressure"); tau_e_ = plist_.get("critical shear stress"); Qe_0_ = plist_.get("empirical coefficient"); gamma_ = plist_.get("specific weight of water"); - umax_ = plist_.get("max current"); - xi_ = plist_.get("Chezy parameter"); Cf_ = plist_.get("drag coefficient"); - lambda_ = 8. / (3 * M_PI) * (umax_ / (xi_ * xi_)); - - dependencies_.insert(KeyTag{ "surface-pressure", tag }); + dependencies_.insert(KeyTag{ velocity_key_, tag }); + dependencies_.insert(KeyTag{ pres_key, Tags::NEXT }); } @@ -43,10 +42,10 @@ ErosionRateEvaluator ::ErosionRateEvaluator(const ErosionRateEvaluator& other) tau_e_ = other.tau_e_; Qe_0_ = other.Qe_0_; gamma_ = other.gamma_; - lambda_ = other.lambda_; - umax_ = other.umax_; - xi_ = other.xi_; Cf_ = other.Cf_; + // lambda_ = other.lambda_; + // umax_ = other.umax_; + // xi_ = other.xi_; } @@ -65,11 +64,17 @@ ErosionRateEvaluator::Evaluate_(const State& S, const std::vector(velocity_key_, tag)->ViewComponent("cell"); Epetra_MultiVector& result_c = *result[0]->ViewComponent("cell"); + double max_tau = 0.0; + double max_v2 = 0.0; + for (int c = 0; c < vel.MyLength(); c++) { //double tau_0 = gamma_ * lambda_ * (sqrt(vel[0][c] * vel[0][c] + vel[1][c] * vel[1][c])); - double tau_0 = gamma_ * Cf_ * - (sqrt(vel[0][c] * vel[0][c] + vel[1][c] * vel[1][c]) * - sqrt(vel[0][c] * vel[0][c] + vel[1][c] * vel[1][c])); + double v2 = vel[0][c] * vel[0][c] + vel[1][c] * vel[1][c]; + double tau_0 = gamma_ * Cf_ * v2; + + max_tau = std::max(tau_0, max_tau); + max_v2 = std::max(v2, max_v2); + if (tau_0 > tau_e_) { result_c[0][c] = Qe_0_ * (tau_0 / tau_e_ - 1); } else { @@ -87,5 +92,4 @@ ErosionRateEvaluator::EvaluatePartialDerivative_(const State& S, AMANZI_ASSERT(0); } - } // namespace Amanzi diff --git a/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator.hh b/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator.hh index eafe17c5b..d71a5d144 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator.hh +++ b/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator.hh @@ -7,9 +7,35 @@ Authors: Daniil Svyatsky (dasvyat@lanl.gov) */ -/* - The erosion evaluator gets the erosion rates. +/*! + +The erosion evaluator gets the erosion rates. We evaluate the erosion flux, +:math:`Q_e`, by way of a relationship which can be applied when the bed +properties are relatively uniform over the depth and the bed is consolidated +[e.g., Mehta, 1984], namely, + +.. math:: + + Q_e = \left\{\begin{array}{ll} + Q_{e_0}\left(\frac{\tau_0}{\tau_e} - 1\right) &\qquad\mbox{if} \qquad \tau_0>\tau_e \\ + 0 &\qquad\mbox{if} \qquad \tau_0\le\tau_e + \end{array} \right. + +where :math:`Q_{e_0}` is an empirical coefficient, :math:`\tau_e` is a critical shear stress + +`"evaluator type`" = `"erosion rate`" + +.. _evaluator-erosion-rate-spec: +.. admonition:: evaluator-erosion-rate-spec + + * `"critical shear stress`" ``[double]`` **0.4** + * `"empirical coefficient`" ``[double]`` **3.0e-4** + * `"drag coefficient`" ``[double]`` **0.02** + * `"specific weight of water`" ``[double]`` **9806.0** + + DEPENDENCIES: + - `"velocity`" **DOMAIN-velocity** */ diff --git a/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator_reg.hh b/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator_reg.hh index 3ea5d8c71..98a6b1bfb 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator_reg.hh +++ b/src/pks/transport/constitutive_relations/sediment_transport/erosion_evaluator_reg.hh @@ -17,7 +17,7 @@ namespace Amanzi { // registry of method -Utils::RegisteredFactory - ErosionRateEvaluator ::factory_("erosion rate"); +Utils::RegisteredFactory ErosionRateEvaluator ::factory_( + "erosion rate"); } // namespace Amanzi diff --git a/src/pks/transport/constitutive_relations/sediment_transport/organic_matter_evaluator.cc b/src/pks/transport/constitutive_relations/sediment_transport/organic_matter_evaluator.cc index 585f6e3a4..d547ae55e 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/organic_matter_evaluator.cc +++ b/src/pks/transport/constitutive_relations/sediment_transport/organic_matter_evaluator.cc @@ -4,11 +4,11 @@ The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. - Authors: Ethan Coon (ecoon@lanl.gov) -*/ + Authors: Daniil Svyatsky (dasvyat@lanl.gov) /* - Determining the molar fraction of a gas component within a gas mixture. + + Determining input organic matter into sediment transport */ @@ -48,7 +48,9 @@ OrganicMatterRateEvaluator::Evaluate_(const State& S, const std::vector("critical shear stress"); ws_ = plist_.get("settling velocity"); gamma_ = plist_.get("specific weight of water"); - sediment_density_ = plist_.get("sediment density [kg m^-3]"); - umax_ = plist_.get("max current"); - xi_ = plist_.get("Chezy parameter"); Cf_ = plist_.get("drag coefficient"); - - lambda_ = 8. / (3 * M_PI) * (umax_ / (xi_ * xi_)); } @@ -55,15 +46,16 @@ void SettlementRateEvaluator::Evaluate_(const State& S, const std::vector& result) { Tag tag = my_keys_.front().second; - const Epetra_MultiVector& vel = *S.Get(velocity_key_, tag).ViewComponent("cell"); + const Epetra_MultiVector& vel = + *S.GetPtr(velocity_key_, tag)->ViewComponent("cell"); const Epetra_MultiVector& tcc = *S.Get(sediment_key_, tag).ViewComponent("cell"); Epetra_MultiVector& result_c = *result[0]->ViewComponent("cell"); + sediment_density_ = S.Get("sediment_density", tag); + for (int c = 0; c < result_c.MyLength(); c++) { - //double tau_0 = gamma_ * lambda_ * (sqrt(vel[0][c] * vel[0][c] + vel[1][c] * vel[1][c])); - double tau_0 = gamma_ * Cf_ * - (sqrt(vel[0][c] * vel[0][c] + vel[1][c] * vel[1][c]) * - sqrt(vel[0][c] * vel[0][c] + vel[1][c] * vel[1][c])); + double tau_0 = gamma_ * Cf_ * (vel[0][c] * vel[0][c] + vel[1][c] * vel[1][c]); + if (tau_0 < tau_d_) { result_c[0][c] = sediment_density_ * ws_ * std::min(tcc[0][c], 0.5) * (1 - tau_0 / tau_d_); } else { diff --git a/src/pks/transport/constitutive_relations/sediment_transport/settlement_evaluator.hh b/src/pks/transport/constitutive_relations/sediment_transport/settlement_evaluator.hh index b458e69d1..4117503c5 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/settlement_evaluator.hh +++ b/src/pks/transport/constitutive_relations/sediment_transport/settlement_evaluator.hh @@ -7,9 +7,38 @@ Authors: Daniil Svyatsky (dasvyat@lanl.gov) */ -/* - The erosion evaluator gets the erosion rates. +/*! + +The settlement evaluator gets the settlement rates. We estimate the deposition +due to settling, Q_ds which is mainly due to the formation and breakup of +flocs, by way of the formulation proposed by Einstein and Krone [1962] who +assumed that most of the particles settled in flocs as long as near bed shear +stresses are small enough to prevent their breaking up, namely, + +.. math:: + + Q_ds = \left\{\begin{array}{ll} + \rho_s w_s min(C, 0.5)\left(1-\frac{\tau_0}{\tau_d}\right) &\qquad\mbox{if} \qquad \tau_0<\tau_d \\ + 0 &\qquad\mbox{if} \qquad \tau_0\ge\tau_d + \end{array} \right. + +where :math:`\rho_s` is the sediment density, :math:`w_s` is the settling velocity which depends on the size +of sediment flocs, :math:`\tau_d` is a critical shear stress, C in a sediment molar ratio. + +`"evaluator type`" = `"settlement rate`" + +.. _evaluator-settlement-rate-spec: +.. admonition:: evaluator-settlement-rate-spec + + * `"critical shear stress`" ``[double]`` **0.1** + * `"settling velocity`" ``[double]`` **0.0001** + * `"drag coefficient`" ``[double]`` **0.02** + * `"specific weight of water`" ``[double]`` **9806.0** + + DEPENDENCIES: + - `"velocity`" **DOMAIN-velocity** + - `"sediment`" **DOMAIN-sediment** */ diff --git a/src/pks/transport/constitutive_relations/sediment_transport/settlement_evaluator_reg.hh b/src/pks/transport/constitutive_relations/sediment_transport/settlement_evaluator_reg.hh index 217e57d15..85f7c79ab 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/settlement_evaluator_reg.hh +++ b/src/pks/transport/constitutive_relations/sediment_transport/settlement_evaluator_reg.hh @@ -17,7 +17,7 @@ namespace Amanzi { // registry of method -Utils::RegisteredFactory - SettlementRateEvaluator ::factory_("settlement rate"); +Utils::RegisteredFactory SettlementRateEvaluator ::factory_( + "settlement rate"); } // namespace Amanzi diff --git a/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator.cc b/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator.cc index c70e4451e..8ac3fba8d 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator.cc +++ b/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator.cc @@ -8,8 +8,7 @@ */ /* - Determining the molar fraction of a gas component within a gas mixture. - + Determining rate for trapping sediment */ #include "trapping_evaluator.hh" @@ -23,10 +22,7 @@ TrappingRateEvaluator ::TrappingRateEvaluator(Teuchos::ParameterList& plist) Key domain_name = Keys::getDomain(my_keys_.front().first); velocity_key_ = Keys::readKey(plist_, domain_name, "velocity", "velocity"); - - // note, this is a proxy for velocity, which does not have an eval yet - Key pres_key = Keys::readKey(plist_, domain_name, "pressure", "pressure"); - dependencies_.insert(KeyTag{ pres_key, tag }); + dependencies_.insert(KeyTag{ velocity_key_, tag }); sediment_key_ = Keys::readKey(plist_, domain_name, "sediment", "sediment"); dependencies_.insert(KeyTag{ sediment_key_, tag }); @@ -34,16 +30,21 @@ TrappingRateEvaluator ::TrappingRateEvaluator(Teuchos::ParameterList& plist) ponded_depth_key_ = Keys::readKey(plist_, domain_name, "ponded depth", "ponded_depth"); dependencies_.insert(KeyTag{ ponded_depth_key_, tag }); - biomass_key_ = Keys::readKey(plist_, domain_name, "biomass", "biomass"); - dependencies_.insert(KeyTag{ biomass_key_, tag }); + stem_diameter_key_ = Keys::readKey(plist_, domain_name, "stem_diameter", "stem_diameter"); + dependencies_.insert(KeyTag{ stem_diameter_key_, tag }); + + stem_height_key_ = Keys::readKey(plist_, domain_name, "stem_height", "stem_height"); + dependencies_.insert(KeyTag{ stem_height_key_, tag }); + + stem_density_key_ = Keys::readKey(plist_, domain_name, "stem_density", "stem_density"); + dependencies_.insert(KeyTag{ stem_density_key_, tag }); - // Please put units on all of these! --etc + // Please put units on all of these! --ETC visc_ = plist_.get("kinematic viscosity"); d_p_ = plist_.get("particle diameter"); alpha_ = plist_.get("alpha"); beta_ = plist_.get("beta"); gamma_ = plist_.get("gamma"); - sediment_density_ = plist_.get("sediment density [kg m^-3]"); } @@ -59,16 +60,17 @@ TrappingRateEvaluator::Evaluate_(const State& S, const std::vector("sediment_density", tag); const Epetra_MultiVector& vel = *S.Get(velocity_key_, tag).ViewComponent("cell"); const Epetra_MultiVector& tcc = *S.Get(sediment_key_, tag).ViewComponent("cell"); const Epetra_MultiVector& depth = *S.Get(ponded_depth_key_, tag).ViewComponent("cell"); const Epetra_MultiVector& bio_n = - *S.Get("surface-stem_density", tag).ViewComponent("cell"); + *S.Get(stem_density_key_, tag).ViewComponent("cell"); const Epetra_MultiVector& bio_d = - *S.Get("surface-stem_diameter", tag).ViewComponent("cell"); + *S.Get(stem_diameter_key_, tag).ViewComponent("cell"); const Epetra_MultiVector& bio_h = - *S.Get("surface-stem_height", tag).ViewComponent("cell"); + *S.Get(stem_height_key_, tag).ViewComponent("cell"); Epetra_MultiVector& result_c = *result[0]->ViewComponent("cell"); result_c.PutScalar(0.); diff --git a/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator.hh b/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator.hh index 8ef2f21f6..bb2825d1b 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator.hh +++ b/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator.hh @@ -8,8 +8,42 @@ */ /* - The erosion evaluator gets the erosion rates. + The trapping evaluator gets the trapping rates. + we have expressed the trapping rate using the + approach proposed by Palmer et al. [2004], + ..math:: + Q_{tr} = \rho_s\,C\,U\,\epsilon d_s n_s min(h_s, p_D) + + ..math:: + \epsilon = \alpha_e\left(\frac{Ud_s}{\nu}\right)^{\beta_\epsilon} + \left(\frac{d}{d_s}\right)^{\gamma_\epsilon} + + where math::'\rho_s' is the sediment density, math::'C' in a sediment molar ratio, + math::'U' is the absolute value of the local flow speed, math::'\epsilon' is + a capture efficiency which gives the rate at which + transported sediment particles are captured by plant stems, + math::'d' is a particle diameter, math::'\nu' is the kinematic viscosity, + math::'d_s' is the stem diameter, math::'n_s' is the stem density, + math::'h_s' is the average height of the stems, and math::'p_D" is the local flow + ponded-depth + + `"evaluator type`" = `"trapping rate`" + + * `"kinematic viscosity`" ``[double]`` **1e-6** + * `"particle diameter`" ``[double]`` **5.e-5** + * `"alpha`" ``[double]`` **0.224** + * `"beta`" ``[double]`` **0.718** + * `"gamma`" ``[double]`` **2.08** + + DEPENDENCIES: + + - `"velocity`" **SURFACE-DOMAIN-velocity** + - `"sediment`" **SURFACE-DOMAIN-sediment** + - `"stem_diameter`" **SURFACE-DOMAIN-stem_diameter** + - `"stem_height`" **SURFACE-DOMAIN-stem_height** + - `"stem_density`" **SURFACE-DOMAIN-stem_density** + - `"ponded depth`" **SURFACE-DOMAIN-ponded_depth** */ #pragma once @@ -42,7 +76,7 @@ class TrappingRateEvaluator : public EvaluatorSecondaryMonotypeCV { Key velocity_key_; Key sediment_key_; Key ponded_depth_key_; - Key biomass_key_; + Key stem_diameter_key_, stem_height_key_, stem_density_key_; double sediment_density_; static Utils::RegisteredFactory factory_; diff --git a/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator_reg.hh b/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator_reg.hh index 256e4087a..94249355a 100644 --- a/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator_reg.hh +++ b/src/pks/transport/constitutive_relations/sediment_transport/trapping_evaluator_reg.hh @@ -17,7 +17,7 @@ namespace Amanzi { // registry of method -Utils::RegisteredFactory - TrappingRateEvaluator ::factory_("trapping rate"); +Utils::RegisteredFactory TrappingRateEvaluator ::factory_( + "trapping rate"); } // namespace Amanzi diff --git a/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator.cc b/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator.cc index 45fb58713..2dac1561e 100644 --- a/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator.cc +++ b/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator.cc @@ -18,14 +18,17 @@ namespace Flow { namespace Relations { -QCRelationFieldEvaluator::QCRelationFieldEvaluator(Teuchos::ParameterList& plist) : EvaluatorSecondaryMonotypeCV(plist) +QCRelationFieldEvaluator::QCRelationFieldEvaluator(Teuchos::ParameterList& plist) + : EvaluatorSecondaryMonotypeCV(plist) { domain_ = Keys::getDomain(my_keys_.front().first); auto tag = my_keys_.front().second; cv_key_ = Keys::readKey(plist, domain_, "cell volume", "cell_volume"); dependencies_.insert(KeyTag{ cv_key_, tag }); - molar_density_key_ = Keys::readKey(plist, domain_, "molar density liquid", "molar_density_liquid"); + molar_density_key_ = + Keys::readKey(plist, domain_, "molar density liquid", "molar_density_liquid"); + tcc_key_ = Keys::readKey(plist, domain_, "concentration", "total_component_concentration"); dependencies_.insert(KeyTag{ molar_density_key_, tag }); field_src_key_ = Keys::readKey(plist, domain_, "field source", "water_source_field"); dependencies_.insert(KeyTag{ field_src_key_, tag }); @@ -41,41 +44,48 @@ QCRelationFieldEvaluator::QCRelationFieldEvaluator(Teuchos::ParameterList& plist // Required methods from SecondaryVariableFieldEvaluator void -QCRelationFieldEvaluator::Evaluate_(const State& S, const std::vector& result) +QCRelationFieldEvaluator::Evaluate_(const State& S, const std::vector& result) { - Tag tag = my_keys_.front().second; const auto& cv = *S.Get(cv_key_, tag).ViewComponent("cell", false); const auto& molar_den = *S.Get(molar_density_key_, tag).ViewComponent("cell", false); + const auto& tcc = *S.Get(tcc_key_, tag).ViewComponent("cell", false); const auto& water_from_field = *S.Get(field_src_key_, tag).ViewComponent("cell", false); auto& surf_src = *result[0]->ViewComponent("cell"); // not being reference const AmanziMesh::Mesh& mesh = *result[0]->Mesh(); - double field_flow, source_mass; - + double field_flow, source_mass, tcc_current; + // Loop through each cell AmanziMesh::Entity_ID ncells = cv.MyLength(); for (AmanziMesh::Entity_ID c = 0; c != ncells; ++c) { - if (extensive_) { - // convert extensive quantity in mol/m2/s to m3/s + // convert extensive quantity in mol/s to m3/s field_flow = water_from_field[0][c] / molar_den[0][c]; } else { - // convert intensive quantity from mol/s to m3/s + // convert intensive quantity from mol/m2/s to m3/s field_flow = water_from_field[0][c] * cv[0][c] / molar_den[0][c]; } + // current concentration + tcc_current = tcc[0][c]; - // transport source (concentration g/m3) as a function of discharge from a field (e.g. tile, groundwater) - source_mass = (*QC_curve_)(std::vector{field_flow}); + // transport source (concentration g/m3) as a function of discharge from a field + source_mass = (*QC_curve_)(std::vector{ std::abs(field_flow) }); - // return solute mass rate by multiplying with discharge (molC/s) - // Here we assume the molar mass is 1. TODO: add molar mass to the function. - surf_src[0][c] = source_mass * field_flow * molar_den[0][c] / cv[0][c]; + // temporarily assume molar mass is 1.0 + // TODO: read molar mass from the xml file + if (field_flow > 0) { + // positive flux means source, concentration is from source_transport + surf_src[0][c] = source_mass * field_flow * 1.0; + } else { + // negative flux means sink, concentration is the same as the current concentration + surf_src[0][c] = tcc_current * field_flow * 1.0; + } } } } // namespace Relations } // namespace Flow -} // namespace Amanzi \ No newline at end of file +} // namespace Amanzi diff --git a/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator.hh b/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator.hh index d32a655f4..50a044842 100644 --- a/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator.hh +++ b/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator.hh @@ -19,7 +19,7 @@ Mass sources into stream/river from a field discharge KEYS: - `"cell volume`" **DOMAIN-cell_volume** - - `"molar density liquid`" **DOMAIN-molar_density_liquid** + - `"molar density liquid`" **DOMAIN-molar_density_liquid** - `"field source`" **DOMAIN-field_source** source - `"extensive`" ``[bool]`` checks if source is extensive. Default value is *false*. @@ -34,12 +34,12 @@ Example - + - + */ #pragma once @@ -63,23 +63,25 @@ class QCRelationFieldEvaluator : public EvaluatorSecondaryMonotypeCV { } // virtual void EnsureCompatibility(State& S) override; - virtual bool - IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override { return false; } - + protected: virtual void Evaluate_(const State& S, const std::vector& result) override; virtual void EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, - const Tag& wrt_tag, - const std::vector& result) override{}; + const Key& wrt_key, + const Tag& wrt_tag, + const std::vector& result) override {}; protected: Key domain_; Key cv_key_; Key molar_density_key_; + Key tcc_key_; Key field_src_key_; bool extensive_; Teuchos::RCP QC_curve_; @@ -91,4 +93,3 @@ class QCRelationFieldEvaluator : public EvaluatorSecondaryMonotypeCV { } // namespace Relations } // namespace Flow } // namespace Amanzi - diff --git a/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator_reg.hh b/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator_reg.hh index c6bb4ac32..f18195b07 100644 --- a/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator_reg.hh +++ b/src/pks/transport/constitutive_relations/sources/qc_relation_field_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { namespace Relations { -Utils::RegisteredFactory - QCRelationFieldEvaluator::reg_("q-c field"); +Utils::RegisteredFactory QCRelationFieldEvaluator::reg_( + "q-c field"); } // namespace Relations } // namespace Flow diff --git a/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator.cc b/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator.cc index be8f9dd20..599fb7507 100644 --- a/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator.cc +++ b/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator.cc @@ -46,6 +46,7 @@ QCRelationOverlandEvaluator::Evaluate_(const State& S, const std::vector(cv_key_, tag).ViewComponent("cell", false); const auto& molar_den = *S.Get(molar_density_key_, tag).ViewComponent("cell", false); + const auto& tcc = *S.Get(tcc_key_, tag).ViewComponent("cell", false); const auto& water_from_field = *S.Get(field_src_key_, tag).ViewComponent("face", false); auto& surf_src = *result[0]->ViewComponent("cell"); // not being reference @@ -58,29 +59,41 @@ QCRelationOverlandEvaluator::Evaluate_(const State& S, const std::vector{ total_flux_meter }); - surf_src[0][c] = source_transport * total_flux_meter * molar_den[0][c] / cv[0][c]; + // transport source (mass/volume e.g., mg/m3) as a function of discharge (e.g. overland) + double source_transport = (*QC_curve_)(std::vector{ std::abs(total_flux_meter) }); + + // temporarily assume molar mass is 1.0 + // TODO: read molar mass from the xml file + if (total_flux_meter > 0) { + // positive flux means source, concentration is from source_transport + surf_src[0][c] = source_transport * total_flux_meter * 1.0; + } else { + // negative flux means sink, concentration is the same as the current concentration + surf_src[0][c] = tcc_current * total_flux_meter * 1.0; + } } } } // namespace Relations } // namespace Flow -} // namespace Amanzi \ No newline at end of file +} // namespace Amanzi diff --git a/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator.hh b/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator.hh index f28fd7eb7..2383cd15b 100644 --- a/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator.hh +++ b/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator.hh @@ -17,8 +17,8 @@ KEYS: - `"cell volume`" **DOMAIN-cell_volume** - - `"molar density liquid`" **DOMAIN-molar_density_liquid** - - `"overland source`" **DOMAIN-overland_source** source + - `"molar density liquid`" **DOMAIN-molar_density_liquid** + - `"overland source`" **DOMAIN-overland_source** source Example @@ -30,7 +30,7 @@ Example - + @@ -60,8 +60,9 @@ class QCRelationOverlandEvaluator : public EvaluatorSecondaryMonotypeCV { } // virtual void EnsureCompatibility(State& S) override; - virtual bool - IsDifferentiableWRT(const State& S, const Key& wrt_key, const Tag& wrt_tag) const override + virtual bool IsDifferentiableWRT(const State& S, + const Key& wrt_key, + const Tag& wrt_tag) const override { return false; } @@ -77,6 +78,7 @@ class QCRelationOverlandEvaluator : public EvaluatorSecondaryMonotypeCV { Key domain_; Key cv_key_; Key molar_density_key_; + Key tcc_key_; Key field_src_key_; Teuchos::RCP QC_curve_; @@ -87,4 +89,3 @@ class QCRelationOverlandEvaluator : public EvaluatorSecondaryMonotypeCV { } // namespace Relations } // namespace Flow } // namespace Amanzi - diff --git a/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator_reg.hh b/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator_reg.hh index 1d530758a..f3928f167 100644 --- a/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator_reg.hh +++ b/src/pks/transport/constitutive_relations/sources/qc_relation_overland_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace Flow { namespace Relations { -Utils::RegisteredFactory - QCRelationOverlandEvaluator::reg_("q-c overland"); +Utils::RegisteredFactory QCRelationOverlandEvaluator::reg_( + "q-c overland"); } // namespace Relations } // namespace Flow diff --git a/src/pks/transport/sediment_transport_pk.cc b/src/pks/transport/sediment_transport_pk.cc index e03ddfe04..fe1bc674b 100644 --- a/src/pks/transport/sediment_transport_pk.cc +++ b/src/pks/transport/sediment_transport_pk.cc @@ -4,40 +4,25 @@ The terms of use and "as is" disclaimer for this license are provided in the top-level COPYRIGHT file. - Authors: Konstantin Lipnikov (lipnikov@lanl.gov) + Authors: Daniil Svyatsky (dasvyat@lanl.gov) */ /* - Transport PK + Special version of transport capabilities to model sediment transport in surface flows. */ #include #include -#include "Epetra_Vector.h" -#include "Epetra_IntVector.h" #include "Epetra_MultiVector.h" -#include "Epetra_Import.h" #include "Teuchos_RCP.hpp" -#include "BCs.hh" #include "errors.hh" -#include "Explicit_TI_RK.hh" -#include "Evaluator.hh" -#include "GMVMesh.hh" -#include "Mesh.hh" -#include "MFD3D_Diffusion.hh" -#include "OperatorDefs.hh" -#include "PDE_DiffusionFactory.hh" -#include "PDE_Diffusion.hh" -#include "PDE_Accumulation.hh" -#include "PK_DomainFunctionFactory.hh" -#include "PK_Utils.hh" +#include "PK_Helpers.hh" +#include "TensorVector.hh" #include "sediment_transport_pk.hh" -#include "TransportDomainFunction.hh" - namespace Amanzi { namespace Transport { @@ -48,1562 +33,237 @@ namespace Transport { SedimentTransport_PK::SedimentTransport_PK(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& glist, const Teuchos::RCP& S, - const Teuchos::RCP& soln) - : S_(S), soln_(soln) -{ - name_ = Keys::cleanPListName(pk_tree.name()); - - // Create miscaleneous lists. - Teuchos::RCP pk_list = Teuchos::sublist(glist, "PKs", true); - - tp_list_ = Teuchos::sublist(pk_list, name_, true); - - if (tp_list_->isParameter("component names")) { - component_names_ = tp_list_->get>("component names").toVector(); - mol_masses_ = tp_list_->get>("component molar masses").toVector(); - } else if (glist->isSublist("Cycle Driver")) { - if (glist->sublist("Cycle Driver").isParameter("component names")) { - // grab the component names - component_names_ = glist->sublist("Cycle Driver") - .get>("component names") - .toVector(); - } else { - Errors::Message msg("Transport PK: parameter component names is missing."); - Exceptions::amanzi_throw(msg); - } - } else { - Errors::Message msg( - "Transport PK: sublist Cycle Driver or parameter component names is missing."); - Exceptions::amanzi_throw(msg); - } - - subcycling_ = tp_list_->get("transport subcycling", false); + const Teuchos::RCP& solution) - // initialize io - Teuchos::RCP units_list = Teuchos::sublist(glist, "units"); - units_.Init(*units_list); - - vo_ = Teuchos::null; -} + : PK(pk_tree, glist, S, solution), Transport_ATS(pk_tree, glist, S, solution) +{} -/* ****************************************************************** -* Define structure of this PK. -****************************************************************** */ void -SedimentTransport_PK::Setup(const Teuchos::Ptr& S) +SedimentTransport_PK::parseParameterList() { - passwd_ = "state"; // owner's password + PK_Physical_Default::parseParameterList(); - // are we subcycling internally? - subcycling_ = plist_->get("transport subcycling", false); - if (subcycling_) { - tag_subcycle_current_ = Tag{ name() + "_subcycling_current" }; - tag_subcycle_next_ = Tag{ name() + "_subcycling_next" }; - } else { - tag_subcycle_current_ = tag_current_; - tag_subcycle_next_ = tag_next_; - } + num_components_ = 1; + component_names_.resize(num_components_); + component_names_[0] = "sediment"; + num_aqueous_ = 1; - domain_name_ = tp_list_->get("domain name", "domain"); + molar_masses_ = + readParameterMapByComponent(plist_->sublist("component molar masses [kg / mol C]"), 1.0); + tcc_max_ = readParameterMapByComponent( + plist_->sublist("component maximum concentration [mol C / mol H2O]"), -1.0); - saturation_key_ = Keys::readKey(*tp_list_, domain_name_, "saturation liquid"); - prev_saturation_key_ = Keys::readKey(*tp_list_, domain_name_, "previous saturation liquid"); - flux_key_ = Keys::readKey(*tp_list_, domain_name_, "water flux", "water_flux"); - tcc_key_ = Keys::readKey(*tp_list_, domain_name_, "concentration", "sediment"); - molar_density_key_ = - Keys::readKey(*tp_list_, domain_name_, "molar density", "molar_density_liquid"); - solid_residue_mass_key_ = - Keys::readKey(*tp_list_, domain_name_, "solid residue", "solid_residue_mass"); - sd_trapping_key_ = Keys::readKey(*tp_list_, domain_name_, "trapping rate", "trapping_rate"); - sd_settling_key_ = Keys::readKey(*tp_list_, domain_name_, "settling rate", "settling_rate"); - sd_erosion_key_ = Keys::readKey(*tp_list_, domain_name_, "erosion rate", "erosion_rate"); - sd_organic_key_ = Keys::readKey(*tp_list_, domain_name_, "organic rate", "organic_rate"); - horiz_mixing_key_ = - Keys::readKey(*tp_list_, domain_name_, "horizontal mixing", "horizontal_mixing"); - elevation_increase_key_ = Keys::getKey(domain_name_, "deformation"); - porosity_key_ = Keys::getKey(domain_name_, "soil_porosity"); - - water_tolerance_ = tp_list_->get("water tolerance", 1e-1); - max_tcc_ = tp_list_->get("maximal concentration", 0.9); - sediment_density_ = tp_list_->get("sediment density [kg m^-3]"); + sd_trapping_key_ = Keys::readKey(*plist_, domain_, "trapping rate", "trapping_rate"); + sd_settling_key_ = Keys::readKey(*plist_, domain_, "settling rate", "settling_rate"); + sd_erosion_key_ = Keys::readKey(*plist_, domain_, "erosion rate", "erosion_rate"); + sd_organic_key_ = Keys::readKey(*plist_, domain_, "organic rate", "organic_rate"); + elevation_increase_key_ = Keys::readKey(*plist_, domain_, "deformation", "deformation"); + requireEvaluatorAtNext(elevation_increase_key_, tag_next_, *S_, name_); - mesh_ = S->GetMesh(domain_name_); - dim = mesh_->getSpaceDimension(); + porosity_key_ = Keys::readKey(*plist_, domain_, "soil porosity", "soil_porosity"); - // cross-coupling of PKs - Teuchos::RCP physical_models = - Teuchos::sublist(tp_list_, "physical models and assumptions"); - bool abs_perm = physical_models->get("permeability field is required", false); + has_dispersion_ = false; + has_diffusion_ = false; - - if (!S->HasRecordSet(flux_key_)) { - S->Require(flux_key_, tag_next_) - .SetMesh(mesh_) - ->SetGhosted(true) - ->SetComponent("face", AmanziMesh::Entity_kind::FACE, 1); - S->RequireEvaluator(flux_key_, tag_next_); + if (plist_->isSublist("sediment diffusion coefficient [m^2 s^-1]")) { + has_diffusion_ = true; + molec_diff_ = + readParameterMapByComponent(plist_->sublist("sediment diffusion coefficient [m^2 s^-1]"), 0.); + tortuosity_ = readParameterMapByPhase(plist_->sublist("tortuosity [-]"), 1.); } - S->Require(saturation_key_, tag_next_) - .SetMesh(mesh_) - ->SetGhosted(true) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->RequireEvaluator(saturation_key_, tag_next_); + // keys, dependencies, etc + // -- flux -- only needed at new time, evaluator controlled elsewhere + water_flux_key_ = Keys::readKey(*plist_, domain_, "water flux", "water_flux"); - // prev_sat does not have an evaluator, this is managed by hand. not sure why - S->Require(saturation_key_, tag_current_) - .SetMesh(mesh_) - ->SetGhosted(true) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->GetRecordW(saturation_key_, tag_current_, passwd_).set_io_vis(false); + mass_flux_advection_key_ = + Keys::readKey(*plist_, domain_, "mass flux advection", "mass_flux_advection"); + requireEvaluatorAtNext(mass_flux_advection_key_, tag_next_, *S_, name_); - if (!S->HasRecordSet(sd_organic_key_)) { - S->Require(sd_organic_key_, tag_next_, sd_organic_key_) - .SetMesh(mesh_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->RequireEvaluator(sd_organic_key_, tag_next_); - } + mass_flux_diffusion_key_ = + Keys::readKey(*plist_, domain_, "mass flux diffusion", "mass_flux_diffusion"); + requireEvaluatorAtNext(mass_flux_diffusion_key_, tag_next_, *S_, name_); - if (!S->HasRecordSet(sd_trapping_key_)) { - S->Require(sd_trapping_key_, tag_next_, sd_trapping_key_) - .SetMesh(mesh_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->RequireEvaluator(sd_trapping_key_, tag_next_); - } + // -- liquid water content - need at new time, copy at current time + lwc_key_ = Keys::readKey(*plist_, domain_, "liquid water content", "water_content"); + requireEvaluatorAtCurrent(lwc_key_, tag_current_, *S_, name_); - if (!S->HasRecordSet(sd_settling_key_)) { - S->Require(sd_settling_key_, tag_next_, sd_settling_key_) - .SetMesh(mesh_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->RequireEvaluator(sd_settling_key_, tag_next_); - } + default_water_src_key_ = Keys::readKey(*plist_, domain_, "water source", "water_source"); + cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); - if (!S->HasRecordSet(sd_erosion_key_)) { - S->Require(sd_erosion_key_, tag_next_, sd_erosion_key_) - .SetMesh(mesh_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->RequireEvaluator(sd_erosion_key_, tag_next_); - } + // workspace, no evaluator + conserve_qty_key_ = + Keys::readKey(*plist_, domain_, "conserved quantity", "total_component_quantity"); + requireEvaluatorAtNext(conserve_qty_key_, tag_next_, *S_, name_); - if (!S->HasRecordSet(horiz_mixing_key_)) { - S->Require( - horiz_mixing_key_, tag_next_, horiz_mixing_key_) - .SetMesh(mesh_) - ->SetGhosted(false) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->RequireEvaluator(horiz_mixing_key_, tag_next_); - } - - if (!S->HasRecordSet(porosity_key_)) { - S->Require(porosity_key_, tag_next_, porosity_key_) - .SetMesh(mesh_) - ->SetGhosted(false) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->RequireEvaluator(porosity_key_, tag_next_); - } + solid_residue_mass_key_ = + Keys::readKey(*plist_, domain_, "solid residue", "solid_residue_quantity"); + // other parameters + // -- a small amount of water, used to define when we are going to completely dry out a grid cell + water_tolerance_ = plist_->get("water tolerance [mol H2O / m^d]", 1e-6); - int ncomponents = component_names_.size(); - std::vector> subfield_names(1); - subfield_names[0] = component_names_; + // global transport parameters + cfl_ = plist_->get("cfl", 1.0); + dt_max_ = plist_->get("maximum timestep [s]", TRANSPORT_LARGE_TIME_STEP); - if (!S->HasRecordSet(solid_residue_mass_key_)) { - S->Require(solid_residue_mass_key_, tag_next_, passwd_) - .SetMesh(mesh_) - ->SetGhosted(true) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, ncomponents); - } + // dispersion coefficient tensor + dispersion_tensor_key_ = + Keys::readKey(*plist_, domain_, "sediment dispersion coefficient", "horizontal_mixing"); + has_dispersion_ = S_->HasEvaluatorList(dispersion_tensor_key_); - if (!S->HasRecordSet(molar_density_key_)) { - S->Require( - molar_density_key_, tag_next_, molar_density_key_) - .SetMesh(mesh_) - ->SetGhosted(true) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - S->RequireEvaluator(molar_density_key_, tag_next_); - } - // require state fields when Transport PK is on - if (component_names_.size() == 0) { + adv_spatial_disc_order_ = plist_->get("advection spatial discretization order", 1); + if (adv_spatial_disc_order_ < 1 || adv_spatial_disc_order_ > 2) { Errors::Message msg; - msg << "Transport PK: list of solutes is empty.\n"; + msg << "Transport_ATS: \"advection spatial discretization order\" must be 1 or 2, not " + << adv_spatial_disc_order_; Exceptions::amanzi_throw(msg); } - - S->Require(tcc_key_, tag_next_, passwd_) - .SetMesh(mesh_) - ->SetGhosted(true) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, ncomponents); -} - - -/* ****************************************************************** -* Routine processes parameter list. It needs to be called only once -* on each processor. -****************************************************************** */ -void -SedimentTransport_PK::Initialize(const Teuchos::Ptr& S) -{ - // Set initial values for transport variables. - dt_ = dt_debug_ = t_physics_ = 0.0; - double time = S->get_time(); - if (time >= 0.0) t_physics_ = time; - - // if (tp_list_->isSublist("initial conditions")) { - // S->GetW(tcc_key_, tag_current_, passwd_).Initialize(tp_list_->sublist("initial conditions")); - // } - - diffusion_preconditioner = "identity"; - - internal_tests = 0; - //tests_tolerance = TRANSPORT_CONCENTRATION_OVERSHOOT; - - bc_scaling = 0.0; - - // Create verbosity object. - Teuchos::ParameterList vlist; - vlist.sublist("verbose object") = tp_list_->sublist("verbose object"); - vo_ = Teuchos::rcp(new VerboseObject("TransportPK", vlist)); - - Teuchos::OSTab tab = vo_->getOSTab(); - MyPID = mesh_->getComm()->MyPID(); - - // // initialize missed fields - InitializeFields_(S); - - //create copies - //S->RequireFieldCopy(tcc_key_, "subcycling", passwd_); - tcc_tmp = S_->GetPtrW(tcc_key_, tag_subcycle_next_, name_); - tcc = S_->GetPtrW(tcc_key_, tag_subcycle_current_, name_); - *tcc_tmp = *tcc; - - ws_subcycle_start = - S_->GetW(saturation_key_, tag_subcycle_current_, name_).ViewComponent("cell"); - - ws_subcycle_end = - S_->GetW(saturation_key_, tag_subcycle_next_, name_).ViewComponent("cell"); - - // Check input parameters. Due to limited amount of checks, we can do it earlier. - // Policy(S.ptr()); - - ncells_owned = - mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); - ncells_wghost = - mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); - - nfaces_owned = - mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::OWNED); - nfaces_wghost = - mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::ALL); - nnodes_wghost = - mesh_->getNumEntities(AmanziMesh::Entity_kind::NODE, AmanziMesh::Parallel_kind::ALL); - - // extract control parameters - InitializeAll_(); - - // state pre-prosessing - Teuchos::RCP cv; - - ws_ = S->Get(saturation_key_, tag_next_).ViewComponent("cell", false); - ws_prev_ = - S->GetPtr(saturation_key_, tag_current_)->ViewComponent("cell", false); - - mol_dens_ = - S->GetPtr(molar_density_key_, tag_next_)->ViewComponent("cell", false); - // mol_dens_prev_ = S_->GetPtr(molar_density_key_) -> ViewComponent("cell", false); - km_ = S->GetPtr(horiz_mixing_key_, tag_next_)->ViewComponent("cell", false); - - tcc = S->GetPtrW(tcc_key_, tag_next_, passwd_); - - flux_ = S->Get(flux_key_, tag_next_).ViewComponent("face", true); - solid_qty_ = S->GetW(solid_residue_mass_key_, tag_next_, passwd_) - .ViewComponent("cell", false); - - //create vector of conserved quatities - conserve_qty_ = Teuchos::rcp(new Epetra_MultiVector( - *(S->Get(tcc_key_, tag_next_).ViewComponent("cell", true)))); - - // memory for new components - // tcc_tmp = Teuchos::rcp(new CompositeVector(*(S->GetPtr(tcc_key_)))); - // *tcc_tmp = *tcc; - - // upwind - const Epetra_Map& fmap_wghost = mesh_->getMap(AmanziMesh::Entity_kind::FACE, true); - upwind_cell_ = Teuchos::rcp(new Epetra_IntVector(fmap_wghost)); - downwind_cell_ = Teuchos::rcp(new Epetra_IntVector(fmap_wghost)); - - IdentifyUpwindCells_(); - - // advection block initialization - current_component_ = -1; - - const Epetra_Map& cmap_owned = mesh_->getMap(AmanziMesh::Entity_kind::CELL, false); - - // reconstruction initialization - const Epetra_Map& cmap_wghost = mesh_->getMap(AmanziMesh::Entity_kind::CELL, true); - lifting_ = Teuchos::rcp(new Operators::ReconstructionCellLinear(mesh_)); - - // create boundary conditions - if (tp_list_->isSublist("boundary conditions")) { - // -- try tracer-type conditions - PK_DomainFunctionFactory factory(mesh_, S_); - Teuchos::ParameterList& clist = - tp_list_->sublist("boundary conditions").sublist("concentration"); - - for (Teuchos::ParameterList::ConstIterator it = clist.begin(); it != clist.end(); ++it) { - std::string name = it->first; - if (clist.isSublist(name)) { - Teuchos::ParameterList& bc_list = clist.sublist(name); - if (name == "coupling") { - Teuchos::ParameterList::ConstIterator it1 = bc_list.begin(); - std::string specname = it1->first; - Teuchos::ParameterList& spec = bc_list.sublist(specname); - Teuchos::RCP bc = factory.Create( - spec, "boundary concentration", AmanziMesh::Entity_kind::FACE, Teuchos::null); - - for (int i = 0; i < component_names_.size(); i++) { - bc->tcc_names().push_back(component_names_[i]); - bc->tcc_index().push_back(i); - } - - bc->set_state(S_); - bcs_.push_back(bc); - } else if (name == "subgrid") { - Teuchos::ParameterList::ConstIterator it1 = bc_list.begin(); - std::string specname = it1->first; - Teuchos::ParameterList& spec = bc_list.sublist(specname); - Teuchos::Array regions(1, domain_name_); - - std::size_t last_of = domain_name_.find_last_of("_"); - AMANZI_ASSERT(last_of != std::string::npos); - int gid = std::stoi(domain_name_.substr(last_of + 1, domain_name_.size())); - spec.set("entity_gid_out", gid); - Teuchos::RCP bc = factory.Create( - spec, "boundary concentration", AmanziMesh::Entity_kind::FACE, Teuchos::null); - - for (int i = 0; i < component_names_.size(); i++) { - bc->tcc_names().push_back(component_names_[i]); - bc->tcc_index().push_back(i); - } - - - bc->set_state(S_); - bcs_.push_back(bc); - - } else { - for (Teuchos::ParameterList::ConstIterator it1 = bc_list.begin(); it1 != bc_list.end(); - ++it1) { - std::string specname = it1->first; - Teuchos::ParameterList& spec = bc_list.sublist(specname); - Teuchos::RCP bc = factory.Create( - spec, "boundary concentration", AmanziMesh::Entity_kind::FACE, Teuchos::null); - - std::vector& tcc_index = bc->tcc_index(); - std::vector& tcc_names = bc->tcc_names(); - bc->set_state(S_); - - tcc_names.push_back(name); - tcc_index.push_back(0); - - bcs_.push_back(bc); - } - } - } - } - } else { - if (vo_->getVerbLevel() > Teuchos::VERB_NONE) { - *vo_->os() << vo_->color("yellow") << "No BCs were specified." << vo_->reset() << std::endl; - } - } - - - // boundary conditions initialization - time = t_physics_; - // for (int i = 0; i < bcs_.size(); i++) { - // bcs_[i]->Compute(time, time); - // } - - // VV_CheckInfluxBC(); - - // source term initialization: so far only "concentration" is available. - if (tp_list_->isSublist("source terms")) { - PK_DomainFunctionFactory factory(mesh_, S_); - //if (domain_name_ == "domain") PKUtils_CalculatePermeabilityFactorInWell(S_.ptr(), Kxy_); - - Teuchos::ParameterList& clist = tp_list_->sublist("source terms").sublist("concentration"); - for (Teuchos::ParameterList::ConstIterator it = clist.begin(); it != clist.end(); ++it) { - std::string name = it->first; - if (clist.isSublist(name)) { - Teuchos::ParameterList& src_list = clist.sublist(name); - if (name == "coupling") { - Teuchos::ParameterList::ConstIterator it1 = src_list.begin(); - std::string specname = it1->first; - Teuchos::ParameterList& spec = src_list.sublist(specname); - Teuchos::RCP src = - factory.Create(spec, "sink", AmanziMesh::Entity_kind::CELL, Teuchos::null); - - for (int i = 0; i < component_names_.size(); i++) { - src->tcc_names().push_back(component_names_[i]); - src->tcc_index().push_back(i); - } - src->set_state(S_); - srcs_.push_back(src); - - } else { - for (Teuchos::ParameterList::ConstIterator it1 = src_list.begin(); it1 != src_list.end(); - ++it1) { - std::string specname = it1->first; - Teuchos::ParameterList& spec = src_list.sublist(specname); - Teuchos::RCP src = - factory.Create(spec, "sink", AmanziMesh::Entity_kind::CELL, Teuchos::null); - - src->tcc_names().push_back(name); - src->tcc_index().push_back(0); - - src->set_state(S_); - srcs_.push_back(src); - } - } - } - } - } - - dt_debug_ = tp_list_->get("maximum timestep", TRANSPORT_LARGE_TIME_STEP); - - - if (vo_->getVerbLevel() >= Teuchos::VERB_MEDIUM) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Number of components: " << tcc->size() << std::endl - << "cfl=" << cfl_ << " spatial/temporal discretization: " << spatial_disc_order - << " " << temporal_disc_order << std::endl; - *vo_->os() << vo_->color("green") << "Initalization of PK is complete." << vo_->reset() - << std::endl - << std::endl; + temporal_disc_order_ = plist_->get("temporal discretization order", 1); + if (temporal_disc_order_ < 1 || temporal_disc_order_ > 2) { + Errors::Message msg; + msg << "Transport_ATS: \"temporal discretization order\" must be 1 or 2, not " + << temporal_disc_order_; + Exceptions::amanzi_throw(msg); } } -/* ****************************************************************** -* Initalized fields left by State and other PKs. -****************************************************************** */ void -SedimentTransport_PK::InitializeFields_(const Teuchos::Ptr& S) +SedimentTransport_PK::SetupPhysicalEvaluators_() { - Teuchos::OSTab tab = vo_->getOSTab(); - - // set popular default values when flow PK is off - // if (S->HasRecordSet(saturation_key_)) { - // if (S->GetW(saturation_key_)->owner() == passwd_) { - // if (!S->GetW(saturation_key_, passwd_)->initialized()) { - // S->GetW(saturation_key_, passwd_).PutScalar(1.0); - // S->GetField(saturation_key_, passwd_)->set_initialized(); + Transport_ATS::SetupPhysicalEvaluators_(); - // if (vo_->getVerbLevel() >= Teuchos::VERB_MEDIUM) - // *vo_->os() << "initilized saturation_liquid to value 1.0" << std::endl; - // } - // InitializeFieldFromField_(prev_saturation_key_, saturation_key_, S, true, true); - // } - // else { - // if (S->GetField(prev_saturation_key_)->owner() == passwd_) { - // if (!S->GetField(prev_saturation_key_, passwd_)->initialized()) { - // InitializeFieldFromField_(prev_saturation_key_, saturation_key_, S, true, true); - // S->GetField(prev_saturation_key_, passwd_)->set_initialized(); - - // if (vo_->getVerbLevel() >= Teuchos::VERB_MEDIUM) - // *vo_->os() << "initilized prev_saturation_liquid from saturation" << std::endl; - // } - // } - // } - // } - - S->GetW(solid_residue_mass_key_, tag_current_, passwd_).PutScalar(0.0); - S->GetRecordW(solid_residue_mass_key_, passwd_).set_initialized(); -} + // setup sediment transport sources + requireEvaluatorAtNext(sd_organic_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted(true) + ->AddComponent("cell", AmanziMesh::CELL, 1); + requireEvaluatorAtNext(sd_trapping_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted(true) + ->AddComponent("cell", AmanziMesh::CELL, 1); -/* **************************************************************** -* Auxiliary initialization technique. -**************************************************************** */ -void -SedimentTransport_PK::InitializeFieldFromField_(const std::string& field0, - const Tag& tag0, - const std::string& field1, - const Tag& tag1, - const Teuchos::Ptr& S, - bool call_evaluator, - bool overwrite) -{ - if (S->HasRecordSet(field0)) { - if (S->GetRecord(field0, tag0).owner() == passwd_) { - if ((!S->GetRecord(field0, tag0).initialized()) || (overwrite)) { - if (call_evaluator) S->GetEvaluator(field1, tag1).Update(*S, passwd_); + requireEvaluatorAtNext(sd_settling_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted(true) + ->AddComponent("cell", AmanziMesh::CELL, 1); - const CompositeVector& f1 = *S->GetPtr(field1, tag1); - CompositeVector& f0 = *S->GetPtrW(field0, tag0, passwd_); + requireEvaluatorAtNext(sd_erosion_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted(true) + ->AddComponent("cell", AmanziMesh::CELL, 1); - double vmin0, vmax0, vavg0; - double vmin1, vmax1, vavg1; + S_->Require("sediment_density", tag_next_); - f0 = f1; + if (!elevation_increase_key_.empty()) { + // note, these are done at the OUTER step, hard-coded to NEXT because dz is + // accumulated through the inner steps, then applied to the mesh at the + // outer step. + requireEvaluatorAtNext(elevation_increase_key_, tag_next_, *S_, name_) + .SetMesh(mesh_) + ->SetGhosted() + ->SetComponent("cell", AmanziMesh::CELL, 1); - S->GetRecordW(field0, tag0, passwd_).set_initialized(); - if ((vo_->getVerbLevel() >= Teuchos::VERB_MEDIUM) && (!overwrite)) { - *vo_->os() << "initiliazed " << field0 << " to " << field1 << std::endl; - } - } - } + requireEvaluatorAtNext(porosity_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::CELL, 1); } } - /* ****************************************************************** -* Inialization of various transport structures. +* Routine processes parameter list. It needs to be called only once +* on each processor. ****************************************************************** */ void -SedimentTransport_PK::InitializeAll_() +SedimentTransport_PK::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); + PK_Physical_Default::Initialize(); - // global transport parameters - cfl_ = tp_list_->get("cfl", 1.0); - - spatial_disc_order = tp_list_->get("spatial discretization order", 1); - if (spatial_disc_order < 1 || spatial_disc_order > 2) spatial_disc_order = 1; - temporal_disc_order = tp_list_->get("temporal discretization order", 1); - if (temporal_disc_order < 1 || temporal_disc_order > 2) temporal_disc_order = 1; - - num_aqueous_ = tp_list_->get("number of sediment components", component_names_.size()); - - // mass_solutes_exact_.assign(num_aqueous_ + num_gaseous_, 0.0); - // mass_solutes_source_.assign(num_aqueous_ + num_gaseous_, 0.0); - // mass_solutes_bc_.assign(num_aqueous_ + num_gaseous_, 0.0); - // mass_solutes_stepstart_.assign(num_aqueous_ + num_gaseous_, 0.0); - - if (tp_list_->isParameter("runtime diagnostics: regions")) { - runtime_regions_ = - tp_list_->get>("runtime diagnostics: regions").toVector(); - } - - internal_tests = tp_list_->get("enable internal tests", "no") == "yes"; - // tests_tolerance = tp_list_->get("internal tests tolerance", TRANSPORT_CONCENTRATION_OVERSHOOT); - // dt_debug_ = tp_list_->get("maximum timestep", TRANSPORT_LARGE_TIME_STEP); -} - - -/* ******************************************************************* -* Estimation of the timestep based on T.Barth (Lecture Notes -* presented at VKI Lecture Series 1994-05, Theorem 4.2.2. -* Routine must be called every time we update a flow field. -* -* Warning: Barth calculates influx, we calculate outflux. The methods -* are equivalent for divergence-free flows and gurantee EMP. Outflux -* takes into account sinks and sources but preserves only positivity -* of an advected mass. -* ***************************************************************** */ -double -SedimentTransport_PK::StableTimeStep_() -{ - S_->Get(flux_key_, Tags::DEFAULT).ScatterMasterToGhosted("face"); - - flux_ = S_->Get(flux_key_, Tags::DEFAULT).ViewComponent("face", true); - //*flux_copy_ = *flux_; // copy flux vector from S_next_ to S_; - - IdentifyUpwindCells_(); - - tcc = S_->GetPtrW(tcc_key_, tag_current_, passwd_); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell"); - - // loop over faces and accumulate upwinding fluxes - std::vector total_outflux(ncells_wghost, 0.0); - - for (int f = 0; f < nfaces_wghost; f++) { - int c = (*upwind_cell_)[f]; - if (c >= 0) total_outflux[c] += fabs((*flux_)[0][f]); - } - - Sinks2TotalOutFlux(tcc_prev, total_outflux, 0, num_aqueous_ - 1); - - // loop over cells and calculate minimal timestep - double vol, outflux, dt_cell; - vol = 0; - dt_ = dt_cell = TRANSPORT_LARGE_TIME_STEP; - int cmin_dt = 0; - for (int c = 0; c < ncells_owned; c++) { - outflux = total_outflux[c]; - - if ((outflux > 0) && ((*ws_prev_)[0][c] > 1e-6) && ((*ws_)[0][c] > 1e-6)) { - vol = mesh_->getCellVolume(c); - dt_cell = vol * (*mol_dens_)[0][c] * std::min((*ws_prev_)[0][c], (*ws_)[0][c]) / outflux; - } - if (dt_cell < dt_) { - dt_ = dt_cell; - cmin_dt = c; - } - } - - - if (spatial_disc_order == 2) dt_ /= 2; - - // communicate global timestep - double dt_tmp = dt_; -#ifdef HAVE_MPI - const Epetra_Comm& comm = ws_prev_->Comm(); - comm.MinAll(&dt_tmp, &dt_, 1); -#endif - - // incorporate developers and CFL constraints - dt_ = std::min(dt_, dt_debug_); - dt_ *= cfl_; - - // //print optional diagnostics using maximum cell id as the filter - // if (vo_->getVerbLevel() >= Teuchos::VERB_HIGH) { - // int cmin_dt_unique = (fabs(dt_tmp * cfl_ - dt_) < 1e-6 * dt_) ? cmin_dt : -1; - - // #ifdef HAVE_MPI - // int cmin_dt_tmp = cmin_dt_unique; - // comm.MaxAll(&cmin_dt_tmp, &cmin_dt_unique, 1); - // #endif - // if (cmin_dt == cmin_dt_unique) { - // const AmanziGeometry::Point& p = mesh_->getCellCentroid(cmin_dt); - - // Teuchos::OSTab tab = vo_->getOSTab(); - // *vo_->os() << "cell " << cmin_dt << " has smallest dt, (" << p[0] << ", " << p[1]; - // if (p.dim() == 3) *vo_->os() << ", " << p[2]; - // *vo_->os() << ")" << std::endl; - // } - // } - return dt_; -} - - -/* ******************************************************************* -* Estimate returns last timestep unless it is zero. -******************************************************************* */ -double -SedimentTransport_PK::get_dt() -{ - if (subcycling_) { - return 1e+99; - } else { - // flux_ = S_next_->Get(flux_key_).ViewComponent("face", true); - // *flux_copy_ = *flux_; // copy flux vector from S_next_ to S_; - // double norm = 0.; - // flux_->NormInf(&norm); - // *vo_->os()<< name()<<" "<<"flux is copied norm:"<getOSTab(); - - if (S_->HasEvaluator(saturation_key_, tag_current_)) { - S_->GetEvaluator(saturation_key_, tag_next_).Update(*S_, saturation_key_); - S_->GetEvaluator(saturation_key_, tag_current_).Update(*S_, saturation_key_); - } - ws_ = S_->Get(saturation_key_, tag_next_).ViewComponent("cell", false); - ws_prev_ = S_->Get(saturation_key_, tag_current_).ViewComponent("cell", false); - - - if (S_->HasEvaluator(molar_density_key_, tag_next_)) { - S_->GetEvaluator(molar_density_key_, tag_next_).Update(*S_, molar_density_key_); - } - mol_dens_ = S_->Get(molar_density_key_, tag_next_).ViewComponent("cell", false); - - - solid_qty_ = S_->GetW(solid_residue_mass_key_, tag_next_, passwd_) - .ViewComponent("cell", false); - - // We use original tcc and make a copy of it later if needed. - tcc = S_->GetPtrW(tcc_key_, tag_current_, passwd_); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell"); - - // calculate stable timestep - double dt_shift = 0.0, dt_global = dt_MPC; - double time = t_old; - if (time >= 0.0) { - t_physics_ = time; - dt_shift = time - S_->get_time(tag_current_); - dt_global = S_->get_time(tag_next_) - S_->get_time(tag_current_); - AMANZI_ASSERT(std::abs(dt_global - dt_MPC) < 1.e-4); - } - - StableTimeStep_(); - double dt_stable = dt_; // advance routines override dt_ - - int interpolate_ws = 0; // (dt_ < dt_global) ? 1 : 0; - - interpolate_ws = (dt_ < dt_global) ? 1 : 0; - - // start subcycling - double dt_sum = 0.0; - double dt_cycle; - if (interpolate_ws) { - dt_cycle = std::min(dt_stable, dt_MPC); - InterpolateCellVector(*ws_prev_, *ws_, dt_shift, dt_global, *ws_subcycle_start); - InterpolateCellVector(*ws_prev_, *ws_, dt_shift + dt_cycle, dt_global, *ws_subcycle_end); - ws_start = ws_subcycle_start; - ws_end = ws_subcycle_end; - mol_dens_start = mol_dens_; - mol_dens_end = mol_dens_; - } else { - dt_cycle = dt_MPC; - ws_start = ws_prev_; - ws_end = ws_; - mol_dens_start = mol_dens_; - mol_dens_end = mol_dens_; - } - - - for (int c = 0; c < ncells_owned; c++) { - double vol_ws_den; - vol_ws_den = mesh_->getCellVolume(c) * (*ws_prev_)[0][c] * (*mol_dens_)[0][c]; - mass_sediment_stepstart_ = tcc_prev[0][c] * vol_ws_den; - } - - - int ncycles = 0, swap = 1; - - - while (dt_sum < dt_MPC - 1e-5) { - // update boundary conditions - time = t_physics_ + dt_cycle / 2; - for (int i = 0; i < bcs_.size(); i++) { bcs_[i]->Compute(time, time); } - - double dt_try = dt_MPC - dt_sum; - double tol = 1e-10 * (dt_try + dt_stable); - bool final_cycle = false; - if (vo_->getVerbLevel() >= Teuchos::VERB_EXTREME) { - *vo_->os() << std::setprecision(10) << "dt_MPC " << dt_MPC << " dt_cycle " << dt_cycle - << " dt_sum " << dt_sum << " dt_stable " << dt_stable << " dt_try " << dt_try - << " " << dt_try - (dt_stable + tol) << " tol " << tol << "\n"; - } - - if (dt_try >= 2 * dt_stable) { - dt_cycle = dt_stable; - } else if (dt_try > dt_stable + tol) { - dt_cycle = dt_try / 2; - } else { - dt_cycle = dt_try; - final_cycle = true; - } - - t_physics_ += dt_cycle; - dt_sum += dt_cycle; - - if (interpolate_ws) { - if (swap) { // Initial water saturation is in 'start'. - ws_start = ws_subcycle_start; - ws_end = ws_subcycle_end; - mol_dens_start = mol_dens_; - mol_dens_end = mol_dens_; - - double dt_int = dt_sum + dt_shift; - InterpolateCellVector(*ws_prev_, *ws_, dt_int, dt_global, *ws_subcycle_end); - //InterpolateCellVector(*mol_dens_prev_, *mol_dens_, dt_int, dt_global, *mol_dens_subcycle_end); - } else { // Initial water saturation is in 'end'. - ws_start = ws_subcycle_end; - ws_end = ws_subcycle_start; - mol_dens_start = mol_dens_; - mol_dens_end = mol_dens_; + // initialize missed fields + Transport_ATS::InitializeFields_(); - double dt_int = dt_sum + dt_shift; - InterpolateCellVector(*ws_prev_, *ws_, dt_int, dt_global, *ws_subcycle_start); - //InterpolateCellVector(*mol_dens_prev_, *mol_dens_, dt_int, dt_global, *mol_dens_subcycle_start); - } - swap = 1 - swap; - } - - if (spatial_disc_order == 1) { // temporary solution (lipnikov@lanl.gov) - AdvanceDonorUpwind_(dt_cycle); - // } else if (spatial_disc_order == 2 && temporal_disc_order == 1) { - // AdvanceSecondOrderUpwindRK1_(dt_cycle); - // } else if (spatial_disc_order == 2 && temporal_disc_order == 2) { - // AdvanceSecondOrderUpwindRK2_(dt_cycle); - } - - if (!final_cycle) { // rotate concentrations (we need new memory for tcc) - tcc = Teuchos::RCP(new CompositeVector(*tcc_tmp)); - } - - ncycles++; - } - - - dt_ = dt_stable; // restore the original timestep (just in case) - - Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", false); - - Advance_Diffusion(t_old, t_new); - - - // statistics output - nsubcycles = ncycles; - if (vo_->getVerbLevel() >= Teuchos::VERB_MEDIUM) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << ncycles << " sub-cycles, dt_stable=" << units_.OutputTime(dt_stable) - << " [sec] dt_MPC=" << units_.OutputTime(dt_MPC) << " [sec]" << std::endl; + // can also now setup the joint diffusion/dispersion workspace tensor + int D_rank = -1; + int D_dim = mesh_->getSpaceDimension(); + if (has_diffusion_) D_rank = 1; // scalar - //PrintSoluteExtrema(tcc_next, dt_MPC); + if (D_rank >= 0) { + CompositeVectorSpace D_space; + D_space.SetMesh(mesh_)->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + D_ = Teuchos::rcp(new TensorVector(D_space, D_dim, D_rank, false)); } - return failed; -} - - -void -SedimentTransport_PK ::Advance_Diffusion(double t_old, double t_new) -{ - double dt_MPC = t_new - t_old; - // We define tracer as the species #0 as calculate some statistics. - Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", false); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell"); - int num_components_ = tcc_prev.NumVectors(); - - bool flag_diffusion(true); - - if (flag_diffusion) { - Teuchos::ParameterList& op_list = - tp_list_->sublist("operators").sublist("diffusion operator").sublist("matrix"); - - Teuchos::RCP bc_dummy = Teuchos::rcp( - new Operators::BCs(mesh_, AmanziMesh::Entity_kind::FACE, WhetStone::DOF_Type::SCALAR)); - - // default boundary conditions (none inside domain and Neumann on its boundary) - auto& bc_model = bc_dummy->bc_model(); - auto& bc_value = bc_dummy->bc_value(); - PopulateBoundaryData_(bc_model, bc_value, -1); - - Operators::PDE_DiffusionFactory opfactory; - Teuchos::RCP op1 = opfactory.Create(op_list, mesh_, bc_dummy); - op1->SetBCs(bc_dummy, bc_dummy); - Teuchos::RCP op = op1->global_operator(); - Teuchos::RCP op2 = - Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, op)); - - const CompositeVectorSpace& cvs = op->DomainMap(); - CompositeVector sol(cvs), factor(cvs), factor0(cvs), source(cvs), zero(cvs); - zero.PutScalar(0.0); - - // instantiate solver - - S_->GetEvaluator(horiz_mixing_key_, tag_current_).Update(*S_, horiz_mixing_key_); + // compute the stable dt for the initial timestep + dt_stable_ = ComputeStableTimeStep_(); - CalculateDiffusionTensor_(*km_, *ws_, *mol_dens_); - - int phase, num_itrs(0); - bool flag_op1(true); - double md_change, md_old(0.0), md_new, residual(0.0); - - // Disperse and diffuse aqueous components - for (int i = 0; i < num_aqueous_; i++) { - // set initial guess - Epetra_MultiVector& sol_cell = *sol.ViewComponent("cell"); - for (int c = 0; c < ncells_owned; c++) { sol_cell[0][c] = tcc_next[i][c]; } - if (sol.HasComponent("face")) { sol.ViewComponent("face")->PutScalar(0.0); } - - op->Init(); - Teuchos::RCP> Dptr = Teuchos::rcpFromRef(D_); - op1->Setup(Dptr, Teuchos::null, Teuchos::null); - op1->UpdateMatrices(Teuchos::null, Teuchos::null); - - // add accumulation term - Epetra_MultiVector& fac = *factor.ViewComponent("cell"); - for (int c = 0; c < ncells_owned; c++) { fac[0][c] = (*ws_)[0][c] * (*mol_dens_)[0][c]; } - op2->AddAccumulationDelta(sol, factor, factor, dt_MPC, "cell"); - - op1->ApplyBCs(true, true, true); - - CompositeVector& rhs = *op->rhs(); - int ierr = op->ApplyInverse(rhs, sol); - - if (ierr < 0) { - Errors::Message msg("SedimentTransport_PK solver failed with message: \""); - msg << op->returned_code_string() << "\""; - Exceptions::amanzi_throw(msg); - } - - residual += op->residual(); - num_itrs += op->num_itrs(); - - for (int c = 0; c < ncells_owned; c++) { tcc_next[i][c] = sol_cell[0][c]; } - } - - if (vo_->getVerbLevel() >= Teuchos::VERB_MEDIUM) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "sediment transport solver: ||r||=" << residual / num_components_ - << " itrs=" << num_itrs / num_components_ << std::endl; - } - } -} - - -/* ******************************************************************* -* Copy the advected tcc field to the state. -******************************************************************* */ -void -SedimentTransport_PK::CommitStep(double t_old, double t_new, const Teuchos::RCP& S) -{ - Teuchos::RCP tcc; - tcc = S->GetPtrW(tcc_key_, tag_next_, passwd_); - *tcc = *tcc_tmp; - - - /// Not sure that it is necessary DSV - InitializeFieldFromField_( - prev_saturation_key_, tag_current_, saturation_key_, tag_next_, S.ptr(), false, true); - - // Copy to S_ as well - // tcc = S_->GetPtrW(tcc_key_, passwd_); - // *tcc = *tcc_tmp; -} - - -/* ******************************************************************* - * A simple first-order transport method - ****************************************************************** */ -void -SedimentTransport_PK::AdvanceDonorUpwind_(double dt_cycle) -{ - dt_ = dt_cycle; // overwrite the maximum stable transport step - mass_sediment_source_ = 0; - mass_sediment_bc_ = 0; - - // populating next state of concentrations - tcc->ScatterMasterToGhosted("cell"); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell", true); - Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", true); - - // prepare conservative state in master and slave cells - double vol_ws_den, tcc_flux; - double mass_start = 0., tmp1, mass; - - // We advect only aqueous components. - int num_advect_ = num_aqueous_; - - for (int c = 0; c < ncells_owned; c++) { - vol_ws_den = mesh_->getCellVolume(c) * (*ws_start)[0][c] * (*mol_dens_start)[0][c]; - for (int i = 0; i < num_advect_; i++) { - (*conserve_qty_)[i][c] = tcc_prev[i][c] * vol_ws_den; - // if ((vol_ws_den > water_tolerance_) && ((*solid_qty_)[i][c] > 0 )){ // Desolve solid residual into liquid - // double add_mass = std::min((*solid_qty_)[i][c], max_tcc_* vol_ws_den - (*conserve_qty_)[i][c]); - // (*solid_qty_)[i][c] -= add_mass; - // (*conserve_qty_)[i][c] += add_mass; - // } - mass_start += (*conserve_qty_)[i][c]; - } - } - - tmp1 = mass_start; - mesh_->getComm()->SumAll(&tmp1, &mass_start, 1); - - if (vo_->getVerbLevel() >= Teuchos::VERB_HIGH) { - if (domain_name_ == "surface") - *vo_->os() << std::setprecision(10) << "Surface mass start " << mass_start << "\n"; - else - *vo_->os() << std::setprecision(10) << "Subsurface mass start " << mass_start << "\n"; - } - - - // advance all components at once - for (int f = 0; f < nfaces_wghost; f++) { // loop over master and slave faces - int c1 = (*upwind_cell_)[f]; - int c2 = (*downwind_cell_)[f]; - - double u = fabs((*flux_)[0][f]); - - if (c1 >= 0 && c1 < ncells_owned && c2 >= 0 && c2 < ncells_owned) { - for (int i = 0; i < num_advect_; i++) { - tcc_flux = dt_ * u * tcc_prev[i][c1]; - (*conserve_qty_)[i][c1] -= tcc_flux; - (*conserve_qty_)[i][c2] += tcc_flux; - } - - } else if (c1 >= 0 && c1 < ncells_owned && (c2 >= ncells_owned || c2 < 0)) { - for (int i = 0; i < num_advect_; i++) { - tcc_flux = dt_ * u * tcc_prev[i][c1]; - (*conserve_qty_)[i][c1] -= tcc_flux; - if (c2 < 0) mass_sediment_bc_ -= tcc_flux; - } - - } else if (c1 >= ncells_owned && c2 >= 0 && c2 < ncells_owned) { - for (int i = 0; i < num_advect_; i++) { - tcc_flux = dt_ * u * tcc_prev[i][c1]; - (*conserve_qty_)[i][c2] += tcc_flux; - } - } - } - - - // loop over exterior boundary sets - for (int m = 0; m < bcs_.size(); m++) { - std::vector& tcc_index = bcs_[m]->tcc_index(); - int ncomp = tcc_index.size(); - - for (auto it = bcs_[m]->begin(); it != bcs_[m]->end(); ++it) { - int f = it->first; - std::vector& values = it->second; - int c2 = (*downwind_cell_)[f]; - if (c2 >= 0) { - double u = fabs((*flux_)[0][f]); - for (int i = 0; i < ncomp; i++) { - int k = tcc_index[i]; - if (k < num_advect_) { - tcc_flux = dt_ * u * values[i]; - (*conserve_qty_)[k][c2] += tcc_flux; - mass_sediment_bc_ += tcc_flux; - } - } - } - } - } - - - // process external sources - //if (srcs_.size() != 0) { - double time = t_physics_; - ComputeAddSourceTerms_(time, dt_, *conserve_qty_, 0, num_advect_ - 1); - //} - - // recover concentration from new conservative state - for (int c = 0; c < ncells_owned; c++) { - vol_ws_den = mesh_->getCellVolume(c) * (*ws_end)[0][c] * (*mol_dens_end)[0][c]; - for (int i = 0; i < num_advect_; i++) { - if ((*ws_end)[0][c] > water_tolerance_ && (*conserve_qty_)[i][c] > 0) { - tcc_next[i][c] = (*conserve_qty_)[i][c] / vol_ws_den; - - } else { - (*solid_qty_)[i][c] += std::max((*conserve_qty_)[i][c], 0.); - tcc_next[i][c] = 0.; - } - } - } - - double mass_final = 0; - for (int c = 0; c < ncells_owned; c++) { - for (int i = 0; i < num_advect_; i++) { mass_final += (*conserve_qty_)[i][c]; } - } - - tmp1 = mass_final; - mesh_->getComm()->SumAll(&tmp1, &mass_final, 1); - - - // update mass balance - - mass_sediment_exact_ += mass_sediment_source_ * dt_; - if (vo_->getVerbLevel() >= Teuchos::VERB_HIGH) { - tmp1 = mass_sediment_bc_; - mesh_->getComm()->SumAll(&tmp1, &mass_sediment_bc_, 1); - // *vo_->os() << "*****************\n"; - // if (domain_name_ == "surface") *vo_->os()<<"Surface mass BC "<os() <<"Subsurface mass BC "<getComm()->SumAll(&tmp1, &mass_sediment_source_, 1); - // if (domain_name_ == "surface") *vo_->os()<<"Surface mass_sediment source "<os() << "Subsurface mass_sediment source "<os() << "*****************\n"; + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { + *vo_->os() << "cfl=" << cfl_ << " spatial/temporal discretization: " << adv_spatial_disc_order_ + << " " << temporal_disc_order_ << std::endl + << std::endl; } - - - // if (internal_tests) { - // CheckGEDProperty(*tcc_tmp->ViewComponent("cell")); - // } - - // if (vo_->getVerbLevel() >= Teuchos::VERB_HIGH){ - // if (domain_name_ == "surface") *vo_->os()<<"Surface mass final "<os()<<"Subsurface mass final "<getVerbLevel() >= Teuchos::VERB_HIGH) - // *vo_->os()<<"mass error "< 1e-6) exit(-1); } -// /* ******************************************************************* -// * We have to advance each component independently due to different -// * reconstructions. We use tcc when only owned data are needed and -// * tcc_next when owned and ghost data. This is a special routine for -// * transient flow and uses first-order time integrator. -// ****************************************************************** */ -// void SedimentTransport_PK::AdvanceSecondOrderUpwindRK1_(double dt_cycle) -// { -// dt_ = dt_cycle; // overwrite the maximum stable transport step -// mass_sediment_source_.assign(num_aqueous_ + num_gaseous_, 0.0); - -// // work memory -// const Epetra_Map& cmap_wghost = mesh_->getMap(AmanziMesh::Entity_kind::CELL,true); -// Epetra_Vector f_component(cmap_wghost); - -// // distribute vector of concentrations -// S_->Get(tcc_key_).ScatterMasterToGhosted("cell"); -// Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell", true); -// Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", true); - - -// Epetra_Vector ws_ratio(Copy, *ws_start, 0); -// for (int c = 0; c < ncells_owned; c++){ -// double vol_phi_ws_den_end = mesh_->getCellVolume(c) * (*phi_)[0][c] * (*ws_end)[0][c] * (*mol_dens_end)[0][c]; -// if (vol_phi_ws_den_end > water_tolerance_) { -// double vol_phi_ws_den_start = mesh_->getCellVolume(c) * (*phi_)[0][c] * (*ws_start)[0][c] * (*mol_dens_start)[0][c]; -// if (vol_phi_ws_den_start > water_tolerance_){ -// ws_ratio[c] = ( (*ws_start)[0][c] * (*mol_dens_start)[0][c] ) -// / ( (*ws_end)[0][c] * (*mol_dens_end)[0][c] ); -// }else{ -// ws_ratio[c] = 1; -// } -// } -// else ws_ratio[c]=0.; -// } - - -// // We advect only aqueous components. -// int num_advect_ = num_aqueous_; - -// for (int i = 0; i < num_advect_; i++) { -// current_component_ = i; // needed by BJ - -// double T = t_physics_; -// Epetra_Vector*& component = tcc_prev(i); -// FunctionalTimeDerivative(T, *component, f_component); - -// for (int c = 0; c < ncells_owned; c++) { -// tcc_next[i][c] = (tcc_prev[i][c] + dt_ * f_component[c]) * ws_ratio[c]; - -// if (tcc_next[i][c] < 0){ -// double vol_phi_ws_den = mesh_->getCellVolume(c) * (*phi_)[0][c] * (*ws_end)[0][c] * (*mol_dens_end)[0][c]; -// (*solid_qty_)[i][c] += abs(tcc_next[i][c])*vol_phi_ws_den; -// tcc_next[i][c] = 0.; -// } -// } -// } - -// // update mass balance -// for (int i = 0; i < num_aqueous_ + num_gaseous_; i++) { -// mass_sediment_exact_[i] += mass_sediment_source_[i] * dt_; -// } - -// if (internal_tests) { -// CheckGEDProperty(*tcc_tmp->ViewComponent("cell")); -// } -// } - - -// /* ******************************************************************* -// * We have to advance each component independently due to different -// * reconstructions. This is a special routine for transient flow and -// * uses second-order predictor-corrector time integrator. -// ****************************************************************** */ -// void SedimentTransport_PK::AdvanceSecondOrderUpwindRK2_(double dt_cycle) -// { -// dt_ = dt_cycle; // overwrite the maximum stable transport step -// mass_sediment_source_.assign(num_aqueous_ + num_gaseous_, 0.0); - -// // work memory -// const Epetra_Map& cmap_wghost = mesh_->getMap(AmanziMesh::Entity_kind::CELL,true); -// Epetra_Vector f_component(cmap_wghost);//, f_component2(cmap_wghost); - -// // distribute old vector of concentrations -// S_->Get(tcc_key_).ScatterMasterToGhosted("cell"); -// Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell", true); -// Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", true); - -// Epetra_Vector ws_ratio(Copy, *ws_start, 0); -// for (int c = 0; c < ncells_owned; c++){ -// if ((*ws_end)[0][c] > 1e-10) { -// if ((*ws_start)[0][c] > 1e-10){ -// ws_ratio[c] = ( (*ws_start)[0][c] * (*mol_dens_start)[0][c] ) -// / ( (*ws_end)[0][c] * (*mol_dens_end)[0][c] ); -// }else{ -// ws_ratio[c] = 1; -// } -// } -// else ws_ratio[c]=0.; -// } - -// // We advect only aqueous components. -// int num_advect_ = num_aqueous_; - -// // predictor step -// for (int i = 0; i < num_advect_; i++) { -// current_component_ = i; // needed by BJ - -// double T = t_physics_; -// Epetra_Vector*& component = tcc_prev(i); -// FunctionalTimeDerivative(T, *component, f_component); - -// for (int c = 0; c < ncells_owned; c++) { -// tcc_next[i][c] = (tcc_prev[i][c] + dt_ * f_component[c]) * ws_ratio[c]; -// //if (tcc_next[i][c] < 0) tcc_next[i][c] = 0.; - -// } -// } - -// tcc_tmp->ScatterMasterToGhosted("cell"); - -// //if (domain_name_ == "surface") { -// //*vo_->os()<<"after predictor ToTaL "<getCellVolume(c) * (*phi_)[0][c] * (*ws_end)[0][c] * (*mol_dens_end)[0][c]; -// (*solid_qty_)[i][c] += abs(tcc_next[i][c])*vol_phi_ws_den; -// tcc_next[i][c] = 0.; -// } - -// } -// } - -// // f_component2.Update(-1, f_component, 1.); -// // double diff_norm; -// // f_component2.NormInf(&diff_norm); -// // *vo_->os()<os()<<"after corrector ToTaL "<ViewComponent("cell")); -// } - -// } - - -// /* ******************************************************************* -// * Advance each component independently due to different field -// * reconstructions. This routine uses generic explicit time integrator. -// ******************************************************************* */ -// // void SedimentTransport_PK::AdvanceSecondOrderUpwindRKn_(double dt_cycle) -// // { -// // dt_ = dt_cycle; // overwrite the maximum stable transport step - -// // S_->Get("total_component_concentration").ScatterMasterToGhosted("cell"); -// // Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell", true); -// // Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", true); - -// // // define time integration method -// // auto ti_method = Explicit_TI::forward_euler; -// // if (temporal_disc_order == 2) { -// // ti_method = Explicit_TI::heun_euler; -// // } else if (temporal_disc_order == 3) { -// // ti_method = Explicit_TI::kutta_3rd_order; -// // } else if (temporal_disc_order == 3) { -// // ti_method = Explicit_TI::runge_kutta_4th_order; -// // } - -// // // We interpolate ws using dt which becomes local time. -// // double T = 0.0; -// // // We advect only aqueous components. -// // int ncomponents = num_aqueous_; - -// // for (int i = 0; i < ncomponents; i++) { -// // current_component_ = i; // it is needed in BJ called inside RK:fun - -// // Epetra_Vector*& component_prev = tcc_prev(i); -// // Epetra_Vector*& component_next = tcc_next(i); - -// // Explicit_TI::RK TVD_RK(*this, ti_method, *component_prev); -// // TVD_RK.TimeStep(T, dt_, *component_prev, *component_next); -// // } -// // } - - -/* ****************************************************************** -* Computes source and sink terms and adds them to vector tcc. -* Returns mass rate for the tracer. -* The routine treats two cases of tcc with one and all components. -****************************************************************** */ void -SedimentTransport_PK::ComputeAddSourceTerms_(double tp, - double dtp, - Epetra_MultiVector& tcc, - int n0, - int n1) +SedimentTransport_PK::AddSourceTerms_(double t0, double t1, Epetra_MultiVector& conserve_qty) { - int num_vectors = tcc.NumVectors(); - int nsrcs = srcs_.size(); + int ncells_owned = + mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); - double mass1 = 0., mass2 = 0., add_mass = 0., tmp1; - bool chg; + sediment_density_ = S_->Get("sediment_density", tag_next_); - chg = S_->GetEvaluator(sd_trapping_key_, tag_next_).Update(*S_, sd_trapping_key_); + bool change1 = S_->GetEvaluator(sd_trapping_key_, tag_next_).Update(*S_, sd_trapping_key_); const Epetra_MultiVector& Q_dt = *S_->GetPtr(sd_trapping_key_, tag_next_)->ViewComponent("cell", false); - chg = S_->GetEvaluator(sd_settling_key_, tag_next_).Update(*S_, sd_settling_key_); + bool change2 = S_->GetEvaluator(sd_settling_key_, tag_next_).Update(*S_, sd_settling_key_); const Epetra_MultiVector& Q_ds = *S_->GetPtr(sd_settling_key_, tag_next_)->ViewComponent("cell", false); - chg = S_->GetEvaluator(sd_erosion_key_, tag_next_).Update(*S_, sd_erosion_key_); + bool change3 = S_->GetEvaluator(sd_erosion_key_, tag_next_).Update(*S_, sd_erosion_key_); const Epetra_MultiVector& Q_e = *S_->GetPtr(sd_erosion_key_, tag_next_)->ViewComponent("cell", false); - chg = S_->GetEvaluator(sd_organic_key_, tag_next_).Update(*S_, sd_organic_key_); - const Epetra_MultiVector& Q_db = - *S_->GetPtr(sd_organic_key_, tag_next_)->ViewComponent("cell", false); - - Epetra_MultiVector& dz = *S_->GetW(elevation_increase_key_, tag_next_, "state") - .ViewComponent("cell", false); - - const Epetra_MultiVector& poro = - *S_->Get(porosity_key_, tag_next_).ViewComponent("cell", false); - - for (int c = 0; c < ncells_owned; c++) { - double value = mesh_->getCellVolume(c) * (Q_e[0][c] - Q_dt[0][c] - Q_ds[0][c]); - tcc[0][c] += value * dtp; - mass_sediment_source_ += value; - dz[0][c] += ((1. / sediment_density_) * ((Q_dt[0][c] + Q_ds[0][c]) - Q_e[0][c]) + +Q_db[0][c]) * - dtp / (1 - poro[0][c]); + double value = mesh_->getCellVolume(c) * (Q_e[0][c] - Q_dt[0][c] - Q_ds[0][c]); /// m^3/s + conserve_qty[0][c] += sediment_density_ * value * (t1 - t0) / molar_masses_["sediment"]; } - for (int m = 0; m < nsrcs; m++) { - double t0 = tp - dtp; - srcs_[m]->Compute(t0, tp); + if (!elevation_increase_key_.empty()) { + { + bool change4 = S_->GetEvaluator(sd_organic_key_, tag_next_).Update(*S_, sd_organic_key_); + const Epetra_MultiVector& Q_db = + *S_->GetPtr(sd_organic_key_, tag_next_)->ViewComponent("cell", false); - std::vector tcc_index = srcs_[m]->tcc_index(); - for (auto it = srcs_[m]->begin(); it != srcs_[m]->end(); ++it) { - int c = it->first; - std::vector& values = it->second; + // Poro and DZ are hard-coded as the NEXT tag -- this should be the outer step's NEXT tag. + const Epetra_MultiVector& poro = + *S_->Get(porosity_key_, tag_next_).ViewComponent("cell", false); - if (c >= ncells_owned) continue; + // NOTE: we do note zero this out here, because it gets accumulated across the outer step size + Epetra_MultiVector& dz = *S_->GetW(elevation_increase_key_, tag_next_, name_) + .ViewComponent("cell", false); + // dz.PutScalar(0.); - for (int k = 0; k < tcc_index.size(); ++k) { - int i = tcc_index[k]; - if (i < n0 || i > n1) continue; - - int imap = i; - if (num_vectors == 1) imap = 0; - - double value; - if (srcs_[m]->getType() == DomainFunction_kind::COUPLING) { - value = values[k]; - } else { - value = mesh_->getCellVolume(c) * values[k]; - } - - //add_mass += dtp * value; - tcc[imap][c] += dtp * value; - mass_sediment_source_ += value; + for (int c = 0; c < ncells_owned; c++) { + dz[0][c] += + ((1. / sediment_density_) * ((Q_dt[0][c] + Q_ds[0][c]) - Q_e[0][c]) + Q_db[0][c]) * + (t1 - t0) / (1 - poro[0][c]); } } - } -} - -void -SedimentTransport_PK::Sinks2TotalOutFlux(Epetra_MultiVector& tcc, - std::vector& total_outflux, - int n0, - int n1) -{ - std::vector sink_add(ncells_wghost, 0.0); - //Assumption that there is only one sink per component per cell - double t0 = S_->get_time(tag_current_); - int num_vectors = tcc.NumVectors(); - int nsrcs = srcs_.size(); - - for (int m = 0; m < nsrcs; m++) { - srcs_[m]->Compute(t0, t0); - std::vector index = srcs_[m]->tcc_index(); - - for (auto it = srcs_[m]->begin(); it != srcs_[m]->end(); ++it) { - int c = it->first; - std::vector& values = it->second; - - double val = 0; - for (int k = 0; k < index.size(); ++k) { - int i = index[k]; - if (i < n0 || i > n1) continue; - - int imap = i; - if (num_vectors == 1) imap = 0; - - if ((values[k] < 0) && (tcc[imap][c] > 0)) { - if (srcs_[m]->getType() == DomainFunction_kind::COUPLING) { - // if (values[k]<0) { - val = std::max(val, fabs(values[k]) / tcc[imap][c]); - //} - } - } - } - sink_add[c] = std::max(sink_add[c], val); - } - } - - for (int c = 0; c < ncells_wghost; c++) total_outflux[c] += sink_add[c]; -} - - -/* ******************************************************************* -* Populates operators' boundary data for given component. -* Returns true if at least one face was populated. -******************************************************************* */ -bool -SedimentTransport_PK::PopulateBoundaryData_(std::vector& bc_model, - std::vector& bc_value, - int component) -{ - bool flag = false; - - for (int i = 0; i < bc_model.size(); i++) { - bc_model[i] = Operators::OPERATOR_BC_NONE; - bc_value[i] = 0.0; - } - - for (int f = 0; f < nfaces_wghost; f++) { - auto cells = mesh_->getFaceCells(f); - if (cells.size() == 1) bc_model[f] = Operators::OPERATOR_BC_NEUMANN; - } - - for (int m = 0; m < bcs_.size(); m++) { - std::vector& tcc_index = bcs_[m]->tcc_index(); - int ncomp = tcc_index.size(); - - for (auto it = bcs_[m]->begin(); it != bcs_[m]->end(); ++it) { - int f = it->first; - std::vector& values = it->second; - - for (int i = 0; i < ncomp; i++) { - int k = tcc_index[i]; - if (k == component) { - bc_model[f] = Operators::OPERATOR_BC_DIRICHLET; - bc_value[f] = values[i]; - flag = true; - } - } - } - } - - return flag; -} - - -/* ******************************************************************* -* Identify flux direction based on orientation of the face normal -* and sign of the Darcy velocity. -******************************************************************* */ -void -SedimentTransport_PK::IdentifyUpwindCells_() -{ - for (int f = 0; f < nfaces_wghost; f++) { - (*upwind_cell_)[f] = -1; // negative value indicates boundary - (*downwind_cell_)[f] = -1; - } - - for (int c = 0; c < ncells_wghost; c++) { - const auto& [faces, dirs] = mesh_->getCellFacesAndDirections(c); - - for (int i = 0; i < faces.size(); i++) { - int f = faces[i]; - double tmp = (*flux_)[0][f] * dirs[i]; - if (tmp > 0.0) { - (*upwind_cell_)[f] = c; - } else if (tmp < 0.0) { - (*downwind_cell_)[f] = c; - } else if (dirs[i] > 0) { - (*upwind_cell_)[f] = c; - } else { - (*downwind_cell_)[f] = c; - } - } - } -} - -// void SedimentTransport_PK::ComputeVolumeDarcyFlux(Teuchos::RCP flux, -// Teuchos::RCP molar_density, -// Teuchos::RCP& vol_darcy_flux){ - -// int nfaces_wghost = mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::ALL); - -// for (int f = 0; f < nfaces_wghost ; f++){ -// auto cells = mesh_->getFaceCells(f); -// double n_liq=0.; -// for (int c=0; c 0) (*vol_darcy_flux)[0][f] = (*flux_)[0][f]/n_liq; -// else (*vol_darcy_flux)[0][f] = 0.; -// } - -// } -// - - -/* ******************************************************************* -* Interpolate linearly in time between two values v0 and v1. The time -* is measuared relative to value v0; so that v1 is at time dt. The -* interpolated data are at time dt_int. -******************************************************************* */ -void -SedimentTransport_PK::InterpolateCellVector(const Epetra_MultiVector& v0, - const Epetra_MultiVector& v1, - double dt_int, - double dt, - Epetra_MultiVector& v_int) -{ - double a = dt_int / dt; - double b = 1.0 - a; - v_int.Update(b, v0, a, v1, 0.); -} - - -/* ******************************************************************* -* Calculate dispersive tensor from given Darcy fluxes. The flux is -* assumed to be scaled by face area. -******************************************************************* */ -void -SedimentTransport_PK::CalculateDiffusionTensor_(const Epetra_MultiVector& km, - const Epetra_MultiVector& ws, - const Epetra_MultiVector& mol_density) -{ - D_.resize(ncells_owned); - for (int c = 0; c < ncells_owned; c++) D_[c].Init(dim, 1); - - //AmanziGeometry::Point velocity(dim); - AmanziMesh::Entity_ID_List faces; - WhetStone::MFD3D_Diffusion mfd3d(mesh_); - for (int c = 0; c < ncells_owned; ++c) { - double mol_den = mol_density[0][c]; - double ponded_depth = ws[0][c]; - D_[c].PutScalar(km[0][c] * mol_den * ponded_depth); + // do NOT mark this as changed here, as that would also recompute the mesh + // despite no deformation in the inner step + // changedEvaluatorPrimary(elevation_increase_key_, tag_next_, *S_); + db_->WriteVector("dz", S_->GetPtr(elevation_increase_key_, tag_next_).ptr()); } } diff --git a/src/pks/transport/sediment_transport_pk.hh b/src/pks/transport/sediment_transport_pk.hh index a1cb8661a..856b35a6e 100644 --- a/src/pks/transport/sediment_transport_pk.hh +++ b/src/pks/transport/sediment_transport_pk.hh @@ -7,272 +7,133 @@ Authors: Daniil Svyatsky (dasvyat@lanl.gov) */ -/* - Transport PK +/*! -*/ +This PK solves sediment transport in surface flows. The assumpotion is that +there is only one sediment component which is called 'sediment'. The +advection-diffusion equation for this component -#ifndef AMANZI_ATS_SEDIMENTTRANSPORT_PK_HH_ -#define AMANZI_ATS_SEDIMENTTRANSPORT_PK_HH_ +.. math:: -// TPLs -#include "Epetra_Vector.h" -#include "Epetra_IntVector.h" -#include "Epetra_Import.h" -#include "Teuchos_RCP.hpp" + \frac{\partial (\Theta \chi_i)}{\partial t} = - \boldsymbol{\nabla} \cdot (\boldsymbol{q} \chi_i) + + \boldsymbol{\nabla} \cdot ( \tau \, \boldsymbol{\nabla} \chi_i) + Q_e - Q_t - Q_s, -// Amanzi -#include "CompositeVector.hh" -#include "Explicit_TI_FnBase.hh" -//#include "MaterialProperties.hh" -#include "PK.hh" -#include "PK_Factory.hh" -#include "ReconstructionCellLinear.hh" -#include "State.hh" -#include "Tensor.hh" -#include "Units.hh" -#include "VerboseObject.hh" -#include "PK_PhysicalExplicit.hh" -#include "DenseVector.hh" -#include +As well as in transport ATS PK the primary variable is the **mole fraction** of a sediment with units of +[mol i mol liquid^-1] -// Transport -#include "TransportDomainFunction.hh" -#include "SedimentTransportDefs.hh" +`"PK type`" = `"sediment transport`" +.. _pk-sediment-transport-spec: +.. admonition:: pk-sediment-transport-spec -/* ****************************************************************** -The transport PK receives a reduced (optional) copy of a physical -state at time n and returns a different state at time n+1. + * `"sediment diffusion coefficient [m^2 s^-1]`" ``[molecular-diffusivity-spec]`` See + below. -Unmodified physical quantaties in the returned state are the smart -pointers to the original variables. -****************************************************************** */ + Math and solver algorithm options: -namespace Amanzi { -namespace Transport { + * `"diffusion`" ``[pde-diffusion-typedinline-spec]`` Diffusion drives the + distribution. Typically we use finite volume here, but mimetic schemes + may be used. See :ref:`Diffusion` -class SedimentTransport_PK : public PK_PhysicalExplicit { - public: - SedimentTransport_PK(Teuchos::ParameterList& pk_tree, - const Teuchos::RCP& glist, - const Teuchos::RCP& S, - const Teuchos::RCP& soln); - SedimentTransport_PK(const Teuchos::RCP& glist, - Teuchos::RCP S, - const std::string& pk_list_name, - std::vector& component_names); + * `"diffusion preconditioner`" ``[pde-diffusion-typedinline-spec]`` Inverse + of the above. Likely only Jacobian term options are needed here, as the + others default to the same as the `"diffusion`" list. See + :ref:`Diffusion`. - ~SedimentTransport_PK() = default; + * `"inverse`" ``[inverse-typed-spec]`` :ref:`Inverse` method for the + diffusion-dispersion solve. See :ref:`Inverse`. - // members required by PK interface - virtual void Setup(const Teuchos::Ptr& S); - virtual void Initialize(const Teuchos::Ptr& S); + * `"cfl`" ``[double]`` **1.0** Courant-Friedrichs-Lewy condition, a limiter + on the timestep size relative to spatial size. Must be <= 1. - virtual double get_dt(); - virtual void set_dt(double dt){}; + * `"advection spatial discretization order`" ``[int]`` **1** Defines + accuracy of the spatial discretization in the advection term. It permits + values 1 or 2. Default value is 1 (donor upwind) but 2 (a limiter scheme) + is much less numerically diffusive, and recommended for most cases. - virtual bool AdvanceStep(double t_old, double t_new, bool reinit = false); - virtual void CommitStep(double t_old, double t_new, const Teuchos::RCP& S); - virtual void CalculateDiagnostics(const Teuchos::RCP& S){}; + * `"temporal discretization order`" ``[int]`` **1** Defines accuracy of + temporal discretization. It permits values 1 (forward Euler) and 2 (a + Runga-Kutta scheme). - virtual std::string name() { return "sediment transport"; } - Key get_domain_name() { return domain_name_; } + * `"reconstruction`" ``[reconstruction-spec]`` collects reconstruction + parameters for use in reconstructing the velocity field for 2nd order + advection schemes. See :ref:`Reconstructions`. - // main transport members - // -- calculation of a stable timestep needs saturations and darcy flux - double StableTimeStep_(); - void - Sinks2TotalOutFlux(Epetra_MultiVector& tcc, std::vector& total_outflux, int n0, int n1); + KEYS - // -- access members - inline double cfl() { return cfl_; } - Teuchos::RCP state() { return S_; } - Teuchos::RCP total_component_concentration() { return tcc_tmp; } + - `"primary variable`" **"mole_fraction"** [mol C mol H2O^-1] + - `"liquid water content`" **"water_content"** This variable is a multiplier + in in the accumulation term. This is often just `"water_content`", but + not in frozen cases, where it must be defined by the user (typically as + :math:`\phi s n_l |V|` in the subsurface, or :math:`h n_l |V|` on the + surface. + - `"molar density liquid`" [mol H2O m^-3] + - `"water flux`" The face-based water flux in [mol H2O s^-1]. + - `"water source`" Defines the water injection rate [mol H2O m^-2 s^-1] in + surface and [mol H2O m^-3 s^-1] in subsurface) which applies to + concentrations specified by the `"geochemical conditions`". Note that if + this PK is coupled to a surface flow PK, the unit of the water source + there *must* be in [mol m^-2 s^-1], *not* in [m s^-1] as is an option for + that PK (e.g. `"water source in meters`" must be set to `"false`" in the + overland flow PK). - // void Policy(Teuchos::Ptr S); + The sources for sediments transport are defined via "erosion rate", + :math:`Q_e`, "traping rate", :math:`Q_t`, "settling rate", :math:`Q_s` + evaluators. These evaluators are defined in unit of [m/s]. Moreover + sediment density has to be defined as a scalar value. - // void CheckGEDProperty(Epetra_MultiVector& tracer) const; - // void VV_CheckTracerBounds(Epetra_MultiVector& tracer, int component, - // double lower_bound, double upper_bound, double tol = 0.0) const; - void VV_CheckInfluxBC() const; - void PrintSoluteExtrema(const Epetra_MultiVector& tcc_next, double dT_MPC); - double VV_SoluteVolumeChangePerSecond(int idx_solute); - double ComputeSolute(const Epetra_MultiVector& tcc, int idx); - double ComputeSolute(const Epetra_MultiVector& tcc, - const Epetra_MultiVector& ws, - const Epetra_MultiVector& den, - int idx); +*/ - // -- sources and sinks for components from n0 to n1 including - void ComputeAddSourceTerms_(double tp, double dtp, Epetra_MultiVector& tcc, int n0, int n1); +#ifndef AMANZI_ATS_SEDIMENTTRANSPORT_PK_HH_ +#define AMANZI_ATS_SEDIMENTTRANSPORT_PK_HH_ - bool - PopulateBoundaryData_(std::vector& bc_model, std::vector& bc_value, int component); +#include - // -- limiters - void LimiterBarthJespersen(const int component, - Teuchos::RCP scalar_field, - Teuchos::RCP& gradient, - Teuchos::RCP& limiter); +// Amanzi +#include "PK_Factory.hh" +#include "State.hh" - // const std::vector component_names(){return component_names_;}; - // int num_aqueous_component() {return num_aqueous;}; +// Transport +#include "transport_ats.hh" +/* ****************************************************************** +The transport PK receives a reduced (optional) copy of a physical +state at time n and returns a different state at time n+1. - private: - void InitializeFields_(const Teuchos::Ptr& S); - - // advection members - void AdvanceDonorUpwind_(double dT); - // void AdvanceSecondOrderUpwindRKn_(double dT); - // void AdvanceSecondOrderUpwindRK1_(double dT); - // void AdvanceSecondOrderUpwindRK2_(double dT); - void Advance_Diffusion(double t_old, double t_new); - - // time integration members - void FunctionalTimeDerivative(const double t, - const Epetra_Vector& component, - Epetra_Vector& f_component){}; - // void Functional(const double t, const Epetra_Vector& component, TreeVector& f_component); - - void IdentifyUpwindCells_(); - - void InterpolateCellVector(const Epetra_MultiVector& v0, - const Epetra_MultiVector& v1, - double dT_int, - double dT, - Epetra_MultiVector& v_int); - - const Teuchos::RCP& upwind_cell() { return upwind_cell_; } - const Teuchos::RCP& downwind_cell() { return downwind_cell_; } - - // physical models - // -- dispersion and diffusion - void CalculateDiffusionTensor_(const Epetra_MultiVector& km, - const Epetra_MultiVector& saturation, - const Epetra_MultiVector& mol_density); - - int FindDiffusionValue_(const std::string& tcc_name, double* md, int* phase); - - void CalculateAxiSymmetryDirection(); - - // initialization methods - void InitializeAll_(); - void InitializeFieldFromField_(const std::string& field0, - const Tag& tag0, - const std::string& field1, - const Tag& tag1, - const Teuchos::Ptr& S, - bool call_evaluator, - bool overwrite); +Unmodified physical quantaties in the returned state are the smart +pointers to the original variables. +****************************************************************** */ - public: - Teuchos::RCP tp_list_; +namespace Amanzi { +namespace Transport { - int MyPID; // parallel information: will be moved to private - int spatial_disc_order, temporal_disc_order, limiter_model; - int nsubcycles; // output information - int internal_tests; - double tests_tolerance; +class SedimentTransport_PK : public Transport_ATS { + public: + SedimentTransport_PK(Teuchos::ParameterList& pk_tree, + const Teuchos::RCP& glist, + const Teuchos::RCP& S, + const Teuchos::RCP& soln); + void parseParameterList() override; + void Initialize() override; protected: - Teuchos::RCP soln_; - - Key domain_name_; - Key saturation_key_; - Key prev_saturation_key_; - Key flux_key_; - Key tcc_key_; - Key molar_density_key_; - Key solid_residue_mass_key_; - Key sd_trapping_key_, sd_settling_key_, sd_erosion_key_, horiz_mixing_key_, porosity_key_, - sd_organic_key_; - Key elevation_increase_key_; - - - private: - Teuchos::RCP mesh_; - Teuchos::RCP S_; - std::string passwd_; - - bool subcycling_; - int dim; - int saturation_name_; - bool vol_flux_conversion_; - - Teuchos::RCP tcc_tmp; // next tcc - Teuchos::RCP tcc; // smart mirrow of tcc - Teuchos::RCP conserve_qty_, solid_qty_; - Teuchos::RCP flux_; - Teuchos::RCP ws_, ws_prev_, mol_dens_; //, mol_dens_prev_; - Teuchos::RCP km_; + void SetupPhysicalEvaluators_() override; + void AddSourceTerms_(double t0, double t1, Epetra_MultiVector& conserve_qty) override; + ; - Teuchos::RCP upwind_cell_; - Teuchos::RCP downwind_cell_; - Teuchos::RCP ws_start, ws_end; // data for subcycling - Teuchos::RCP mol_dens_start, mol_dens_end; // data for subcycling - Teuchos::RCP ws_subcycle_start, ws_subcycle_end; - Teuchos::RCP mol_dens_subcycle_start, mol_dens_subcycle_end; - - int current_component_; // data for lifting - Teuchos::RCP lifting_; - - std::vector> srcs_; // Source or sink for components - std::vector> bcs_; // influx BC for components - double bc_scaling; - - Teuchos::RCP cell_importer; // parallel communicators - Teuchos::RCP face_importer; - - // mechanical dispersion and molecual diffusion - // Teuchos::RCP mdm_; - - std::vector D_; - std::string diffusion_preconditioner, diffusion_solver; - - // bool flag_dispersion_; - // std::vector axi_symmetry_; // axi-symmetry direction of permeability tensor - - - // std::vector > mat_properties_; // vector of materials - // std::vector > diffusion_phase_; // vector of phases - - - double cfl_, dt_, dt_debug_, t_physics_; - - double mass_sediment_exact_, mass_sediment_source_; // mass for all sediment - double mass_sediment_bc_, mass_sediment_stepstart_; - std::vector runtime_sediment_; // names of trached sediment - std::vector runtime_regions_; - - int ncells_owned, ncells_wghost; - int nfaces_owned, nfaces_wghost; - int nnodes_wghost; + Key sd_trapping_key_, sd_settling_key_, sd_erosion_key_, horiz_mixing_key_, sd_organic_key_; + Key elevation_increase_key_; + Key porosity_key_; + Key plant_area_key_, stem_diameter_key_, stem_height_key_, stem_density_key_; - std::vector mol_masses_; + private: double sediment_density_; - int num_aqueous; - - std::vector component_names_; // details of components - double water_tolerance_, max_tcc_; - - // io - Utils::Units units_; - Teuchos::RCP vo_; - Tag tag_subcycle_; - Tag tag_subcycle_current_; - Tag tag_subcycle_next_; - - // Forbidden. - SedimentTransport_PK(const SedimentTransport_PK&); - SedimentTransport_PK& operator=(const SedimentTransport_PK&); private: // factory registration diff --git a/src/pks/transport/transport_ats.hh b/src/pks/transport/transport_ats.hh index 458da22b6..f42c2380f 100644 --- a/src/pks/transport/transport_ats.hh +++ b/src/pks/transport/transport_ats.hh @@ -5,229 +5,143 @@ provided in the top-level COPYRIGHT file. Authors: Konstantin Lipnikov (lipnikov@lanl.gov) + Daniil Svyatsky (dasvyat@lanl.gov) + Ethan Coon (coonet@ornl.gov) */ +/*! -/* - Transport PK +This PK solves for transport of chemical species in water. It may optionally +be paired with a PK for reactions, typically in an operator-split form, to +solve reactive transport. -*/ +The advection-dispersion equation for component *i* may be written as: +.. math:: + \frac{\partial (\Theta \chi_i)}{\partial t} = - \boldsymbol{\nabla} \cdot (\boldsymbol{q} \chi_i) + + \boldsymbol{\nabla} \cdot (\Theta \, (\boldsymbol{D^*}_l + \tau \boldsymbol{D}_i) \boldsymbol{\nabla} \chi_i) + Q_s, -/*! +The primary variable for this PK is :math:`\chi_i`, the **mole fraction** of a +specie :math:`i` in the aqueous phase, with units of [mol i mol liquid^-1]. -The advection-diffusion equation for component *i* in partially saturated porous media may be written as +This seems a bit odd to most people who are used to reactive transport codes +where the primary variable is total component concentration :math:`C`, in units +of [mol i L^-1]. The reason for this differences is to better enable +variable-density problems. Note that the two are related: .. math:: - \frac{\partial (\phi s_l C_i)}{\partial t} - = - - \boldsymbol{\nabla} \cdot (\boldsymbol{q} C_i) - + \boldsymbol{\nabla} \cdot (\phi s_l\, (\boldsymbol{D^*}_l + \tau \boldsymbol{D}_i) \boldsymbol{\nabla} C_i) + Q_s, + C_i = n_l \chi_i -The advection-diffusion equation for component *i* in the surface may be written as +for molar density of liquid :math:`n_l`. -.. math:: - \frac{\partial (C_i)}{\partial t} - = - - \boldsymbol{\nabla} \cdot (\boldsymbol{q_s} C_i) - + \boldsymbol{\nabla} \cdot ( (\boldsymbol{D^*}_l + \tau \boldsymbol{D}_i) \boldsymbol{\nabla} C_i) + Q_s, +For reactive transport problems, both concentration and mole fraction are +output in the visualization file. For transport-only problems, concentration +may be output by adding a total component concentration evaluator that +multiplies the two quantities using an `"evaluator type`" = `"multiplicative +evaluator`". -.. _transport-spec: -.. admonition:: transport-spec +`"PK type`" = `"transport ATS`" - * `"PK type`" ``[string]`` **"transport ats"** +.. _pk-transport-ats-spec: +.. admonition:: pk-transport-ats-spec - * `"domain name`" ``[string]`` **domain** specifies mesh name that defines + * `"domain name`" ``[string]`` **"domain"** specifies mesh name that defines the domain of this PK. - * `"component names`" ``[Array(string)]`` No default. Provides the names of the - components that will be transported. Must be in the order: aqueous, gaseous, solid. + * `"component names`" ``[Array(string)]`` **optional** No default. Provides + the names of the components that will be transported. Note that these + must be provided by the user if transport is used alone, or are provided + by the geochemical engine if reactions are to be used. * `"number of aqueous components`" ``[int]`` **-1** The total number of aqueous components. Default value is the length of `"component names`" - * `"number of gaseous components`" ``[int]`` **0** The total number of - gaseous components. - * `"boundary conditions`" ``[transport-bc-spec]`` Boundary conditions for transport are dependent on the boundary conditions for flow. See - `Flow-specific Boundary Conditions`_ and `Transport-specific Boundary Conditions`_ - - * `"component molar masses`" ``[Array(double)]`` No default. Molar mass of - each component. + :ref:`Transport-specific Boundary Conditions` - * `"molecular diffusion`" ``[molecular-diffusion-spec]`` defines names of - solutes in aqueous and gaseous phases and related diffusivity values. + * `"molecular diffusivity [m^2 s^-1]`" ``[molecular-diffusivity-spec]`` See + below. - * "material properties" ``[material-properties-spec-list]`` Defines material - properties see below). - - Source terms: + * `"tortuosity [-]`" ``[tortuosity-spec]`` See below. * `"source terms`" ``[transport-source-spec-list]`` Provides solute source. - Physical model and assumptions: - - * `"physical models and assumptions`" [material-properties-spec] Defines material properties. - - * `"effective transport porosity`" ``[bool]`` **false** If *true*, effective transport porosity - will be used by dispersive-diffusive fluxes instead of total porosity. - Math and solver algorithm options: - * `"diffusion`" ``[pde-diffusion-spec]`` Diffusion drives the distribution. - Typically we use finite volume here. See PDE_Diffusion_ - - * `"diffusion preconditioner`" ``[pde-diffusion-spec]`` Inverse of the - above. Likely only Jacobian term options are needed here, as the others - default to the same as the `"diffusion`" list. See PDE_Diffusion_. - - * `"inverse`" ``[inverse-typed-spec]`` Inverse_ method for the solve. - - * `"cfl`" [double] Time step limiter, a number less than 1. Default value is 1. - - * `"spatial discretization order`" [int] defines accuracy of spatial discretization. - It permits values 1 or 2. Default value is 1. - - * `"temporal discretization order`" [int] defines accuracy of temporal discretization. - It permits values 1 or 2 and values 3 or 4 when expert parameter - `"generic RK implementation`" is set to true. Note that RK3 is not monotone. - Default value is 1. - - * `"reconstruction`" [list] collects reconstruction parameters. The available options are - describe in the separate section below. - - * `"transport subcycling`" ``[bool]`` **true** The code will default to - subcycling for transport within the master PK if there is one. - + * `"diffusion`" ``[pde-diffusion-typedinline-spec]`` Diffusion drives the + distribution. Typically we use finite volume here, but mimetic schemes + may be used. See :ref:`Diffusion` - Developer parameters: + * `"diffusion preconditioner`" ``[pde-diffusion-typedinline-spec]`` Inverse + of the above. Likely only Jacobian term options are needed here, as the + others default to the same as the `"diffusion`" list. See + :ref:`Diffusion`. - * `"enable internal tests`" [bool] turns on various internal tests during - run time. Default value is `"false`". + * `"inverse`" ``[inverse-typed-spec]`` :ref:`Inverse` method for the + diffusion-dispersion solve. See :ref:`Inverse`. - * `"generic RK implementation`" [bool] leads to generic implementation of - all Runge-Kutta methods. Default value is `"false`". + * `"cfl`" ``[double]`` **1.0** Courant-Friedrichs-Lewy condition, a limiter + on the timestep size relative to spatial size. Must be <= 1. - * `"internal tests tolerance`" [double] tolerance for internal tests such as the - divergence-free condition. The default value is 1e-6. + * `"advection spatial discretization order`" ``[int]`` **1** Defines + accuracy of the spatial discretization in the advection term. It permits + values 1 or 2. Default value is 1 (donor upwind) but 2 (a limiter scheme) + is much less numerically diffusive, and recommended for most cases. - * `"runtime diagnostics: solute names`" [Array(string)] defines solutes that will be - tracked closely each timestep if verbosity `"high`". Default value is the first - solute in the global list of `"aqueous names`" and the first gas in the global list - of `"gaseous names`". + * `"temporal discretization order`" ``[int]`` **1** Defines accuracy of + temporal discretization. It permits values 1 (forward Euler) and 2 (a + Runga-Kutta scheme). - * `"runtime diagnostics: regions`" [Array(string)] defines a boundary region for - tracking solutes. Default value is a seepage face boundary, see Flow PK. + * `"reconstruction`" ``[reconstruction-spec]`` collects reconstruction + parameters for use in reconstructing the velocity field for 2nd order + advection schemes. See :ref:`Reconstructions`. KEYS - - `"saturation liquid`" This variable is a multiplier in in the - accumulation term. For subsurface transport, this will typically be the - saturation (`"saturation_liquid`"). For surface transport, this will - typically be the ponded depth (`"ponded_depth`"). - - - `"previous saturation liquid`" - - - `"molar density liquid`" Transport is solved - for concentrations in units of mol fractions. Molar density is needed for conversion. - - - `"water flux`" - + - `"primary variable`" **"mole_fraction"** [mol C mol H2O^-1] + - `"liquid water content`" **"water_content"** This variable is a multiplier + in in the accumulation term. This is often just `"water_content`", but + not in frozen cases, where it must be defined by the user (typically as + :math:`\phi s n_l |V|` in the subsurface, or :math:`h n_l |V|` on the + surface. + - `"molar density liquid`" [mol H2O m^-3] + - `"water flux`" The face-based water flux in [mol H2O s^-1]. - `"water source`" Defines the water injection rate [mol H2O m^-2 s^-1] in - surface and [mol H2O m^-3 s^-1] in subsurface) which applies to - concentrations specified by the `"geochemical conditions`". Note that if - this PK is coupled to a surface flow PK, the unit of the water source - there *must* be in [mol m^-2 s^-1], *not* in [m s^-1] as is an option for - that PK (e.g. `"water source in meters`" must be set to `"false`" in the - overland flow PK). - - The injection rate of a solute [molC s^-1], when given as the product of - a concentration and a water source, is evaluated as: - - Concentration [mol C L^-1] * - 1000 [L m^-3] of water * - water source [mol H2O m^-3 s^-1] * - volume of injection domain [m^3] / - molar density of water [mol H2O m^-3] - - -.. _molecular-diffusion-spec: -.. admonition:: molecular-diffusion-spec - - * `"aqueous names`" ``[Array(string)]`` List of aqueous component names to - be diffused. - * `"aqueous values`" ``[Array(string)]`` Diffusivities of each component. - - -.. code-block:: xml - - - - - - - -.. _material-properties-spec: -.. admonition:: material-properties-spec - - * `"region`" ``[Array(string)]`` Defines geometric regions for material SOIL. - - * `"model`" ``[string]`` **scalar** Defines dispersivity model. One of: - - - `"scalar`" : scalar dispersivity - - `"Bear`" : dispersion split into along- and across- velocity - - `"Burnett-Frind`" - - `"Lichtner-Kelkar-Robinson`" - - * `"parameters for MODEL`" ``[list]`` where `"MODEL`" is the model name. - - IF model == scalar + surface and [mol H2O m^-3 s^-1] in subsurface) which applies to + concentrations specified by the `"geochemical conditions`". Note that if + this PK is coupled to a surface flow PK, the unit of the water source + there *must* be in [mol m^-2 s^-1], *not* in [m s^-1] as is an option for + that PK (e.g. `"water source in meters`" must be set to `"false`" in the + overland flow PK). - ONE OF + The injection rate of a solute [molC s^-1], when given as the product of a + concentration and a water source, is evaluated as: - * `"alpha`" ``[double]`` defines dispersivity in all directions, [m]. + Concentration [mol C L^-1] :math:`\times` + 1000 [L m^-3] of water :math:`\times` + water source [mol m^-3 s^-1] :math:`\times` + volume of injection domain [m^3] :math:`/` + molar density of water [mol m^-3] - OR - * `"dispersion coefficient`" ``[double]`` defines dispersion coefficient [m^2 s^-1]. +Note, this is not dispersion, but strictly isotropic diffusion. - END +.. _molecular-diffusivity-spec: +.. admonition:: molecular-diffusivity-spec - ELSE IF model == Bear + For each aqueous component, a single value is provided for molecular diffusivity, e.g. - * `"alpha_l`" ``[double]`` defines dispersion in the direction of Darcy velocity, [m]. - * `"alpha_t`" ``[double]`` defines dispersion in the orthogonal direction, [m]. + `"COMPONENT_NAME`" ``[double]`` value [m^2 s^-1] - ELSE IF model == Burnett-Frind - * `"alphaL`" ``[double]`` defines the longitudinal dispersion in the direction - of Darcy velocity, [m]. - * `"alpha_th`" ``[double]`` Defines the transverse dispersion in the horizonal - direction orthogonal directions, [m]. - * `"alpha_tv`" ``[double]`` Defines dispersion in the orthogonal directions, - [m]. When `"alpha_th`" equals to `"alpha_tv`", we obtain dispersion in - the direction of the Darcy velocity. +.. _tortuosity-spec: +.. admonition:: tortuosity-spec - ELSE IF model == Lichtner-Kelker-Robinson - - * `"alpha_lh`" ``[double]`` defines the longitudinal dispersion in the - horizontal direction, [m]. - * `"alpha_lv`" ``[double]`` Defines the longitudinal dispersion in the vertical - direction, [m]. When `"alpha_lh`" equals to `"alpha_lv`", we obtain - dispersion in the direction of the Darcy velocity. - * `"alpha_th`" ``[double]`` Defines the transverse dispersion in the horizontal - direction orthogonal directions, [m]. - * `"alpha_tv" ``[double]`` Defines dispersion in the orthogonal directions. - When `"alpha_th`" equals to `"alpha_tv`", we obtain dispersion in the - direction of the Darcy velocity. - - END - - * `"aqueous tortuosity`" ``[double]`` Defines tortuosity for calculating + * `"aqueous`" ``[double]`` Defines tortuosity for calculating diffusivity of liquid solutes, [-]. - * `"gaseous tortuosity`" ``[double]`` Defines tortuosity for calculating - diffusivity of gas solutes, [-]. + * `"gaseous`" ``[double]`` Defines tortuosity for calculating + diffusivity of gas solutes, [-]. Not currently implemented! .. _transport-source-spec: @@ -269,14 +183,14 @@ The advection-diffusion equation for component *i* in the surface may be written #include "Units.hh" #include "VerboseObject.hh" #include "Debugger.hh" -#include "PK_PhysicalExplicit.hh" #include "DenseVector.hh" +#include "PK_Physical_Default.hh" #include #ifdef ALQUIMIA_ENABLED -# include "Alquimia_PK.hh" -# include "ChemistryEngine.hh" +#include "Alquimia_PK.hh" +#include "ChemistryEngine.hh" #endif // Transport @@ -287,23 +201,25 @@ The advection-diffusion equation for component *i* in the surface may be written #include "TransportDefs.hh" namespace Amanzi { + +// forward declarations +struct TensorVector; +namespace Operators { +class PDE_Diffusion; +class PDE_Accumulation; +class BCs; +class Operator; +} + namespace Transport { -// ummm -- why does this not use TreeVector? --ETC -class Transport_ATS : public PK_PhysicalExplicit { +class Transport_ATS : public PK_Physical_Default { public: Transport_ATS(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& glist, const Teuchos::RCP& S, const Teuchos::RCP& solution); - Transport_ATS(const Teuchos::RCP& glist, - Teuchos::RCP S, - const std::string& pk_list_name, - std::vector& component_names); - - ~Transport_ATS() = default; - void parseParameterList() override; // members required by PK interface @@ -311,181 +227,161 @@ class Transport_ATS : public PK_PhysicalExplicit { // coupling with chemistry #ifdef ALQUIMIA_ENABLED - void SetupAlquimia(Teuchos::RCP chem_pk, - Teuchos::RCP chem_engine); + void setChemEngine(Teuchos::RCP chem_pk); #endif virtual void Initialize() override; virtual double get_dt() override; - virtual void set_dt(double dt) override{}; - virtual void set_tags(const Tag& current, const Tag& next) override; + virtual void set_dt(double dt) override {}; virtual bool AdvanceStep(double t_old, double t_new, bool reinit = false) override; virtual void CommitStep(double t_old, double t_new, const Tag& tag) override; - virtual void CalculateDiagnostics(const Tag& tag) override{}; - - virtual void ChangedSolutionPK(const Tag& tag) override; - - // Time integration members - virtual void FunctionalTimeDerivative(const double t, - const Epetra_Vector& component, - Epetra_Vector& f_component) override; + virtual void CalculateDiagnostics(const Tag& tag) override {}; // -- helper functions - // These are in the public API because reactive transport calls them when - // chemistry fails. Probably should go away or become nonmember functions. - void PrintSoluteExtrema(const Epetra_MultiVector& tcc_next, - double dT_MPC); - int get_num_aqueous_component() const { - return num_aqueous_; - } + int get_num_aqueous_component() const { return num_aqueous_; } - private: + protected: + // component-based or phase-based parameters + using ParameterMap = std::map; + ParameterMap readParameterMapByComponent(Teuchos::ParameterList& plist, double default_val); + ParameterMap readParameterMapByPhase(Teuchos::ParameterList& plist, double default_val); // transport physics members // -- calculation of a stable timestep needs saturations and darcy flux double ComputeStableTimeStep_(); - // -- WHAT DOES THIS DO? - void ComputeSinks2TotalOutFlux_(Epetra_MultiVector& tcc, - std::vector& total_outflux, int n0, int n1); - - void CheckInfluxBC_(const Epetra_MultiVector& flux) const; - bool PopulateBoundaryData_(std::vector& bc_model, std::vector& bc_value, int component); - - // -- sources and sinks for components from n0 to n1 including - void ComputeAddSourceTerms_(double tp, double dtp, Epetra_MultiVector& tcc, int n0, int n1); - // -- setup/initialize helper functions void InitializeFields_(); - void SetupTransport_(); - void SetupPhysicalEvaluators_(); + virtual void SetupTransport_(); + virtual void SetupPhysicalEvaluators_(); - // -- advection members - void AdvanceDonorUpwind_(double dT); - void AdvanceSecondOrderUpwindRKn_(double dT); - void AdvanceSecondOrderUpwindRK1_(double dT); - void AdvanceSecondOrderUpwindRK2_(double dT); - void Advance_Dispersion_Diffusion_(double t_old, double t_new); + // -- advance members -- portions of the operator + void AdvanceAdvectionSources_RK1_(double t_old, double t_new, int spatial_order); + void AdvanceAdvectionSources_RK2_(double t_old, double t_new, int spatial_order); + void AdvanceDispersionDiffusion_(double t_old, double t_new); - void IdentifyUpwindCells_(); - - // physical models - // -- dispersion and diffusion - void CalculateDispersionTensor_(const Epetra_MultiVector& darcy_flux, - const Epetra_MultiVector& porosity, - const Epetra_MultiVector& saturation, - const Epetra_MultiVector& mol_density); - - void CalculateDiffusionTensor_(double md, - int phase, - const Epetra_MultiVector& porosity, - const Epetra_MultiVector& saturation, - const Epetra_MultiVector& mol_density); + // -- helper functions used in AdvanceDispersionDiffusion_ + bool PopulateBoundaryData_(int component, Operators::BCs& bcs); - int FindDiffusionValue_(const std::string& tcc_name, double* md, int* phase); - void CalculateAxiSymmetryDirection_(); + // -- helper functions used in AdvanceAdvectionSources* + void IdentifyUpwindCells_(); + void AddAdvection_FirstOrderUpwind_(double t_old, + double t_new, + const Epetra_MultiVector& tcc, + Epetra_MultiVector& conserve_qty, + Epetra_MultiVector& f); + void AddAdvection_SecondOrderUpwind_(double t_old, + double t_new, + const Epetra_MultiVector& tcc, + Epetra_MultiVector& conserve_qty, + Epetra_MultiVector& f); + void AddAdvection_SecondOrderUpwind_(double t_old, + double t_new, + const Epetra_Vector& tcc, + Epetra_Vector& conserve_qty, + Epetra_Vector& f, + int component); + + virtual void AddSourceTerms_(double t_old, double t_new, Epetra_MultiVector& conserve_qty); + + void InvertTccNew_(const Epetra_MultiVector& conserve_qty, + Epetra_MultiVector& tcc, + Epetra_MultiVector* solid_qty, + bool include_current_water_mass); // -- air-water partitioning using Henry's law. This is a temporary // solution to get things moving. - void PrepareAirWaterPartitioning_(); - void MakeAirWaterPartitioning_(); + // void PrepareAirWaterPartitioning_(); + // void MakeAirWaterPartitioning_(); // -- multiscale methods - void AddMultiscalePorosity_(double t_old, double t_new, double t_int1, double t_int2); - - // miscaleneous methods - int FindComponentNumber_(const std::string& component_name); + // void AddMultiscalePorosity_(double t_old, double t_new, double t_int1, double t_int2); + + // miscillaneous methods + int FindComponentNumber_(const std::string& component_name) + { + auto comp = std::find(component_names_.begin(), component_names_.end(), component_name); + if (comp == component_names_.end() ) return -1; + else return comp - component_names_.begin(); + } protected: - Key saturation_key_; - Key flux_key_; - Key darcy_flux_key_; - Key permeability_key_; - Key tcc_key_; - Key porosity_key_; - Key tcc_matrix_key_; - Key molar_density_key_; - Key solid_residue_mass_key_; - Key water_content_key_; - Key water_src_key_, solute_src_key_; - Key water_src_tile_key_; - bool has_water_src_key_; - bool water_src_in_meters_; - bool has_water_src_tile_key_; - Key geochem_src_factor_key_; - Key conserve_qty_key_; + // dependencies + Key water_flux_key_; // advecting water flux [mol / s] on faces + Key lwc_key_; // liquid water content [mol] + Key source_key_; + bool is_source_term_; Key cv_key_; - // control flags - std::unordered_map convert_to_field_; - Key passwd_; + // workspace + Key solid_residue_mass_key_; // residue -- mass that was left behind by water + // sinks that do not carry aqueous species, e.g. freezing or evaporation + Key conserve_qty_key_; + Key mass_flux_advection_key_; + Key mass_flux_diffusion_key_; + Key dispersion_tensor_key_; + + // component information + std::vector component_names_; // details of components + int num_components_, num_aqueous_; - // NOTE: these should go away -- instead get vectors from State, then pass as - // function arguments if needed. --ETC - Teuchos::RCP tcc_w_src; - Teuchos::RCP tcc_tmp; // next tcc - Teuchos::RCP tcc; // smart mirrow of tcc + // parameters + ParameterMap molar_masses_; // molar mass [kg / mol C] by component + ParameterMap tcc_max_; // maximum valid concentration [mol C / mol H2O] by component - Teuchos::RCP ws_, ws_prev_, mol_dens_, mol_dens_prev_; + ParameterMap molec_diff_; // molecular diffusivity by component [m^2 s^-1] + ParameterMap tortuosity_; // phase-based tortuosity [-] + double water_tolerance_; // mol H2O / m^d (d = 2 for surface, d = 3 for subsurface) #ifdef ALQUIMIA_ENABLED Teuchos::RCP chem_pk_; Teuchos::RCP chem_engine_; +#else + Teuchos::RCP chem_pk_; + Teuchos::RCP chem_engine_; #endif - Teuchos::RCP upwind_cell_, downwind_cell_; + // temporal integration + // -- discretization order: RK1 (forward Euler) or RK2 (predictor-corrector) + int temporal_disc_order_; + double cfl_; + double dt_stable_, dt_max_; - int current_component_; // data for lifting - Teuchos::RCP lifting_; - Teuchos::RCP limiter_; - - // srcs should go away, and instead use vectors from State and evaluators --ETC - std::vector> srcs_; // Source or sink for components - std::vector> bcs_; // influx BC for components - Teuchos::RCP Kxy_; // absolute permeability in plane xy + // Source terms + // -- REMOVE IN 1.7 + Key default_water_src_key_; + bool default_water_src_in_meters_; - // mechanical dispersion and molecual diffusion - Teuchos::RCP mdm_; - std::vector D_; + std::map water_src_keys_; + std::map water_src_in_meters_; + std::map geochem_src_factor_keys_; + Key molar_dens_key_; - bool flag_dispersion_; - std::vector axi_symmetry_; // axi-symmetry direction of permeability tensor - - std::vector> mat_properties_; // vector of materials - std::vector> diffusion_phase_; // vector of phases - - // Hosting temporarily Henry law - bool henry_law_; - std::vector kH_; - std::vector air_water_map_; - - // control parameters - int spatial_disc_order_, temporal_disc_order_, limiter_model_; - - int nsubcycles; // output information - int internal_tests; - double tests_tolerance; + std::vector> srcs_; // Source or sink for components - double cfl_, dt_, dt_max_, t_physics_; + // operators for advection + int adv_spatial_disc_order_; + Teuchos::RCP upwind_cell_, downwind_cell_; + Teuchos::RCP lifting_; + Teuchos::RCP limiter_; - std::vector mass_solutes_exact_, mass_solutes_source_; // mass for all solutes - std::vector mass_solutes_bc_, mass_solutes_stepstart_; - std::vector runtime_solutes_; // solutes tracked for diagnostics - std::vector runtime_regions_; + Teuchos::RCP adv_bcs_; + std::vector> bcs_; - std::vector component_names_; // details of components - Teuchos::Array tcc_max_; // max concentrations of components allowed - std::vector mol_masses_; // molar masses of components - int num_aqueous_, num_gaseous_, num_components_, num_advect_; - double water_tolerance_, max_tcc_; - bool dissolution_; + // operators for dispersion/diffusion + bool has_diffusion_, has_dispersion_; + Teuchos::RCP D_; // workspace, disp + diff + Teuchos::RCP diff_bcs_; + Teuchos::RCP diff_global_op_; + Teuchos::RCP diff_op_; + Teuchos::RCP diff_acc_op_; + Teuchos::RCP diff_sol_; // workspace // io Utils::Units units_; - Tag flow_tag_; private: // Forbidden. @@ -498,8 +394,7 @@ class Transport_ATS : public PK_PhysicalExplicit { }; // helper functions -void CheckGEDProperty(const Epetra_MultiVector& tracer, - double t_physics); +void CheckGEDProperty(const Epetra_MultiVector& tracer, double t_physics); void CheckTracerBounds(const Epetra_MultiVector& tcc, const Epetra_MultiVector& tcc_prev, diff --git a/src/pks/transport/transport_ats_dispersion.cc b/src/pks/transport/transport_ats_dispersion.cc index bea4b1e8c..ba36d0023 100644 --- a/src/pks/transport/transport_ats_dispersion.cc +++ b/src/pks/transport/transport_ats_dispersion.cc @@ -145,25 +145,7 @@ Transport_ATS::CalculateAxiSymmetryDirection_() int ncells_owned = mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); - axi_symmetry_.resize(ncells_owned, -1); - if (S_->HasRecord(permeability_key_, tag_next_)) { - const Epetra_MultiVector& perm = - *S_->Get(permeability_key_, tag_next_).ViewComponent("cell"); - - if (perm.NumVectors() == 3) { - for (int c = 0; c < ncells_owned; ++c) { - int k; - if (perm[0][c] != perm[1][c] && perm[1][c] == perm[2][c]) { - k = 0; - } else if (perm[1][c] != perm[2][c] && perm[2][c] == perm[0][c]) { - k = 1; - } else if (perm[2][c] != perm[0][c] && perm[0][c] == perm[1][c]) { - k = 2; - } - axi_symmetry_[c] = k; - } - } - } + axi_symmetry_.resize(ncells_owned, mesh_->getSpaceDimension() - 1); } } // namespace Transport diff --git a/src/pks/transport/transport_ats_pk.cc b/src/pks/transport/transport_ats_pk.cc index c8f0fe684..057bd2d09 100644 --- a/src/pks/transport/transport_ats_pk.cc +++ b/src/pks/transport/transport_ats_pk.cc @@ -23,20 +23,22 @@ #include "Epetra_Import.h" #include "Teuchos_RCP.hpp" -#include "BCs.hh" #include "errors.hh" #include "Explicit_TI_RK.hh" #include "Evaluator.hh" #include "Mesh.hh" #include "MeshAlgorithms.hh" +#include "TensorVector.hh" #include "OperatorDefs.hh" +#include "BCs.hh" #include "PDE_DiffusionFactory.hh" #include "PDE_Diffusion.hh" #include "PDE_Accumulation.hh" -#include "PK_DomainFunctionFactory.hh" + #include "PK_Utils.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" +#include "PK_DomainFunctionFactory.hh" #include "TransportDomainFunction.hh" #include "TransportBoundaryFunction_Alquimia.hh" #include "TransportSourceFunction_Alquimia.hh" @@ -57,17 +59,11 @@ Transport_ATS::Transport_ATS(Teuchos::ParameterList& pk_tree, const Teuchos::RCP& S, const Teuchos::RCP& solution) : PK(pk_tree, global_plist, S, solution), - PK_PhysicalExplicit(pk_tree, global_plist, S, solution), - has_water_src_key_(false), - flow_tag_(Tags::NEXT), - passwd_("state"), - internal_tests(0), - tests_tolerance(TRANSPORT_CONCENTRATION_OVERSHOOT), - dt_(0.0), - dt_max_(0.0), - t_physics_(0.0), - current_component_(-1), - flag_dispersion_(false) + PK_Physical_Default(pk_tree, global_plist, S, solution), + dt_stable_(-1.0), + dt_max_(-1.0), + has_diffusion_(false), + has_dispersion_(false) { // initialize io units_.Init(global_plist->sublist("units")); @@ -76,76 +72,142 @@ Transport_ATS::Transport_ATS(Teuchos::ParameterList& pk_tree, void Transport_ATS::parseParameterList() { - if (plist_->isParameter("component molar masses")) { - mol_masses_ = plist_->get>("component molar masses").toVector(); - } else { - Errors::Message msg("Transport PK: parameter \"component molar masses\" is missing."); + if (!plist_->isParameter("primary variable key suffix")) { + plist_->set("primary variable key suffix", "mole_fraction"); + } + + // with subfield names, the header width is often insufficient + if (!plist_->sublist("verbose object").isParameter("debug cell header width")) + plist_->sublist("verbose object").set("debug cell header width", 34); + PK_Physical_Default::parseParameterList(); + + // protect user from old naming convention + if (Keys::getVarName(key_) == "total_component_concentration") { + Errors::Message msg; + msg << "Transport_ATS PK \"" << name() << "\": primary variable can no longer be called " + << "\"total_component_concentration\", but should instead be left blank (to use " + << "\"molar_fraction\") or provided something else. Transport units are " + << "[mol-C mol-H2O^-1], not [mol L^-1], and therefore should not be called concentration."; Exceptions::amanzi_throw(msg); } - // primary variable - tcc_key_ = Keys::readKey(*plist_, domain_, "concentration", "total_component_concentration"); - requireAtNext(tcc_key_, tag_next_, *S_, passwd_); - requireAtCurrent(tcc_key_, tag_current_, *S_, passwd_); + if (component_names_.size() == 0) { + // not set by chemistry... must get set by user + component_names_ = plist_->get>("component names").toVector(); + num_components_ = component_names_.size(); + } + + // NOTE: names MUST be aqueous, solid, gaseous + num_aqueous_ = plist_->get("number of aqueous components", component_names_.size()); + + // parameters + molar_masses_ = + readParameterMapByComponent(plist_->sublist("component molar masses [kg / mol C]"), 1.0); + tcc_max_ = readParameterMapByComponent( + plist_->sublist("component maximum concentration [mol C / mol H2O]"), -1.0); + + if (plist_->isSublist("molecular diffusivity [m^2 s^-1]")) { + has_diffusion_ = true; + molec_diff_ = + readParameterMapByComponent(plist_->sublist("molecular diffusivity [m^2 s^-1]"), 0.); + + tortuosity_ = readParameterMapByPhase(plist_->sublist("tortuosity [-]"), 1.); + } // keys, dependencies, etc - saturation_key_ = Keys::readKey(*plist_, domain_, "saturation liquid", "saturation_liquid"); - flux_key_ = Keys::readKey(*plist_, domain_, "water flux", "water_flux"); - permeability_key_ = Keys::readKey(*plist_, domain_, "permeability", "permeability"); + // -- flux -- only needed at new time, evaluator controlled elsewhere + water_flux_key_ = Keys::readKey(*plist_, domain_, "water flux", "water_flux"); + + mass_flux_advection_key_ = + Keys::readKey(*plist_, domain_, "mass flux advection", "mass_flux_advection"); + requireEvaluatorAtNext(mass_flux_advection_key_, tag_next_, *S_, name_); + + mass_flux_diffusion_key_ = + Keys::readKey(*plist_, domain_, "mass flux diffusion", "mass_flux_diffusion"); + requireEvaluatorAtNext(mass_flux_diffusion_key_, tag_next_, *S_, name_); + + // -- liquid water content - need at new time, copy at current time + lwc_key_ = Keys::readKey(*plist_, domain_, "liquid water content", "water_content"); + requireEvaluatorAtCurrent(lwc_key_, tag_current_, *S_, name_); + + // NOTE: these to go away in 1.7 + default_water_src_key_ = Keys::readKey(*plist_, domain_, "water source", "water_source"); + default_water_src_in_meters_ = plist_->get("water source in meters", false); + + cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); + + // workspace, no evaluator conserve_qty_key_ = Keys::readKey(*plist_, domain_, "conserved quantity", "total_component_quantity"); - porosity_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); - molar_density_key_ = Keys::readKey(*plist_, domain_, "molar density", "molar_density_liquid"); - tcc_matrix_key_ = - Keys::readKey(*plist_, domain_, "tcc matrix", "total_component_concentration_matrix"); - solid_residue_mass_key_ = Keys::readKey(*plist_, domain_, "solid residue", "solid_residue_mass"); - water_src_key_ = Keys::readKey(*plist_, domain_, "water source", "water_source"); - water_src_tile_key_ = Keys::readKey(*plist_, domain_, "water source tile", "water_source_tile"); - geochem_src_factor_key_ = - Keys::readKey(*plist_, domain_, "geochem source factor", "geochem_src_factor"); - water_content_key_ = Keys::readKey(*plist_, domain_, "water content", "water_content"); - cv_key_ = Keys::readKey(*plist_, domain_, "cell volume", "cell_volume"); - key_ = tcc_key_; + requireEvaluatorAtNext(conserve_qty_key_, tag_next_, *S_, name_); + + solid_residue_mass_key_ = + Keys::readKey(*plist_, domain_, "solid residue", "solid_residue_quantity"); + + if (chem_engine_ != Teuchos::null) { + // needed by geochemical bcs + molar_dens_key_ = + Keys::readKey(*plist_, domain_, "molar density liquid", "molar_density_liquid"); + } + + // dispersion coefficient tensor + dispersion_tensor_key_ = + Keys::readKey(*plist_, domain_, "dispersion coefficient", "dispersion_coefficient"); + has_dispersion_ = S_->HasEvaluatorList(dispersion_tensor_key_); // other parameters - water_tolerance_ = plist_->get("water tolerance", 1e-6); - dissolution_ = plist_->get("allow dissolution", false); - max_tcc_ = plist_->get("maximum concentration", -1.0); + // -- a small amount of water, used to define when we are going to completely dry out a grid cell + water_tolerance_ = plist_->get("water tolerance [mol H2O / m^d]", 1e-6); // global transport parameters cfl_ = plist_->get("cfl", 1.0); - dt_max_ = plist_->get("maximum timestep", TRANSPORT_LARGE_TIME_STEP); + dt_max_ = plist_->get("maximum timestep [s]", TRANSPORT_LARGE_TIME_STEP); - spatial_disc_order_ = plist_->get("spatial discretization order", 1); - if (spatial_disc_order_ < 1 || spatial_disc_order_ > 2) { + adv_spatial_disc_order_ = plist_->get("advection spatial discretization order", 1); + if (adv_spatial_disc_order_ < 1 || adv_spatial_disc_order_ > 2) { Errors::Message msg; - msg << "Transport_ATS: \"spatial discretization order\" must be 1 or 2, not " << spatial_disc_order_; + msg << "Transport_ATS: \"advection spatial discretization order\" must be 1 or 2, not " + << adv_spatial_disc_order_; Exceptions::amanzi_throw(msg); } + temporal_disc_order_ = plist_->get("temporal discretization order", 1); if (temporal_disc_order_ < 1 || temporal_disc_order_ > 2) { Errors::Message msg; - msg << "Transport_ATS: \"temporal discretization order\" must be 1 or 2, not " << temporal_disc_order_; + msg << "Transport_ATS: \"temporal discretization order\" must be 1 or 2, not " + << temporal_disc_order_; Exceptions::amanzi_throw(msg); } - - if (plist_->isParameter("runtime diagnostics: regions")) { - runtime_regions_ = - plist_->get>("runtime diagnostics: regions").toVector(); + // source terms + is_source_term_ = plist_->get("source term", false); + if (is_source_term_) { + source_key_ = Keys::readKey(*plist_, domain_, "source", "component_source"); } - internal_tests = plist_->get("enable internal tests", false); - tests_tolerance = - plist_->get("internal tests tolerance", TRANSPORT_CONCENTRATION_OVERSHOOT); - db_ = Teuchos::rcp(new Debugger(mesh_, name_, *plist_)); } -void -Transport_ATS::set_tags(const Tag& current, const Tag& next) + +Transport_ATS::ParameterMap +Transport_ATS::readParameterMapByComponent(Teuchos::ParameterList& plist, double default_val) { - PK_PhysicalExplicit::set_tags(current, next); + Transport_ATS::ParameterMap map; + for (int i = 0; i != num_components_; ++i) { + map[component_names_[i]] = plist.get(component_names_[i], default_val); + } + return map; +} + + +Transport_ATS::ParameterMap +Transport_ATS::readParameterMapByPhase(Teuchos::ParameterList& plist, double default_val) +{ + Transport_ATS::ParameterMap map; + map["aqueous"] = plist.get("aqueous", default_val); + map["solid"] = plist.get("solid", default_val); + map["gaseous"] = plist.get("gaseous", default_val); + return map; } @@ -154,11 +216,10 @@ Transport_ATS::set_tags(const Tag& current, const Tag& next) ****************************************************************** */ #ifdef ALQUIMIA_ENABLED void -Transport_ATS::SetupAlquimia(Teuchos::RCP chem_pk, - Teuchos::RCP chem_engine) +Transport_ATS::setChemEngine(Teuchos::RCP chem_pk) { chem_pk_ = chem_pk; - chem_engine_ = chem_engine; + chem_engine_ = chem_pk->getChemEngine(); if (chem_engine_ != Teuchos::null) { // Retrieve the component names (primary and secondary) from the chemistry @@ -176,6 +237,7 @@ Transport_ATS::SetupAlquimia(Teuchos::RCP chem_pk, void Transport_ATS::Setup() { + PK_Physical_Default::Setup(); SetupTransport_(); SetupPhysicalEvaluators_(); } @@ -187,73 +249,65 @@ Transport_ATS::Setup() void Transport_ATS::SetupTransport_() { - // a few last things that ought to be in the constructor, but cannot be there - // because they depend upon component_names, which may not get set in the - // constructor (as they get set by the chemical engine). - if (component_names_.size() == 0) { - // not set by chemistry... must get set by user - component_names_ = plist_->get>("component names").toVector(); - num_components_ = component_names_.size(); - } - num_aqueous_ = plist_->get("number of aqueous components", component_names_.size()); - num_advect_ = plist_->get("number of aqueous components advected", num_aqueous_); - num_gaseous_ = plist_->get("number of gaseous components", 0); - - tcc_max_.resize(num_aqueous_, 1.e10); - tcc_max_ = plist_->get>("component max concentrations", tcc_max_); - - // statistics of solutes - if (plist_->isParameter("runtime diagnostics: solute names")) { - runtime_solutes_ = - plist_->get>("runtime diagnostics: solute names").toVector(); - if (runtime_solutes_.size() == 1 && runtime_solutes_[0] == "all") { - runtime_solutes_ = component_names_; - } - } - mass_solutes_exact_.assign(num_aqueous_ + num_gaseous_, 0.0); - mass_solutes_source_.assign(num_aqueous_ + num_gaseous_, 0.0); - mass_solutes_bc_.assign(num_aqueous_ + num_gaseous_, 0.0); - mass_solutes_stepstart_.assign(num_aqueous_ + num_gaseous_, 0.0); + // upwind and downwind vectors + const Epetra_Map& fmap_wghost = mesh_->getMap(AmanziMesh::Entity_kind::FACE, true); + upwind_cell_ = Teuchos::rcp(new Epetra_IntVector(fmap_wghost)); + downwind_cell_ = Teuchos::rcp(new Epetra_IntVector(fmap_wghost)); - // cross-coupling of PKs - Teuchos::RCP physical_models = - Teuchos::sublist(plist_, "physical models and assumptions"); + if (adv_spatial_disc_order_ == 2) { + // reconstruction initialization + Teuchos::ParameterList& recon_list = plist_->sublist("reconstruction"); - if (num_components_ == 0) { - Errors::Message msg("Transport PK: list of solutes is empty."); - Exceptions::amanzi_throw(msg); + // check and set defaults + if (!recon_list.isParameter("limiter extension for transport")) + recon_list.set("limiter extension for transport", true); + if (!recon_list.isParameter("limiter") ) recon_list.set("limiter", "tensorial"); + + lifting_ = Teuchos::rcp(new Operators::ReconstructionCellLinear(mesh_)); + lifting_->Init(recon_list); + + limiter_ = Teuchos::rcp(new Operators::LimiterCell(mesh_)); + limiter_->Init(recon_list); } - // upwind - const Epetra_Map& fmap_wghost = mesh_->getMap(AmanziMesh::Entity_kind::FACE, true); - upwind_cell_ = Teuchos::rcp(new Epetra_IntVector(fmap_wghost)); - downwind_cell_ = Teuchos::rcp(new Epetra_IntVector(fmap_wghost)); + adv_bcs_ = Teuchos::rcp( + new Operators::BCs(mesh_, AmanziMesh::Entity_kind::FACE, WhetStone::DOF_Type::SCALAR)); - // reconstruction initialization - limiter_ = Teuchos::rcp(new Operators::LimiterCell(mesh_)); - lifting_ = Teuchos::rcp(new Operators::ReconstructionCellLinear(mesh_)); + // workspace for diffusion and dispersion solve + if (has_dispersion_) { + // note this space has the wrong number of DoFs, but that will be corrected + // by the evaluator later. The rest of the info (name, location, and mesh) + // are needed. + CompositeVectorSpace disp_space; + disp_space.SetMesh(mesh_)->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - // dependencies: - // -- permeability - bool abs_perm = physical_models->get("permeability field is required", false); - if (abs_perm) { - requireAtNext(permeability_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, mesh_->getSpaceDimension()); + S_->Require(dispersion_tensor_key_, tag_next_) + .set_map(disp_space); + S_->RequireEvaluator(dispersion_tensor_key_, tag_next_); } - // HACK ALERT -- FIXME --ETC - // This PK is liberally sprinkled with hard-coded Tags::NEXT and - // Tags::CURRENT, forcing all things provided by FLOW to be provided at that - // tag and not at tag_current and tag_next as it should be. This is because - // we don't have a good way of aliasing everything we need yet. In - // particular, aliases needed to be introduced between Setup() on flow and - // Setup() on transport, and this was not possible when the quantity of - // interest (porosity)'s evaluator was not required directly (only - // indirectly) in flow PK. + // operator and boundary conditions for diffusion/dispersion solve + if (has_dispersion_ || has_diffusion_) { + // default boundary conditions (none inside domain and Neumann on its boundary) + diff_bcs_ = Teuchos::rcp( + new Operators::BCs(mesh_, AmanziMesh::Entity_kind::FACE, WhetStone::DOF_Type::SCALAR)); + PopulateBoundaryData_(-1, *diff_bcs_); + // diffusion operator + Operators::PDE_DiffusionFactory opfactory; + Teuchos::ParameterList& op_list = plist_->sublist("diffusion"); + diff_op_ = opfactory.Create(op_list, mesh_, diff_bcs_); + diff_global_op_ = diff_op_->global_operator(); + diff_acc_op_ = + Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, diff_global_op_)); + + // diffusion workspace + const CompositeVectorSpace& cvs = diff_global_op_->DomainMap(); + diff_sol_ = Teuchos::rcp(new CompositeVector(cvs)); + } // source term setup + // -------------------------------------------------------------------------------- if (plist_->isSublist("source terms")) { auto sources_list = Teuchos::sublist(plist_, "source terms"); @@ -267,12 +321,11 @@ Transport_ATS::SetupTransport_() if (conc_sources_list->isSublist(name)) { auto src_list = Teuchos::sublist(conc_sources_list, name); - convert_to_field_[name] = src_list->get("convert to field", false); std::string src_type = src_list->get("spatial distribution method", "none"); if (src_type == "domain coupling") { - Teuchos::RCP src = - factory.Create(*src_list, "fields", AmanziMesh::Entity_kind::CELL, Kxy_, tag_current_); + Teuchos::RCP src = factory.Create( + *src_list, "fields", AmanziMesh::Entity_kind::CELL, Teuchos::null, tag_current_); // domain couplings functions is special -- always work on all components for (int i = 0; i < num_components_; i++) { @@ -281,9 +334,10 @@ Transport_ATS::SetupTransport_() } src->set_state(S_); srcs_.push_back(src); + } else if (src_type == "field") { - Teuchos::RCP src = - factory.Create(*src_list, "field", AmanziMesh::Entity_kind::CELL, Kxy_, tag_current_); + Teuchos::RCP src = factory.Create( + *src_list, "field", AmanziMesh::Entity_kind::CELL, Teuchos::null, tag_current_); for (int i = 0; i < num_components_; i++) { src->tcc_names().push_back(component_names_[i]); @@ -305,18 +359,19 @@ Transport_ATS::SetupTransport_() for (int fid = 1; fid != (num_fields + 1); ++fid) { std::stringstream sublist_name; sublist_name << "field " << fid << " info"; - auto field_key = flist.sublist(sublist_name.str()).get("field key"); - auto field_tag = Keys::readTag(flist.sublist(sublist_name.str()), "tag"); - requireAtNext(field_key, field_tag, *S_) + Key field_key = + Keys::readKey(flist.sublist(sublist_name.str()), domain_, "field"); + Tag field_tag = Keys::readTag(flist.sublist(sublist_name.str())); + requireEvaluatorAtNext(field_key, field_tag, *S_) .SetMesh(mesh_) ->SetGhosted(true) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } } } else { // if only one field - auto field_key = src_list->sublist("field").get("field key"); - auto field_tag = Keys::readTag(src_list->sublist("field"), "tag"); - requireAtNext(field_key, field_tag, *S_) + Key field_key = Keys::readKey(src_list->sublist("field"), domain_, "field"); + Tag field_tag = Keys::readTag(src_list->sublist("field"), "field"); + requireEvaluatorAtNext(field_key, field_tag, *S_) .SetMesh(mesh_) ->SetGhosted(true) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, num_components_); @@ -326,9 +381,14 @@ Transport_ATS::SetupTransport_() } } else { // all others work on a subset of components - Teuchos::RCP src = factory.Create( - *src_list, "source function", AmanziMesh::Entity_kind::CELL, Kxy_, tag_current_); - src->set_tcc_names(src_list->get>("component names").toVector()); + Teuchos::RCP src = + factory.Create(*src_list, + "source function", + AmanziMesh::Entity_kind::CELL, + Teuchos::null, + tag_current_); + src->set_tcc_names( + src_list->get>("component names").toVector()); for (const auto& n : src->tcc_names()) { src->tcc_index().push_back(FindComponentNumber_(n)); } @@ -336,107 +396,58 @@ Transport_ATS::SetupTransport_() src->set_state(S_); srcs_.push_back(src); } - - if (convert_to_field_[name]) { - name = Keys::cleanName(name); - if (Keys::getDomain(name)!=domain_){ - name = Keys::getKey(domain_, name); - } - requireAtNext(name, Tags::NEXT, *S_, name) - .SetMesh(mesh_) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, num_components_); - } } } } - // sources of water that include C at a known concentration + // sources of water that include C at a known concentration, done by + // geochemical engine if (sources_list->isSublist("geochemical")) { - // note these are computed at the flow PK's NEXT tag, which assumes all - // sources are dealt with implicitly (backward Euler). This could be relaxed --ETC - requireAtNext(water_src_key_, flow_tag_, *S_) - .SetMesh(mesh_) - ->SetGhosted(true) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - has_water_src_key_ = true; - - // this flag is just for convenience -- some flow PKs accept a water - // source in m/s not in mol/m^d/s. - water_src_in_meters_ = plist_->get("water source in meters", false); - - if (water_src_in_meters_) { - geochem_src_factor_key_ = water_src_key_; - } else { - // set the coefficient as water source / water density - Teuchos::ParameterList& wc_eval = S_->GetEvaluatorList(geochem_src_factor_key_); - wc_eval.set("evaluator type", "reciprocal evaluator"); - std::vector dep{ water_src_key_, molar_density_key_ }; - wc_eval.set>("dependencies", dep); - wc_eval.set("reciprocal", dep[1]); - } - requireAtNext(geochem_src_factor_key_, Tags::NEXT, *S_) - .SetMesh(mesh_) - ->SetGhosted(true) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - } - } - - // material properties - if (plist_->isSublist("material properties")) { - auto mat_prop_list = Teuchos::sublist(plist_, "material properties"); - mdm_ = CreateMDMPartition(mesh_, mat_prop_list, flag_dispersion_); - - int nblocks = 0; - for (Teuchos::ParameterList::ConstIterator i = mat_prop_list->begin(); i != mat_prop_list->end(); i++) { - if (mat_prop_list->isSublist(mat_prop_list->name(i))) nblocks++; - } - - mat_properties_.resize(nblocks); + auto geochem_list = Teuchos::sublist(sources_list, "geochemical"); + for (const auto& it : *geochem_list) { + std::string specname = it.first; + Teuchos::ParameterList& spec = geochem_list->sublist(specname); - int iblock = 0; - for (Teuchos::ParameterList::ConstIterator i = mat_prop_list->begin(); i != mat_prop_list->end(); i++) { - if (mat_prop_list->isSublist(mat_prop_list->name(i))) { - mat_properties_[iblock] = Teuchos::rcp(new MaterialProperties()); + // source-specific corresponding water source + // in 1.7, remove the default + water_src_keys_[specname] = Keys::readKey(spec, domain_, "water source", + Keys::getVarName(default_water_src_key_)); + // in 1.7, set default to false + water_src_in_meters_[specname] = spec.get("water source in meters", default_water_src_in_meters_); - Teuchos::ParameterList& model_list = mat_prop_list->sublist(mat_prop_list->name(i)); + if (water_src_in_meters_[specname]) { + geochem_src_factor_keys_[specname] = water_src_keys_[specname]; + } else { + Key water_src_varname = Keys::getVarName(water_src_keys_[specname]); + geochem_src_factor_keys_[specname] = Keys::readKey(spec, domain_, "geochem source factor", + water_src_varname + "_geochem_src_factor"); + + // set the coefficient as water source / water density + if (!S_->HasEvaluatorList(geochem_src_factor_keys_[specname])) { + Teuchos::ParameterList& wc_eval = S_->GetEvaluatorList(geochem_src_factor_keys_[specname]); + wc_eval.set("evaluator type", "reciprocal evaluator"); + std::vector dep{ water_src_keys_[specname], molar_dens_key_ }; + wc_eval.set>("dependencies", dep); + wc_eval.set("reciprocal", dep[1]); + } + } - mat_properties_[iblock]->tau[0] = model_list.get("aqueous tortuosity", 0.0); - mat_properties_[iblock]->tau[1] = model_list.get("gaseous tortuosity", 0.0); - mat_properties_[iblock]->regions = - model_list.get>("regions").toVector(); - iblock++; + requireEvaluatorAtNext(geochem_src_factor_keys_[specname], tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted(true) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } } } - // transport diffusion (default is none) - diffusion_phase_.resize(TRANSPORT_NUMBER_PHASES, Teuchos::null); - - if (plist_->isSublist("molecular diffusion")) { - auto diff_list = Teuchos::sublist(plist_, "molecular diffusion"); - if (diff_list->isParameter("aqueous names")) { - diffusion_phase_[0] = Teuchos::rcp(new DiffusionPhase()); - diffusion_phase_[0]->names() = - diff_list->get>("aqueous names").toVector(); - diffusion_phase_[0]->values() = - diff_list->get>("aqueous values").toVector(); - } - - if (diff_list->isParameter("gaseous names")) { - diffusion_phase_[1] = Teuchos::rcp(new DiffusionPhase()); - diffusion_phase_[1]->names() = - diff_list->get>("gaseous names").toVector(); - diffusion_phase_[1]->values() = - diff_list->get>("gaseous values").toVector(); - } - } - + // // create boundary conditions + // -------------------------------------------------------------------------------- if (plist_->isSublist("boundary conditions")) { // -- try tracer-type conditions PK_DomainFunctionFactory factory(mesh_, S_); auto bcs_list = Teuchos::sublist(plist_, "boundary conditions"); - auto conc_bcs_list = Teuchos::sublist(bcs_list, "concentration"); + auto conc_bcs_list = Teuchos::sublist(bcs_list, "mole fraction"); for (const auto& it : *conc_bcs_list) { std::string name = it.first; @@ -446,8 +457,8 @@ Transport_ATS::SetupTransport_() if (bc_type == "domain coupling") { // domain couplings are special -- they always work on all components - Teuchos::RCP bc = - factory.Create(bc_list, "fields", AmanziMesh::Entity_kind::FACE, Kxy_, tag_current_); + Teuchos::RCP bc = factory.Create( + bc_list, "fields", AmanziMesh::Entity_kind::FACE, Teuchos::null, tag_current_); for (int i = 0; i < num_components_; i++) { bc->tcc_names().push_back(component_names_[i]); @@ -462,10 +473,13 @@ Transport_ATS::SetupTransport_() std::size_t last_of = domain_.find_last_of(":"); AMANZI_ASSERT(last_of != std::string::npos); int gid = std::stoi(domain_.substr(last_of + 1, domain_.size())); - bc_list.set("entity_gid_out", gid); + bc_list.set("entity GID", gid); - Teuchos::RCP bc = factory.Create( - bc_list, "boundary concentration", AmanziMesh::Entity_kind::FACE, Kxy_, tag_current_); + Teuchos::RCP bc = factory.Create(bc_list, + "boundary mole fraction", + AmanziMesh::Entity_kind::FACE, + Teuchos::null, + tag_current_); for (int i = 0; i < num_components_; i++) { bc->tcc_names().push_back(component_names_[i]); @@ -477,9 +491,9 @@ Transport_ATS::SetupTransport_() } else { Teuchos::RCP bc = factory.Create(bc_list, - "boundary concentration function", + "boundary mole fraction function", AmanziMesh::Entity_kind::FACE, - Kxy_, + Teuchos::null, tag_current_); bc->set_state(S_); @@ -503,10 +517,10 @@ Transport_ATS::SetupTransport_() for (const auto& it : *geochem_list) { std::string specname = it.first; Teuchos::ParameterList& spec = geochem_list->sublist(specname); + Teuchos::RCP bc = Teuchos::rcp( new TransportBoundaryFunction_Alquimia_Units(spec, mesh_, chem_pk_, chem_engine_)); - bc->set_conversion(1000.0, mol_dens_, true); std::vector& tcc_index = bc->tcc_index(); std::vector& tcc_names = bc->tcc_names(); @@ -529,62 +543,111 @@ Transport_ATS::SetupTransport_() void Transport_ATS::SetupPhysicalEvaluators_() { - // -- water flux - requireAtNext(flux_key_, Tags::NEXT, *S_) + // primary variable + S_->Require(key_, tag_next_, passwd_) .SetMesh(mesh_) ->SetGhosted(true) - ->SetComponent("face", AmanziMesh::Entity_kind::FACE, 1); + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, num_components_); + // ->AddComponent("face", AmanziMesh::Entity_kind::FACE, num_components_); + S_->GetRecordSetW(key_).set_subfieldnames(component_names_); - // -- water saturation - requireAtNext(saturation_key_, Tags::NEXT, *S_) + // -- water flux + requireEvaluatorAtNext(water_flux_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted(true) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(saturation_key_, Tags::CURRENT, *S_); + ->SetComponent("face", AmanziMesh::Entity_kind::FACE, 1); - requireAtNext(porosity_key_, Tags::NEXT, *S_) + // -- water state + requireEvaluatorAtNext(lwc_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted(true) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + requireEvaluatorAtCurrent(lwc_key_, tag_current_, *S_, name_); - requireAtNext(molar_density_key_, Tags::NEXT, *S_) + if (!molar_dens_key_.empty()) { + requireEvaluatorAtNext(molar_dens_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->SetGhosted(true) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + requireEvaluatorAtCurrent(molar_dens_key_, tag_current_, *S_); + } + + // cell volume + requireEvaluatorAtNext(cv_key_, tag_next_, *S_) .SetMesh(mesh_) - ->SetGhosted(true) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); - requireAtCurrent(molar_density_key_, Tags::CURRENT, *S_); - requireAtNext(tcc_key_, tag_next_, *S_, passwd_) + // Need to figure out primary vs secondary -- are both in component names? --ETC + std::vector subfield_names(num_aqueous_); + for (int i = 0; i != num_aqueous_; ++i) subfield_names[i] = component_names_[i]; + requireEvaluatorAtNext(solid_residue_mass_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetGhosted(true) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, num_components_); - S_->GetRecordSetW(tcc_key_).set_subfieldnames(component_names_); - requireAtCurrent(tcc_key_, tag_current_, *S_, passwd_); + ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, num_components_); + + S_->GetRecordSetW(solid_residue_mass_key_).set_subfieldnames(subfield_names); + S_->GetRecordSetW(mass_flux_advection_key_).set_subfieldnames(subfield_names); + S_->GetRecordSetW(mass_flux_diffusion_key_).set_subfieldnames(subfield_names); + + // source term -- at next to match regression tests -- should this be at current? + if (!source_key_.empty()) { + requireEvaluatorAtNext(source_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, num_aqueous_); + S_->GetRecordSetW(source_key_).set_subfieldnames(subfield_names); + } - // CellVolume it may not be used in this PK, but having it makes vis nicer - requireAtNext(cv_key_, tag_next_, *S_) + // This vector stores the conserved amount (in mols) of num_components_ + // transported solutes, plus two for water. + // + // The first water component is given by dt * all water fluxes for which the + // resulting component flux is treated implicitly (notably just + // DomainCoupling fluxes like infiltration, which must be able to take all + // the transported quantity.) This is used to invert for the new + // concentration. + // + // The second water component is given by dt * all water fluxes for which the + // resulting component flux is treated explicitly (advection, most + // sources/sinks of water). Then, we can compute: + // + // (lwc_new - lwc_old) - (Q_implicit + Q_explicit) * dt + // + // The result is a "water balance error" -- in many problems it will be + // zero, but in problems where there are sources/sinks of water with no + // corresponding transport of chemical species, it will be this amount. + // Examples of this include evaporation, freezing of liquid --> solid water, + // etc. + // + // solute mass advective flux + requireEvaluatorAtNext(mass_flux_advection_key_, tag_next_, *S_) .SetMesh(mesh_) - ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + ->SetGhosted(true) + ->SetComponent("face", AmanziMesh::Entity_kind::FACE, num_aqueous_); + S_->GetRecordSetW(mass_flux_advection_key_).set_subfieldnames(subfield_names); - // Need to figure out primary vs secondary -- are both in component names? --ETC - std::vector primary_names = component_names_; - requireAtNext(solid_residue_mass_key_, tag_next_, *S_, name_) + // solute mass diffusive flux + requireEvaluatorAtNext(mass_flux_diffusion_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted(true) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, num_components_); - S_->GetRecordSetW(solid_residue_mass_key_).set_subfieldnames(primary_names); - // This vector stores the conserved amount (in mols) of num_components_ transported solutes, plus two for water. - // - The first water component is given by the water content (in mols) at the current (old) time plus dt * all fluxes treated explictly. - // - The second water component is given by the water content at the new time plus dt * all fluxes treated implicitly - // (notably just DomainCoupling fluxes, which must be able to take all the transported quantity.) + ->SetComponent("face", AmanziMesh::Entity_kind::FACE, num_aqueous_); + S_->GetRecordSetW(mass_flux_diffusion_key_).set_subfieldnames(subfield_names); + + // source term -- at next to match regression tests -- should this be at current? + if (!source_key_.empty()) { + requireEvaluatorAtNext(source_key_, tag_next_, *S_) + .SetMesh(mesh_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, num_aqueous_); + S_->GetRecordSetW(source_key_).set_subfieldnames(subfield_names); + } // Note that component_names includes secondaries, but we only need primaries - primary_names.emplace_back("H2O_old"); - primary_names.emplace_back("H2O_new"); - requireAtNext(conserve_qty_key_, tag_next_, *S_, name_) + subfield_names.emplace_back("H2O_sources_implicit"); + subfield_names.emplace_back("H2O_sources_explicit"); + requireEvaluatorAtNext(conserve_qty_key_, tag_next_, *S_, name_) .SetMesh(mesh_) ->SetGhosted(true) - ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, num_components_ + 2); - S_->GetRecordSetW(conserve_qty_key_).set_subfieldnames(primary_names); + ->SetComponent("cell", AmanziMesh::Entity_kind::CELL, num_aqueous_ + 2); + S_->GetRecordSetW(conserve_qty_key_).set_subfieldnames(subfield_names); } @@ -595,39 +658,12 @@ void Transport_ATS::Initialize() { Teuchos::OSTab tab = vo_->getOSTab(); - - // Set initial values for transport variables. - if (plist_->isSublist("initial condition")) { - S_->GetRecordW(tcc_key_, tag_next_, passwd_).Initialize(plist_->sublist("initial condition")); - } + PK_Physical_Default::Initialize(); // initialize missed fields InitializeFields_(); - // make this go away -- local pointers to data are a no-no! --ETC - tcc_tmp = S_->GetPtrW(tcc_key_, tag_next_, passwd_); - tcc = S_->GetPtrW(tcc_key_, tag_current_, passwd_); - - ws_ = S_->Get(saturation_key_, Tags::NEXT).ViewComponent("cell", false); - ws_prev_ = S_->Get(saturation_key_, Tags::CURRENT).ViewComponent("cell", false); - mol_dens_ = S_->Get(molar_density_key_, Tags::NEXT).ViewComponent("cell", false); - mol_dens_prev_ = - S_->Get(molar_density_key_, Tags::CURRENT).ViewComponent("cell", false); - - // upwind - IdentifyUpwindCells_(); - - // mechanical dispersion - if (flag_dispersion_) CalculateAxiSymmetryDirection_(); - - // boundary conditions initialization - double time = t_physics_; - - const Epetra_MultiVector& flux = *S_->Get(flux_key_, Tags::NEXT).ViewComponent("face", true); - CheckInfluxBC_(flux); - - // Move to Setup() with other sources? --ETC - // This must be called after S_->setup() since "water_source" data not created before this step. --PL + // geochemical sources can now be set up if (plist_->isSublist("source terms")) { auto sources_list = Teuchos::sublist(plist_, "source terms"); if (sources_list->isSublist("geochemical")) { @@ -638,37 +674,57 @@ Transport_ATS::Initialize() for (const auto& it : *geochem_list) { std::string specname = it.first; Teuchos::ParameterList& spec = geochem_list->sublist(specname); + Teuchos::RCP src = Teuchos::rcp( new TransportSourceFunction_Alquimia_Units(spec, mesh_, chem_pk_, chem_engine_)); - if (S_->HasEvaluator(geochem_src_factor_key_, Tags::NEXT)) { - S_->GetEvaluator(geochem_src_factor_key_, Tags::NEXT).Update(*S_, name_); + if (S_->HasEvaluator(geochem_src_factor_keys_[specname], tag_next_)) { + S_->GetEvaluator(geochem_src_factor_keys_[specname], tag_next_).Update(*S_, name_); } auto src_factor = - S_->Get(geochem_src_factor_key_, Tags::NEXT).ViewComponent("cell", false); + S_->Get(geochem_src_factor_keys_[specname], tag_next_).ViewComponent("cell", false); src->set_conversion(-1000., src_factor, false); - for (const auto& n : src->tcc_names()) { src->tcc_index().push_back(FindComponentNumber_(n)); } - + for (const auto& n : src->tcc_names()) { + src->tcc_index().push_back(FindComponentNumber_(n)); + } srcs_.push_back(src); } #endif } } - // Temporarily Transport hosts Henry law. - PrepareAirWaterPartitioning_(); + // can also now setup the joint diffusion/dispersion workspace tensor + // + // This cannot be done in setup because it needs the rank? --ETC + int D_rank = -1; + int D_dim = mesh_->getSpaceDimension(); + if (has_diffusion_) D_rank = 1; // scalar + if (has_dispersion_) { + // dispersion rank is 1 or 2 + D_rank = + S_->Require(dispersion_tensor_key_, tag_next_).get_rank(); + } + if (D_rank >= 0) { + CompositeVectorSpace D_space; + D_space.SetMesh(mesh_)->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + D_ = Teuchos::rcp(new TensorVector(D_space, D_dim, D_rank, false)); + } + + // compute the stable dt for the initial timestep + dt_stable_ = ComputeStableTimeStep_(); if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { - *vo_->os() << "Number of components: " << tcc->size() << std::endl - << "cfl=" << cfl_ << " spatial/temporal discretization: " << spatial_disc_order_ - << " " << temporal_disc_order_ << std::endl; - *vo_->os() << vo_->color("green") << "Initalization of PK is complete." << vo_->reset() - << std::endl + *vo_->os() << "Number of components: " << num_components_ << std::endl + << " aqueous: " << num_aqueous_ << std::endl + << " "; + for (int i = 0; i != num_aqueous_; ++i) *vo_->os() << component_names_[i] << ", "; + + *vo_->os() << "cfl=" << cfl_ << " spatial/temporal discretization: " << adv_spatial_disc_order_ + << " " << temporal_disc_order_ << std::endl << std::endl; } - ComputeStableTimeStep_(); } @@ -681,7 +737,18 @@ Transport_ATS::InitializeFields_() Teuchos::OSTab tab = vo_->getOSTab(); S_->GetW(solid_residue_mass_key_, tag_next_, name_).PutScalar(0.0); S_->GetRecordW(solid_residue_mass_key_, tag_next_, name_).set_initialized(); - S_->GetW(conserve_qty_key_, tag_next_, name_).PutScalar(0.0); + + // initialize conserved quantity + S_->GetEvaluator(lwc_key_, tag_next_).Update(*S_, name_); + const Epetra_MultiVector& lwc = + *S_->Get(lwc_key_, tag_next_).ViewComponent("cell", false); + const Epetra_MultiVector& tcc = + *S_->Get(key_, tag_next_).ViewComponent("cell", false); + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", false); + for (int i = 0; i != num_aqueous_; ++i) { + conserve_qty(i)->Multiply(1., *lwc(0), *tcc(i), 0.); + } S_->GetRecordW(conserve_qty_key_, tag_next_, name_).set_initialized(); } @@ -699,108 +766,70 @@ Transport_ATS::InitializeFields_() double Transport_ATS::ComputeStableTimeStep_() { + double dt = TRANSPORT_LARGE_TIME_STEP; + // Get flux at faces for time NEXT IdentifyUpwindCells_(); - // Total concentration at current tag - tcc = S_->GetPtrW(tcc_key_, tag_current_, passwd_); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell"); + int ncells_owned = S_->GetMesh(domain_)->getNumEntities(AmanziMesh::Entity_kind::CELL, + AmanziMesh::Parallel_kind::OWNED); - // flux at flow tag - const Epetra_MultiVector& flux = *S_->Get(flux_key_, Tags::NEXT).ViewComponent("face", true); + // flux at next tag + S_->GetEvaluator(water_flux_key_, tag_next_).Update(*S_, name_); + const CompositeVector& flux_cv = S_->Get(water_flux_key_, tag_next_); + flux_cv.ScatterMasterToGhosted(); + const Epetra_MultiVector& flux = *flux_cv.ViewComponent("face", true); - int ncells_all = - mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); - int nfaces_all = - mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::ALL); + // extensive liquid water content at start and end of step + S_->GetEvaluator(lwc_key_, tag_next_).Update(*S_, name_); + const Epetra_MultiVector& lwc_old = + *S_->Get(lwc_key_, tag_current_).ViewComponent("cell"); + const Epetra_MultiVector& lwc_new = + *S_->Get(lwc_key_, tag_next_).ViewComponent("cell"); - // loop over faces and accumulate upwinding fluxes - std::vector total_outflux(ncells_all, 0.0); + // loop over ALL faces and accumulate outgoing fluxes from each OWNED cell + std::vector total_outflux(ncells_owned, 0.0); - for (int f = 0; f < nfaces_all; f++) { + for (int f = 0; f < flux.MyLength(); f++) { int c = (*upwind_cell_)[f]; - if (c >= 0) { total_outflux[c] += std::abs(flux[0][f]); } + if (c >= 0 && c < ncells_owned) { + total_outflux[c] += std::abs(flux[0][f]); + } } - ComputeSinks2TotalOutFlux_(tcc_prev, total_outflux, 0, num_aqueous_ - 1); - // loop over cells and calculate minimal timestep - double vol = 0.; - double ws_min_dt = 0.; - double outflux_min_dt = 0.; - dt_ = TRANSPORT_LARGE_TIME_STEP; - double dt_cell = TRANSPORT_LARGE_TIME_STEP; - int cmin_dt = 0; + double min_dt_lwc = 0.; + double min_dt_outflux = 0.; + int min_dt_cell = 0; - S_->GetEvaluator(porosity_key_, Tags::NEXT).Update(*S_, name_); - const Epetra_MultiVector& phi = *S_->Get(porosity_key_, Tags::NEXT).ViewComponent("cell", false); - - for (int c = 0; c < tcc_prev.MyLength(); c++) { + for (int c = 0; c != ncells_owned; ++c) { double outflux = total_outflux[c]; + double min_lwc = std::min(lwc_old[0][c], lwc_new[0][c]); + double dt_cell = TRANSPORT_LARGE_TIME_STEP; - if ((outflux > 0) && ((*ws_prev_)[0][c] > 0) && ((*ws_)[0][c] > 0) && (phi[0][c] > 0)) { - vol = mesh_->getCellVolume(c); - dt_cell = vol * (*mol_dens_)[0][c] * phi[0][c] * - std::min((*ws_prev_)[0][c], (*ws_)[0][c]) / outflux; + if (outflux > 0 && min_lwc > 0) { + dt_cell = min_lwc / outflux; } - if (dt_cell < dt_) { - dt_ = dt_cell; - cmin_dt = c; - ws_min_dt = std::min((*ws_prev_)[0][c], (*ws_)[0][c]); - outflux_min_dt = total_outflux[c]; + + if (dt_cell < dt) { + dt = dt_cell; + min_dt_cell = c; + min_dt_lwc = min_lwc; + min_dt_outflux = total_outflux[c]; } } - if (spatial_disc_order_ == 2) dt_ /= 2; + if (adv_spatial_disc_order_ == 2) dt /= 2; // communicate global timestep - double dt_tmp = dt_; - const Epetra_Comm& comm = ws_prev_->Comm(); - comm.MinAll(&dt_tmp, &dt_, 1); + double dt_tmp = dt; + auto comm = mesh_->getComm(); + comm->MinAll(&dt_tmp, &dt, 1); // incorporate developers and CFL constraints - dt_ = std::min(dt_, dt_max_); - dt_ *= cfl_; - - // print optional diagnostics using maximum cell id as the filter - auto& cell_map = mesh_->getMap(AmanziMesh::Entity_kind::CELL, false); - if (vo_->os_OK(Teuchos::VERB_HIGH)) { - int cmin_dt_unique = (std::abs(dt_tmp * cfl_ - dt_) < 1e-6 * dt_) ? cell_map.GID(cmin_dt) : -2; - - int cmin_dt_tmp = cmin_dt_unique; - comm.MaxAll(&cmin_dt_tmp, &cmin_dt_unique, 1); - int min_pid = -1; - - double tmp_package[6]; - if (cell_map.GID(cmin_dt) == cmin_dt_unique) { - const AmanziGeometry::Point& p = mesh_->getCellCentroid(cmin_dt); - - min_pid = comm.MyPID(); - tmp_package[0] = ws_min_dt; - tmp_package[1] = outflux_min_dt; - tmp_package[2] = p[0]; - tmp_package[3] = p[1]; - if (p.dim() == 3) - tmp_package[4] = p[2]; - else - tmp_package[4] = 0.; - tmp_package[5] = p.dim(); - } - - int min_pid_tmp = min_pid; - comm.MaxAll(&min_pid_tmp, &min_pid, 1); - comm.Broadcast(tmp_package, 6, min_pid); - - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "Stable timestep " << dt_ << " is computed at (" << tmp_package[2] << ", " - << tmp_package[3]; - if (std::abs(3 - tmp_package[5]) < 1e-10) *vo_->os() << ", " << tmp_package[4]; - *vo_->os() << ")" << std::endl; - *vo_->os() << "Stable timestep " << dt_ << " is limited by saturation/ponded_depth " - << tmp_package[0] << " and " - << "output flux " << tmp_package[1] << std::endl; - } - return dt_; + dt = std::min(dt, dt_max_); + dt *= cfl_; + return dt; } @@ -810,7 +839,7 @@ Transport_ATS::ComputeStableTimeStep_() double Transport_ATS::get_dt() { - return dt_; + return dt_stable_; } @@ -823,353 +852,207 @@ bool Transport_ATS::AdvanceStep(double t_old, double t_new, bool reinit) { bool failed = false; - double dt_MPC = t_new - t_old; + double dt = t_new - t_old; Teuchos::OSTab tab = vo_->getOSTab(); if (vo_->os_OK(Teuchos::VERB_LOW)) *vo_->os() << "----------------------------------------------------------------" << std::endl - << "Advancing: t0 = " << S_->get_time(tag_current_) - << " t1 = " << S_->get_time(tag_next_) << " h = " << dt_MPC << std::endl + << "Advancing: t0 = " << t_old << " t1 = " << t_new << " h = " << dt << std::endl << "----------------------------------------------------------------" << std::endl; + AMANZI_ASSERT(std::abs(S_->get_time(tag_current_) - t_old) < 1.e-4); + AMANZI_ASSERT(std::abs(S_->get_time(tag_next_) - t_new) < 1.e-4); + db_->WriteCellInfo(true); + + // check the stable step size again -- flow can now be computed at the + // correct, new time, and may have changed, resulting in a smaller dt. + // + // By failing the step, it will get repeated with the smaller dt, again + // potentially recomputing a flow field, but should be closer. + dt_stable_ = ComputeStableTimeStep_(); + if (dt > dt_stable_ + 1.e-4) { + if (vo_->os_OK(Teuchos::VERB_LOW)) + *vo_->os() << "Failed step: requested dt = " << dt << " > stable dt = " << dt_stable_ + << std::endl; + return true; + } - // NOTE: these "flow" variables are hard-coded as Tag::NEXT assuming that - // flow is supercycled relative to transport and therefore we must - // interpolate the flow variables from the "global" CURRENT+NEXT to the - // subcycled current + next. This would be fixed by having evaluators that - // interpolate in time, allowing transport to not have to know how flow is - // being integrated... FIXME --etc - S_->GetEvaluator(flux_key_, Tags::NEXT).Update(*S_, name_); - S_->Get(flux_key_, Tags::NEXT).ScatterMasterToGhosted("face"); - - S_->GetEvaluator(saturation_key_, Tags::NEXT).Update(*S_, name_); - S_->GetEvaluator(saturation_key_, Tags::CURRENT).Update(*S_, name_); - S_->GetEvaluator(molar_density_key_, Tags::NEXT).Update(*S_, name_); - S_->GetEvaluator(molar_density_key_, Tags::CURRENT).Update(*S_, name_); - + if (vo_->os_OK(Teuchos::VERB_HIGH) ) *vo_->os() << "Water state:" << std::endl; + std::vector vnames{ "lwc_old", "lwc_new" }; + std::vector> vecs{ + S_->GetPtr(lwc_key_, tag_current_).ptr(), + S_->GetPtr(lwc_key_, tag_next_).ptr(), + }; + db_->WriteVectors(vnames, vecs); + db_->WriteVector("mol_frac_old", + S_->GetPtr(key_, tag_current_).ptr(), + true, + S_->GetRecordSet(key_).subfieldnames()); + + // update geochemical condition conversions #ifdef ALQUIMIA_ENABLED - if (plist_->sublist("source terms").isSublist("geochemical")) { - for (auto& src : srcs_) { - if (src->getType() == DomainFunction_kind::ALQUIMIA) { - // src_factor = water_source / molar_density_liquid, both flow - // quantities, see note above. - S_->GetEvaluator(geochem_src_factor_key_, Tags::NEXT).Update(*S_, name_); - auto src_factor = S_->Get(geochem_src_factor_key_, Tags::NEXT) - .ViewComponent("cell", false); - Teuchos::RCP src_alq = - Teuchos::rcp_dynamic_cast(src); - src_alq->set_conversion(-1000, src_factor, false); - } + for (auto& src : srcs_) { + if (src->getType() == DomainFunction_kind::ALQUIMIA) { + Key geochem_src_factor_key = geochem_src_factor_keys_[src->getName()]; + + S_->GetEvaluator(geochem_src_factor_key, tag_next_).Update(*S_, name_); + auto src_factor = + S_->Get(geochem_src_factor_key, tag_next_).ViewComponent("cell", false); + Teuchos::RCP src_alq = + Teuchos::rcp_dynamic_cast(src); + src_alq->set_conversion(-1000, src_factor, false); } } - if (plist_->sublist("boundary conditions").isSublist("geochemical")) { - for (auto& bc : bcs_) { - if (bc->getType() == DomainFunction_kind::ALQUIMIA) { - Teuchos::RCP bc_alq = - Teuchos::rcp_dynamic_cast(bc); - bc_alq->set_conversion(1000.0, mol_dens_, true); - } + for (auto& bc : bcs_) { + if (bc->getType() == DomainFunction_kind::ALQUIMIA) { + Teuchos::RCP bc_alq = + Teuchos::rcp_dynamic_cast(bc); + + S_->GetEvaluator(molar_dens_key_, tag_next_).Update(*S_, name_); + auto molar_dens = + S_->Get(molar_dens_key_, tag_next_).ViewComponent("cell", false); + bc_alq->set_conversion(1000.0, molar_dens, true); } } #endif - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell"); - db_->WriteVector("tcc_old", tcc.ptr()); - - // calculate stable timestep - double dt_shift = 0.0, dt_global = dt_MPC; - double time = t_old; - if (time >= 0.0) { - t_physics_ = time; - dt_shift = time - S_->get_time(tag_current_); - dt_global = S_->get_time(tag_next_) - S_->get_time(tag_current_); - AMANZI_ASSERT(std::abs(dt_global - dt_MPC) < 1.e-4); - } - - ComputeStableTimeStep_(); - double dt_stable = dt_; // advance routines override dt_ - double dt_sum = 0.0; - double dt_cycle; - dt_cycle = std::min(dt_stable, dt_MPC); - - Tag water_tag_current = Tags::CURRENT; - Tag water_tag_next = Tags::NEXT; - - S_->GetEvaluator(porosity_key_, Tags::NEXT).Update(*S_, name_); - const Epetra_MultiVector& phi = *S_->Get(porosity_key_, Tags::NEXT).ViewComponent("cell", false); - - db_->WriteVector("sat_old", - S_->GetPtr(saturation_key_, water_tag_current).ptr()); - db_->WriteVector("sat_new", S_->GetPtr(saturation_key_, water_tag_next).ptr()); - db_->WriteVector("mol_dens_old", - S_->GetPtr(molar_density_key_, water_tag_current).ptr()); - db_->WriteVector("mol_dens_new", - S_->GetPtr(molar_density_key_, water_tag_next).ptr()); - db_->WriteVector("poro", S_->GetPtr(porosity_key_, Tags::NEXT).ptr()); - - for (int c = 0; c < tcc_prev.MyLength(); c++) { - double vol_phi_ws_den; - vol_phi_ws_den = - mesh_->getCellVolume(c) * phi[0][c] * (*ws_prev_)[0][c] * (*mol_dens_prev_)[0][c]; - for (int i = 0; i < num_aqueous_ + num_gaseous_; i++) { - mass_solutes_stepstart_[i] = tcc_prev[i][c] * vol_phi_ws_den; - } + // update boundary conditions + for (int i = 0; i < bcs_.size(); i++) { + bcs_[i]->Compute(t_old, t_new); } - int ncycles = 0, swap = 1; - while (dt_sum < dt_MPC - 1e-6) { - // update boundary conditions - time = t_physics_ + dt_cycle / 2; - for (int i = 0; i < bcs_.size(); i++) { bcs_[i]->Compute(t_physics_, t_physics_ + dt_cycle); } - - double dt_try = dt_MPC - dt_sum; - double tol = 1e-10 * (dt_try + dt_stable); - bool final_cycle = false; - - if (dt_try >= 2 * dt_stable) { - dt_cycle = dt_stable; - } else if (dt_try > dt_stable + tol) { - dt_cycle = dt_try / 2; - } else { - dt_cycle = dt_try; - final_cycle = true; - } - - t_physics_ += dt_cycle; - dt_sum += dt_cycle; - - if (spatial_disc_order_ == 1) { // temporary solution (lipnikov@lanl.gov) - AdvanceDonorUpwind_(dt_cycle); - } else if (spatial_disc_order_ == 2 && temporal_disc_order_ == 1) { - AdvanceSecondOrderUpwindRK1_(dt_cycle); - } else if (spatial_disc_order_ == 2 && temporal_disc_order_ == 2) { - AdvanceSecondOrderUpwindRK2_(dt_cycle); - } else { - AMANZI_ASSERT(false); - } - - if (!final_cycle) { // rotate concentrations (we need new memory for tcc) - // should not be allocating here, we have tons of memory for tcc --ETC - tcc = Teuchos::RCP(new CompositeVector(*tcc_tmp)); - } - - ncycles++; + // advance advection term + if (temporal_disc_order_ == 1) { + AdvanceAdvectionSources_RK1_(t_old, t_new, adv_spatial_disc_order_); + } else if (temporal_disc_order_ == 2) { + AdvanceAdvectionSources_RK2_(t_old, t_new, adv_spatial_disc_order_); + } else { + AMANZI_ASSERT(false); } - dt_ = dt_stable; // restore the original timestep (just in case) - - Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", false); - Advance_Dispersion_Diffusion_(t_old, t_new); - // optional Henry Law for the case of gas diffusion - if (henry_law_) MakeAirWaterPartitioning_(); + // advance dispersion and diffusion term + AdvanceDispersionDiffusion_(t_old, t_new); // statistics output - nsubcycles = ncycles; - if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { - *vo_->os() << ncycles << " sub-cycles, dt_stable=" << units_.OutputTime(dt_stable) - << " [sec] dt_MPC=" << units_.OutputTime(dt_MPC) << " [sec]" << std::endl; - - PrintSoluteExtrema(tcc_next, dt_MPC); - } - - ComputeStableTimeStep_(); + const Epetra_MultiVector& tcc_new = + *S_->Get(key_, tag_next_).ViewComponent("cell"); ChangedSolutionPK(tag_next_); + db_->WriteVector("mol_frac_new", + S_->GetPtr(key_, tag_next_).ptr(), + true, + S_->GetRecordSet(key_).subfieldnames()); return failed; } void -Transport_ATS ::Advance_Dispersion_Diffusion_(double t_old, double t_new) +Transport_ATS ::AdvanceDispersionDiffusion_(double t_old, double t_new) { - double dt_MPC = t_new - t_old; - // We define tracer as the species #0 as calculate some statistics. - Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", false); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell"); - int num_components_ = tcc_prev.NumVectors(); - - bool flag_diffusion(false); - for (int i = 0; i < 2; i++) { - if (diffusion_phase_[i] != Teuchos::null) { - if (diffusion_phase_[i]->values().size() != 0) flag_diffusion = true; + if (!has_diffusion_ && !has_dispersion_) return; + double dt = t_new - t_old; + + Epetra_MultiVector& tcc_new = + *S_->GetW(key_, tag_next_, passwd_).ViewComponent("cell", false); + + // needed for diffusion coefficent and for accumulation term + const Epetra_MultiVector& lwc = + *S_->Get(lwc_key_, tag_next_).ViewComponent("cell", false); + const Epetra_MultiVector& cv = + *S_->Get(cv_key_, tag_next_).ViewComponent("cell", false); + + // + // first step -- aqueous dispersion + diffusion + // + if (has_dispersion_) { + // + // The dispersion tensor is consistent for all aqueous phase components. + S_->GetEvaluator(dispersion_tensor_key_, tag_next_).Update(*S_, name_); + (*D_) = S_->Get(dispersion_tensor_key_, tag_next_); + + // scale by (volumetric) liquid water content + for (int c = 0; c != lwc.MyLength(); ++c) { + (*D_)[c] *= (lwc[0][c] / cv[0][c]); } + } else { + D_->PutScalar(0.); } - if (flag_diffusion) { - // no molecular diffusion if all tortuosities are zero. - double tau(0.0); - for (int i = 0; i < mat_properties_.size(); i++) { - tau += mat_properties_[i]->tau[0] + mat_properties_[i]->tau[1]; - } - if (tau == 0.0) flag_diffusion = false; - } - - if (flag_dispersion_ || flag_diffusion) { - // default boundary conditions (none inside domain and Neumann on its boundary) - Teuchos::RCP bc_dummy = Teuchos::rcp( - new Operators::BCs(mesh_, AmanziMesh::Entity_kind::FACE, WhetStone::DOF_Type::SCALAR)); - auto& bc_model = bc_dummy->bc_model(); - auto& bc_value = bc_dummy->bc_value(); - PopulateBoundaryData_(bc_model, bc_value, -1); - - // diffusion operator - Teuchos::ParameterList& op_list = plist_->sublist("diffusion"); - op_list.set("inverse", plist_->sublist("inverse")); - Operators::PDE_DiffusionFactory opfactory; - Teuchos::RCP op1 = opfactory.Create(op_list, mesh_, bc_dummy); - op1->SetBCs(bc_dummy, bc_dummy); - Teuchos::RCP op = op1->global_operator(); - Teuchos::RCP op2 = - Teuchos::rcp(new Operators::PDE_Accumulation(AmanziMesh::Entity_kind::CELL, op)); - - const CompositeVectorSpace& cvs = op1->global_operator()->DomainMap(); - CompositeVector sol(cvs), factor(cvs), factor0(cvs), source(cvs), zero(cvs); - zero.PutScalar(0.0); - - S_->GetEvaluator(porosity_key_, Tags::NEXT).Update(*S_, name_); - const Epetra_MultiVector& phi = *S_->Get(porosity_key_, Tags::NEXT).ViewComponent("cell", false); - - // populate the dispersion operator (if any) - if (flag_dispersion_) { - const Epetra_MultiVector& flux = *S_->Get(flux_key_, Tags::NEXT).ViewComponent("face", true); - CalculateDispersionTensor_(flux, phi, *ws_, *mol_dens_); - } - - int phase; // transport phase -- 0: liquid, 1: gas - int num_itrs(0); - bool flag_op1(true); - double md_change, md_old(0.0), md_new; // molecular diffusion - double residual(0.0); - - // Disperse and diffuse aqueous components - for (int i = 0; i < num_aqueous_; i++) { - FindDiffusionValue_(component_names_[i], &md_new, &phase); - md_change = md_new - md_old; - md_old = md_new; - - if (md_change != 0.0) { - CalculateDiffusionTensor_(md_change, phase, phi, *ws_, *mol_dens_); - flag_op1 = true; - } - - // set initial guess - Epetra_MultiVector& sol_cell = *sol.ViewComponent("cell"); - for (int c = 0; c < sol_cell.MyLength(); c++) { sol_cell[0][c] = tcc_next[i][c]; } - if (sol.HasComponent("face")) { sol.ViewComponent("face")->PutScalar(0.0); } - - if (flag_op1) { - op->Init(); - Teuchos::RCP> Dptr = Teuchos::rcpFromRef(D_); - op1->Setup(Dptr, Teuchos::null, Teuchos::null); - op1->UpdateMatrices(Teuchos::null, Teuchos::null); - - // add accumulation term - Epetra_MultiVector& fac = *factor.ViewComponent("cell"); - for (int c = 0; c < fac.MyLength(); c++) { - fac[0][c] = phi[0][c] * (*ws_)[0][c] * (*mol_dens_)[0][c]; - } - op2->AddAccumulationDelta(sol, factor, factor, dt_MPC, "cell"); - op1->ApplyBCs(true, true, true); - - } else { - Epetra_MultiVector& rhs_cell = *op->rhs()->ViewComponent("cell"); - for (int c = 0; c < rhs_cell.MyLength(); c++) { - double tmp = - mesh_->getCellVolume(c) * (*ws_)[0][c] * phi[0][c] * (*mol_dens_)[0][c] / dt_MPC; - rhs_cell[0][c] = tcc_next[i][c] * tmp; - } - } - - CompositeVector& rhs = *op->rhs(); - int ierr = op->ApplyInverse(rhs, sol); - - if (ierr != 0) { - Errors::Message msg("TransportExplicit_PK solver failed with message: \""); - msg << op->returned_code_string() << "\""; - Exceptions::amanzi_throw(msg); - } - - residual += op->residual(); - num_itrs += op->num_itrs(); - - for (int c = 0; c < sol_cell.MyLength(); c++) { tcc_next[i][c] = sol_cell[0][c]; } - if (sol.HasComponent("face")) { - if (tcc_tmp->HasComponent("boundary_face")) { - Epetra_MultiVector& tcc_tmp_bf = *tcc_tmp->ViewComponent("boundary_face", false); - Epetra_MultiVector& sol_faces = *sol.ViewComponent("face", false); - const Epetra_Map& vandalay_map = - mesh_->getMap(AmanziMesh::Entity_kind::BOUNDARY_FACE, false); - const Epetra_Map& face_map = mesh_->getMap(AmanziMesh::Entity_kind::FACE, false); - int nbfaces = tcc_tmp_bf.MyLength(); - for (int bf = 0; bf != nbfaces; ++bf) { - AmanziMesh::Entity_ID f = face_map.LID(vandalay_map.GID(bf)); - tcc_tmp_bf[i][bf] = sol_faces[i][f]; - } + // we track only the difference in molecular diffusion from component to + // component -- if they don't exist or stay the same, the matrices do not + // change and can be reused. + double md_old(0.0); + + for (int i = 0; i != num_aqueous_; ++i) { + // add molecular diffusion to the dispersion tensor + bool changed_tensor(false); + if (has_diffusion_) { + double md_new = molec_diff_[component_names_[i]] * tortuosity_["aqueous"]; + double md_change = md_new - md_old; + if (std::abs(md_change) > 1.e-12) { + // shift the tensor diagonal by the lwc * delta diff coef + for (int c = 0; c != cv.MyLength(); ++c) { + (*D_)[c] += md_change * lwc[0][c] / cv[0][c]; } + md_old = md_new; + changed_tensor = true; } } - // Diffuse aqueous components. We ignore dispersion - // tensor (D is reset). Inactive cells (s[c] = 1 and D_[c] = 0) - // are treated with a hack of the accumulation term. - D_.clear(); - md_old = 0.0; - for (int i = num_aqueous_; i < num_components_; i++) { - FindDiffusionValue_(component_names_[i], &md_new, &phase); - md_change = md_new - md_old; - md_old = md_new; - - if (md_change != 0.0 || i == num_aqueous_) { - CalculateDiffusionTensor_(md_change, phase, phi, *ws_, *mol_dens_); - } + // + // apply the diffusion operator + // + // -- set initial guess + Epetra_MultiVector& diff_sol_cell = *diff_sol_->ViewComponent("cell", false); + *diff_sol_cell(0) = *tcc_new(i); + if (diff_sol_->HasComponent("face")) { + diff_sol_->ViewComponent("face", false)->PutScalar(0.0); + } - // set initial guess - Epetra_MultiVector& sol_cell = *sol.ViewComponent("cell"); - for (int c = 0; c < sol_cell.MyLength(); c++) { sol_cell[0][c] = tcc_next[i][c]; } - if (sol.HasComponent("face")) { sol.ViewComponent("face")->PutScalar(0.0); } + // -- build the matrices if needed + if (changed_tensor || i == 0) { + // update mass, stiffness matrices of diffusion operator + diff_global_op_->Init(); + diff_op_->SetTensorCoefficient(Teuchos::rcpFromRef(D_->data)); + diff_op_->UpdateMatrices(Teuchos::null, Teuchos::null); - op->Init(); - Teuchos::RCP> Dptr = Teuchos::rcpFromRef(D_); - op1->Setup(Dptr, Teuchos::null, Teuchos::null); - op1->UpdateMatrices(Teuchos::null, Teuchos::null); + // add accumulation term + diff_acc_op_->AddAccumulationTerm( + S_->Get(lwc_key_, tag_next_), dt, "cell", false); + } - // add boundary conditions and sources for gaseous components - PopulateBoundaryData_(bc_model, bc_value, i); + // whether or not diffusion operator is changed, RHS is different + Epetra_MultiVector& rhs_cell = *diff_global_op_->rhs()->ViewComponent("cell"); + for (int c = 0; c < rhs_cell.MyLength(); c++) { + rhs_cell[0][c] = lwc[0][c] / dt * tcc_new[i][c]; + } + // apply BCs -- must always do + diff_op_->ApplyBCs(true, true, true); - Epetra_MultiVector& rhs_cell = *op->rhs()->ViewComponent("cell"); - ComputeAddSourceTerms_(t_new, 1.0, rhs_cell, i, i); - op1->ApplyBCs(true, true, true); + // get diffusive mass fluxes + Teuchos::RCP cq_flux = + S_->GetPtrW(mass_flux_diffusion_key_, tag_next_, name_); - // add accumulation term - Epetra_MultiVector& fac1 = *factor.ViewComponent("cell"); - Epetra_MultiVector& fac0 = *factor0.ViewComponent("cell"); + // get a sliced vector of the ith component + Teuchos::RCP cq_flux_i = cq_flux->GetVector(i); - for (int c = 0; c < fac0.MyLength(); c++) { - fac1[0][c] = phi[0][c] * (1.0 - (*ws_)[0][c]) * (*mol_dens_)[0][c]; - fac0[0][c] = phi[0][c] * (1.0 - (*ws_prev_)[0][c]) * (*mol_dens_prev_)[0][c]; - if ((*ws_)[0][c] == 1.0) fac1[0][c] = 1.0 * (*mol_dens_)[0][c]; // hack so far - } - op2->AddAccumulationDelta(sol, factor0, factor, dt_MPC, "cell"); - - CompositeVector& rhs = *op->rhs(); - int ierr = op->ApplyInverse(rhs, sol); - if (ierr != 0) { - Errors::Message msg("Transport_PK solver failed with message: \""); - msg << op->returned_code_string() << "\""; - Exceptions::amanzi_throw(msg); - } + // compute the flux for the ith component + diff_op_->UpdateFlux(diff_sol_.ptr(), cq_flux_i.ptr()); - residual += op->residual(); - num_itrs += op->num_itrs(); + // -- apply the inverse + CompositeVector& rhs = *diff_global_op_->rhs(); + int ierr = diff_global_op_->ApplyInverse(rhs, *diff_sol_); - for (int c = 0; c < tcc_next.MyLength(); c++) { tcc_next[i][c] = sol_cell[0][c]; } + if (ierr != 0) { + Errors::Message msg("TransportExplicit_PK solver failed with message: \""); + msg << diff_global_op_->returned_code_string() << "\""; + Exceptions::amanzi_throw(msg); } - if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { - Teuchos::OSTab tab = vo_->getOSTab(); - *vo_->os() << "dispersion solver ||r||=" << residual / num_components_ - << " itrs=" << num_itrs / num_components_ << std::endl; - } + // -- copy back the solution + *tcc_new(i) = *(*diff_sol_->ViewComponent("cell", false))(0); } + + // NOTE: here was gas diffusion! --ETC } @@ -1183,549 +1066,298 @@ Transport_ATS::CommitStep(double t_old, double t_new, const Tag& tag_next) if (vo_->os_OK(Teuchos::VERB_EXTREME)) *vo_->os() << "Commiting state @ " << tag_next << std::endl; - *vo_->os() << "tag assertion " << std::endl; - AMANZI_ASSERT(tag_next == tag_next_ || tag_next == Tags::NEXT); - *vo_->os() << "tag current setting " << std::endl; - Tag tag_current = tag_next == tag_next_ ? tag_current_ : Tags::CURRENT; + PK_Physical_Default::CommitStep(t_old, t_new, tag_next); - *vo_->os() << "assign tcc key to tag current and tag next " << std::endl; - assign(tcc_key_, tag_current, tag_next, *S_); - - if (tag_next == Tags::NEXT) { - *vo_->os() << "assigning saturation key " << std::endl; - assign(saturation_key_, tag_current, tag_next, *S_); - *vo_->os() << "assigining density key " << std::endl; - assign(molar_density_key_, tag_current, tag_next, *S_); - } + Tag tag_current = tag_next == tag_next_ ? tag_current_ : Tags::CURRENT; + assign(lwc_key_, tag_current, tag_next, *S_); } /* ******************************************************************* - * A simple first-order transport method + * Advance RK1 ****************************************************************** */ void -Transport_ATS::AdvanceDonorUpwind_(double dt_cycle) +Transport_ATS::AdvanceAdvectionSources_RK1_(double t_old, double t_new, int spatial_order) { - IdentifyUpwindCells_(); - dt_ = dt_cycle; // overwrite the maximum stable transport step - mass_solutes_source_.assign(num_aqueous_ + num_gaseous_, 0.0); - mass_solutes_bc_.assign(num_aqueous_ + num_gaseous_, 0.0); + double dt = t_new - t_old; + // distribute vector of concentrations // scattering total concentration from master to others - tcc->ScatterMasterToGhosted("cell"); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell", true); // tag current - Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", true); // tag next - - S_->GetEvaluator(porosity_key_, Tags::NEXT).Update(*S_, name_); - const Epetra_MultiVector& phi = *S_->Get(porosity_key_, Tags::NEXT).ViewComponent("cell", false); - - double mass_current = 0.; - double tmp1, mass; - int num_components_ = tcc_next.NumVectors(); - - // populating conserved quantity (unit: molC) - // The conserve_qty has `num_components_+2` vectors - Epetra_MultiVector& conserve_qty = - *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", false); - conserve_qty.PutScalar(0.); // set all values in conserve_qty to 0 -- why? - - // populating solid quantity (unit: molC) - // solid_qty has `num_components_` vectors only (solute mass) - Epetra_MultiVector& solid_qty = - *S_->GetW(solid_residue_mass_key_, tag_next_, name_).ViewComponent("cell", false); - - for (int c = 0; c < conserve_qty.MyLength(); c++) { - double vol_phi_ws_den = - mesh_->getCellVolume(c) * phi[0][c] * (*ws_prev_)[0][c] * (*mol_dens_prev_)[0][c]; - (conserve_qty)[num_components_ + 1][c] = vol_phi_ws_den; - - for (int i = 0; i < num_advect_; i++) { - (conserve_qty)[i][c] = tcc_prev[i][c] * vol_phi_ws_den; // get and store current solute mass - - if (dissolution_) { - if (((*ws_prev_)[0][c] > water_tolerance_) && - (solid_qty[i][c] > 0)) { // Dissolve solid residual into liquid - double add_mass = - std::min(solid_qty[i][c], tcc_max_[i] * vol_phi_ws_den - conserve_qty[i][c]); - solid_qty[i][c] -= add_mass; - conserve_qty[i][c] += add_mass; - } - } - - mass_current += conserve_qty[i][c]; // this includes total current mass of all solutes + S_->Get(key_, tag_current_).ScatterMasterToGhosted(); + + { // context for Multiply -- on owned cells + const Epetra_MultiVector& tcc_old = + *S_->Get(key_, tag_current_).ViewComponent("cell", false); + + // old and new water contents -- note these were updated in StableStep + const Epetra_MultiVector& lwc_old = + *S_->Get(lwc_key_, tag_current_).ViewComponent("cell", false); + + // populating conserved quantity (unit: molC) + // The conserve_qty (M) has `num_components_+2` vectors, the extras for tracking water + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", false); + + // Compute mass from concentration and water content: Mass <-- Concentration * water content + // conserved component quantity [mol C] = (mol C / mol H20) * mol H2O + // Note that: this calculation uses the "old" (previous time step) values to determine the + // initial mass of the conserved component quantity. + for (int i = 0; i != num_aqueous_; ++i) { + conserve_qty(i)->Multiply(1., *lwc_old(0), *tcc_old(i), 0.); } + conserve_qty(num_aqueous_)->PutScalar(0.); + conserve_qty(num_aqueous_ + 1)->PutScalar(0.); + db_->WriteCellVector( + "qnty (old)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); } - db_->WriteCellVector("cons (start)", conserve_qty); - tmp1 = mass_current; - mesh_->getComm()->SumAll(&tmp1, &mass_current, 1); // sum all mass_current from all processors - int nfaces_all = - mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::ALL); - - const Epetra_MultiVector& flux = *S_->Get(flux_key_, Tags::NEXT).ViewComponent("face", true); - - // advance all components at once - for (int f = 0; f < nfaces_all; f++) { - // flow moves from upwind cell (c1) to downwind cell (c2). - // If ci < 0 || ci > ncells_owned -> indicates boundary or halo cells (i=1,2) - int c1 = (*upwind_cell_)[f]; - int c2 = (*downwind_cell_)[f]; - double u = std::abs(flux[0][f]); - - if (c1 >= 0 && c1 < conserve_qty.MyLength() && c2 >= 0 && c2 < conserve_qty.MyLength()) { - // Here c1 & c2 are inside local domain. Update solute fluxes for both cells - for (int i = 0; i < num_advect_; i++) { - double tcc_flux = dt_ * u * tcc_prev[i][c1]; - conserve_qty[i][c1] -= tcc_flux; - conserve_qty[i][c2] += tcc_flux; - } - // Update (tag next) water fluxes for both cells - conserve_qty[num_components_ + 1][c1] -= dt_ * u; - conserve_qty[num_components_ + 1][c2] += dt_ * u; - - } else if (c1 >= 0 && c1 < conserve_qty.MyLength() && (c2 >= conserve_qty.MyLength() || c2 < 0)) { - // downind cell c2 is boundary or belong to another domain owned by other processors - // Update solute flux for c1 - for (int i = 0; i < num_advect_; i++) { - double tcc_flux = dt_ * u * tcc_prev[i][c1]; - conserve_qty[i][c1] -= tcc_flux; - if (c2 < 0) mass_solutes_bc_[i] -= tcc_flux; // if c2 is boundary, update BC - } - // Update or subtract (tag next) water fluxes for c1 - conserve_qty[num_components_ + 1][c1] -= dt_ * u; - - } else if (c1 >= conserve_qty.MyLength() && c2 >= 0 && c2 < conserve_qty.MyLength()) { - // upwind cell c1 is boundary or belong to another domain owned by other processors - // Update solute flux for c2 - for (int i = 0; i < num_advect_; i++) { - double tcc_flux = dt_ * u * tcc_prev[i][c1]; - conserve_qty[i][c2] += tcc_flux; - } - // Update or add (tag next) water fluxes for c2 - conserve_qty[num_components_ + 1][c2] += dt_ * u; - - } else if (c2 < 0 && c1 >= 0 && c1 < conserve_qty.MyLength()) { - // this case is very similar to line 1165, except c2<0 only. Why we don't update solute flux??? --PL - conserve_qty[num_components_ + 1][c1] -= dt_ * u; - - } else if (c1 < 0 && c2 >= 0 && c2 < conserve_qty.MyLength()) { - // why no solute update??? --PL - conserve_qty[num_components_ + 1][c2] += dt_ * u; + { // context for advection -- on all cells + const Epetra_MultiVector& tcc_old = + *S_->Get(key_, tag_current_).ViewComponent("cell", true); + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", true); + // populating solute mass flux (unit: molC/s) + Epetra_MultiVector& mass_flux_advection = + *S_->GetW(mass_flux_advection_key_, tag_next_, name_) + .ViewComponent("face", false); + + // advection: M <-- M + dt * div q * C0 + if (spatial_order == 1) { + // conserve_qty = conserve_qty + div qC + AddAdvection_FirstOrderUpwind_(t_old, t_new, tcc_old, conserve_qty, mass_flux_advection); + } else if (spatial_order == 2) { + // conserve_qty = conserve_qty + div qC + AddAdvection_SecondOrderUpwind_(t_old, t_new, tcc_old, conserve_qty, mass_flux_advection); } + db_->WriteCellVector( + "qnty (adv)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); } - Epetra_MultiVector* tcc_tmp_bf = nullptr; - if (tcc_tmp->HasComponent("boundary_face")) { - tcc_tmp_bf = &(*tcc_tmp->ViewComponent("boundary_face", false)); - } - - // loop over exterior boundary sets - for (int m = 0; m < bcs_.size(); m++) { - std::vector& tcc_index = bcs_[m]->tcc_index(); - int ncomp = tcc_index.size(); - - for (auto it = bcs_[m]->begin(); it != bcs_[m]->end(); ++it) { - int f = it->first; - int bf = tcc_tmp_bf ? AmanziMesh::getFaceOnBoundaryBoundaryFace(*mesh_, f) : -1; - - std::vector& values = it->second; - int c2 = (*downwind_cell_)[f]; - int c1 = (*upwind_cell_)[f]; + { // context for sources + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", false); - double u = std::abs(flux[0][f]); - if (c2 >= 0) { - for (int i = 0; i < ncomp; i++) { - int k = tcc_index[i]; - if (k < num_advect_) { - double tcc_flux = dt_ * u * values[i]; - conserve_qty[k][c2] += tcc_flux; - mass_solutes_bc_[k] += tcc_flux; - - if (tcc_tmp_bf) (*tcc_tmp_bf)[i][bf] = values[i]; - } - } - } - } + // process external sources: M <-- M + dt * Q + AddSourceTerms_(t_old, t_new, conserve_qty); + db_->WriteCellVector( + "qnty (src)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); } - db_->WriteCellVector("cons (adv)", conserve_qty); - // process external sources - if (srcs_.size() != 0) { - double time = t_physics_; - ComputeAddSourceTerms_(time, dt_, conserve_qty, 0, num_aqueous_ - 1); - } - db_->WriteCellVector("cons (src)", conserve_qty); - - // recover concentration from new conservative state - for (int c = 0; c < conserve_qty.MyLength(); c++) { - double water_new = - mesh_->getCellVolume(c) * phi[0][c] * (*ws_)[0][c] * (*mol_dens_)[0][c]; // next water in cell c - double water_sink = conserve_qty[num_components_][c]; // current water in cell c (seem always 0 because conserve_qty.PutScalar(0.)) - double water_total = water_new + water_sink; // unit: mol H20 - AMANZI_ASSERT(water_total >= water_new); - conserve_qty[num_components_][c] = water_total; // update current water in cell c - - for (int i = 0; i < num_advect_; i++) { - if (water_new > water_tolerance_ && conserve_qty[i][c] > 0) { - // there is both water and stuff present at the new time - // this is stuff at the new time + stuff leaving through the domain coupling, divided by water of both - tcc_next[i][c] = conserve_qty[i][c] / water_total; - - // limit tcc_next to tcc_max_, precipitating the remainder as solid residue - if (tcc_next[i][c] > tcc_max_[i]) { - solid_qty[i][c] += (tcc_next[i][c] - tcc_max_[i]) * water_total; - tcc_next[i][c] = tcc_max_[i]; - } - } else if (water_sink > water_tolerance_ && conserve_qty[i][c] > 0) { - // there is water and stuff leaving through the domain coupling, but it all leaves (none at the new time) - tcc_next[i][c] = 0.; - } else { - // there is no water leaving, and no water at the new time. Change any stuff into solid - solid_qty[i][c] += std::max(conserve_qty[i][c], 0.); - conserve_qty[i][c] = 0.; - tcc_next[i][c] = 0.; - } - } - } - db_->WriteCellVector("tcc_new", tcc_next); - PrintSoluteExtrema(tcc_next, dt_); + { // context for inversion + // invert for C1: C1 <-- M / WC1, also deals with dissolution/precipitation + // tcc_new, the new solution + Epetra_MultiVector& tcc_new = + *S_->GetW(key_, tag_next_, passwd_).ViewComponent("cell", false); - double mass_final = 0; - for (int c = 0; c < conserve_qty.MyLength(); c++) { - for (int i = 0; i < num_advect_; i++) { mass_final += conserve_qty[i][c]; } - } + // solid quantity (unit: molC) stores extra solute mass + // solid_qty has `num_components_` vectors only (solute mass) + Epetra_MultiVector& solid_qty = + *S_->GetW(solid_residue_mass_key_, tag_next_, name_) + .ViewComponent("cell", false); - tmp1 = mass_final; - mesh_->getComm()->SumAll(&tmp1, &mass_final, 1); + const Epetra_MultiVector& conserve_qty = + *S_->Get(conserve_qty_key_, tag_next_).ViewComponent("cell", false); - // update mass balance - for (int i = 0; i < mass_solutes_exact_.size(); i++) { - mass_solutes_exact_[i] += mass_solutes_source_[i] * dt_; + InvertTccNew_(conserve_qty, tcc_new, &solid_qty, true); + db_->WriteCellVector("mol_frac (pre-diff)", tcc_new, S_->GetRecordSet(key_).subfieldnames()); } - - if (internal_tests) { CheckGEDProperty(*tcc_tmp->ViewComponent("cell"), t_physics_); } } /* ******************************************************************* * We have to advance each component independently due to different - * reconstructions. We use tcc when only owned data are needed and - * tcc_next when owned and ghost data. This is a special routine for - * transient flow and uses first-order time integrator. + * reconstructions. ****************************************************************** */ void -Transport_ATS::AdvanceSecondOrderUpwindRK1_(double dt_cycle) +Transport_ATS::AdvanceAdvectionSources_RK2_(double t_old, double t_new, int spatial_order) { - dt_ = dt_cycle; // overwrite the maximum stable transport step - mass_solutes_source_.assign(num_aqueous_ + num_gaseous_, 0.0); - - // work memory - const Epetra_Map& cmap_wghost = mesh_->getMap(AmanziMesh::Entity_kind::CELL, true); + double dt = t_new - t_old; // distribute vector of concentrations - tcc->ScatterMasterToGhosted("cell"); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell", true); - Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", true); + // scattering total concentration from master to others + S_->Get(key_, tag_current_).ScatterMasterToGhosted(); - // We advect only aqueous components. - int num_components_ = tcc_next.NumVectors(); + { // context for Multiply -- on owned cells + const Epetra_MultiVector& tcc_old = + *S_->Get(key_, tag_current_).ViewComponent("cell", false); - // populating conserved quantity - Epetra_MultiVector& conserve_qty = - *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", false); - conserve_qty.PutScalar(0.); + // old and new water contents -- note these were updated in StableStep + const Epetra_MultiVector& lwc_old = + *S_->Get(lwc_key_, tag_current_).ViewComponent("cell", false); - // populating solid quantity - Epetra_MultiVector& solid_qty = - *S_->GetW(solid_residue_mass_key_, tag_next_, name_).ViewComponent("cell", false); + // populating conserved quantity (unit: molC) + // The conserve_qty (M) has `num_components_+2` vectors, the extras for tracking water + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", false); - // using vectors - S_->GetEvaluator(porosity_key_, Tags::NEXT).Update(*S_, name_); - const Epetra_MultiVector& phi = *S_->Get(porosity_key_, Tags::NEXT).ViewComponent("cell", false); - - // prepopulate with initial water for better debugging - for (int c = 0; c < conserve_qty.MyLength(); c++) { - conserve_qty[num_components_ + 1][c] = mesh_->getCellVolume(c) * phi[0][c] * (*ws_prev_)[0][c] * (*mol_dens_prev_)[0][c]; + // -- M <-- C0 * W0 + // -- mol H2O * (mol C / mol H20) --> mol C, the conserved component quantity + for (int i = 0; i != num_aqueous_; ++i) { + conserve_qty(i)->Multiply(1., *lwc_old(0), *tcc_old(i), 0.); + } + conserve_qty(num_aqueous_)->PutScalar(0.); + conserve_qty(num_aqueous_ + 1)->PutScalar(0.); + db_->WriteCellVector( + "qnty (start)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); } - for (int i = 0; i < num_advect_; i++) { - current_component_ = i; // needed by BJ - double T = t_physics_; - Epetra_Vector*& component = tcc_prev(i); - FunctionalTimeDerivative(T, *component, *(conserve_qty)(i)); - } - db_->WriteCellVector("cons (time_deriv)", conserve_qty); - - // calculate the new conc - for (int c = 0; c < conserve_qty.MyLength(); c++) { - double water_old = conserve_qty[num_components_ + 1][c]; - double water_new = - mesh_->getCellVolume(c) * phi[0][c] * (*ws_)[0][c] * (*mol_dens_)[0][c]; - double water_sink = conserve_qty[num_components_][c]; - double water_total = water_sink + water_new; - conserve_qty[num_components_][c] = water_total; - - for (int i = 0; i != num_components_; ++i) { - double cons_qty = (tcc_prev[i][c] + dt_ * conserve_qty[i][c]) * water_old; - conserve_qty[i][c] = cons_qty; - if (water_new > water_tolerance_ && cons_qty > 0) { - // there is both water and stuff present at the new time - // this is stuff at the new time + stuff leaving through the domain coupling, divided by water of both - tcc_next[i][c] = cons_qty / water_total; - } else if (water_sink > water_tolerance_ && cons_qty > 0) { - // there is water and stuff leaving through the domain coupling, but it all leaves (none at the new time) - tcc_next[i][c] = 0.; - } else { - // there is no water leaving, and no water at the new time. Change any stuff into solid - solid_qty[i][c] += std::max(cons_qty, 0.); - conserve_qty[i][c] = 0.; - tcc_next[i][c] = 0.; - } + { // context for advection -- on all cells + const Epetra_MultiVector& tcc_old = + *S_->Get(key_, tag_current_).ViewComponent("cell", true); + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", true); + // populating solute mass flux (unit: molC/s) + Epetra_MultiVector& mass_flux_advection = + *S_->GetW(mass_flux_advection_key_, tag_next_, name_) + .ViewComponent("face", false); + + // Predictor Step: + // -- advection: M <-- M + dt * div q * C0 + if (spatial_order == 1) { + AddAdvection_FirstOrderUpwind_(t_old, t_new, tcc_old, conserve_qty, mass_flux_advection); + } else if (spatial_order == 2) { + AddAdvection_SecondOrderUpwind_(t_old, t_new, tcc_old, conserve_qty, mass_flux_advection); } - } - db_->WriteCellVector("tcc_new", tcc_next); + db_->WriteCellVector( + "qnty (pred adv)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); - // update mass balance - for (int i = 0; i < num_aqueous_ + num_gaseous_; i++) { - mass_solutes_exact_[i] += mass_solutes_source_[i] * dt_; + // -- process external sources: M <-- M + dt * Q(t0) + AddSourceTerms_(t_old, t_new, conserve_qty); + db_->WriteCellVector( + "qnty (pred src)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); } - if (internal_tests) { CheckGEDProperty(*tcc_tmp->ViewComponent("cell"), t_physics_); } -} - + // -- invert for C': C' <-- M / WC1, note no dissolution/precip + { // context for inversion + Epetra_MultiVector& tcc_new = + *S_->GetW(key_, tag_next_, passwd_).ViewComponent("cell", false); + const Epetra_MultiVector& conserve_qty = + *S_->Get(conserve_qty_key_, tag_next_).ViewComponent("cell", false); -/* ******************************************************************* - * We have to advance each component independently due to different - * reconstructions. This is a special routine for transient flow and - * uses second-order predictor-corrector time integrator. - ****************************************************************** */ -void -Transport_ATS::AdvanceSecondOrderUpwindRK2_(double dt_cycle) -{ - // Q: Why we don't have conserve_qty calculation in this function? --PL - - dt_ = dt_cycle; // overwrite the maximum stable transport step - mass_solutes_source_.assign(num_aqueous_ + num_gaseous_, 0.0); + InvertTccNew_(conserve_qty, tcc_new, nullptr, false); + db_->WriteCellVector("mol_frac (pred)", tcc_new, S_->GetRecordSet(key_).subfieldnames()); + } - // work memory - const Epetra_Map& cmap_wghost = mesh_->getMap(AmanziMesh::Entity_kind::CELL, true); - Epetra_Vector f_component(cmap_wghost); + { // context for Corrector Step Multiply + const Epetra_MultiVector& tcc_old = + *S_->Get(key_, tag_current_).ViewComponent("cell", false); - // populating solid quantity - Epetra_MultiVector& solid_qty = - *S_->GetW(solid_residue_mass_key_, tag_next_, name_).ViewComponent("cell", false); + // old and new water contents -- note these were updated in StableStep + const Epetra_MultiVector& lwc_old = + *S_->Get(lwc_key_, tag_current_).ViewComponent("cell", false); - // distribute old vector of concentrations - tcc->ScatterMasterToGhosted("cell"); - Epetra_MultiVector& tcc_prev = *tcc->ViewComponent("cell", true); - Epetra_MultiVector& tcc_next = *tcc_tmp->ViewComponent("cell", true); - Epetra_Vector ws_ratio(Copy, *ws_prev_, 0); + // populating conserved quantity (unit: molC) + // The conserve_qty (M) has `num_components_+2` vectors, the extras for tracking water + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", false); - S_->GetEvaluator(porosity_key_, Tags::NEXT).Update(*S_, name_); - const Epetra_MultiVector& phi = *S_->Get(porosity_key_, Tags::NEXT).ViewComponent("cell", false); + // -- M <-- M/2 + M0 C0 / 2 + // <-- (C0 W0 + dt div q C0 + dt Q0) / 2 + W0 C0 / 2 + for (int i = 0; i != num_aqueous_; ++i) { + conserve_qty(i)->Multiply(0.5, *lwc_old(0), *tcc_old(i), 0.5); + } - for (int c = 0; c < solid_qty.MyLength(); c++) { - if ((*ws_)[0][c] > 1e-10) { - if ((*ws_prev_)[0][c] > 1e-10) { - ws_ratio[c] = ((*ws_prev_)[0][c] * (*mol_dens_prev_)[0][c]) / - ((*ws_)[0][c] * (*mol_dens_)[0][c]); - } else { - ws_ratio[c] = 1; - } - } else - ws_ratio[c] = 0.; + conserve_qty(num_aqueous_)->PutScalar(0.); + conserve_qty(num_aqueous_ + 1)->PutScalar(0.); + db_->WriteCellVector( + "qnty (corr start)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); } - // predictor step - for (int i = 0; i < num_advect_; i++) { - current_component_ = i; // needed by BJ - - double T = t_physics_; - Epetra_Vector*& component = tcc_prev(i); - FunctionalTimeDerivative(T, *component, f_component); - - for (int c = 0; c < tcc_prev.MyLength(); c++) { - tcc_next[i][c] = (tcc_prev[i][c] + dt_ * f_component[c]) * ws_ratio[c]; + // scatter updated values + S_->Get(key_, tag_next_).ScatterMasterToGhosted(); + + { // -- advect the predicted C' + const Epetra_MultiVector& tcc_new = + *S_->Get(key_, tag_next_).ViewComponent("cell", true); + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", true); + Epetra_MultiVector& mass_flux_advection = + *S_->GetW(mass_flux_advection_key_, tag_next_, name_) + .ViewComponent("face", false); + + // M <-- M + dt/2 * div q * C' + // <-- (C0 W0 + dt div q C0 + dt Q0) / 2 + W0 C0 / 2 + dt div q C' / 2 + if (spatial_order == 1) { + AddAdvection_FirstOrderUpwind_( + t_old + dt / 2., t_new, tcc_new, conserve_qty, mass_flux_advection); + } else if (spatial_order == 2) { + AddAdvection_SecondOrderUpwind_( + t_old + dt / 2., t_new, tcc_new, conserve_qty, mass_flux_advection); } + db_->WriteCellVector( + "qnty (corr adv)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); } - tcc_tmp->ScatterMasterToGhosted("cell"); - - // corrector step - for (int i = 0; i < num_advect_; i++) { - current_component_ = i; // needed by BJ - - double T = t_physics_; - Epetra_Vector*& component = tcc_next(i); - FunctionalTimeDerivative(T, *component, f_component); - - for (int c = 0; c < tcc_prev.MyLength(); c++) { - double value = (tcc_prev[i][c] + dt_ * f_component[c]) * ws_ratio[c]; - tcc_next[i][c] = (tcc_next[i][c] + value) / 2; - if (tcc_next[i][c] < 0) { - double vol_phi_ws_den = - mesh_->getCellVolume(c) * phi[0][c] * (*ws_)[0][c] * (*mol_dens_)[0][c]; - solid_qty[i][c] += std::abs(tcc_next[i][c]) * vol_phi_ws_den; - tcc_next[i][c] = 0.; - } - } + { // -- add sources at the new time, predicted C' + Epetra_MultiVector& conserve_qty = + *S_->GetW(conserve_qty_key_, tag_next_, name_).ViewComponent("cell", false); + // M <-- M + dt/2 Q(t1) + // <-- (C0 W0 + dt div q C0 + dt Q(t0)) / 2 + W0 C0 / 2 + dt div q C' / 2 + dt Q(t1) / 2 + // <-- C0 W0 + dt * (div q C0 + div q C') / 2 + dt (Q(t0) + Q(t1)) / 2 + AddSourceTerms_(t_old + dt / 2., t_new, conserve_qty); + db_->WriteCellVector( + "qnty (corr src)", conserve_qty, S_->GetRecordSet(conserve_qty_key_).subfieldnames()); } - // update mass balance - for (int i = 0; i < num_aqueous_ + num_gaseous_; i++) { - mass_solutes_exact_[i] += mass_solutes_source_[i] * dt_ / 2; - } + { // -- Invert to get C1, this time with dissolution/solidification + // solid quantity (unit: molC) stores extra solute mass + // solid_qty has `num_components_` vectors only (solute mass) + const Epetra_MultiVector& conserve_qty = + *S_->Get(conserve_qty_key_, tag_next_).ViewComponent("cell", false); - if (internal_tests) { CheckGEDProperty(*tcc_tmp->ViewComponent("cell"), t_physics_); } -} + Epetra_MultiVector& solid_qty = + *S_->GetW(solid_residue_mass_key_, tag_next_, name_) + .ViewComponent("cell", false); + Epetra_MultiVector& tcc_new = + *S_->GetW(key_, tag_next_, passwd_).ViewComponent("cell", false); -/* ****************************************************************** -* Computes source and sink terms and adds them to vector tcc. -* Returns mass rate for the tracer. -* The routine treats two cases of tcc with one and all components. -****************************************************************** */ -void -Transport_ATS::ComputeAddSourceTerms_(double tp, - double dtp, - Epetra_MultiVector& cons_qty, - int n0, - int n1) -{ - int num_vectors = cons_qty.NumVectors(); - int nsrcs = srcs_.size(); - - for (int m = 0; m < nsrcs; m++) { - double t0 = tp - dtp; - srcs_[m]->Compute(t0, tp); - std::vector tcc_index = srcs_[m]->tcc_index(); - - for (auto it = srcs_[m]->begin(); it != srcs_[m]->end(); ++it) { - int c = it->first; - std::vector& values = it->second; - - if (c >= cons_qty.MyLength()) continue; - - if (srcs_[m]->getType() == DomainFunction_kind::COUPLING && n0 == 0) { - cons_qty[num_vectors - 2][c] += values[num_vectors - 2]; - } - - if (convert_to_field_[srcs_[m]->getName()]) { - std::string name = srcs_[m]->getName(); - name = Keys::cleanName(name); - if (Keys::getDomain(name)!=domain_){ - name = Keys::getKey(domain_, name); - } - copyToCompositeVector(*srcs_[m], - S_->GetW(name, Tags::NEXT, name) - ); - changedEvaluatorPrimary(name, Tags::NEXT, *S_); - } - - for (int k = 0; k < tcc_index.size(); ++k) { - int i = tcc_index[k]; - if (i < n0 || i > n1) continue; - - int imap = i; - if (num_vectors == 1) imap = 0; - double value = mesh_->getCellVolume(c) * values[k]; - cons_qty[imap][c] += dtp * value; - mass_solutes_source_[i] += value; - } - } + InvertTccNew_(conserve_qty, tcc_new, &solid_qty, true); + db_->WriteCellVector("mol_frac_new", tcc_new, S_->GetRecordSet(key_).subfieldnames()); } } -/* ****************************************************************** -* Update source/sink terms to outflux -* - tcc_c: Total concentration in previous step (known) -* - total_outflux: water flux -* - n0: lower number of components -* - n1: upper number of components -****************************************************************** */ -void -Transport_ATS::ComputeSinks2TotalOutFlux_(Epetra_MultiVector& tcc_c, - std::vector& total_outflux, - int n0, - int n1) -{ - int ncells_all = - mesh_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); - - std::vector sink_add(ncells_all, 0.0); - //Assumption that there is only one sink per component per cell - double t0 = S_->get_time(tag_current_); - int num_vectors = tcc_c.NumVectors(); // number of components (e.g. tracers) - int nsrcs = srcs_.size(); // number of sources / sinks - - for (int m = 0; m < nsrcs; m++) { - srcs_[m]->Compute(t0, t0); // compute source term at time t0 - std::vector index = srcs_[m]->tcc_index(); // get the index of the component in the global list - - for (auto it = srcs_[m]->begin(); it != srcs_[m]->end(); ++it) { - int c = it->first; // cell id - std::vector& values = it->second; // magnitude of source terms - double val = 0; - for (int k = 0; k < index.size(); ++k) { - int i = index[k]; - if (i < n0 || i > n1) continue; - - int imap = i; - if (num_vectors == 1) imap = 0; - - if ((values[k] < 0) && (tcc_c[imap][c] > 1e-16)) { - if (srcs_[m]->getType() == DomainFunction_kind::COUPLING) { - const Epetra_MultiVector& flux_interface_ = - *S_->Get("surface-surface_subsurface_flux", Tags::NEXT).ViewComponent("cell", false); - val = std::max(val, std::abs(flux_interface_[0][c])); - } - } - } - sink_add[c] = std::max(sink_add[c], val); - } - } - - for (int c = 0; c < ncells_all; c++) total_outflux[c] += sink_add[c]; -} - /* ******************************************************************* * Populates operators' boundary data for given component. * Returns true if at least one face was populated. ******************************************************************* */ bool -Transport_ATS::PopulateBoundaryData_(std::vector& bc_model, - std::vector& bc_value, - int component) +Transport_ATS::PopulateBoundaryData_(int component, Operators::BCs& bc) { int nfaces_all = mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::ALL); bool flag = false; + auto& bc_model = bc.bc_model(); + auto& bc_value = bc.bc_value(); + for (int i = 0; i < bc_model.size(); i++) { bc_model[i] = Operators::OPERATOR_BC_NONE; bc_value[i] = 0.0; } - // This is not efficient. We should do this only once, not every timestep. + // set the default BC for (int f = 0; f < nfaces_all; f++) { auto cells = mesh_->getFaceCells(f); if (cells.size() == 1) bc_model[f] = Operators::OPERATOR_BC_NEUMANN; } - for (int m = 0; m < bcs_.size(); m++) { - std::vector& tcc_index = bcs_[m]->tcc_index(); - int ncomp = tcc_index.size(); - - for (auto it = bcs_[m]->begin(); it != bcs_[m]->end(); ++it) { - int f = it->first; - std::vector& values = it->second; - for (int i = 0; i < ncomp; i++) { - int k = tcc_index[i]; - if (k == component) { - bc_model[f] = Operators::OPERATOR_BC_DIRICHLET; - bc_value[f] = values[i]; - flag = true; + if (component >= 0) { + for (int m = 0; m < bcs_.size(); m++) { + std::vector& tcc_index = bcs_[m]->tcc_index(); + int ncomp = tcc_index.size(); + + for (auto it = bcs_[m]->begin(); it != bcs_[m]->end(); ++it) { + int f = it->first; + std::vector& values = it->second; + for (int i = 0; i < ncomp; i++) { + int k = tcc_index[i]; + if (k == component) { + bc_model[f] = Operators::OPERATOR_BC_DIRICHLET; + bc_value[f] = values[i]; + flag = true; + } } } } @@ -1748,14 +1380,15 @@ Transport_ATS::IdentifyUpwindCells_() upwind_cell_->PutValue(-1); downwind_cell_->PutValue(-1); - S_->Get(flux_key_, Tags::NEXT).ScatterMasterToGhosted("face"); - const Epetra_MultiVector& flux = *S_->Get(flux_key_, Tags::NEXT).ViewComponent("face", true); + S_->Get(water_flux_key_, tag_next_).ScatterMasterToGhosted("face"); + const Epetra_MultiVector& flux = + *S_->Get(water_flux_key_, tag_next_).ViewComponent("face", true); // identify upwind and downwind cell of each face - for (int c = 0; c < ncells_all; c++) { + for (int c = 0; c != ncells_all; ++c) { const auto& [faces, dirs] = mesh_->getCellFacesAndDirections(c); - for (int i = 0; i < faces.size(); i++) { + for (int i = 0; i != faces.size(); ++i) { int f = faces[i]; double tmp = flux[0][f] * dirs[i]; if (tmp > 0.0) { @@ -1772,28 +1405,5 @@ Transport_ATS::IdentifyUpwindCells_() } -void -Transport_ATS::ChangedSolutionPK(const Tag& tag) -{ - changedEvaluatorPrimary(key_, tag, *S_); -} - -/* **************************************************************** -* Find place of the given component in a multivector. -**************************************************************** */ -int -Transport_ATS::FindComponentNumber_(const std::string& component_name) -{ - int ncomponents = component_names_.size(); - for (int i = 0; i < ncomponents; i++) { - if (component_names_[i] == component_name) return i; - } - Errors::Message msg("TransportExplicit_PK: component \""); - msg << component_name << "\" was requested, but this is not a known component for this PK."; - Exceptions::amanzi_throw(msg); - return -1; -} - - } // namespace Transport } // namespace Amanzi diff --git a/src/pks/transport/transport_ats_ti.cc b/src/pks/transport/transport_ats_ti.cc index 450c18b2f..b48581fb7 100644 --- a/src/pks/transport/transport_ats_ti.cc +++ b/src/pks/transport/transport_ats_ti.cc @@ -20,153 +20,249 @@ namespace Amanzi { namespace Transport { -/* ******************************************************************* - * Routine takes a parallel overlapping vector C and returns a parallel - * overlapping vector F(C). - ****************************************************************** */ +// +// Given C at t_old, computes cq_flux += div q * C * dt +// +// NOTE, we can assume safely that most normal things (water contents, flux, +// etc) are already updated, and upwind/downwind cells are already identified, +// because we have called ComputeStableTimestep already. +// +// This uses a first-order donor upwind scheme. +// +// DEV NOTE: this requires that tcc is ghosted and scattered, and that c_qty is +// owned. void -Transport_ATS::FunctionalTimeDerivative(double t, - const Epetra_Vector& component, - Epetra_Vector& f_component) +Transport_ATS::AddAdvection_FirstOrderUpwind_( + double t_old, + double t_new, // old and new time + const Epetra_MultiVector& tcc, // concentration in a cell at old time [mols C / mols H2O] + Epetra_MultiVector& c_qty, // component quantity in a cell [mols C] + Epetra_MultiVector& cq_flux) // component flux across a face [mols C / s] { - int nfaces_owned = - mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::OWNED); + double dt = t_new - t_old; // timestep [s] + + // total number of faces in the domain int nfaces_all = mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::ALL); - // distribute vector - auto component_tmp = Teuchos::rcp(new Epetra_Vector(component)); - component_tmp->Import(component, tcc->importer("cell"), Insert); - - Teuchos::ParameterList recon_list = plist_->sublist("reconstruction"); - lifting_->Init(recon_list); - lifting_->Compute(component_tmp); + // get water flux (water_flux_key_) for each face at next timestep (tag_next_) + const Epetra_MultiVector& flux = + *S_->Get(water_flux_key_, tag_next_).ViewComponent("face", true); - // extract boundary conditions for the current component - std::vector bc_model(nfaces_all, Operators::OPERATOR_BC_NONE); - std::vector bc_value(nfaces_all); + // advance all components at once + for (int f = 0; f < nfaces_all; f++) { + // flow from upwind cell (c1) to downwind cell (c2). + // If ci < 0 || ci > ncells_owned -> indicates boundary or halo cells (i=1,2...) + int c1 = (*upwind_cell_)[f]; + int c2 = (*downwind_cell_)[f]; + double u = std::abs(flux[0][f]); // magnitude of water flux [mols H2O /s] + + if (c1 >= 0 && c1 < c_qty.MyLength() && c2 >= 0 && c2 < c_qty.MyLength()) { + // Here c1 & c2 are inside local domain + // Thus, update solute fluxes for both cells + for (int i = 0; i < num_aqueous_; i++) { + double delta_c_mass = dt * u * tcc[i][c1]; // [mols C] + c_qty[i][c1] -= delta_c_mass; // [mols C] + c_qty[i][c2] += delta_c_mass; // [mols C] + cq_flux[i][f] = u * tcc[i][c1]; // tcc [mols C / mols H2O] --> cq_flux [mols C / s] + } + // update (tag next) water fluxes for both cells + c_qty[num_aqueous_ + 1][c1] -= dt * u; // [mols H2O] + c_qty[num_aqueous_ + 1][c2] += dt * u; // [mols H2O] + + } else if (c1 >= 0 && c1 < cq_flux.MyLength() && (c2 >= cq_flux.MyLength() || c2 < 0)) { + // downind cell c2 is boundary or belong to another domain owned by other processors + // update solute flux for c1 only + for (int i = 0; i < num_aqueous_; i++) { + double delta_c_mass = dt * u * tcc[i][c1]; // [mols C] + c_qty[i][c1] -= delta_c_mass; // [mols C] + cq_flux[i][f] = u * tcc[i][c1]; // [mols C / s] + } + // update or subtract (tag next) water fluxes for c1 + c_qty[num_aqueous_ + 1][c1] -= dt * u; // [mols H2O] + + } else if (c1 >= c_qty.MyLength() && c2 >= 0 && c2 < c_qty.MyLength()) { + // upwind cell c1 is boundary or belong to another domain owned by other processors + // update solute flux for c2 only + for (int i = 0; i < num_aqueous_; i++) { + double delta_c_mass = dt * u * tcc[i][c1]; // [mols C] + c_qty[i][c2] += delta_c_mass; // [mols C] + } + // update or add (tag next) water fluxes for c2 + c_qty[num_aqueous_ + 1][c2] += dt * u; // [mols H2O] + + } else if (c2 < 0 && c1 >= 0 && c1 < c_qty.MyLength()) { + // Negative cell value implies the face is a domain boundary. + // This mean flux is going from a regular cell (c1) to a domain boundary (c2). + // Solute fluxes over domain boundaries are taken care of in the + // below boundary loop, but water fluxes aren't because water + // fluxes may not bring solute, so deal with water fluxes only here. + c_qty[num_aqueous_ + 1][c1] -= dt * u; // [mols C] + + } else if (c1 < 0 && c2 >= 0 && c2 < c_qty.MyLength()) { + // This mean flux is going from a domain boundary (c1) to a regular cell (c2). + // Similarly, solute fluxes over domain boundaries are taken care + // of in the below boundary loop. We only need to deal with + // water fluxes here. + c_qty[num_aqueous_ + 1][c2] += dt * u; // [mols C] + } + } + // Process fluxes and quantities at the boundary faces + // Why no check on the boundary type? This can be Dirichlet or Neumann? + // Or is this hard-coded as just Dirichlet data? --ETC for (int m = 0; m < bcs_.size(); m++) { std::vector& tcc_index = bcs_[m]->tcc_index(); - int ncomp = tcc_index.size(); - - for (int i = 0; i < ncomp; i++) { - if (current_component_ == tcc_index[i]) { - for (auto it = bcs_[m]->begin(); it != bcs_[m]->end(); ++it) { - int f = it->first; - std::vector& values = it->second; - - bc_model[f] = Operators::OPERATOR_BC_DIRICHLET; - bc_value[f] = values[i]; + int ncomp = tcc_index.size(); // number of components + + for (auto it = bcs_[m]->begin(); it != bcs_[m]->end(); ++it) { + int f = it->first; // get face id + std::vector& values = it->second; + int c2 = (*downwind_cell_)[f]; // downwind cell id + int c1 = (*upwind_cell_)[f]; // upwind cell id + + double u = std::abs(flux[0][f]); + // if downwind cell c2 is inside local domain, update solute fluxes for c2 + if (c2 >= 0 && c2 < c_qty.MyLength()) { + for (int i = 0; i < ncomp; i++) { + int k = tcc_index[i]; + if (k < num_aqueous_) { + double delta_c_mass = dt * u * values[i]; // [mols C] + c_qty[k][c2] += delta_c_mass; // [mols C] + } } } } } +} + + +void +Transport_ATS::AddAdvection_SecondOrderUpwind_( + double t_old, + double t_new, // old and new time + const Epetra_MultiVector& tcc, // concentration in a cell at old time [mols C / mols H2O] + Epetra_MultiVector& c_qty, // component quantity in a cell [mols C] + Epetra_MultiVector& cq_flux) // component flux across a face [mols C / s] +{ + for (int i = 0; i != num_aqueous_; ++i) { + AddAdvection_SecondOrderUpwind_(t_old, t_new, *tcc(i), *c_qty(i), *cq_flux(i), i); + } +} - Teuchos::RCP flux = S_->Get(flux_key_, Tags::NEXT).ViewComponent("face", true); - limiter_->Init(recon_list, flux); - limiter_->ApplyLimiter(component_tmp, 0, lifting_, bc_model, bc_value); - lifting_->data()->ScatterMasterToGhosted("cell"); + +// +// Given C_old, this computes div Cq using a second order limiter +// +// DEV NOTE: requires that tcc is ghosted and scattered, while c_qty is +// owned. +void +Transport_ATS::AddAdvection_SecondOrderUpwind_(double t_old, + double t_new, + const Epetra_Vector& tcc, + Epetra_Vector& c_qty, + Epetra_Vector& cq_flux, + int component) +{ + double dt = t_new - t_old; // timestep [s] + + // number of faces owned by this processor + // and total number of faces in the domain + int nfaces_owned = + mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::OWNED); + int nfaces_all = + mesh_->getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::ALL); + + // API funkiness + Teuchos::RCP tcc_rcp = + Teuchos::rcpFromRef(tcc); + lifting_->Compute(tcc_rcp, 0); + + // populate boundary conditions for the current component + PopulateBoundaryData_(component, *adv_bcs_); + auto& bc_model = adv_bcs_->bc_model(); + auto& bc_value = adv_bcs_->bc_value(); + + auto flux = S_->Get(water_flux_key_, tag_next_).ViewComponent("face", true); + limiter_->SetFlux(flux); + limiter_->ApplyLimiter(tcc_rcp, 0, lifting_, bc_model, bc_value); // ADVECTIVE FLUXES // We assume that limiters made their job up to round-off errors. // Min-max condition will enforce robustness w.r.t. these errors. - - f_component.PutScalar(0.0); for (int f = 0; f < nfaces_all; f++) { // loop over master and slave faces int c1 = (*upwind_cell_)[f]; int c2 = (*downwind_cell_)[f]; - double u1, u2, umin, umax; + double tcc1, tcc2, tccmin, tccmax; if (c1 >= 0 && c2 >= 0) { - u1 = (*component_tmp)[c1]; - u2 = (*component_tmp)[c2]; - umin = std::min(u1, u2); - umax = std::max(u1, u2); + tcc1 = tcc[c1]; + tcc2 = tcc[c2]; + tccmin = std::min(tcc1, tcc2); + tccmax = std::max(tcc1, tcc2); } else if (c1 >= 0) { - u1 = u2 = umin = umax = (*component_tmp)[c1]; + tcc1 = tcc2 = tccmin = tccmax = tcc[c1]; } else if (c2 >= 0) { - u1 = u2 = umin = umax = (*component_tmp)[c2]; + tcc1 = tcc2 = tccmin = tccmax = tcc[c2]; } double u = std::abs((*flux)[0][f]); const AmanziGeometry::Point& xf = mesh_->getFaceCentroid(f); - double upwind_tcc, tcc_flux; - if (c1 >= 0 && c1 < f_component.MyLength() && c2 >= 0 && c2 < f_component.MyLength() ) { + double upwind_tcc, delta_c_mass; + if (c1 >= 0 && c1 < c_qty.MyLength() && c2 >= 0 && c2 < c_qty.MyLength()) { upwind_tcc = limiter_->getValue(c1, xf); - upwind_tcc = std::max(upwind_tcc, umin); - upwind_tcc = std::min(upwind_tcc, umax); + upwind_tcc = std::max(upwind_tcc, tccmin); + upwind_tcc = std::min(upwind_tcc, tccmax); - tcc_flux = u * upwind_tcc; - f_component[c1] -= tcc_flux; - f_component[c2] += tcc_flux; + delta_c_mass = dt * u * upwind_tcc; + c_qty[c1] -= delta_c_mass; // [mols C] + c_qty[c2] += delta_c_mass; // [mols C] - } else if (c1 >= 0 && c1 < f_component.MyLength() && (c2 >= f_component.MyLength() || c2 < 0)) { + } else if (c1 >= 0 && c1 < c_qty.MyLength() && (c2 >= c_qty.MyLength() || c2 < 0)) { upwind_tcc = limiter_->getValue(c1, xf); - upwind_tcc = std::max(upwind_tcc, umin); - upwind_tcc = std::min(upwind_tcc, umax); + upwind_tcc = std::max(upwind_tcc, tccmin); + upwind_tcc = std::min(upwind_tcc, tccmax); - tcc_flux = u * upwind_tcc; - f_component[c1] -= tcc_flux; + delta_c_mass = dt * u * upwind_tcc; + c_qty[c1] -= delta_c_mass; // [mols C] - } else if (c1 >= 0 && c1 < f_component.MyLength() && (c2 < 0)) { - upwind_tcc = component[c1]; - upwind_tcc = std::max(upwind_tcc, umin); - upwind_tcc = std::min(upwind_tcc, umax); + } else if (c1 >= 0 && c1 < c_qty.MyLength() && (c2 < 0)) { + upwind_tcc = tcc[c1]; + upwind_tcc = std::max(upwind_tcc, tccmin); + upwind_tcc = std::min(upwind_tcc, tccmax); - tcc_flux = u * upwind_tcc; - f_component[c1] -= tcc_flux; + delta_c_mass = dt * u * upwind_tcc; + c_qty[c1] -= delta_c_mass; // [mols C] - } else if (c1 >= f_component.MyLength() && c2 >= 0 && c2 < f_component.MyLength() ) { + } else if (c1 >= c_qty.MyLength() && c2 >= 0 && c2 < c_qty.MyLength()) { upwind_tcc = limiter_->getValue(c1, xf); - upwind_tcc = std::max(upwind_tcc, umin); - upwind_tcc = std::min(upwind_tcc, umax); + upwind_tcc = std::max(upwind_tcc, tccmin); + upwind_tcc = std::min(upwind_tcc, tccmax); - tcc_flux = u * upwind_tcc; - f_component[c2] += tcc_flux; + delta_c_mass = dt * u * upwind_tcc; // [mols C] + c_qty[c2] += delta_c_mass; } - } - - // process external sources - if (srcs_.size() != 0) { - ComputeAddSourceTerms_(t, 1., f_component, current_component_, current_component_); - } - - S_->GetEvaluator(porosity_key_, Tags::NEXT).Update(*S_, name_); - const Epetra_MultiVector& phi = *S_->Get(porosity_key_, Tags::NEXT).ViewComponent("cell", false); - for (int c = 0; c < f_component.MyLength() ; c++) { // calculate conservative quantatity - double vol_phi_ws_den = - mesh_->getCellVolume(c) * phi[0][c] * (*ws_prev_)[0][c] * (*mol_dens_prev_)[0][c]; - if ((*ws_prev_)[0][c] < 1e-12) - vol_phi_ws_den = - mesh_->getCellVolume(c) * phi[0][c] * (*ws_)[0][c] * (*mol_dens_)[0][c]; - - if (vol_phi_ws_den > water_tolerance_) { f_component[c] /= vol_phi_ws_den; } + cq_flux[f] = u * upwind_tcc; // [mols C / s] } // boundary conditions for advection for (int m = 0; m < bcs_.size(); m++) { std::vector& tcc_index = bcs_[m]->tcc_index(); - int ncomp = tcc_index.size(); + int ncomp = tcc_index.size(); // number of components for (int i = 0; i < ncomp; i++) { - if (current_component_ == tcc_index[i]) { + if (component == tcc_index[i]) { for (auto it = bcs_[m]->begin(); it != bcs_[m]->end(); ++it) { - int f = it->first; - std::vector& values = it->second; - int c2 = (*downwind_cell_)[f]; + int f = it->first; // get face id + std::vector& values = it->second; // concentration values [mols C / mols H2O] + int c2 = (*downwind_cell_)[f]; // get downwind cell id + // if downwind cell c2 is inside local domain and face id is owned by this processor if (c2 >= 0 && f < nfaces_owned) { - double u = std::abs((*flux)[0][f]); - double vol_phi_ws_den = mesh_->getCellVolume(c2) * phi[0][c2] * - (*ws_prev_)[0][c2] * (*mol_dens_prev_)[0][c2]; - if ((*ws_prev_)[0][c2] < 1e-12) - vol_phi_ws_den = mesh_->getCellVolume(c2) * phi[0][c2] * (*ws_)[0][c2] * - (*mol_dens_)[0][c2]; - - double tcc_flux = u * values[i]; - if (vol_phi_ws_den > water_tolerance_) { f_component[c2] += tcc_flux / vol_phi_ws_den; } + double u = std::abs((*flux)[0][f]); // water flux [mols H2O / s] + double delta_c_mass = dt * u * values[i]; // [mols C] + c_qty[c2] += delta_c_mass; // [mols C] } } } @@ -175,5 +271,134 @@ Transport_ATS::FunctionalTimeDerivative(double t, } +// Given the conserved quantity, computes new tcc +// +// DEV NOTE: all vectors are owned only +// +void +Transport_ATS::InvertTccNew_(const Epetra_MultiVector& conserve_qty, + Epetra_MultiVector& tcc, + Epetra_MultiVector* solid_qty, + bool include_current_water_mass) +{ + // note this was updated in StableStep + const Epetra_MultiVector& lwc_new = + *S_->Get(lwc_key_, tag_next_).ViewComponent("cell", false); + const Epetra_MultiVector& cv = + *S_->Get(cv_key_, tag_next_).ViewComponent("cell", false); + + // calculate the new conc based on advected term + for (int c = 0; c < conserve_qty.MyLength(); c++) { + double water_new = lwc_new[0][c]; + double water_sink = conserve_qty[num_aqueous_][c]; + double water_total = water_sink + water_new; + + for (int i = 0; i != num_components_; ++i) { + double tcc_max = tcc_max_[component_names_[i]]; + + if (water_new > water_tolerance_ / cv[0][c] && conserve_qty[i][c] > 0) { + // there is both water and stuff present at the new time this is stuff + // at the new time + stuff leaving through the domain coupling, divided + // by water of both + tcc[i][c] = conserve_qty[i][c] / water_total; + if (include_current_water_mass) conserve_qty[num_aqueous_][c] = water_total; + + if (solid_qty && tcc_max > 0 && tcc[i][c] > tcc_max) { + (*solid_qty)[i][c] += (tcc[i][c] - tcc_max) * water_total; + tcc[i][c] = tcc_max; + } + + } else if (water_sink > water_tolerance_ / cv[0][c] && conserve_qty[i][c] > 0) { + // there is water and stuff leaving through the domain coupling, but it + // all leaves (none at the new time) + tcc[i][c] = 0.; + } else { + // there is no water leaving, and no water at the new time. Change any + // stuff into solid + if (solid_qty) (*solid_qty)[i][c] += std::max(conserve_qty[i][c], 0.); + conserve_qty[i][c] = 0.; + tcc[i][c] = 0.; + } + + // dissolve solid + if (solid_qty && + water_total > water_tolerance_ / cv[0][c] && // water available for dissolution + (*solid_qty)[i][c] > 0. && // solid available to dissolve + tcc[i][c] < tcc_max) { + double dissolved_qty = std::min((tcc_max - tcc[i][c]) * water_total, (*solid_qty)[i][c]); + if (water_new > water_tolerance_ / cv[0][c]) { + // new water -- dissolve in place + tcc[i][c] += dissolved_qty / water_new; + } // otherwise dissolve into water_sink, advect out, tcc stays 0 + + (*solid_qty)[i][c] -= dissolved_qty; + conserve_qty[i][c] += dissolved_qty; + } + } + } +} + + +/* ****************************************************************** +* Computes source and sink terms and adds them to vector tcc. +* Returns mass rate for the tracer. +* The routine treats two cases of tcc with one and all components. +****************************************************************** */ +void +Transport_ATS::AddSourceTerms_(double t0, double t1, Epetra_MultiVector& conserve_qty) +{ + // note: conserve_qty is OWNED vector + double dt = t1 - t0; + + // First add evaluator-based sources + if (!source_key_.empty()) { + S_->GetEvaluator(source_key_, tag_next_).Update(*S_, name_); + const Epetra_MultiVector& Q_c = + *S_->Get(source_key_, tag_next_).ViewComponent("cell", false); + const Epetra_MultiVector& cv = + *S_->Get(cv_key_, tag_next_).ViewComponent("cell", false); + // std::cout << "Source: " << Q_c[0][0] << ", " << Q_c[1][0] << std::endl; + // std::cout << "CQ: " << conserve_qty[0][0] << ", " << conserve_qty[1][0] << std::endl; + + AMANZI_ASSERT(conserve_qty.MyLength() == cv.MyLength()); + AMANZI_ASSERT(conserve_qty.MyLength() == Q_c.MyLength()); + AMANZI_ASSERT(conserve_qty.NumVectors() == Q_c.NumVectors() + 2); + for (unsigned i = 0; i != Q_c.NumVectors(); ++i) { + for (unsigned c = 0; c != Q_c.MyLength(); ++c) { + conserve_qty[i][c] += dt * cv[0][c] * Q_c[i][c]; + } + } + // std::cout << "CQ: " << conserve_qty[0][0] << ", " << conserve_qty[1][0] << std::endl; + } + + // next add DomainFunction-based sources, which are particularly useful from + // more complex, hard-coded sources that need to be visualized. + int nsrcs = srcs_.size(); + + for (int m = 0; m < nsrcs; m++) { + srcs_[m]->Compute(t0, t1); + std::vector tcc_index = srcs_[m]->tcc_index(); + + for (auto it = srcs_[m]->begin(); it != srcs_[m]->end(); ++it) { + int c = it->first; + std::vector& values = it->second; + + if (c < conserve_qty.MyLength()) { + if (srcs_[m]->getType() == DomainFunction_kind::COUPLING) { + AMANZI_ASSERT(values.size() == num_aqueous_ + 1); + conserve_qty[num_aqueous_][c] += values[num_aqueous_]; + } + + for (int k = 0; k < tcc_index.size(); ++k) { + int i = tcc_index[k]; + if (i > num_aqueous_) continue; + conserve_qty[i][c] += dt * mesh_->getCellVolume(c) * values[k]; + } + } + } + } +} + + } // namespace Transport } // namespace Amanzi diff --git a/src/pks/transport/transport_ats_vandv.cc b/src/pks/transport/transport_ats_vandv.cc index afefb69be..3738caacf 100644 --- a/src/pks/transport/transport_ats_vandv.cc +++ b/src/pks/transport/transport_ats_vandv.cc @@ -30,8 +30,7 @@ namespace Transport { * Calculates extrema of specified solutes and print them. ******************************************************************* */ void -Transport_ATS::PrintSoluteExtrema(const Epetra_MultiVector& tcc_next, - double dT_MPC) +Transport_ATS::PrintSoluteExtrema(const Epetra_MultiVector& tcc_next, double dT_MPC) { int num_components_ = tcc_next.NumVectors(); double tccmin_vec[num_components_]; @@ -40,8 +39,10 @@ Transport_ATS::PrintSoluteExtrema(const Epetra_MultiVector& tcc_next, tcc_next.MinValue(tccmin_vec); tcc_next.MaxValue(tccmax_vec); - const Epetra_MultiVector& flux = *S_->Get(flux_key_, Tags::NEXT).ViewComponent("face", true); - const Epetra_MultiVector& phi = *S_->Get(porosity_key_, Tags::NEXT).ViewComponent("cell", false); + const Epetra_MultiVector& flux = + *S_->Get(flux_key_, tag_next_).ViewComponent("face", true); + const Epetra_MultiVector& phi = + *S_->Get(porosity_key_, tag_next_).ViewComponent("cell", false); for (int n = 0; n < runtime_solutes_.size(); n++) { int i = FindComponentNumber_(runtime_solutes_[n]); diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 1dbc6de5d..7508a72e1 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -17,7 +17,7 @@ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ats-regression-tests/README.md") # figure out what tests are available if (ENABLE_Regression_Tests) set(ats_available_tests_string "") - if (ENABLE_GEOCHEMISTRY) + if (ENABLE_ALQUIMIA) execute_process(COMMAND ${PYTHON_EXECUTABLE} ${ATS_REGRESSION_TESTS_DIR}/regression_tests.py --suites=testing --ats=${ATS_SOURCE_DIR} --list-tests . OUTPUT_VARIABLE ats_available_tests_string WORKING_DIRECTORY ${ATS_REGRESSION_TESTS_DIR}) diff --git a/testing/ats-regression-tests b/testing/ats-regression-tests index a5cb4b0ad..c1a474e68 160000 --- a/testing/ats-regression-tests +++ b/testing/ats-regression-tests @@ -1 +1 @@ -Subproject commit a5cb4b0ad10365446aac3519e7858f2c83311991 +Subproject commit c1a474e680ad6c707246e5f2c6ede773c7afbe19 diff --git a/tools/evaluator_generator/templates/evaluator.cc b/tools/evaluator_generator/templates/evaluator.cc index 8283be976..bc172d5ae 100644 --- a/tools/evaluator_generator/templates/evaluator.cc +++ b/tools/evaluator_generator/templates/evaluator.cc @@ -25,75 +25,81 @@ namespace Amanzi { { // Constructor from ParameterList { evalClassName } Evaluator::{ evalClassName } Evaluator(Teuchos::ParameterList & plist) - : EvaluatorSecondaryMonotypeCV(plist){ - { Teuchos::ParameterList& sublist = plist_.sublist("{evalName} parameters"); - model_ = Teuchos::rcp(new { evalClassName } Model(sublist)); - InitializeFromPlist_(); - } // namespace Relations - } // namespace Relations + : EvaluatorSecondaryMonotypeCV(plist) + { + { + Teuchos::ParameterList& sublist = plist_.sublist("{evalName} parameters"); + model_ = Teuchos::rcp(new { evalClassName } Model(sublist)); + InitializeFromPlist_(); + } // namespace Relations + } // namespace Relations - // Copy constructor - { evalClassName } Evaluator::{ evalClassName } Evaluator(const { evalClassName } Evaluator & - other) - : EvaluatorSecondaryMonotypeCV(other), { keyCopyConstructorList } model_(other.model_) - { - {} - } + // Copy constructor + { evalClassName } Evaluator::{ evalClassName } Evaluator(const { evalClassName } Evaluator & + other) + : EvaluatorSecondaryMonotypeCV(other), { keyCopyConstructorList } model_(other.model_) + { + {} + } - // Virtual copy constructor - Teuchos::RCP{ evalClassName } Evaluator::Clone() const - { + // Virtual copy constructor + Teuchos::RCP{ evalClassName } Evaluator::Clone() const { - return Teuchos::rcp(new { evalClassName } Evaluator(*this)); + { + return Teuchos::rcp(new { evalClassName } Evaluator(*this)); + } } - } - // Initialize by setting up dependencies - void{ evalClassName } Evaluator::InitializeFromPlist_() - { + // Initialize by setting up dependencies + void{ evalClassName } Evaluator::InitializeFromPlist_() { - // Set up my dependencies - // - defaults to prefixed via domain - Key domain_name = Keys::getDomain(my_key_); - - // - pull Keys from plist { - keyInitializeList + // Set up my dependencies + // - defaults to prefixed via domain + Key domain_name = Keys::getDomain(my_key_); + + // - pull Keys from plist + { + keyInitializeList + } } } - } - void{ evalClassName } Evaluator::EvaluateField_(const Teuchos::Ptr& S, - const Teuchos::Ptr& result) - { + void{ evalClassName } Evaluator::EvaluateField_(const Teuchos::Ptr& S, + const Teuchos::Ptr& result) { - { keyCompositeVectorList } - { - evaluateModel + { + keyCompositeVectorList + } + + { + evaluateModel + } } } - } - void{ evalClassName } Evaluator::EvaluateFieldPartialDerivative_( - const Teuchos::Ptr& S, Key wrt_key, const Teuchos::Ptr& result) - { + void{ evalClassName } Evaluator::EvaluateFieldPartialDerivative_( + const Teuchos::Ptr& S, Key wrt_key, const Teuchos::Ptr& result) { - { keyCompositeVectorList } - { - evaluateDerivs + { + keyCompositeVectorList + } + + { + evaluateDerivs + } } } - } - } // namespace Relations - } // namespace } -} // namespace Amanzi -} // namespace Amanzi + } // namespace Relations + } // namespace } + } // namespace Amanzi + } // namespace Amanzi } // namespace Amanzi } // namespace Amanzi diff --git a/tools/evaluator_generator/templates/evaluator.hh b/tools/evaluator_generator/templates/evaluator.hh index f1e1de27d..09a24c85e 100644 --- a/tools/evaluator_generator/templates/evaluator.hh +++ b/tools/evaluator_generator/templates/evaluator.hh @@ -65,7 +65,7 @@ namespace Amanzi { private: static Utils::RegisteredFactory reg_; - } // namespace Relations + } // namespace Relations }; // namespace Relations } } // namespace } diff --git a/tools/evaluator_generator/templates/evaluator_keyEpetraVector.cc b/tools/evaluator_generator/templates/evaluator_keyEpetraVector.cc index 0666e2a8e..c3faef0f5 100644 --- a/tools/evaluator_generator/templates/evaluator_keyEpetraVector.cc +++ b/tools/evaluator_generator/templates/evaluator_keyEpetraVector.cc @@ -10,4 +10,4 @@ const Epetra_MultiVector& { var } _v = * { var - } -> ViewComponent(*comp, false); +} -> ViewComponent(*comp, false); diff --git a/tools/evaluator_generator/templates/evaluator_keyEpetraVectorIndented.cc b/tools/evaluator_generator/templates/evaluator_keyEpetraVectorIndented.cc index 0666e2a8e..c3faef0f5 100644 --- a/tools/evaluator_generator/templates/evaluator_keyEpetraVectorIndented.cc +++ b/tools/evaluator_generator/templates/evaluator_keyEpetraVectorIndented.cc @@ -10,4 +10,4 @@ const Epetra_MultiVector& { var } _v = * { var - } -> ViewComponent(*comp, false); +} -> ViewComponent(*comp, false); diff --git a/tools/evaluator_generator/templates/model.cc b/tools/evaluator_generator/templates/model.cc index db894cc5f..b334fd1b0 100644 --- a/tools/evaluator_generator/templates/model.cc +++ b/tools/evaluator_generator/templates/model.cc @@ -36,12 +36,20 @@ namespace Amanzi { // Initialize parameters - void{ evalClassName } Model::InitializeFromPlist_( - Teuchos::ParameterList & plist){ { { modelInitializeParamsList } } } + void{ evalClassName } Model::InitializeFromPlist_(Teuchos::ParameterList & plist) + { + { + { + modelInitializeParamsList + } + } + } // main method - { modelMethodImplementation } + { + modelMethodImplementation + } { modelDerivImplementationList diff --git a/tools/evaluator_generator/templates/model.hh b/tools/evaluator_generator/templates/model.hh index 946736e63..f5095bee1 100644 --- a/tools/evaluator_generator/templates/model.hh +++ b/tools/evaluator_generator/templates/model.hh @@ -31,7 +31,9 @@ namespace Amanzi { public : explicit { evalClassName } Model(Teuchos::ParameterList & plist); - { modelMethodDeclaration } + { + modelMethodDeclaration + } { modelDerivDeclarationList @@ -45,7 +47,7 @@ namespace Amanzi { paramDeclarationList } - } // namespace Relations + } // namespace Relations }; // namespace Relations } } // namespace } diff --git a/tools/evaluator_generator/test/results/eos_ideal_gas_evaluator.hh b/tools/evaluator_generator/test/results/eos_ideal_gas_evaluator.hh index 3e9cfbc7c..af9c024d0 100644 --- a/tools/evaluator_generator/test/results/eos_ideal_gas_evaluator.hh +++ b/tools/evaluator_generator/test/results/eos_ideal_gas_evaluator.hh @@ -48,8 +48,8 @@ class EosIdealGasEvaluator : public EvaluatorSecondaryMonotypeCV { virtual Teuchos::RCP Clone() const; // Required methods from EvaluatorSecondaryMonotypeCV - virtual void - EvaluateField_(const Teuchos::Ptr& S, const Teuchos::Ptr& result); + virtual void EvaluateField_(const Teuchos::Ptr& S, + const Teuchos::Ptr& result); virtual void EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, Key wrt_key, const Teuchos::Ptr& result); diff --git a/tools/evaluator_generator/test/results/eos_ideal_gas_evaluator_reg.hh b/tools/evaluator_generator/test/results/eos_ideal_gas_evaluator_reg.hh index fa1a38c2e..181fdad4d 100644 --- a/tools/evaluator_generator/test/results/eos_ideal_gas_evaluator_reg.hh +++ b/tools/evaluator_generator/test/results/eos_ideal_gas_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace General { namespace Relations { -Utils::RegisteredFactory - EosIdealGasEvaluator::reg_("ideal gas equation of state"); +Utils::RegisteredFactory EosIdealGasEvaluator::reg_( + "ideal gas equation of state"); } // namespace Relations } // namespace General diff --git a/tools/evaluator_generator/test2/results/eos_ideal_gas_evaluator.hh b/tools/evaluator_generator/test2/results/eos_ideal_gas_evaluator.hh index 0f313b09f..30b303cce 100644 --- a/tools/evaluator_generator/test2/results/eos_ideal_gas_evaluator.hh +++ b/tools/evaluator_generator/test2/results/eos_ideal_gas_evaluator.hh @@ -35,8 +35,8 @@ class EosIdealGasEvaluator : public EvaluatorSecondaryMonotypeCV { virtual Teuchos::RCP Clone() const; // Required methods from EvaluatorSecondaryMonotypeCV - virtual void - EvaluateField_(const Teuchos::Ptr& S, const Teuchos::Ptr& result); + virtual void EvaluateField_(const Teuchos::Ptr& S, + const Teuchos::Ptr& result); virtual void EvaluateFieldPartialDerivative_(const Teuchos::Ptr& S, Key wrt_key, const Teuchos::Ptr& result); diff --git a/tools/evaluator_generator/test2/results/eos_ideal_gas_evaluator_reg.hh b/tools/evaluator_generator/test2/results/eos_ideal_gas_evaluator_reg.hh index fa1a38c2e..181fdad4d 100644 --- a/tools/evaluator_generator/test2/results/eos_ideal_gas_evaluator_reg.hh +++ b/tools/evaluator_generator/test2/results/eos_ideal_gas_evaluator_reg.hh @@ -13,8 +13,8 @@ namespace Amanzi { namespace General { namespace Relations { -Utils::RegisteredFactory - EosIdealGasEvaluator::reg_("ideal gas equation of state"); +Utils::RegisteredFactory EosIdealGasEvaluator::reg_( + "ideal gas equation of state"); } // namespace Relations } // namespace General diff --git a/tools/input_converters/xml-1.5-1.6.py b/tools/input_converters/xml-1.5-1.6.py new file mode 100644 index 000000000..18b26935a --- /dev/null +++ b/tools/input_converters/xml-1.5-1.6.py @@ -0,0 +1,698 @@ +#!/usr/bin/env python3 +"""ATS input converter from version 1.5 to master branch""" + +import sys, os +import numpy as np +import copy +try: + amanzi_xml = os.path.join(os.environ["AMANZI_SRC_DIR"], "tools","amanzi_xml") +except KeyError: + pass +else: + if amanzi_xml not in sys.path: + sys.path.append(amanzi_xml) + +from amanzi_xml.utils import search as asearch +from amanzi_xml.utils import io as aio +from amanzi_xml.utils import errors as aerrors +from amanzi_xml.common import parameter, parameter_list, comment +import fix_chemistry_ts_control + +def moveLC(xml): + ics = asearch.find_path(xml, ["state", "initial conditions"]) + + if ics.isElement("land cover types"): + lc = ics.pop("land cover types") + model_pars = xml.sublist("state").sublist("model parameters") + model_pars.append(lc) + +def viscosityRelationType(xml): + for par in asearch.findall_path(xml, ["state", "evaluators", "viscosity relation type"]): + par.setName("viscosity type") + +def molarMass(xml): + for par in asearch.findall_path(xml, ["state", "evaluators", "molar mass"]): + par.setName("molar mass [kg mol^-1]") + +def enforceDtHistory(xml): + """Find and revert the timestep from file option, moving it to the cycle driver list. + + Note, this was intermediary -- this changed a few times and is not + relevant to users, only regression tests. + + """ + ti_file_pars = None + for ti in asearch.findall_name(xml, "time integrator"): + if asearch.child_by_name(ti, "timestep controller type").getValue() == "from file": + for child in ti: + if child.getName().startswith("timestep controller") and \ + child.getName().endswith("parameters") and \ + child.getName() != "timestep controller from file parameters": + new_type = child.getName()[len("timestep controller "):-len(" parameters")] + asearch.child_by_name(ti, "timestep controller type").setValue(new_type) + break + ti_file_pars = ti.pop("timestep controller from file parameters") + + if ti_file_pars is not None: + # push the filename into the cycle driver list instead. We + # just use the last one found -- they should all be the same! + cycle_driver_list = asearch.child_by_name(xml, "cycle driver") + tsm_list = cycle_driver_list.sublist("timestep manager") + tsm_list.setParameter("prescribed timesteps file name", "string", asearch.child_by_name(ti_file_pars, "file name").getValue()) + + +def timeStep(xml): + """Many parameters changed "time step" --> "timestep" """ + def fix(xml, pname): + for p in asearch.findall_name(xml, pname): + p.setName(pname.replace("time step", "timestep")) + + fix(xml, "time step reduction factor") + fix(xml, "time step control method") + fix(xml, "time step increase factor") + fix(xml, "time step cut factor") + fix(xml, "time step cut threshold") + fix(xml, "time step increase threshold") + fix(xml, "max time step") + fix(xml, "min time step") + fix(xml, "max time step [s]") + fix(xml, "min time step [s]") + fix(xml, "max time step (s)") + fix(xml, "min time step (s)") + fix(xml, "initial time step") + fix(xml, "initial time step [s]") + fix(xml, "initial time step (s)") + fix(xml, "max valid change in saturation in a time step [-]") + fix(xml, "max valid change in ice saturation in a time step [-]") + fix(xml, "subcycling target time step [s]") + fix(xml, "time step") + + for ti in asearch.findall_name(xml, "timestep controller fixed parameters"): + if ti.isElement("initial timestep [s]"): + ti.getElement("initial timestep [s]").setName("timestep [s]") + + for ti_type in ["standard", "smarter"]: + for ti in asearch.findall_name(xml, f"timestep controller {ti_type} parameters"): + if not ti.isElement("initial timestep [s]"): + ti.setParameter("initial timestep [s]", "double", 1.0) + + +def tensorPerm(xml): + for eval_list in asearch.find_path(xml, ["state", "evaluators"], True): + ename = eval_list.getName() + if ename == "permeability" or ename.endswith("-permeability"): + tensorPerm_(eval_list) + + +def tensorPerm_(perm): + # set the type to tensor + ptype = perm.getElement("evaluator type") + if ptype.getValue() == "independent variable": + ptype.setValue("independent variable tensor") + elif ptype.getValue() == "independent variable constant": + ptype.setValue("independent variable tensor") + + # create the function list + value = perm.getElement("value").getValue() + flist = perm.sublist("function").sublist("domain") + flist.setParameter("region", "string", "computational domain") + flist.setParameter("component", "string", "cell") + flist.sublist("function").sublist("function-constant").setParameter("value", 'double', value) + + else: + return + + # set the rank + if not perm.isElement("tensor rank"): + if perm.isElement("permeability type"): + tt = perm.getElement("permeability type") + tt.setName("tensor type") + if tt.getValue() == "full tensor": + tt.setValue("full symmetric") + elif tt.getValue() == "diagonal tensor": + tt.setValue("diagonal") + else: + perm.setParameter("tensor type", "string", "scalar") + + +def _pkTreeIter(tree, recurse=True): + yield tree + for el in tree: + if el.getName() != "PK type": + for pk in _pkTreeIter(el, recurse): + yield pk + + +def coupledFlowTransportMPC(xml): + pk_tree = asearch.find_path(xml, ["cycle driver", "PK tree"]) + pk_list = asearch.find_path(xml, ["PKs",]) + + transport_pk_types = ["transport ATS", "surface subsurface transport"] + flow_pk_types = ["richards flow", "richards steady state", "overland flow, pressure basis", + "subsurface permafrost", "icy surface", "permafrost model", "coupled water", + "operator split coupled water", "operator split permafrost",] + + for pk in _pkTreeIter(list(pk_tree)[0]): + if pk.getElement("PK type").getValue() == "subcycling MPC": + subpk_types = [el.getElement("PK type").getValue() for el in pk if el.getName() != "PK type"] + print(f'Found a subcycling MPC with subpk types: {subpk_types}') + + if len(subpk_types) == 2 and \ + subpk_types[0] in flow_pk_types and \ + subpk_types[1] in transport_pk_types: + print(f'... changing to type "coupled flow and transport"') + pk.getElement("PK type").setValue("coupled flow and transport") + pk_list.sublist(pk.getName()).getElement("PK type").setValue("coupled flow and transport") + + +def removeTc99(xml): + # Tc-99 not a valid name + for cnames in asearch.findall_path(xml, ["component names",]): + old_names = cnames.getValue() + new_names = [] + for name in cnames.getValue(): + if name == 'Tc-99': + new_names.append('Tracer1') + elif '-' in name: + # - is ok at the end, e.g. HCO3-, but not in the middle, e.g. Tc-99 + count = 0 + while name.endswith('-'): + count += 1 + name = name[:-1] + + new_name = name.replace('-', '') + new_name = new_name + '-'*count + new_names.append(new_name) + else: + new_names.append(name) + cnames.setValue(new_names) + + +def removeVerboseObject(xml): + """This is only for regression tests -- should not override user.""" + pm = asearch.parent_map(xml) + + # let global verbosity control for tests + for vo in asearch.findall_path(xml, ["verbose object",]): + pm[vo].remove(vo) + + +def _getKey(domain, key): + if domain == '' or domain == 'domain': + return key + else: + return '-'.join([domain, key]) + +def _getVarName(key): + if '-' not in key: + return key + else: + return key.split('-')[1] + + +def _readSuffix(plist, domain_name, varname, default=None): + if plist.isElement(f"{varname} key suffix"): + return plist.getElement(f"{varname} suffix").getValue() + elif plist.isElement(f"{varname} key"): + return _getVarName(plist.getElement(f"{varname} key")) + else: + return default + + +def _createTransportSource_Simple(in_source, out_source, components, dist_method): + """Constructs an evaluator for function""" + # check the submodel -- only support rate for now? + if in_source.isElement("submodel"): + submodel = in_source.getElement("submodel").getValue() + else: + submodel = "rate" + + if submodel != "rate": + raise RuntimeError(f"Cannot fix transport source: {in_source.name()} -- do not support Simple/Volume submodel {submodel}") + + # set the evaluator type + out_source.setParameter("evaluator type", "string", "independent variable") + out_source.setParameter("spatial distribution method", "string", dist_method); + + out_source_entry = out_source.sublist("function").sublist(in_source.getName()) + + # pass all parameters from in list to out list + skip = ["submodel"] + [out_source_entry.append(par) for par in in_source if par.getName() not in skip] + out_source_entry.sublist("source function").setName("function") + + # make it a cell function + out_source_entry.insert(1, parameter.StringParameter("component", "cell")) + + # check that num_components and num_dofs match those in PK list (if they exist) + if components is not None: + components = [c.strip() for c in components] + + # check that this matches the source + if out_source_entry.isElement("component names"): + func_comps = out_source_entry.getElement("component names").getValue() + if len(func_comps) != len(components): + # try to remap the components to a full-dof vector set of components + mapping = dict() + for i,comp in enumerate(func_comps): + mapping[comp] = (i, components.index(comp)) + + # if that was successful, remap the DoFs + asearch.find_path(out_source_entry, ["number of dofs",]).setValue(len(components)) + for c in mapping.keys(): + func_i, pk_i = mapping[c] + func_i_list = asearch.find_path(out_source_entry, [f"dof {func_i+1} function",]) + func_i_list.setName(f"dof {pk_i+1} function") + + n_dofs = 1 + if out_source_entry.sublist("function").isElement("number of dofs"): + n_dofs = out_source_entry.sublist("function").getElement("number of dofs").getValue() + + if n_dofs != len(components): + raise RuntimeError(f"Cannot fix transport source: {in_source.name()} -- number of function DoFs ({n_dofs})" + f" does not match num components from PK ({len(components)}).") + return + + + + +def _createTransportSource_FirstOrderExchange(in_source, out_source, evals_list, domain, alpha_suffix): + out_source.setParameter("evaluator type", "string", "multiplicative reciprocal") + + # first order exchange flux = - alpha * Theta * X / CV + lwc_suffix = _readSuffix(in_source, domain, "liquid water content", "water_content") + exchange_suffix = _readSuffix(in_source, domain, "exchanged quantity", "mole_fraction") + out_source.setParameter("multiplicative dependency key suffixes", "Array(string)", [alpha_suffix, lwc_suffix, exchange_suffix]) + out_source.setParameter("reciprocal dependency key suffixes", "Array(string)", ["cell_volume",]) + out_source.setParameter("coefficient", "double", -1.0) + + # alpha -- always constant in time? + alpha_eval_list = evals_list.sublist(_getKey(domain, alpha_suffix)) + alpha_eval_list.setParameter("evaluator type", "string", "independent variable") + alpha_eval_list.setParameter("constant in time", "bool", True) + + func_list = in_source.sublist("source function").sublist("function") + regions = in_source.getElement("regions") + entry_list = alpha_eval_list.sublist("function").sublist("entry") + entry_list.append(regions) + entry_list.setParameter("component", "string", "cell") + entry_list.append(func_list) + return + + +def _createTransportSource_SubgridReturn(in_source, out_source): + out_source.setParameter("evaluator type", "string", "subgrid return") + + if in_source.sublist("source function").isElement("subgrid domain set"): + subgrid_ds_name = in_source.sublist("source function").getElement("subgrid domain set").getValue() + else: + subgrid_ds_name = "subgrid" + mol_frac_suffix = in_source.sublist("source function").getElement("subgrid field suffix").getValue() + out_source.setParameter("subgrid domain set", "string", subgrid_ds_name) + out_source.setParameter("subgrid field suffix", "string", mol_frac_suffix) + + exchange_coef_suffix = f"exchange_coefficient_{subgrid_ds_name}" + out_source.setParameter("exchange coefficient key suffix", "string", exchange_coef_suffix) + return exchange_coef_suffix, subgrid_ds_name + + +def _fixTransportPK_OneSource(source_term, pk, evals_list, domain, **kwargs): + """Move ONE source terms from PK to evaluators.""" + + # try to come up with a reasonable name for the field + name = source_term.getName().lower() + if name.startswith(f'{domain}-'): + name = name[len(domain)+1:] + + name = name.replace(':', '_').replace('-', '_').replace(' ', '_').replace('@','_') + while '__' in name: + name = name.replace('__', '_') + if 'source' not in name and 'sink' not in name and 'return' not in name: + name = name + "_source" + + suffix = name + if domain != '' and domain != "domain": + name = f"{domain}-{name}" + + # check the model and call the right function + model = source_term.getElement("spatial distribution method").getValue() + if model == "volume" or model == "none": + # create the eval list + new_source = evals_list.sublist(name) + source_term.pop("spatial distribution method") + ret = _createTransportSource_Simple(source_term, new_source, kwargs["components"], model) + + elif model == "first order exchange": + new_source = evals_list.sublist(name) + ret = _createTransportSource_FirstOrderExchange(source_term, new_source, evals_list, domain, kwargs['alpha_suffix']) + + elif model == "subgrid return": + new_source = evals_list.sublist(name) + ret = _createTransportSource_SubgridReturn(source_term, new_source) + + elif model == "domain coupling": + raise RuntimeError(f"Transport source {source_term.getName()} is a 'domain coupling' source -- " + "this should get written by an MPC -- do you really need to provide it?") + else: + return None + + return suffix, ret + + +def fixTransportPK_Source(pk, evals_list, domain, components): + """Moves source terms from PK to evaluators, like all other ATS PKs.""" + sources = [] + + if pk.isElement("source terms"): + source_terms = pk.sublist("source terms").sublist("component mass source") + + # each entry is a separate source + for source_term in list(source_terms): + if not isinstance(source_term, comment.Comment): + model = source_term.getElement("spatial distribution method").getValue() + + if model not in ["first order exchange", "subgrid return"]: + res = _fixTransportPK_OneSource(source_term, pk, evals_list, domain, + components=components) + if res is not None: + sources.append(res[0]) + source_terms.remove(source_term) + + # second pass for subgrid return + first order exchange + for source_term in list(source_terms): + if not isinstance(source_term, comment.Comment): + model = source_term.getElement("spatial distribution method").getValue() + if model == "subgrid return": + # do the subgrid return + suffix, (exchange_coef, domain_set) = _fixTransportPK_OneSource(source_term, pk, evals_list, domain) + sources.append(suffix) + source_terms.remove(source_term) + + # find the corresponding first order exchange + found = False + for source_term2 in list(source_terms): + if not isinstance(source_term2, comment.Comment): + model = source_term2.getElement("spatial distribution method").getValue() + if model == "first order exchange" and domain_set in source_term2.getName().lower(): + found = True + suffix = _fixTransportPK_OneSource(source_term2, pk, evals_list, domain, alpha_suffix=exchange_coef) + sources.append(suffix[0]) + source_terms.remove(source_term2) + if not found: + raise RuntimeError(f"Cannot find corresponding first order exchange flux for return flux named \"{source_term}\"") + + # clean up empty lists + if len(source_terms) == 0: + pk.sublist("source terms").remove(source_terms) + if len(pk.sublist("source terms")) == 0: + pk.pop("source terms") + + if len(sources) > 0: + pk.setParameter("source term", 'bool', True) + + if len(sources) == 1: + # if only one source, name it for the PK + pk.setParameter("source key suffix", "string", sources[0]) + else: + # if more than one source, we have to create an additive + # evaluator to sum the sources + assert not evals_list.isElement(f'{domain}-component_source') + total_source_list = evals_list.sublist(f'{domain}-component_source') + total_source_list.setParameter("evaluator type", "string", "additive evaluator") + total_source_list.setParameter("dependency suffixes", "Array(string)", sources) + + pk.setParameter("source key suffix", "string", "component_source") + + +def fixTransportPK_Dead(pk, evals_list): + """Removes dead options from transport PK list.""" + # internal subcycling is dead + if pk.isElement("transport subcycling"): + pk.pop("transport subcycling") + + # runtime diagnostics is dead + if pk.isElement("runtime diagnostics: regions"): + pk.pop("runtime diagnostics: regions") + + # remove dead keys + def removeDead(keyname, default_names, evals_list, remove_eval=False): + if isinstance(default_names, str): + default_names = [default_names,] + keyname_key = keyname + " key" + + if pk.isElement(keyname_key): + key = pk.getElement(keyname_key).getValue() + if key in default_names: + pk.pop(keyname_key) + if remove_eval and evals_list.isElement(key): + evals_list.pop(key) + + keyname_key = keyname_key + " suffix" + default_names = [dn.split('-')[-1] for dn in default_names] + if pk.isElement(keyname_key): + key = pk.getElement(keyname_key).getValue() + if key in default_names: + pk.pop(keyname_key) + + removeDead("porosity", ["porosity",], evals_list) + removeDead("porosity", ["surface-porosity", "surface-one"], evals_list, True) + removeDead("molar density liquid", ["surface-molar_density_liquid", "molar_density_liquid"], evals_list) + removeDead("saturation", ["surface-saturation_liquid", "surface-ponded_depth", "saturation_liquid"], evals_list) + removeDead("saturation liquid", ["surface-saturation_liquid", "surface-ponded_depth", "saturation_liquid"], evals_list) + removeDead("flux", ["surface-water_flux", "water_flux"], evals_list) + removeDead("water flux", ["surface-water_flux", "water_flux"], evals_list) + if pk.isElement("flux_key"): + pk.pop("flux_key") + if pk.isElement("molar_density_key"): + pk.pop("molar_density_key") + + if pk.isElement("number of liquid components"): + pk.pop("number of liquid components") + if pk.isElement("number of gaseous components") and pk.getElement("number of gaseous components").getValue() == 0: + pk.pop("number of gaseous components") + if pk.isElement("number of aqueous components") and pk.isElement("component names") and \ + pk.getElement("number of aqueous components").getValue() == len(pk.getElement("component names").getValue()): + pk.pop("number of aqueous components") + if pk.isElement("PK origin"): + pk.pop("PK origin") + if pk.isElement("solver"): + pk.pop("solver") + + if pk.isElement("physical models and assumptions"): + pk.pop("physical models and assumptions") + if pk.isElement("flow mode"): + pk.pop("flow mode") + + +def fixTransportPK(pk, evals_list): + """Many changes to transport PK input spec...""" + + # get the domain + if pk.isElement("domain name"): + domain = pk.getElement("domain name").getValue() + else: + domain = "domain" + + # spatial discretization order --> advection spatial discretization order + if not pk.isElement("advection spatial discretization order") and pk.isElement("spatial discretization order"): + order = pk.getElement("spatial discretization order") + order.setName("advection spatial discretization order") + order = pk.getElement("advection spatial discretization order").getValue() + if order == 1 and pk.isElement("reconstruction"): + # this is unused for order 1, remove it + pk.pop("reconstruction") + + # moves and changes format of molecular diffusion coefficient + if pk.isElement("molecular diffusion") and not pk.isElement("molecular diffusivity [m^2 s^-1]"): + md = pk.pop("molecular diffusion") + if md.isElement("aqueous names"): + names = md.getElement("aqueous names").getValue() + vals = md.getElement("aqueous values").getValue() + print("found MD for names:", names) + if len(names) > 0 and names[0] != '': + diff = pk.sublist("molecular diffusivity [m^2 s^-1]") + for name, val in zip(names, vals): + diff.setParameter(name.strip(), "double", val) + + # inverse list in diffusion list + if pk.isElement("inverse") and pk.isElement("diffusion"): + inv = pk.pop("inverse") + pk.sublist("diffusion").append(inv) + elif pk.isElement("inverse"): + pk.pop("inverse") + + # rehome material properties + if pk.isElement("material properties"): + mat_props = pk.pop("material properties").sublist("domain") + + # moves dispersion coefficient to MDM type + if mat_props.isElement("model"): + if domain == "domain": + disp_key = "dispersion_coefficient" + else: + disp_key = domain + "-dispersion_coefficient" + + if not evals_list.isElement(disp_key): + all_zero = True + disp_list = evals_list.sublist(disp_key) + disp_list.setParameter("evaluator type", "string", "dispersion tensor") + disp_list2 = disp_list.sublist("mechanical dispersion parameters").sublist(domain) + if domain == "domain": + disp_list2.setParameter("region", "string", "computational domain") + else: + disp_list2.setParameter("region", "string", domain + " domain") + + disp_type = mat_props.getElement("model").getValue() + if disp_type == "scalar": + disp_list2.setParameter("mechanical dispersion type", "string", "isotropic") + params_list = mat_props.sublist(f"parameters for {disp_type}") + params_list.setName("isotropic parameters") + disp_list2.append(params_list) + + for par in params_list: + if par.getValue() != 0.0: + all_zero = False + else: + disp_list2.setParameter("mechanical dispersion type", "string", disp_type) + params_list = mat_props.sublist(f"parameters for {disp_type}") + params_list.setName(f"{disp_type} parameters") + disp_list2.append(params_list) + + for par in params_list: + if par.getValue() != 0.0: + all_zero = False + + if all_zero: + # all params are zero, remove dispersivity compleletely + evals_list.pop(disp_key) + + # moves/reformats tortuosity + if mat_props.isElement("aqueous tortuosity"): + pk.sublist("tortuosity [-]").setParameter("aqueous", "double", mat_props.getElement("aqueous tortuosity").getValue()) + if mat_props.isElement("gaseous tortuosity"): + pk.sublist("tortuosity [-]").setParameter("gaseous", "double", mat_props.getElement("gaseous tortuosity").getValue()) + + # component molar masses gets units, moves to sublist + if pk.isElement("component molar masses"): + mms = pk.pop("component molar masses") + names = pk.getElement("component names").getValue() + for name, mm in zip(names, mms): + pk.sublist("molar mass [kg mol^-1]").setParameter(name, "double", mm) + + # look for a water_content, define if needed + if domain == "domain": + lwc_key = "water_content" + else: + lwc_key = f"{domain}-water_content" + + print(f'searching for LWC = {lwc_key}') + + if not evals_list.isElement(lwc_key): + print(' ... is not eval') + lwc_list = evals_list.sublist(lwc_key) + lwc_list.setParameter("evaluator type", "string", "multiplicative evaluator") + + if "surface" in domain: + print('adding surface quantities for LWC') + lwc_list.setParameter("dependencies", "Array(string)", [f"{domain}-ponded_depth", f"{domain}-molar_density_liquid", f"{domain}-cell_volume"]) + else: + print('adding subsurface quantities for LWC') + lwc_list.setParameter("dependencies", "Array(string)", ["saturation_liquid", "molar_density_liquid", "porosity", "cell_volume"]) + + # boundary conditions->concentration --> bondary conditions->mole fraction + bcs_list = pk.sublist('boundary conditions') + if bcs_list.isElement('concentration') and not bcs_list.isElement('mole fraction'): + bcs_list.sublist('concentration').setName('mole fraction') + + if bcs_list.isElement('mole fraction'): + mf = bcs_list.sublist('mole fraction') + for sublist in mf: + if sublist.isElement('boundary concentration function') and not sublist.isElement('boundary mole fraction function'): + sublist.sublist('boundary concentration function').setName('boundary mole fraction function') + + # remove dead options + fixTransportPK_Dead(pk,evals_list) + + # source terms are now evaluators + if pk.isElement("component names"): + components = pk.getElement("component names").getValue() + else: + components = None + fixTransportPK_Source(pk, evals_list, domain, components) + + +def fixTransportPKs(xml): + """Searches for all transport PKs and calls fixTransportPK""" + evals_list = asearch.find_path(xml, ["state", "evaluators"], True) + pk_tree = asearch.find_path(xml, ["cycle driver", "PK tree"]) + pk_list = asearch.find_path(xml, ["PKs",]) + + for pk in _pkTreeIter(list(pk_tree)[0]): + pk_type = pk.getElement("PK type") + + if pk_type.getValue() == "transport ATS": + print("fixing transport pk") + fixTransportPK(pk_list.sublist(pk.getName()), evals_list) + elif pk_type.getValue() == "transport ats": + pk_type.setValue("transport ATS") + print("fixing transport pk") + fixTransportPK(pk_list.sublist(pk.getName()), evals_list) + + +def initialConditionsList(xml): + """'initial condition' --> 'initial conditions'""" + for pk in xml.sublist("PKs"): + if pk.isElement("initial condition"): + pk.sublist("initial condition").setName("initial conditions") + + +def update(xml): + """This function always exists, and calls all other fix functions, allowing __main__ to be the same.""" + coupledFlowTransportMPC(xml) + + #enforceDtHistory(xml) + timeStep(xml) + tensorPerm(xml) + initialConditionsList(xml) + fixTransportPKs(xml) + + # this fixes chemistry + fix_chemistry_ts_control.fixAll(xml) + + # moves lc types from ICs -> model parameters + moveLC(xml) + + # viscosity relation type -> viscosity type + viscosityRelationType(xml) + + # molar mass --> molar mass [kg m^-3] + molarMass(xml) + + # tc-99 --> tracer + removeTc99(xml) + + # verbose object controlled by global verbosity + # NOTE: this is useful on tests, but a bad idea to use for user input files + # removeVerboseObject(xml) + + + +if __name__ == "__main__": + import argparse + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("infile", help="input filename") + + group = parser.add_mutually_exclusive_group() + group.add_argument("-i", "--inplace", action="store_true", help="fix file in place") + group.add_argument("-o", "--outfile", help="output filename") + args = parser.parse_args() + + # check for orig file + print("Converting file: %s"%args.infile) + xml = aio.fromFile(args.infile, True) + update(xml) + if args.inplace: + aio.toFile(xml, args.infile) + else: + aio.toFile(xml, args.outfile) + sys.exit(0) diff --git a/tools/input_converters/xml-1.5-master.py b/tools/input_converters/xml-1.5-master.py deleted file mode 100644 index 584b57d4b..000000000 --- a/tools/input_converters/xml-1.5-master.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env python3 -"""ATS input converter from version 1.5 to master branch""" - -import sys, os -import numpy as np -import copy -try: - amanzi_xml = os.path.join(os.environ["AMANZI_SRC_DIR"], "tools","amanzi_xml") -except KeyError: - pass -else: - if amanzi_xml not in sys.path: - sys.path.append(amanzi_xml) - -from amanzi_xml.utils import search as asearch -from amanzi_xml.utils import io as aio -from amanzi_xml.utils import errors as aerrors -from amanzi_xml.common import parameter, parameter_list - - -def enforceDtHistory(xml): - """Find and revert the timestep from file option, moving it to the cycle driver list.""" - ti_file_pars = None - for ti in asearch.findall_name(xml, "time integrator"): - if asearch.child_by_name(ti, "timestep controller type").getValue() == "from file": - for child in ti: - if child.getName().startswith("timestep controller") and \ - child.getName().endswith("parameters") and \ - child.getName() != "timestep controller from file parameters": - new_type = child.getName()[len("timestep controller "):-len(" parameters")] - asearch.child_by_name(ti, "timestep controller type").setValue(new_type) - break - ti_file_pars = ti.pop("timestep controller from file parameters") - - if ti_file_pars is not None: - # push the filename into the cycle driver list instead. We - # just use the last one found -- they should all be the same! - cycle_driver_list = asearch.child_by_name(xml, "cycle driver") - tsm_list = cycle_driver_list.sublist("timestep manager") - tsm_list.setParameter("prescribed timesteps file name", "string", asearch.child_by_name(ti_file_pars, "file name").getValue()) - -def timeStep(xml): - """Many parameters changed "time step" --> "timestep" """ - def fix(xml, pname): - for p in asearch.findall_name(xml, pname): - p.setName(pname.replace("time step", "timestep")) - - fix(xml, "time step reduction factor") - fix(xml, "time step control method") - fix(xml, "time step increase factor") - fix(xml, "time step cut factor") - fix(xml, "time step cut threshold") - fix(xml, "time step increase threshold") - fix(xml, "max time step") - fix(xml, "min time step") - fix(xml, "max time step [s]") - fix(xml, "min time step [s]") - fix(xml, "max time step (s)") - fix(xml, "min time step (s)") - fix(xml, "initial time step") - fix(xml, "initial time step [s]") - fix(xml, "initial time step (s)") - fix(xml, "max valid change in saturation in a time step [-]") - fix(xml, "max valid change in ice saturation in a time step [-]") - fix(xml, "subcycling target time step [s]") - fix(xml, "time step") - - for ti in asearch.findall_name(xml, "timestep controller fixed parameters"): - if ti.isElement("initial timestep [s]"): - ti.getElement("initial timestep [s]").setName("timestep [s]") - - for ti_type in ["standard", "smarter"]: - for ti in asearch.findall_name(xml, f"timestep controller {ti_type} parameters"): - if not ti.isElement("initial timestep [s]"): - ti.setParameter("initial timestep [s]", "double", 1.0) - - -def update(xml): - enforceDtHistory(xml) - timeStep(xml) - - -if __name__ == "__main__": - import argparse - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("infile", help="input filename") - - group = parser.add_mutually_exclusive_group() - group.add_argument("-i", "--inplace", action="store_true", help="fix file in place") - group.add_argument("-o", "--outfile", help="output filename") - args = parser.parse_args() - - # check for orig file - print("Converting file: %s"%args.infile) - xml = aio.fromFile(args.infile, True) - update(xml) - if args.inplace: - aio.toFile(xml, args.infile) - else: - aio.toFile(xml, args.outfile) - sys.exit(0) diff --git a/tools/meshing/extrude/extrude_homogeneous_variable.cc b/tools/meshing/extrude/extrude_homogeneous_variable.cc index 5dfd81c5a..643ce1e76 100644 --- a/tools/meshing/extrude/extrude_homogeneous_variable.cc +++ b/tools/meshing/extrude/extrude_homogeneous_variable.cc @@ -51,14 +51,11 @@ main() dzs[inode] = 0.0; continue; } - if (rem_soil[inode] > 2 * ref_soil_mlay_dz[ilay]) - dzs[inode] = ref_soil_mlay_dz[ilay]; + if (rem_soil[inode] > 2 * ref_soil_mlay_dz[ilay]) dzs[inode] = ref_soil_mlay_dz[ilay]; else if (rem_soil[inode] > ref_soil_mlay_dz[ilay] + eps_dz) dzs[inode] = 0.5 * rem_soil[inode]; - else if (rem_soil[inode] < ref_soil_mlay_dz[ilay] - eps_dz) - dzs[inode] = rem_soil[inode]; - else - dzs[inode] = ref_soil_mlay_dz[ilay]; + else if (rem_soil[inode] < ref_soil_mlay_dz[ilay] - eps_dz) dzs[inode] = rem_soil[inode]; + else dzs[inode] = ref_soil_mlay_dz[ilay]; rem_soil[inode] -= dzs[inode]; } @@ -86,14 +83,11 @@ main() dzs[inode] = 0.0; continue; } - if (rem_soil[inode] > 2 * ref_soil_mlay_dz[ilay]) - dzs[inode] = ref_soil_mlay_dz[ilay]; + if (rem_soil[inode] > 2 * ref_soil_mlay_dz[ilay]) dzs[inode] = ref_soil_mlay_dz[ilay]; else if (rem_soil[inode] > ref_soil_mlay_dz[ilay] + eps_dz) dzs[inode] = 0.5 * rem_soil[inode]; - else if (rem_soil[inode] < ref_soil_mlay_dz[ilay] - eps_dz) - dzs[inode] = rem_soil[inode]; - else - dzs[inode] = ref_soil_mlay_dz[ilay]; + else if (rem_soil[inode] < ref_soil_mlay_dz[ilay] - eps_dz) dzs[inode] = rem_soil[inode]; + else dzs[inode] = ref_soil_mlay_dz[ilay]; rem_soil[inode] -= dzs[inode]; } diff --git a/tools/meshing/extrude/extrude_uniform.cc b/tools/meshing/extrude/extrude_uniform.cc index f302021c1..b25e06165 100644 --- a/tools/meshing/extrude/extrude_uniform.cc +++ b/tools/meshing/extrude/extrude_uniform.cc @@ -38,7 +38,9 @@ main() int nsnodes = m.coords.size(); Mesh3D m3(&m, nsoil_lay + nbedrock_lay); - for (int ilay = 0; ilay != nsoil_lay; ++ilay) { m3.extrude(ref_soil_mlay_dz[ilay], soil_type); } + for (int ilay = 0; ilay != nsoil_lay; ++ilay) { + m3.extrude(ref_soil_mlay_dz[ilay], soil_type); + } for (int ilay = 0; ilay != nbedrock_lay; ++ilay) { m3.extrude(ref_bedrock_mlay_dz[ilay], bedrock_type); } diff --git a/tools/meshing/extrude/extrude_variable.cc b/tools/meshing/extrude/extrude_variable.cc index 93a228356..5642ad8dd 100644 --- a/tools/meshing/extrude/extrude_variable.cc +++ b/tools/meshing/extrude/extrude_variable.cc @@ -58,14 +58,11 @@ main() dzs[inode] = 0.0; continue; } - if (rem_soil[inode] > 2 * ref_soil_mlay_dz[ilay]) - dzs[inode] = ref_soil_mlay_dz[ilay]; + if (rem_soil[inode] > 2 * ref_soil_mlay_dz[ilay]) dzs[inode] = ref_soil_mlay_dz[ilay]; else if (rem_soil[inode] > ref_soil_mlay_dz[ilay] + eps_dz) dzs[inode] = 0.5 * rem_soil[inode]; - else if (rem_soil[inode] < ref_soil_mlay_dz[ilay] - eps_dz) - dzs[inode] = rem_soil[inode]; - else - dzs[inode] = ref_soil_mlay_dz[ilay]; + else if (rem_soil[inode] < ref_soil_mlay_dz[ilay] - eps_dz) dzs[inode] = rem_soil[inode]; + else dzs[inode] = ref_soil_mlay_dz[ilay]; rem_soil[inode] -= dzs[inode]; } diff --git a/tools/meshing/extrude/src/Mesh.cc b/tools/meshing/extrude/src/Mesh.cc index 15abbe01d..9ca66a521 100644 --- a/tools/meshing/extrude/src/Mesh.cc +++ b/tools/meshing/extrude/src/Mesh.cc @@ -20,7 +20,9 @@ Mesh2D::Mesh2D(std::vector& coords_, { double area_eps = 1.e-6; - for (auto& set : cell_sets) { AMANZI_ASSERT(set.size() == cell2node.size()); } + for (auto& set : cell_sets) { + AMANZI_ASSERT(set.size() == cell2node.size()); + } nnodes = coords.size(); ncells = cell2node.size(); @@ -30,7 +32,9 @@ Mesh2D::Mesh2D(std::vector& coords_, v1.set(coords[c[1]][0] - coords[c[0]][0], coords[c[1]][1] - coords[c[0]][1]); v2.set(coords[c[2]][0] - coords[c[0]][0], coords[c[2]][1] - coords[c[0]][1]); Point cross = v1 ^ v2; - if (cross[0] < 0) { std::reverse(c.begin(), c.end()); } + if (cross[0] < 0) { + std::reverse(c.begin(), c.end()); + } if (std::abs(cross[0]) < area_eps) { std::cout << "Zero area triangle:" << std::endl << " " << coords[c[0]] << std::endl @@ -131,12 +135,16 @@ Mesh3D::Mesh3D(const Mesh2D* const m_, int n_layers) // move the 2d cell sets to face sets on the surface std::set set_ids; - for (auto& part : m->cell_sets) { set_ids.insert(part.begin(), part.end()); } + for (auto& part : m->cell_sets) { + set_ids.insert(part.begin(), part.end()); + } for (int sid : set_ids) { std::vector set_cells; for (auto& part : m->cell_sets) { for (int c = 0; c != part.size(); ++c) { - if (part[c] == sid) { set_cells.push_back(c); } + if (part[c] == sid) { + set_cells.push_back(c); + } } } std::vector set_faces(set_cells.size(), 0); diff --git a/tools/meshing/extrude/src/Mesh2D.cc b/tools/meshing/extrude/src/Mesh2D.cc index 568658b59..46726f839 100644 --- a/tools/meshing/extrude/src/Mesh2D.cc +++ b/tools/meshing/extrude/src/Mesh2D.cc @@ -20,7 +20,9 @@ Mesh2D::Mesh2D(std::vector& coords_, { double area_eps = 1.e-6; - for (auto& set : cell_sets) { AMANZI_ASSERT(set.size() == cell2node.size()); } + for (auto& set : cell_sets) { + AMANZI_ASSERT(set.size() == cell2node.size()); + } nnodes = coords.size(); ncells = cell2node.size(); @@ -30,7 +32,9 @@ Mesh2D::Mesh2D(std::vector& coords_, v1.set(coords[c[1]][0] - coords[c[0]][0], coords[c[1]][1] - coords[c[0]][1]); v2.set(coords[c[2]][0] - coords[c[0]][0], coords[c[2]][1] - coords[c[0]][1]); Point cross = v1 ^ v2; - if (is_greater(0.0, cross[0])) { std::reverse(c.begin(), c.end()); } + if (is_greater(0.0, cross[0])) { + std::reverse(c.begin(), c.end()); + } if (is_greater(area_eps, std::abs(cross[0]))) { std::cout << "Zero area triangle:" << std::endl << " " << coords[c[0]] << std::endl diff --git a/tools/meshing/extrude/src/Mesh3D.cc b/tools/meshing/extrude/src/Mesh3D.cc index 1ef7f7e50..0ea8f4655 100644 --- a/tools/meshing/extrude/src/Mesh3D.cc +++ b/tools/meshing/extrude/src/Mesh3D.cc @@ -167,13 +167,17 @@ Mesh3D::finish() // move the 2d cell sets to face sets on the surface std::set set_ids; - for (auto& part : m->cell_sets) { set_ids.insert(part.begin(), part.end()); } + for (auto& part : m->cell_sets) { + set_ids.insert(part.begin(), part.end()); + } for (int sid : set_ids) { std::vector set_cells; for (auto& part : m->cell_sets) { for (int c = 0; c != part.size(); ++c) { - if (part[c] == sid) { set_cells.push_back(side_sets[1].first[c]); } + if (part[c] == sid) { + set_cells.push_back(side_sets[1].first[c]); + } } } std::vector set_faces(set_cells.size(), 0); diff --git a/tools/meshing/extrude/src/Point.hh b/tools/meshing/extrude/src/Point.hh index 0b3a1ad42..ab14e6ece 100644 --- a/tools/meshing/extrude/src/Point.hh +++ b/tools/meshing/extrude/src/Point.hh @@ -67,7 +67,7 @@ class Point { xyz[1] = y; xyz[2] = z; } - ~Point(){}; + ~Point() {}; // main members diff --git a/tools/meshing/extrude/src/dbc.cc b/tools/meshing/extrude/src/dbc.cc index ab3ff5fcd..4db63137e 100644 --- a/tools/meshing/extrude/src/dbc.cc +++ b/tools/meshing/extrude/src/dbc.cc @@ -14,7 +14,7 @@ namespace DBC { Assertion::Assertion(const char* assertion, const char* filename, unsigned int line_number) - : assertion_(assertion), filename_(filename), line_number_(line_number){}; + : assertion_(assertion), filename_(filename), line_number_(line_number) {}; const char* diff --git a/tools/meshing/extrude/src/dbc.hh b/tools/meshing/extrude/src/dbc.hh index 46c5ef3c9..237631132 100644 --- a/tools/meshing/extrude/src/dbc.hh +++ b/tools/meshing/extrude/src/dbc.hh @@ -30,8 +30,7 @@ class Assertion : public Exceptions::Amanzi_exception { unsigned int line_number_; }; -void -amanzi_assert(const char* cond, const char* file, unsigned int line); +void amanzi_assert(const char* cond, const char* file, unsigned int line); } // namespace DBC @@ -46,15 +45,15 @@ amanzi_assert(const char* cond, const char* file, unsigned int line); // unused variables in the expression a. #ifdef ENABLE_DBC -# define AMANZI_ASSERT(bool_expression) \ - do { \ - if (!(bool_expression)) DBC::amanzi_assert(#bool_expression, __FILE__, __LINE__); \ - } while (0) +#define AMANZI_ASSERT(bool_expression) \ + do { \ + if (!(bool_expression)) DBC::amanzi_assert(#bool_expression, __FILE__, __LINE__); \ + } while (0) #else -# define AMANZI_ASSERT(a) \ - do { \ - (void)sizeof(a); \ - } while (0); +#define AMANZI_ASSERT(a) \ + do { \ + (void)sizeof(a); \ + } while (0); #endif /* ENABLE_DBC */ diff --git a/tools/meshing/extrude/src/exceptions.hh b/tools/meshing/extrude/src/exceptions.hh index 128643f32..a10701002 100644 --- a/tools/meshing/extrude/src/exceptions.hh +++ b/tools/meshing/extrude/src/exceptions.hh @@ -22,13 +22,10 @@ class Amanzi_exception : public std::exception {}; enum Exception_action { RAISE, ABORT }; // Functions for setting and querying the current exception behavior. -void -set_exception_behavior_raise(); -void -set_exception_behavior_abort(); +void set_exception_behavior_raise(); +void set_exception_behavior_abort(); void set_exception_behavior(Exception_action); -Exception_action -exception_behavior(); +Exception_action exception_behavior(); } // namespace Exceptions @@ -41,14 +38,12 @@ Exceptions::Exception_action behavior = Exceptions::RAISE; namespace Exceptions { // Either raise the given exception or abort, depending on the value of behavior. -template +template void amanzi_throw(const E& exception) { - if (behavior == Exceptions::RAISE) - throw exception; - else - abort(); + if (behavior == Exceptions::RAISE) throw exception; + else abort(); } } // namespace Exceptions diff --git a/tools/meshing/extrude/src/readMesh2D.hh b/tools/meshing/extrude/src/readMesh2D.hh index 049500d2d..a2b2e6539 100644 --- a/tools/meshing/extrude/src/readMesh2D.hh +++ b/tools/meshing/extrude/src/readMesh2D.hh @@ -42,13 +42,12 @@ struct PointFactory { std::vector points; }; -Mesh2D -readMesh2D_text(const std::string& filename, - std::vector& soil_type, - std::vector& bedrock_type, - std::vector& depth_to_bedrock, - double cut_x = 1.e80, - double cut_y = 1.e80); +Mesh2D readMesh2D_text(const std::string& filename, + std::vector& soil_type, + std::vector& bedrock_type, + std::vector& depth_to_bedrock, + double cut_x = 1.e80, + double cut_y = 1.e80); } // namespace AmanziGeometry } // namespace Amanzi diff --git a/tools/meshing/extrude/src/writeMesh3D.cc b/tools/meshing/extrude/src/writeMesh3D.cc index 70a83cccc..f111ba3bd 100644 --- a/tools/meshing/extrude/src/writeMesh3D.cc +++ b/tools/meshing/extrude/src/writeMesh3D.cc @@ -91,7 +91,9 @@ writeMesh3D_exodus(const Mesh3D& m, const std::string& filename) // make the coordinate arrays, set the coordinates // NOTE: exodus seems to only deal with floats! std::vector> coords(3); - for (int i = 0; i != 3; ++i) { coords[i].resize(m.coords.size()); } + for (int i = 0; i != 3; ++i) { + coords[i].resize(m.coords.size()); + } for (int n = 0; n != coords[0].size(); ++n) { coords[0][n] = m.coords[n][0]; @@ -160,7 +162,9 @@ writeMesh3D_exodus(const Mesh3D& m, const std::string& filename) auto& s = m.side_sets[lcvs]; std::vector elems_copy(s.first.size(), -1); auto faces_copy(s.second); - for (int i = 0; i != elems_copy.size(); ++i) { elems_copy[i] = cell_map[s.first[i]] + 1; } + for (int i = 0; i != elems_copy.size(); ++i) { + elems_copy[i] = cell_map[s.first[i]] + 1; + } for (auto& e : faces_copy) e++; ierr |= ex_put_set_param(fid, EX_SIDE_SET, m.side_sets_id[lcvs], elems_copy.size(), 0); AMANZI_ASSERT(!ierr); diff --git a/tools/meshing/extrude/src/writeMesh3D.hh b/tools/meshing/extrude/src/writeMesh3D.hh index 986b1c360..15bebaf08 100644 --- a/tools/meshing/extrude/src/writeMesh3D.hh +++ b/tools/meshing/extrude/src/writeMesh3D.hh @@ -16,8 +16,7 @@ namespace Amanzi { namespace AmanziGeometry { -void -writeMesh3D_exodus(const Mesh3D& m, const std::string& filename); +void writeMesh3D_exodus(const Mesh3D& m, const std::string& filename); } } // namespace Amanzi diff --git a/tools/testing/test_manager.py b/tools/testing/test_manager.py index 5e7655f70..ca937bd87 100644 --- a/tools/testing/test_manager.py +++ b/tools/testing/test_manager.py @@ -30,7 +30,6 @@ import textwrap import time import traceback -import distutils.spawn import numpy import collections import configparser @@ -40,6 +39,15 @@ _aliases = {'surface-water_flux':['surface-mass_flux','surface-mass_flux_next'], 'water_flux':['mass_flux','mass_flux_next'], 'saturation_liquid':['prev_saturation_liquid'], + 'free_ion_species':['primary_free_ion_concentration',], + 'mole_fraction':['molar_ratio','molar_mixing_ratio',], + 'surface-mole_fraction':['surface-molar_ratio','surface-molar_mixing_ratio',], + 'subgrid:9-mole_fraction':['subgrid:9-molar_ratio','subgrid:9-molar_mixing_ratio',], + 'subgrid:0-mole_fraction':['subgrid:0-molar_ratio','subgrid:0-molar_mixing_ratio',], + 'subgrid_1:9-mole_fraction':['subgrid_1:9-molar_ratio','subgrid_1:9-molar_mixing_ratio',], + 'subgrid_1:0-mole_fraction':['subgrid_1:0-molar_ratio','subgrid_1:0-molar_mixing_ratio',], + 'subgrid_2:9-mole_fraction':['subgrid_2:9-molar_ratio','subgrid_2:9-molar_mixing_ratio',], + 'subgrid_2:0-mole_fraction':['subgrid_2:0-molar_ratio','subgrid_2:0-molar_mixing_ratio',], } @@ -362,17 +370,14 @@ def _run_test(self, test_name, dry_run, status, testlog): message = self._txtwrap.fill( "FAIL : {name} : {execute} return an error " "code ({status}) indicating the simulation may have " - "failed. Please check '{name}.stdout' " - "for error messages (included below).".format( - execute=self._executable, name=test_name, status=ierr_status)) + "failed. Please check '{stdout}' " + "for error messages.".format( + execute=self._executable, + name=test_name, + status=ierr_status, + stdout=os.path.join(test_directory, f'{test_name}.stdout'))) print("".join(['\n', message, '\n']), file=testlog) - print("~~~~~ {0}.stdout ~~~~~".format(test_name), file=testlog) - try: - with open("{0}.stdout".format(test_name), 'r') as tempfile: - shutil.copyfileobj(tempfile, testlog) - except Exception as e: - print(" Error opening file: {0}.stdout\n {1}".format(test_name, e)) print("~~~~~~~~~~", file=testlog) os.chdir(test_directory) @@ -1061,7 +1066,7 @@ def _run_check(self, dry_run, testlog): test.run(dry_run, status, testlog) - if not dry_run and status.skipped == 0: + if not (status.fail or dry_run or status.skipped): test.check(status, testlog) self._add_to_file_status(status) @@ -1489,7 +1494,7 @@ def check_for_executable(options, testlog): if options.executable is None: # try to detect from env try: - executable = distutils.spawn.find_executable("ats") + executable = shutil.which("ats") except Exception: executable = None finally: @@ -1533,7 +1538,7 @@ def check_for_mpiexec(options, testlog): if options.mpiexec is None: # try to detect from env try: - mpiexec = distutils.spawn.find_executable("mpiexec") + mpiexec = shutil.which("mpiexec") except IOError: mpiexec = None else: @@ -1705,3 +1710,34 @@ def setup_testlog(txtwrap, silence=False): return testlog + +def find_last_logfile(entry=-1): + """ + Finds the last-in-time logfile from the LOGS directory. + """ + logfiles = [l for l in os.listdir("LOGS") if l.startswith('ats-tests-') \ + and l.endswith('.testlog')] + all_files = list(sorted(logfiles)) + return os.path.join('LOGS', all_files[entry]) + + +def find_failed(logfile): + """ + Given a logfile, searches for all failed tests. + + Failed tests will include an entry of the form: + + FAIL : TESTNAME : ... + + or + + ERROR : TESTNAME : ... + """ + with open(logfile, 'r') as fid: + failed = set(l.split(':')[1].strip() for l in fid \ + if l.strip().startswith(('FAIL','ERROR'))) + return list(failed) + + + + diff --git a/tools/utils/ats_xdmf.py b/tools/utils/ats_xdmf.py index 10fcdcf99..143f9912e 100644 --- a/tools/utils/ats_xdmf.py +++ b/tools/utils/ats_xdmf.py @@ -3,7 +3,12 @@ import sys,os import numpy as np import h5py +import math import matplotlib.collections +from matplotlib import pyplot as plt +import plot_lines + +from numpy import s_ as s def valid_data_filename(domain, format=None): """The filename for an HDF5 data filename formatter""" @@ -22,10 +27,28 @@ def valid_mesh_filename(domain, format=None): format = 'ats_vis_{}_mesh.h5' return valid_data_filename(domain, format) +def time_unit_conversion(value, input_unit, output_unit): + time_in_seconds = { + 'yr': 365.25 * 24 * 3600, + 'noleap': 365 * 24 *3600, + 'd': 24 * 3600, + 'hr': 3600, + 's': 1 + } + if input_unit not in time_in_seconds: + raise ValueError("Invalid input time unit : must be one of 'yr', 'noleap', 'd', 'hr', or 's'") + if output_unit not in time_in_seconds: + raise ValueError("Invalid output time unit : must be one of 'yr', 'noleap', 'd', 'hr', or 's'") + + value2sec = value * time_in_seconds[input_unit] + output_value = value2sec / time_in_seconds[output_unit] + return output_value + class VisFile: """Class managing the reading of ATS visualization files.""" - def __init__(self, directory='.', domain=None, filename=None, mesh_filename=None, time_unit='yr'): + def __init__(self, directory='.', domain=None, filename=None, mesh_filename=None, + input_time_unit='yr', output_time_unit='d'): """Create a VisFile object. Parameters @@ -39,6 +62,8 @@ def __init__(self, directory='.', domain=None, filename=None, mesh_filename=None (e.g. ats_vis_surface_data.h5). mesh_filename : str, optional Filename for the h5 mesh file. Default is 'ats_vis_DOMAIN_mesh.h5'. + input_time_unit : time unit used in visualization of ATS input files. + output_time_unit : time unit used in this vis filrs postprocessing. Returns ------- @@ -60,21 +85,9 @@ def __init__(self, directory='.', domain=None, filename=None, mesh_filename=None self.mesh_filename = 'ats_vis_mesh.h5' else: self.mesh_filename = 'ats_vis_{}_mesh.h5'.format(self.domain) - - if time_unit == 'yr': - time_factor = 1.0 - elif time_unit == 'noleap': - time_factor = 365.25 / 365 - elif time_unit == 'd': - time_factor = 365.25 - elif time_unit == 'hr': - time_factor = 365.25 * 24 - elif time_unit == 's': - time_factor = 365.25 * 24 * 3600 - else: - raise ValueError("Invalid time unit '{}': must be one of 'yr', 'noleap', 'd', 'hr', or 's'".format(time_unit)) - self.time_factor = time_factor - self.time_unit = time_unit + + self.input_time_unit = input_time_unit + self.output_time_unit = output_time_unit self.fname = os.path.join(self.directory, self.filename) if not os.path.isfile(self.fname): @@ -100,7 +113,8 @@ def loadTimes(self): """(Re-)loads the list of cycles and times.""" a_field = next(iter(self.d.keys())) self.cycles = list(sorted(self.d[a_field].keys(), key=int)) - self.times = np.array([self.d[a_field][cycle].attrs['Time'] for cycle in self.cycles]) * self.time_factor + self.times = np.array([time_unit_conversion(t, self.input_time_unit, self.output_time_unit) + for t in [self.d[a_field][cycle].attrs['Time'] for cycle in self.cycles]]) def filterIndices(self, indices): """Filter based on the index into the current set of cycles. @@ -195,14 +209,14 @@ def variable(self, vname): Variable name mangled like it is used in Amanzi/ATS. Something like 'DOMAIN-vname.cell.0' """ - if self.domain and '-' not in vname: + if self.domain and '-' not in vname[:-1]: vname = self.domain + '-' + vname return vname - + def _get(self, vname, cycle): """Private get: assumes vname is fully resolved, and does not deal with maps.""" return self.d[vname][cycle][:,0] - + def get(self, vname, cycle): """Access a data member. @@ -225,7 +239,7 @@ def get(self, vname, cycle): else: return reorder(val, self.map) return - + def getArray(self, vname): """Access an array of all cycle values. @@ -246,7 +260,6 @@ def getArray(self, vname): else: return reorder(val, self.map) - def loadMesh(self, cycle=None, order=None, shape=None, columnar=False, round=5): """Load and reorder centroids and volumes of mesh. @@ -270,12 +283,13 @@ def loadMesh(self, cycle=None, order=None, shape=None, columnar=False, round=5): if order is None and shape is None and not columnar: self.map = None self.centroids = centroids + self.ordering = None else: - self.centroids, self.map = structuredOrdering(centroids, order, shape, columnar) + self.ordering, self.centroids, self.map = structuredOrdering(centroids, order, shape, columnar) self.volume = self.get('cell_volume', cycle) - + def loadMeshPolygons(self, cycle=None): """Load a mesh into 2D polygons.""" if cycle is None: @@ -290,6 +304,67 @@ def getMeshPolygons(self, edgecolor='k', cmap='jet', linewidth=1): polygons = matplotlib.collections.PolyCollection(self.polygon_coordinates, edgecolor=edgecolor, cmap=cmap, linewidths=linewidth) return polygons + def plotLinesInTime(self, varname, spatial_slice=None, coordinate=None, time_slice=None, transpose=None, ax=None, colorbar_label=None, **kwargs): + """Plot multiple lines, one for each slice in time, as a function of coordinate. + + Parameters + ---------- + varname : str + The variable to plot + + """ + # make sure time_slice is a slice + if time_slice is None: + time_slice = s[:] + elif isinstance(time_slice, int): + time_slice = s[::time_slice] + else: + time_slice = s[time_slice] + + # slice centroids to get coordinate + if spatial_slice is None: + spatial_slice = [s[:],] + + if coordinate is None: + coordinate = next(self.ordering[i] for i in range(len(spatial_slice)) if spatial_slice[i] == s[:]) + if isinstance(coordinate, str): + if coordinate == 'x': coordinate = 0 + elif coordinate == 'y': coordinate = 1 + elif coordinate == 'z': coordinate = 2 + elif coordinate == 'xy': + raise ValuerError("Cannot infer coordinate 'xy' -- likely this dataset was loaded with inconsistent ordering or you provided an invalid coordinate.") + coordinate_slice = spatial_slice + [s[coordinate],] + coords = self.centroids[tuple(coordinate_slice)] + + # default transpose is True for z, False for others + if transpose is None: + if coordinate == 2: transpose = True + else: transpose = False + + # slice data to get values + vals = self.getArray(varname) + vals_slicer = [time_slice,] + spatial_slice + vals = vals[tuple(vals_slicer)] + + X = np.tile(coords, (vals.shape[0], 1)) + Y = vals + + if transpose: + X,Y = Y,X + + if colorbar_label is None: + colorbar_label = f'{varname} in time [{self.output_time_unit}]' + ax, axcb = plot_lines.plotLines(X, Y, self.times[time_slice], ax=ax, + t_min=self.times[0], t_max=self.times[-1], + colorbar_label=colorbar_label, **kwargs) + + # label x and y axes + xy_labels = (varname, ['x','y','z'][coordinate]+' [m]') if transpose else (['x','y','z'][coordinate]+' [m]', varname) + ax.set_xlabel(xy_labels[0]) + ax.set_ylabel(xy_labels[1]) + + return ax, axcb + elem_type = {5:'QUAD', 8:'PRISM', @@ -427,6 +502,8 @@ def structuredOrdering(coordinates, order=None, shape=None, columnar=False): Returns ------- + ordering : List[str] + Order used to sort, e.g. ['x', 'y'] ordered_coordinates : np.ndarray The re-ordered coordinates, shape (n_coordinates, dimension). map : np.ndarray(int) @@ -443,33 +520,34 @@ def structuredOrdering(coordinates, order=None, shape=None, columnar=False): Sort a column of 100 unordered cells into a 1D sorted array. The input and output are both of shape (100,3). - > ordered_centroids, map = structuredOrdering(centroids, list()) + > order, ordered_centroids, map = structuredOrdering(centroids, list()) Sort a logically structured transect of size NX x NY x NZ = (100,1,20), where x is structured and z may vary as a function of x. Both input and output are of shape (2000, 3), but the output is sorted with each column appearing sequentially and the - z-dimension fastest-varying. map is of shape (2000,). + z-dimension fastest-varying. map is of shape (2000,). The + returned order is ['z',]. - > ordered_centroids, map = structuredOrdering(centroids, ['z',]) + > order, ordered_centroids, map = structuredOrdering(centroids, ['z',]) Do the same, but this time reshape into a 2D array. Now the ordered_centroids are of shape (100, 20, 3), and the map is of - shape (100, 20). + shape (100, 20). The returned order is ['z', 'xy']. - > ordered_centroids, map = structuredOrdering(centroids, ['z',], [20,]) + > order, ordered_centroids, map = structuredOrdering(centroids, ['z',], [20,]) Do the same as above, but detect the shape. This works only - because the mesh is columnar. + because the mesh is columnar. The returned order is ['z', 'xy']. - > ordered_centroids, map = structuredOrdering(centroids, columnar=True) + > order, ordered_centroids, map = structuredOrdering(centroids, columnar=True) Sort a 3D map-view "structured-in-z" mesh into arbitrarily-ordered x and y columns. Assume there are 1000 map-view triangles, each extruded 20 cells deep. The input is is of shape (20000, 3) and - the output is of shape (1000, 20, 3). + the output is of shape (1000, 20, 3). The returned order is ['z', 'xy']. - > ordered_centroids, map = structuredOrdering(centroids, columnar=True) + > order, ordered_centroids, map = structuredOrdering(centroids, columnar=True) Note that map can be used with the reorder() function to place data in this ordering. @@ -478,7 +556,6 @@ def structuredOrdering(coordinates, order=None, shape=None, columnar=False): if columnar: order = ['x', 'y', 'z',] - # Surely there is a cleaner way to do this in numpy? # The current approach packs, sorts, and unpacks. if (coordinates.shape[1] == 3): @@ -496,6 +573,8 @@ def structuredOrdering(coordinates, order=None, shape=None, columnar=False): else: ordered_coordinates = np.array([coords_a['x'], coords_a['y']]).transpose() + out_order = order + if columnar: # try to guess the shape based on new-found contiguity n_cells_in_column = 0 @@ -504,7 +583,7 @@ def structuredOrdering(coordinates, order=None, shape=None, columnar=False): np.allclose(xy, ordered_coordinates[n_cells_in_column,0:2], 0., 1.e-5): n_cells_in_column += 1 shape = [n_cells_in_column,] - + out_order = ['xy', 'z'] if shape is not None: new_shape = (-1,) + tuple(shape) @@ -512,11 +591,20 @@ def structuredOrdering(coordinates, order=None, shape=None, columnar=False): ordered_coordinates = np.reshape(ordered_coordinates, coord_shape) map = np.reshape(map, new_shape) + if len(new_shape) == 3: + out_order = ['x', 'y', 'z'] + elif len(new_shape) == 2: + if coordinates.shape[1] == 3: + out_order = ['xy', 'z'] + else: + out_order = ['x', 'y'] + if map.shape[0] == 1: map = map[0] ordered_coordinates = ordered_coordinates[0] + out_order = out_order[1:] - return ordered_coordinates, map + return out_order, ordered_coordinates, map def reorder(data, map): diff --git a/tools/utils/plot_column_data.py b/tools/utils/plot_column_data.py index 3218d944a..b16f8a81a 100644 --- a/tools/utils/plot_column_data.py +++ b/tools/utils/plot_column_data.py @@ -4,6 +4,7 @@ from matplotlib import pyplot as plt import matplotlib.cm import colors +import plot_lines import ats_xdmf, ats_units @@ -24,7 +25,7 @@ Makes a figure with 4 axes in a 2x2 block. Note each list is a row. - --layout="saturation_liquid + saturation_ice, temperature" +--layout="saturation_liquid & saturation_ice, temperature" Makes a figure with 2 axes, the first containing saturations and the second temperature. @@ -90,7 +91,7 @@ def valid_layout(arg): if columns[-1] == '': columns.pop() for column in columns: - variables = column.split('+') + variables = column.split('&') row_layout.append(variables) layout.append(row_layout) @@ -102,13 +103,30 @@ def valid_layout(arg): def domain_var(varname): + if '.' in varname: + dot_split = varname.split('.') + suffix = '.'.join(dot_split[1:]) + varname = dot_split[0] + else: + suffix = '' + vs = varname.split('-') - if len(vs) == 2: - return vs[0],vs[1] + + if len(vs) >= 2: + domain = vs[0] + varname = '-'.join(vs[1:]) + if suffix != '': + varname = varname + '.' + suffix + elif len(vs) == 1: - return '', varname - else: - raise RuntimeError("Invalid variable name: {}".format(varname)) + domain = '' + varname = varname + if suffix != '': + varname = varname + '.' + suffix + + return domain, varname + + def label(varname): return '{} [{}]'.format(varname, ats_units.get_units(varname)) @@ -133,27 +151,10 @@ def annotate(layout, axs, time_unit): def plot_subsurface(vis, col, ax, label, color=None, cmap=None): if cmap is None: cmap = colors.alpha_cmap(color) - - z = vis.centroids[:,2] - - if len(vis.times) == 1: - cm = colors.cm_mapper(vis.times[0]-1, vis.times[0], cmap) - else: - cm = colors.cm_mapper(vis.times[0], vis.times[-1], cmap) formats = ['-', '--', '-.'] - - for varname, form in zip(col, formats): - data = vis.getArray(varname) - assert(len(data.shape) == 2) - assert(data.shape[1] == len(vis.centroids)) - - for i,time in enumerate(vis.times): - mylabel = None - if i == len(vis.times)-1: - mylabel = label - - ax.plot(data[i,:], z, form, color=cm(time), label=mylabel) + for i, (varname, form) in enumerate(zip(col, formats)): + vis.plotLinesInTime(varname, ax=ax, colorbar_ticks=(i == 0), cmap=cmap, linestyle=form, colorbar_label=f'{varname} of {label} in time') def animate_subsurface(vis, varnames, ax, label, colors=None): if type(colors) is str: @@ -238,7 +239,62 @@ def s_to_i(s): else: return int(sl) +def plotColumnData(directories, + layout, + color_mode='runs', + color_sample='enumerated', + color_map='jet', + subsurface_time_slice=None, + surface_time_slice=None, + data_filename_format='ats_vis_{}_data.h5', + mesh_filename_format='ats_vis_{}_mesh.h5', + time_unit='d', + fig=None, + figsize=[5,3]): + """Plots the column data given directories and a layout.""" + + if isinstance(layout, str): + layout = valid_layout(layout) + + if color_mode == 'runs': + if color_sample == 'enumerated': + color_list = colors.enumerated_colors(len(directories)) + else: + color_list = colors.sampled_colors(len(directories), + getattr(matplotlib.cm, color_map)) + elif color_mode == 'time': + color_list = [color_map,]*len(directories) + + + if fig is None: + fig = plt.figure(figsize=figsize) + axs = fig.subplots(len(layout), len(layout[0]), squeeze=False) + domains = set([domain_var(v)[0] for v in layout_flattener(layout)]) + for dirname, color in zip(directories, color_list): + vis_objs = dict() + for domain in domains: + vis = ats_xdmf.VisFile(dirname, domain, + ats_xdmf.valid_data_filename(domain, data_filename_format), + ats_xdmf.valid_mesh_filename(domain, mesh_filename_format), + time_unit=time_unit) + if domain == '': + vis.loadMesh(columnar=True) + if subsurface_time_slice is not None: + vis.filterIndices(subsurface_time_slice) + else: + vis.loadMesh() + if surface_time_slice is not None: + vis.filterIndices(surface_time_slice) + + vis_objs[domain] = vis + + plot(vis_objs, layout, axs, dirname, color, color_mode) + + annotate(layout, axs, time_unit) + return axs + + if __name__ == '__main__': import argparse import colors @@ -276,42 +332,10 @@ def s_to_i(s): args = parser.parse_args() - if args.color_mode == 'runs': - if args.color_sample == 'enumerated': - color_list = colors.enumerated_colors(len(args.directories)) - else: - color_list = colors.sampled_colors(len(args.directories), - getattr(matplotlib.cm, args.color_map)) - elif args.color_mode == 'time': - color_list = [args.color_map,]*len(args.directories) - - - - fig = plt.figure(figsize=args.figsize) - axs = fig.subplots(len(args.layout), len(args.layout[0]), squeeze=False) - - domains = set([domain_var(v)[0] for v in layout_flattener(args.layout)]) - for dirname, color in zip(args.directories, color_list): - vis_objs = dict() - for domain in domains: - vis = ats_xdmf.VisFile(dirname, domain, - ats_xdmf.valid_data_filename(domain, args.data_filename_format), - ats_xdmf.valid_mesh_filename(domain, args.mesh_filename_format), - time_unit=args.time_unit) - if domain == '': - vis.loadMesh(columnar=True) - if args.subsurface_time_slice is not None: - vis.filterIndices(args.subsurface_time_slice) - else: - vis.loadMesh() - if args.surface_time_slice is not None: - vis.filterIndices(args.surface_time_slice) - - vis_objs[domain] = vis - - plot(vis_objs, args.layout, axs, dirname, color, args.color_mode) - - annotate(args.layout, axs, args.time_unit) + plotColumnData(args.directories, args.layout, args.color_mode, args.color_sample, args.color_map, + args.subsurface_time_slice, args.surface_time_slice, + args.data_filename_format, args.mesh_filename_format, + args.time_unit, args.figsize) plt.show() sys.exit(0) diff --git a/tools/utils/plot_lines.py b/tools/utils/plot_lines.py new file mode 100644 index 000000000..9de423727 --- /dev/null +++ b/tools/utils/plot_lines.py @@ -0,0 +1,57 @@ +import numpy as np +from matplotlib import pyplot as plt +import matplotlib.collections +import matplotlib.ticker + +def plotLines(x, y, t, ax=None, colorbar=True, colorbar_ticks=True, colorbar_label=None, t_min=None, t_max=None, **kwargs): + """Plots lines by color.""" + + # create an axis if none + if ax is None: + fig, ax = plt.subplots() + else: + fig = ax.get_figure() + + # set bounds + if t_min is None: + t_min = t[0] + if t_max is None: + t_max = t[-1] + + # plot the lines + segments = [np.column_stack((x,y)) for (x,y) in zip(x,y)] + lc = matplotlib.collections.LineCollection(segments, **kwargs) + c = (t - t_min) / (t_max - t_min) + lc.set_array(c) + + # add to axis + ax.add_collection(lc) + ax.autoscale() + + if colorbar: + # create the colorbar + cb = fig.colorbar(lc) + + # label it + if colorbar_label is not None: + cb.set_label(colorbar_label) + + if colorbar_ticks: + # transform ticks from [0,1] to [times[0], times[-1]] to get + # the correct labels + def my_formatter(x, pos): + xp = x * (t_max - t_min) + t_min + if abs(xp - np.round(xp)) < 1.e-2: + return str(int(np.round(xp))) + elif abs(xp - np.round(xp, 1)) < 1.e-2: + return str(np.round(xp, 1)) + return str(np.round(xp, 2)) + + cb.ax.yaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(my_formatter)) + + else: + cb.set_ticks(list()) + else: + cb = None + return ax, cb + From c794367ae1271a7a9cfa20fafc5375fa5aef7efd Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 19 Nov 2025 17:00:01 -0800 Subject: [PATCH 570/582] finishing 1.6 update --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 14 +++++++------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 2 +- src/pks/ecosim/data/CMakeLists.txt | 2 +- src/pks/flow/richards_pk.cc | 9 --------- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index a5e8b1746..ac14c836c 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -37,7 +37,7 @@ #include "bulk_density_evaluator.hh" #include "matric_pressure_evaluator.hh" -#include "pk_helpers.hh" +#include "PK_Helpers.hh" #include "EcoSIM_ATS_interface.hh" namespace Amanzi { @@ -328,25 +328,25 @@ void EcoSIM::Setup() { } //Setup Evaluators - requireAtNext(hydraulic_conductivity_key_, tag_next_, *S_) + requireEvaluatorAtNext(hydraulic_conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtCurrent(hydraulic_conductivity_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(hydraulic_conductivity_key_, tag_current_, *S_, name_); - requireAtNext(bulk_density_key_, tag_next_, *S_) + requireEvaluatorAtNext(bulk_density_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtCurrent(bulk_density_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(bulk_density_key_, tag_current_, *S_, name_); - requireAtNext(matric_pressure_key_, tag_next_, *S_) + requireEvaluatorAtNext(matric_pressure_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() ->AddComponent("cell", AmanziMesh::CELL, 1); - requireAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); + requireEvaluatorAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index be622b90a..771d331a8 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -39,7 +39,7 @@ #include "State.hh" #include "BGCEngine.hh" #include "PK_Factory.hh" -#include "pk_physical_default.hh" +#include "PK_Physical_Default.hh" #include "PK_Physical.hh" #include "ecosim_mod_test_wrapper.h" #include "MeshPartition.hh" diff --git a/src/pks/ecosim/data/CMakeLists.txt b/src/pks/ecosim/data/CMakeLists.txt index 0760f0721..37d733eee 100644 --- a/src/pks/ecosim/data/CMakeLists.txt +++ b/src/pks/ecosim/data/CMakeLists.txt @@ -78,7 +78,7 @@ set(ats_ecosim_data_link_libs ats_eos ats_operators ${NETCDF_LIB}/libnetcdf.so - ${NETCDF_LIB}/libnetcdf.so.19 + ${NETCDF_LIB}/libnetcdf.so.22 ${NETCDF_LIB}/libnetcdff.so ${NETCDF_LIB}/libnetcdff.so.7 ${NETCDF_LIB}/libnetcdff.so.7.1.0 diff --git a/src/pks/flow/richards_pk.cc b/src/pks/flow/richards_pk.cc index d0eabc872..5f653ad0e 100644 --- a/src/pks/flow/richards_pk.cc +++ b/src/pks/flow/richards_pk.cc @@ -477,15 +477,6 @@ Richards::SetupPhysicalEvaluators_() // and at the current time, where it is a copy evaluator requireEvaluatorAtCurrent(sat_key_, tag_current_, *S_, name_); - /*requireAtNext(matric_pressure_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::CELL, 1); - S_->RequireEvaluator(matric_pressure_key_, tag_next_); - */ - // and at the current time, where it is a copy evaluator - requireAtCurrent(sat_key_, tag_current_, *S_, name_); - // -- rel perm requireEvaluatorAtNext(coef_key_, tag_next_, *S_) .SetMesh(mesh_) From a248d51a414e4c92cc66d085af77ddbe21218bb3 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 25 Nov 2025 16:24:45 -0800 Subject: [PATCH 571/582] Working ATS-EcoSIM for ATS 1.6 This commit fixes the ATS-EcoSIM coupling to be compatible with ATS 1.6. The major change post- merge is concentrations are now accessed via mole_fraction instead of total_component_concentration. --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 42 +++++++++++++------------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index ac14c836c..6645e8d10 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -57,8 +57,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, domain_surface_ = Keys::readDomainHint(*plist_, domain_, "subsurface", "surface"); // transport - tcc_key_ = Keys::readKey(*plist_, domain_, "total component concentration", "total_component_concentration"); - //Remember tcc components are accessed by tcc[i][c] where i is the component and c is the cell + mole_fraction_key_ = Keys::readKey(*plist_, domain_, "mole fraction", "mole_fraction"); + //mole_fraction components are accessed by mole_fraction[i][c] where i is the component and c is the cell //Flow porosity_key_ = Keys::readKey(*plist_, domain_, "porosity", "porosity"); @@ -66,7 +66,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_gas_key_ = Keys::readKey(*plist_,domain_,"saturation gas", "saturation_gas"); saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); - relative_permeability_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); + //relative_permeability_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); matric_pressure_key_ = Keys::readKey(*plist_,domain_,"matric pressure","matric_pressure"); liquid_density_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); ice_density_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); @@ -359,14 +359,14 @@ void EcoSIM::Setup() { void EcoSIM::Initialize() { PK_Physical_Default::Initialize(); //Need to know the number of components to initialize data structures - const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, Tags::DEFAULT)->ViewComponent("cell")); - int tcc_num = tcc.NumVectors(); + const Epetra_MultiVector& mole_fraction= *(S_->GetPtr(mole_fraction_key_, Tags::DEFAULT)->ViewComponent("cell")); + int mole_fraction_num = mole_fraction.NumVectors(); Teuchos::OSTab tab = vo_->getOSTab(); num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //Now we call the engine's init state function which allocates the data - bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, tcc_num, num_columns_); + bgc_engine_->InitState(bgc_props_, bgc_state_, bgc_aux_data_, ncells_per_col_, mole_fraction_num, num_columns_); int ierr = 0; @@ -502,11 +502,11 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // Ensure dependencies are filled - S_->GetEvaluator(tcc_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(mole_fraction_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(relative_permeability_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(relative_permeability_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(liquid_density_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(rock_density_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(T_key_, Tags::DEFAULT).Update(*S_, name_); @@ -583,9 +583,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); - S_->GetEvaluator("relative_permeability", tag_next_).Update(*S_, name_); - const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) - .ViewComponent("cell",false))(0); + //S_->GetEvaluator("relative_permeability", tag_next_).Update(*S_, name_); + //const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) + // .ViewComponent("cell",false))(0); S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) @@ -896,12 +896,12 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, //This is the copy function for a loop over a single process instead of a single column //Fill state with ATS variables that are going to be changed by EcoSIM const Epetra_Vector& porosity = *(*S_->Get(porosity_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& tcc= *(S_->GetPtr(tcc_key_, water_tag)->ViewComponent("cell")); - int tcc_num = tcc.NumVectors(); + const Epetra_MultiVector& mole_fraction= *(S_->GetPtr(mole_fraction_key_, water_tag)->ViewComponent("cell")); + int mole_fraction_num = mole_fraction.NumVectors(); const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& relative_permeability = *(*S_->Get(relative_permeability_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& relative_permeability = *(*S_->Get(relative_permeability_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& liquid_density = *(*S_->Get(liquid_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rock_density = *(*S_->Get(rock_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cell_volume_key_, water_tag).ViewComponent("cell", false))(0); @@ -986,7 +986,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_depth_c = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); + auto col_mole_fraction = Teuchos::rcp(new Epetra_SerialDenseMatrix(mole_fraction_num,ncells_per_col_)); //Gather columns on this process: num_columns_global = mesh_surf_->getMap(AmanziMesh::Entity_kind::CELL,false).NumGlobalElements(); @@ -1016,7 +1016,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,porosity,col_porosity.ptr()); FieldToColumn_(column,liquid_saturation,col_l_sat.ptr()); FieldToColumn_(column,water_content,col_wc.ptr()); - FieldToColumn_(column,relative_permeability,col_relative_permeability.ptr()); + //FieldToColumn_(column,relative_permeability,col_relative_permeability.ptr()); FieldToColumn_(column,liquid_density,col_l_dens.ptr()); FieldToColumn_(column,rock_density,col_r_dens.ptr()); FieldToColumn_(column,cell_volume,col_vol.ptr()); @@ -1030,7 +1030,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,temp, col_temp.ptr()); FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); - //MatrixFieldToColumn_(column, tcc, col_tcc.ptr()); + //MatrixFieldToColumn_(column, mole_fraction, col_mole_fraction.ptr()); // This is for computing depth //ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); @@ -1150,14 +1150,14 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, const Tag& water_tag) { - Epetra_MultiVector& tcc= *(S_->GetPtrW(tcc_key_, Tags::DEFAULT, "state")->ViewComponent("cell",false)); - int tcc_num = tcc.NumVectors(); + Epetra_MultiVector& mole_fraction= *(S_->GetPtrW(mole_fraction_key_, Tags::DEFAULT, "subsurface transport")->ViewComponent("cell",false)); + int mole_fraction_num = mole_fraction.NumVectors(); auto& porosity = *(*S_->GetW(porosity_key_, Tags::DEFAULT, porosity_key_).ViewComponent("cell",false))(0); auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Tags::DEFAULT, saturation_liquid_key_).ViewComponent("cell",false))(0); auto& water_content = *(*S_->GetW(water_content_key_, Tags::DEFAULT, water_content_key_).ViewComponent("cell",false))(0); //auto& suction_head = *(*S_->GetW(suc_key_, Tags::DEFAULT, suc_key_).ViewComponent("cell",false))(0); - auto& relative_permeability = *(*S_->GetW(relative_permeability_key_, Tags::DEFAULT, relative_permeability_key_).ViewComponent("cell",false))(0); + //auto& relative_permeability = *(*S_->GetW(relative_permeability_key_, Tags::DEFAULT, relative_permeability_key_).ViewComponent("cell",false))(0); auto& liquid_density = *(*S_->GetW(liquid_density_key_, Tags::DEFAULT, liquid_density_key_).ViewComponent("cell",false))(0); auto& rock_density = *(*S_->GetW(rock_density_key_, Tags::DEFAULT, rock_density_key_).ViewComponent("cell",false))(0); auto& cell_volume = *(*S_->GetW(cell_volume_key_, Tags::DEFAULT, cell_volume_key_).ViewComponent("cell",false))(0); @@ -1202,7 +1202,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_snow_temperature = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); - auto col_tcc = Teuchos::rcp(new Epetra_SerialDenseMatrix(tcc_num,ncells_per_col_)); + auto col_mole_fraction = Teuchos::rcp(new Epetra_SerialDenseMatrix(mole_fraction_num,ncells_per_col_)); //Gather columns on this process: num_columns_global = mesh_surf_->getMap(AmanziMesh::Entity_kind::CELL, false).NumGlobalElements(); diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 771d331a8..86c18acf8 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -180,7 +180,7 @@ class EcoSIM : public PK_Physical_Default { double t_ecosim = 0.0; // keys - Key tcc_key_; + Key mole_fraction_key_; Key porosity_key_; Key saturation_liquid_key_; Key saturation_gas_key_; From 2ffda4fb620f9c408256334f3bf48b7314c987ee Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 16 Dec 2025 09:53:58 -0800 Subject: [PATCH 572/582] Inital header documentation and code cleanup This commit contains alot of comment cleanup, and a first pass at adding documentation to the header in the ATS style. --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 27 +----- src/pks/ecosim/EcoSIM_ATS_interface.hh | 122 ++++++++++++++++++++++--- 2 files changed, 112 insertions(+), 37 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 6645e8d10..5394c58ce 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -141,13 +141,13 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, v_type_key_ = Keys::readKey(*plist_, domain_surface_, "vegetation type", "vegetation_type"); //Atmospheric abundance keys - atm_n2_ = plist_->get("atmospheric N2"); + /*atm_n2_ = plist_->get("atmospheric N2"); atm_o2_ = plist_->get("atmospheric O2"); atm_co2_ = plist_->get("atmospheric CO2"); atm_ch4_ = plist_->get("atmospheric CH4"); atm_n2o_ = plist_->get("atmospheric N2O"); atm_h2_ = plist_->get("atmospheric H2"); - atm_nh3_ = plist_->get("atmospheric NH3"); + atm_nh3_ = plist_->get("atmospheric NH3");*/ //Starting values and parameters for precribed phenology / albedo @@ -197,7 +197,6 @@ void EcoSIM::Setup() { //Need to do some basic setup of the columns: mesh_surf_ = S_->GetMesh(domain_surface_); mesh_ = S_->GetMesh(domain_); - //num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Parallel_type::OWNED, AmanziMesh::Parallel_kind::OWNED); int num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); @@ -371,8 +370,6 @@ void EcoSIM::Initialize() { int ierr = 0; if (S_->HasRecord(ice_density_key_, Tags::DEFAULT)) { - //Teuchos::OSTab tab = vo_->getOSTab(); - //*vo_->os() << "found ice key" << std::endl; S_->GetEvaluator(saturation_ice_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(ice_density_key_, Tags::DEFAULT).Update(*S_, name_); has_ice = true; @@ -422,11 +419,6 @@ void EcoSIM::Initialize() { S_->GetW(sublimation_snow_key_, Tags::DEFAULT, "surface-sublimation_snow").PutScalar(0.0); S_->GetRecordW(sublimation_snow_key_, Tags::DEFAULT, "surface-sublimation_snow").set_initialized(); - //S_->GetW(lai_key_, Tags::DEFAULT, "surface-LAI").PutScalar(0.0); - //S_->GetRecordW(lai_key_, Tags::DEFAULT, "surface-LAI").set_initialized(); - //surface_energy_source_ecosim_key_ - //surface_water_source_ecosim_key_ - S_->GetW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).PutScalar(0.0); S_->GetRecordW(surface_water_source_ecosim_key_, Tags::DEFAULT, surface_water_source_ecosim_key_).set_initialized(); @@ -691,8 +683,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { num_columns_local = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); num_columns_global_ptype = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::ALL); - //*vo_->os() << "Before Advance, p_rain: " << p_rain[1] << " m/s, p_snow: " << p_snow << "m SWE/s, water_content: " << water_content[1][1] << " mol" << std::endl; - //Trying to loop over processors now: int numProcesses, p_rank; MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); @@ -805,13 +795,6 @@ void EcoSIM::ColDepthDz_(AmanziMesh::Entity_ID column, // depth centroid (*depth)[i] = surf_centroid[2] - mesh_->getCellCentroid(col_iter[i])[2]; - // dz - // -- find face_below - //AmanziMesh::Entity_ID_List faces; - //std::vector dirs; - //mesh_->cell_get_faces_and_dirs(col_iter[i], &faces, &dirs); - ///double vol = mesh_->cell_volume(col_iter[i]); - const auto& [faces, dirs] = mesh_->getCellFacesAndDirections(col_iter[i]); // -- mimics implementation of build_columns() in Mesh @@ -924,11 +907,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector* precipitation_snow = nullptr; if(p_bool){ - //const Epetra_Vector& precipitation = *(*S_->Get(p_total_key_, water_tag).ViewComponent("cell", false))(0); precipitation = &(*(*S_->Get(p_total_key_, water_tag).ViewComponent("cell", false))(0)); } else { - //const Epetra_Vector& precipitation = *(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0); - //const Epetra_Vector& precipitation_snow = *(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0); precipitation = &(*(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0)); precipitation_snow = &(*(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0)); } @@ -1001,8 +981,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, std::cout << "ATS2EcoSIM rank: " << p_rank <getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); //Now that the arrays are flat we need to be a little more careful about how we load an unload the data - /*const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); - for (int column=0; column!=num_columns_local; ++column) { + /*for (int column=0; column!=num_columns_local; ++column) { FieldToColumn_(column, temp, col_temp.ptr()); for (int i=0; i < ncells_per_col_; ++i) { diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 86c18acf8..ea65bbe06 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -2,21 +2,117 @@ ATS License: see $ATS_DIR/COPYRIGHT - Author: Andrew Graus - - The idea here is to begin writing the EcoSIM ATS interface with a simple - program. To start we are going to try to do a few things: - - 1) Initalize a PK called EcoSIM_ATS - 2) Have that PK take in the water content - 3) modify the water content in a simple way to mock roots (take away water) - 4) modify it so it will take in tracers (how roots take in nutrients) + Author: Andrew Graus (agraus@lbl.gov) --------------------------------------------------------------------------*/ -//Eventually add if statement here (probably tied to something at compile time -// -//#ifndef PKS_BGC_SIMPLE_HH_ -//#define PKS_BGC_SIMPLE_HH_ +/*! + +This PK couples ATS to the BGC code EcoSIM. This PK essentially takes over the +surface balance aspects of ATS and replaces them with those from EcoSIM. + +In addition this code takes data from ATS state and loads it into a struct that +is fortran readable (BGCContainer). The data structures and methods were adapted +from those used in the Alquimia code, additionally the general code structure +Engine code are adapted from Alquimia as well. + +Structures for looping over cells of columns were adapted from ATS's simpleBGC code + +`"PK type`" = `"EcoSIM for ATS`" + +.. _pk-ecosim-spec: +.. admonition:: pk-ecosim-spec + + * `"engine`" ``[string]`` **EcoSIM** Engine name - inspired by Alquimias options if this + code is adapted to used to drive other BGC codes. + + * `"heat capacity [MJ mol^-1 K^-1]`" ``[double]]`` **0.02** heat capacity of the soil layers + + * `"Field Capacity [MPa]`" ``[double]]`` **-0.033** pressure at field capacity + + * `"Wilting Point [MPa]`" ``[double]]`` **-1.5** pressure at wilting point + + * `"initial time step [s]`" ``[double]]`` **3600.0** EcoSIM is an hourly model so the + standard is to run it after the end of hour 1 + + * `"EcoSIM Precipitation`" ``[bool]`` This allows EcoSIM to partition the precipitation + itself. If false it will expect the precipitation forcing to be already divided into + rain and snow as in ATS. + + * `"Prescribe Albedo`" ``[bool]`` determines if the code will use EcoSIM's internal + albedo calculation, or if it will be prescirbed from data. + + * `"Prescribe Phenology`" ``[bool]`` Determines if the coupling will use the prescribed + phenology methodology where LAI and PFT are input. This will eventually be complemented + with a full phenology method, where plant parameters are directly, but will remain in + the code as an option. + + * `"starting day of year [0-364]`" ``[int]`` day of the year, needed for EcoSIMs internal + radiation and biogeochemical processes. + + * `"Starting year`" ``[int]`` Year also needed for internal EcoSIM computations + + * `"Number of PFTs [1-5] "`" ``[int]`` Number of PFTs allowed in every column. 5 + is the maximum number allowed + + * `"domain name`" ``[string]`` **domain** + + * `"surface domain name`" ``[string]`` **surface** + + EVALUATORS: + + - `"Bulk Density`" `[ ]` + - `"Hydraulic Conductivity `[Pa]` + - `"Matric Pressure`" `[Pa]` + + DEPENDENCIES + //Sources + `"surface water source ecosim`" **surface-ecosim_water_source** + `"surface energy source ecosim`" **surface-ecosim_source** + `"subsurface water source ecosim`" **ecosim_water_source** + `"surface water source ecosim`" **surface-ecosim_water_source** + + //surface balance variables + `"incoming shortwave radiation`" **surface-incoming_shortwave_radiation** + `"incoming longwave radiation`" **surface-incoming_longwave_radiation** + `"air temperature`" **surface-air_temperature** + `"vapor pressure air`" **surface-vapor_pressure_air** + `"wind speed`" **surface-wind_speed** + `"precipitation rain`" **surface-precipitation_rain** + `"precipitation snow`" **surface-precipitation_snow** + `"precipitation total`" **surface-precipitation_total** + `"snow depth`" **surface-snow_depth** + `"snow_albedo`" **surface-snow_albedo** + `"snow temperature`" **surface-snow_temperature** + `"canopy longwave radiation`" **surface-canopy_longwave_radiation** + `"canopy latent heat`" **surface-canopy_latent_heat** + `"canopy sensible heat`" **surface-canopy_sensible_heat** + `"canopy surface water`" **surface-canopy_surface_water** + `"evapotranspiration`" **surface-evapotranspiration** + `"evaporation ground`" **surface-evaporation_ground** + `"evaporation litter`" **surface-evaporation_litter** + `"evaporation snow`" **surface-evaporation_snow** + `"sublimation snow`" **surface-sublimation_snow** + `"LAI`" **surface-LAI** + `"SAI`" **surface-SAI** + `"vegetation type`" **surface-vegetation_type** + + //General Flow Transport Energy + `"mole fraction`" **mole_fraction** + `"porosity`" **porosity** + `"saturation liquid`" **saturation_liquid** + `"saturation gas`" **saturation_gas** + `"saturation ice`" **saturation_ice** + `"water content`" **water_content** + `"mass density liquid`" **mass_density_liquid** + `"mass density ice`" **mass_density_ice** + `"mass density gas`" **mass_density_gas** + `"density rock`" **density_rock** + `"temperature`" **temperature** + `"thermal conductivity`" **thermal_conductivity** + `"cell volume`" **cell_volume** + + */ + #ifndef PKS_ECOSIM_HH_ #define PKS_ECOSIM_HH_ From 523b018545e0a62d32d029a8e3d671d1fabf14bc Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 6 Jan 2026 19:43:17 -0800 Subject: [PATCH 573/582] Adding a fix to area, add the column-area dataset This is a fix for a bug I found in the area. Prior to this the computation was done by length of the side which only works for rectangular cells. Changed it to actually use the area of the ATS column instead. --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 13 +++++++++++-- src/pks/ecosim/data/BGC_containers.hh | 1 + src/pks/ecosim/data/BGC_memory.cc | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 5394c58ce..ab92800e7 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -1014,6 +1014,15 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, // This is for computing depth //ColDepthDz_(column, col_depth.ptr(), col_dz.ptr()); + //Grabbing the cross sectional area in the z direction + int f = mesh_surf_->getEntityParent(AmanziMesh::Entity_kind::CELL, column); + auto col_iter = mesh_->columns.getCells(column); + std::size_t ncol_cells = col_iter.size(); + + double column_area = mesh_->getFaceArea(f); + std::cout << "column: " << column << " column_area: " << column_area << std::endl; + props.column_area.data[column] = column_area; + VolDepthDz_(column, col_depth.ptr(), col_dz.ptr(), col_vol.ptr()); double sum = 0.0; for (int i = ncells_per_col_ - 1; i >= 0; --i) { @@ -1234,7 +1243,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, std::cout << "(CopyFromEcoSIM) subsurface energy flux: " << std::endl; - for (int col=0; col!=num_columns_local; ++col) { + /*for (int col=0; col!=num_columns_local; ++col) { for (int i=0; i < ncells_per_col_; ++i) { std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_energy_source[col*ncells_per_col_+i] << std::endl; } @@ -1244,7 +1253,7 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, for (int i=0; i < ncells_per_col_; ++i) { std::cout << "col: " << col << " cell: " << i << "value: " << subsurface_water_source[col*ncells_per_col_+i] << std::endl; } - } + }*/ } int EcoSIM::InitializeSingleProcess(int proc) diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 54603e4e5..4c843d46f 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -142,6 +142,7 @@ extern const int kBGCMaxWordLength; BGCMatrixDouble dz; BGCMatrixDouble plant_wilting_factor; BGCMatrixDouble rooting_depth_fraction; + BGCVectorDouble column_area; BGCVectorDouble shortwave_radiation; BGCVectorDouble longwave_radiation; BGCVectorDouble air_temperature; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 75331564c..9b09b654f 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -418,6 +418,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->plant_wilting_factor)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(properties->rooting_depth_fraction)); + AllocateBGCVectorDouble(sizes->num_columns, &(properties->column_area)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->shortwave_radiation)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->longwave_radiation)); AllocateBGCVectorDouble(sizes->num_columns, &(properties->air_temperature)); @@ -447,6 +448,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(properties->plant_wilting_factor)); FreeBGCMatrixDouble(&(properties->rooting_depth_fraction)); + FreeBGCVectorDouble(&(properties->column_area)); FreeBGCVectorDouble(&(properties->shortwave_radiation)); FreeBGCVectorDouble(&(properties->longwave_radiation)); FreeBGCVectorDouble(&(properties->air_temperature)); From f11cee2fe2a949a031b2954462605d918e851bc8 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 7 Jan 2026 15:12:20 -0800 Subject: [PATCH 574/582] Moving wrapper and removing old files moved the ecosim_wrapper to the ecosim side, and deleted it from the ATS side. I also removed some old testing files that are no longer needed. The CMake files have also been changed to reflect this. --- src/pks/ecosim/CMakeLists.txt | 3 +- src/pks/ecosim/EcoSIM_ATS_interface.hh | 1 - src/pks/ecosim/ecosim_mod_test.F90 | 66 ------------ src/pks/ecosim/ecosim_mod_test_wrapper.c | 42 -------- src/pks/ecosim/ecosim_mod_test_wrapper.h | 51 --------- src/pks/ecosim/ecosim_wrappers.F90 | 126 ----------------------- 6 files changed, 1 insertion(+), 288 deletions(-) delete mode 100644 src/pks/ecosim/ecosim_mod_test.F90 delete mode 100644 src/pks/ecosim/ecosim_mod_test_wrapper.c delete mode 100644 src/pks/ecosim/ecosim_mod_test_wrapper.h delete mode 100644 src/pks/ecosim/ecosim_wrappers.F90 diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 051293b45..1cbe02adb 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -68,7 +68,6 @@ if(ENABLE_ECOSIM) set(ats_ecosim_src_files EcoSIM_ATS_interface.cc BGCEngine.cc - ecosim_wrappers.F90 data/bgc_fortran_memory_mod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/BGC_containers.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSCPLMod.F90 @@ -77,10 +76,10 @@ if(ENABLE_ECOSIM) ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ATSUtilsMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/SharedDataMod.F90 ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/c_f_interface_module.F90 + ${ECOSIM_INSTALL_PREFIX}/f90src/ATSUtils/ecosim_wrappers.F90 ) set(ats_ecosim_inc_files - ecosim_mod_test_wrapper.h EcoSIM_ATS_interface.hh BGCEngine.hh ecosim_interface.h diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index ea65bbe06..a3c08e9a9 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -137,7 +137,6 @@ Structures for looping over cells of columns were adapted from ATS's simpleBGC c #include "PK_Factory.hh" #include "PK_Physical_Default.hh" #include "PK_Physical.hh" -#include "ecosim_mod_test_wrapper.h" #include "MeshPartition.hh" namespace Amanzi { diff --git a/src/pks/ecosim/ecosim_mod_test.F90 b/src/pks/ecosim/ecosim_mod_test.F90 deleted file mode 100644 index cabf297c3..000000000 --- a/src/pks/ecosim/ecosim_mod_test.F90 +++ /dev/null @@ -1,66 +0,0 @@ -! -! This is a simple test module to test -! running F90 code within the interface -! - -module ecosim_datatest_mod - use BGCContainers_module, only : BGCSizes, & - BGCProperties - implicit none - - public :: & - ecosim_datatest - - private :: & - SetBGCSizes - -contains - subroutine ecosim_datatest(col, props, sizes) bind(C) - - use, intrinsic :: iso_c_binding - use BGCContainers_module, only : BGCSizes, & - BGCProperties - integer (c_int), value, intent(in) :: col - type(BGCProperties), intent(in) :: props - type(BGCSizes), intent(out) :: sizes - integer :: i - integer :: len - integer(c_int), pointer :: idata(:) - real (c_double), pointer :: data(:) - - write(*,*) "calling set sizes" - write(*,*) "does sizes exist?" - write(*,*) sizes%num_components - - call SetBGCSizes(sizes) - - write(*,*) "Okay calling the props function works." - write(*,*) "num col is: ", col - write(*,*) "printing the BGCProps data: " - - len = props%volume%size - - call c_f_pointer(props%volume%data, data, (/len/)) - write(*,*) "the length is: ", len - do i = 1, len - write(*,*) data(i) - end do - - write(*,*) "the properties are finished" - - end subroutine ecosim_datatest - - subroutine SetBGCSizes(sizes) - - use BGCContainers_module, only : BGCSizes - - implicit none - - type (BGCSizes), intent(out) :: sizes - - sizes%num_components = 1 - sizes%ncells_per_col_ = 100 - - end subroutine SetBGCSizes - -end module ecosim_datatest_mod diff --git a/src/pks/ecosim/ecosim_mod_test_wrapper.c b/src/pks/ecosim/ecosim_mod_test_wrapper.c deleted file mode 100644 index 8048ab0ba..000000000 --- a/src/pks/ecosim/ecosim_mod_test_wrapper.c +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ - -/* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -** through Lawrence Berkeley National Laboratory (subject to receipt of any -** required approvals from the U.S. Dept. of Energy). All rights reserved. -** -** Alquimia is available under a BSD license. See LICENSE.txt for more -** information. -** -** If you have questions about your rights to use or distribute this software, -** please contact Berkeley Lab's Technology Transfer and Intellectual Property -** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -** -** NOTICE. This software was developed under funding from the U.S. Department -** of Energy. As such, the U.S. Government has been granted for itself and -** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -** license in the Software to reproduce, prepare derivative works, and perform -** publicly and display publicly. Beginning five (5) years after the date -** permission to assert copyright is obtained from the U.S. Department of Energy, -** and subject to any subsequent five (5) year renewals, the U.S. Government is -** granted for itself and others acting on its behalf a paid-up, nonexclusive, -** irrevocable, worldwide license in the Software to reproduce, prepare derivative -** works, distribute copies to the public, perform publicly and display publicly, -** and to permit others to do so. -** -** Authors: Benjamin Andre -*/ - -/******************************************************************************* - ** - ** C declarations of the ecosim interface - ** - ******************************************************************************/ - -#include "ecosim_mod_test_wrapper.h" - -extern void ecosim_datatest(int col, BGCProperties* props, BGCSizes* sizes); - -void ecosim_datatest_wrapper(int col, BGCProperties* props, BGCSizes* sizes) { - ecosim_datatest(col, props, sizes); -} diff --git a/src/pks/ecosim/ecosim_mod_test_wrapper.h b/src/pks/ecosim/ecosim_mod_test_wrapper.h deleted file mode 100644 index 04c7faeed..000000000 --- a/src/pks/ecosim/ecosim_mod_test_wrapper.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */ - -/* -** Alquimia Copyright (c) 2013-2016, The Regents of the University of California, -** through Lawrence Berkeley National Laboratory (subject to receipt of any -** required approvals from the U.S. Dept. of Energy). All rights reserved. -** -** Alquimia is available under a BSD license. See LICENSE.txt for more -** information. -** -** If you have questions about your rights to use or distribute this software, -** please contact Berkeley Lab's Technology Transfer and Intellectual Property -** Management at TTD@lbl.gov referring to Alquimia (LBNL Ref. 2013-119). -** -** NOTICE. This software was developed under funding from the U.S. Department -** of Energy. As such, the U.S. Government has been granted for itself and -** others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide -** license in the Software to reproduce, prepare derivative works, and perform -** publicly and display publicly. Beginning five (5) years after the date -** permission to assert copyright is obtained from the U.S. Department of Energy, -** and subject to any subsequent five (5) year renewals, the U.S. Government is -** granted for itself and others acting on its behalf a paid-up, nonexclusive, -** irrevocable, worldwide license in the Software to reproduce, prepare derivative -** works, distribute copies to the public, perform publicly and display publicly, -** and to permit others to do so. -** -** Authors: Benjamin Andre -*/ - -/******************************************************************************* - ** - ** C declarations of the ecosim interface - ** - ******************************************************************************/ - -#ifndef ECOSIM_MOD_TEST_WRAPPER_H -#define ECOSIM_MOD_TEST_WRAPPER_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "data/BGC_containers.hh" - -void ecosim_datatest_wrapper(int col, BGCProperties* props, BGCSizes* sizes); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/src/pks/ecosim/ecosim_wrappers.F90 b/src/pks/ecosim/ecosim_wrappers.F90 deleted file mode 100644 index 3f60e78c2..000000000 --- a/src/pks/ecosim/ecosim_wrappers.F90 +++ /dev/null @@ -1,126 +0,0 @@ -! -!There needs to be a wrapper for the eocsim f90 driver -!as there are differences between how gfortran and intel compilers -!handle mangling conventions. -! -! Copied from the alquimia wrapper: -! **************************************************************************** ! -! -! PFloTran Alquimia Inteface Wrappers -! -! Author: Benjamin Andre -! -! Different fortran compilers use different name mangling conventions -! for fortran modules: -! -! gfortran : ___modulename_MOD_procedurename -! -! intel : _modulename_mp_procedurename_ -! -! as a consequence we can't put the alquimia interface into a -! module and call it directly from C/C++. Instead we use -! some simple wrapper functions. -! -! Notes: -! -! * Function call signatures are dictated by the alquimia API! -! -! * alquimia data structures defined in AlquimiaContainers_module -! (alquimia_containers.F90) are dictated by the alquimia API. -! -! **************************************************************************** ! - -subroutine EcoSIM_DataTest() bind(c) - use, intrinsic :: iso_c_binding - !Simple test for wrapper functionality - implicit none - - write(*,*) "in the data test" - - end subroutine EcoSIM_DataTest - -! **************************************************************************** ! - -subroutine EcoSIM_Setup(properties, state, sizes, num_iterations,& - num_columns, ncells_per_col_) bind(C) - - use, intrinsic :: iso_c_binding - - use BGCContainers_module - use ATSCPLMod, only : ATS2EcoSIMData, Init_EcoSIM, EcoSIM2ATSData - - implicit none - - ! function parameters - !character(kind=c_char), dimension(*), intent(in) :: input_filename - type (BGCSizes), intent(out) :: sizes - type (BGCState), intent(inout) :: state - !type (BGCAuxiliaryData), intent(inout) :: aux_data - type (BGCProperties), intent(in) :: properties - integer, intent(inout) :: num_columns - integer, intent(inout) :: num_iterations - integer, intent(inout) :: ncells_per_col_ - - call ATS2EcoSIMData(num_columns, state, properties, sizes) - - call Init_EcoSIM(sizes) - - call EcoSIM2ATSData(num_columns, state, sizes) - -end subroutine EcoSIM_Setup - -! **************************************************************************** ! - -subroutine EcoSIM_Shutdown() bind(C) - - !For now this does nothing, but it should clear all - !the data structures - use, intrinsic :: iso_c_binding - - use BGCContainers_module - - implicit none - - ! function parameters - !character(kind=c_char), dimension(*), intent(in) :: input_filename - !type (BGCSizes), intent(out) :: sizes - !type (BGCState), intent(in) :: state - !type (BGCAuxiliaryData), intent(in) :: aux_data - !type (BGCProperties), intent(in) :: properties - !integer :: num_columns, jz, js - !integer, intent(in) :: num_iterations - -end subroutine EcoSIM_Shutdown - -! **************************************************************************** ! - -subroutine EcoSIM_Advance( & - delta_t, & - properties, & - state, & - sizes, & - num_iterations, & - num_columns) bind(C) - - use, intrinsic :: iso_c_binding - use BGCContainers_module - use ATSCPLMod, only : Run_EcoSIM_one_step, ATS2EcoSIMData, EcoSIM2ATSData - - implicit none - - ! function parameters - real (c_double), value, intent(in) :: delta_t - type (BGCProperties), intent(in) :: properties - type (BGCState), intent(inout) :: state - type (BGCSizes), intent(out) :: sizes - !type (BGCEngineStatus), intent(out) :: status - integer, intent(in) :: num_columns - integer, intent(in) :: num_iterations - - call ATS2EcoSIMData(num_columns, state, properties, sizes) - - call Run_EcoSIM_one_step(sizes) - - call EcoSIM2ATSData(num_columns, state, sizes) - -end subroutine EcoSIM_Advance From 59eecacf53777c410d1cd222f14fa6f825cb6093 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Fri, 9 Jan 2026 09:27:33 -0800 Subject: [PATCH 575/582] Switching density to molar density The water content is in mols because we only currently need the density to convert water content to m in EcoSIM it makes more sense to just use the molar densitSwitching density to molar density --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index ab92800e7..4c240d20b 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -68,7 +68,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); //relative_permeability_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); matric_pressure_key_ = Keys::readKey(*plist_,domain_,"matric pressure","matric_pressure"); - liquid_density_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); + //liquid_density_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); + liquid_density_key_ = Keys::readKey(*plist_, domain_, "molar density liquid", "molar_density_liquid"); ice_density_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); gas_density_key_ = Keys::readKey(*plist_, domain_,"mass density gas", "mass_density_gas"); gas_density_key_test_ = Keys::readKey(*plist_, domain_, "mass density gas", "mass_density_gas"); From 8fbdc8d6b9e785758414c840dbfe0127a3be661f Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 13 Jan 2026 14:22:47 -0800 Subject: [PATCH 576/582] Updates to remove transport and ATS SEB PK In prior versions of the coupler the ATS SEB PK was used. Now that EcoSIM is doing the SEB we no longer need to use ATSs SEB PK. However fully removing it requiured changing the initialization so that the EcoSIM PK owns those variables. Additionally, transport is access but not used currently. So I commneted out transport sections until we actually need to test transport --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 84 +++++++++++++++++++------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 4c240d20b..bd058c66a 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -215,6 +215,9 @@ void EcoSIM::Setup() { } } + //Setting records for variables ONLY used by the EcoSIM PK, this includes, weather forcings, + // ecosim surface and subsurface forces, and surface variables from EcoSIM that are saved + // over to ATS (evaporation fluxes, snow related variables) if (!S_->HasRecord(snow_depth_key_,tag_next_)) { S_->Require(snow_depth_key_, tag_next_, snow_depth_key_) .SetMesh(mesh_surf_) @@ -292,8 +295,6 @@ void EcoSIM::Setup() { ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); - //May need to setup surface evaluators as they are now owned by surface_balance PK insteady of surface energy?? - // S_->RequireEvaluator(snow_albedo_key_, tag_next_); S_->Require(snow_albedo_key_, tag_next_).SetMesh(mesh_surf_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); @@ -316,7 +317,8 @@ void EcoSIM::Setup() { Teuchos::OSTab tab = vo_->getOSTab(); - //Check for total precipitation and set the record if it's there + //EcoSIM can do its own precipitation partitioning so you can put in total precipitation if + // you want EcoSIM to do it, or snow/rain if the forcing is already split. if (p_bool) { S_->RequireEvaluator(p_total_key_, tag_next_); S_->Require(p_total_key_, tag_next_).SetMesh(mesh_surf_) @@ -327,7 +329,7 @@ void EcoSIM::Setup() { ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } - //Setup Evaluators + //Setup custom evaluators for EcoSIM, found in constitutive relations requireEvaluatorAtNext(hydraulic_conductivity_key_, tag_next_, *S_) .SetMesh(mesh_) ->SetGhosted() @@ -348,6 +350,36 @@ void EcoSIM::Setup() { requireEvaluatorAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); +//Setup variables that were owned by ATS SEB, but now are controlled by EcoSIM +// Can remove SEB from the cycle_driver + requireEvaluatorAtNext(lw_key_, tag_next_, *S_) + .SetMesh(mesh_surf_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireEvaluatorAtCurrent(lw_key_, tag_current_, *S_, name_); + + requireEvaluatorAtNext(air_temp_key_, tag_next_, *S_) + .SetMesh(mesh_surf_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireEvaluatorAtCurrent(air_temp_key_, tag_current_, *S_, name_); + + requireEvaluatorAtNext(vp_air_key_, tag_next_, *S_) + .SetMesh(mesh_surf_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireEvaluatorAtCurrent(vp_air_key_, tag_current_, *S_, name_); + + requireEvaluatorAtNext(wind_speed_key_, tag_next_, *S_) + .SetMesh(mesh_surf_) + ->SetGhosted() + ->AddComponent("cell", AmanziMesh::CELL, 1); + + requireEvaluatorAtCurrent(wind_speed_key_, tag_current_, *S_, name_); + if (vo_->os_OK(Teuchos::VERB_MEDIUM)) { Teuchos::OSTab tab = vo_->getOSTab(); *vo_->os() << vo_->color("green") << "Setup of PK was successful" @@ -359,8 +391,11 @@ void EcoSIM::Setup() { void EcoSIM::Initialize() { PK_Physical_Default::Initialize(); //Need to know the number of components to initialize data structures - const Epetra_MultiVector& mole_fraction= *(S_->GetPtr(mole_fraction_key_, Tags::DEFAULT)->ViewComponent("cell")); - int mole_fraction_num = mole_fraction.NumVectors(); + + //Transport removal: + /*const Epetra_MultiVector& mole_fraction= *(S_->GetPtr(mole_fraction_key_, Tags::DEFAULT)->ViewComponent("cell")); + int mole_fraction_num = mole_fraction.NumVectors();*/ + int mole_fraction_num = 1; Teuchos::OSTab tab = vo_->getOSTab(); num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); @@ -495,7 +530,9 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { // Ensure dependencies are filled - S_->GetEvaluator(mole_fraction_key_, Tags::DEFAULT).Update(*S_, name_); + // Transport removal + + //S_->GetEvaluator(mole_fraction_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(porosity_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(saturation_liquid_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(water_content_key_, Tags::DEFAULT).Update(*S_, name_); @@ -506,13 +543,14 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(cell_volume_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); + //Surface data S_->GetEvaluator(sw_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(lw_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(air_temp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(vp_air_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(wind_speed_key_, Tags::DEFAULT).Update(*S_, name_); @@ -533,8 +571,8 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(p_snow_key_, Tags::DEFAULT).Update(*S_, name_); } - S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); - S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(surface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); + //S_->GetEvaluator(surface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); if (has_gas) { S_->GetEvaluator(saturation_gas_key_, Tags::DEFAULT).Update(*S_, name_); @@ -564,6 +602,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { AmanziMesh::Entity_ID num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); // grab the required fields + S_->GetEvaluator("porosity", tag_next_).Update(*S_, name_); const Epetra_MultiVector& porosity = *(*S_->Get("porosity", tag_next_) .ViewComponent("cell",false))(0); @@ -576,10 +615,6 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); - //S_->GetEvaluator("relative_permeability", tag_next_).Update(*S_, name_); - //const Epetra_MultiVector& relative_permeability = *(*S_->Get("relative_permeability", tag_next_) - // .ViewComponent("cell",false))(0); - S_->GetEvaluator("mass_density_liquid", tag_next_).Update(*S_, name_); const Epetra_MultiVector& liquid_density = *(*S_->Get("mass_density_liquid", tag_next_) .ViewComponent("cell",false))(0); @@ -880,8 +915,11 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, //This is the copy function for a loop over a single process instead of a single column //Fill state with ATS variables that are going to be changed by EcoSIM const Epetra_Vector& porosity = *(*S_->Get(porosity_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_MultiVector& mole_fraction= *(S_->GetPtr(mole_fraction_key_, water_tag)->ViewComponent("cell")); - int mole_fraction_num = mole_fraction.NumVectors(); + + //Transport removal + /*const Epetra_MultiVector& mole_fraction= *(S_->GetPtr(mole_fraction_key_, water_tag)->ViewComponent("cell")); + int mole_fraction_num = mole_fraction.NumVectors();*/ + int mole_fraction_num = 1; const Epetra_Vector& liquid_saturation = *(*S_->Get(saturation_liquid_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& water_content = *(*S_->Get(water_content_key_, water_tag).ViewComponent("cell", false))(0); @@ -899,7 +937,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, //const auto& shortwave_radiation = *S_.Get(sw_key_, water_tag).ViewComponent("cell", false); const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& longwave_radiation = *(*S_->Get(lw_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& air_temperature = *(*S_->Get(air_temp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& vapor_pressure_air = *(*S_->Get(vp_air_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& wind_speed= *(*S_->Get(wind_speed_key_, water_tag).ViewComponent("cell", false))(0); @@ -1078,7 +1116,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.sublimation_snow.data[column] = sublimation_snow[0][column]; props.shortwave_radiation.data[column] = shortwave_radiation[column]; - props.longwave_radiation.data[column] = longwave_radiation[column]; + //props.longwave_radiation.data[column] = longwave_radiation[column]; props.air_temperature.data[column] = air_temperature[column]; props.vapor_pressure_air.data[column] = vapor_pressure_air[column]; props.wind_speed.data[column] = wind_speed[column]; @@ -1139,8 +1177,10 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, const Tag& water_tag) { - Epetra_MultiVector& mole_fraction= *(S_->GetPtrW(mole_fraction_key_, Tags::DEFAULT, "subsurface transport")->ViewComponent("cell",false)); - int mole_fraction_num = mole_fraction.NumVectors(); + //Transport removal + /*Epetra_MultiVector& mole_fraction= *(S_->GetPtrW(mole_fraction_key_, Tags::DEFAULT, "subsurface transport")->ViewComponent("cell",false)); + int mole_fraction_num = mole_fraction.NumVectors();*/ + int mole_fraction_num = 1; auto& porosity = *(*S_->GetW(porosity_key_, Tags::DEFAULT, porosity_key_).ViewComponent("cell",false))(0); auto& liquid_saturation = *(*S_->GetW(saturation_liquid_key_, Tags::DEFAULT, saturation_liquid_key_).ViewComponent("cell",false))(0); From b6b0fab50da87812341b76780bc03c5307ad4efe Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Wed, 14 Jan 2026 18:29:35 -0800 Subject: [PATCH 577/582] Minor update to parameter naming convention Changed parameters for the EcoSIM PK parameter file to be more consistent with capitalization. --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index bd058c66a..d1ceb0e6f 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -152,17 +152,17 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //Starting values and parameters for precribed phenology / albedo - pressure_at_field_capacity = plist_->get("Field Capacity [Mpa]"); - pressure_at_wilting_point = plist_->get("Wilting Point [Mpa]"); - p_bool = plist_->get("EcoSIM Precipitation"); - a_bool = plist_->get("Prescribe Albedo"); - pheno_bool = plist_->get("Prescribe Phenology"); + pressure_at_field_capacity = plist_->get("field capacity [Mpa]"); + pressure_at_wilting_point = plist_->get("wilting point [Mpa]"); + p_bool = plist_->get("EcoSIM precipitation"); + a_bool = plist_->get("prescribe snow albedo"); + pheno_bool = plist_->get("prescribe phenology"); //Parameters for times and time of year dt_ = plist_->get("initial time step"); c_m_ = plist_->get("heat capacity [MJ mol^-1 K^-1]"); - day0_ = plist_->get("Starting day of year [0-364]"); - year0_ = plist_->get("Starting year"); + day0_ = plist_->get("starting day of year [0-364]"); + year0_ = plist_->get("starting year"); curr_day_ = day0_; curr_year_ = year0_; From dc2046a0ea0ff23107b966178883bf95715547fc Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Thu, 15 Jan 2026 15:02:55 -0800 Subject: [PATCH 578/582] Adding diagnostic variables for transpiration and canopy evaporation This update changes the coupling data structures to replace evapotranspiration with transpiration, and add an individual key for the canopy evaporation component. From now on total evapotranspiration should be done in ATS by explicitly summing transpiration and evaporation components with a custom evaluator. --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 29 +++++++++++++++++++------- src/pks/ecosim/EcoSIM_ATS_interface.hh | 3 ++- src/pks/ecosim/data/BGC_containers.hh | 3 ++- src/pks/ecosim/data/BGC_memory.cc | 6 ++++-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index d1ceb0e6f..3b149f254 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -130,7 +130,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, canopy_latent_heat_key_ = Keys::readKey(*plist_, domain_surface_, "canopy latent heat", "canopy_latent_heat"); canopy_sensible_heat_key_ = Keys::readKey(*plist_, domain_surface_, "canopy sensible heat", "canopy_sensible_heat"); canopy_surface_water_key_ = Keys::readKey(*plist_, domain_surface_, "canopy surface water", "canopy_surface_water"); - evapotranspiration_key_ = Keys::readKey(*plist_, domain_surface_, "evapotranspiration", "evapotranspiration"); + transpiration_key_ = Keys::readKey(*plist_, domain_surface_, "transpiration", "transpiration"); + evaporation_canopy_key_ = Keys::readKey(*plist_, domain_surface_, "evaporation canopy", "evaporation_canopy"); evaporation_ground_key_ = Keys::readKey(*plist_, domain_surface_, "evaporation ground", "evaporation_ground"); evaporation_litter_key_ = Keys::readKey(*plist_, domain_surface_, "evaporation litter", "evaporation_litter"); evaporation_snow_key_ = Keys::readKey(*plist_, domain_surface_, "evaporation snow", "evaporation_snow"); @@ -245,7 +246,12 @@ void EcoSIM::Setup() { ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); - S_->Require(evapotranspiration_key_ , tag_next_, evapotranspiration_key_) + S_->Require(transpiration_key_ , tag_next_, transpiration_key_) + .SetMesh(mesh_surf_) + ->SetGhosted(false) + ->SetComponent("cell", AmanziMesh::CELL, 1); + + S_->Require(evaporation_canopy_key_ , tag_next_, evaporation_canopy_key_) .SetMesh(mesh_surf_) ->SetGhosted(false) ->SetComponent("cell", AmanziMesh::CELL, 1); @@ -440,8 +446,11 @@ void EcoSIM::Initialize() { S_->GetW(canopy_surface_water_key_, Tags::DEFAULT, "surface-canopy_surface_water").PutScalar(0.0); S_->GetRecordW(canopy_surface_water_key_, Tags::DEFAULT, "surface-canopy_surface_water").set_initialized(); - S_->GetW(evapotranspiration_key_, Tags::DEFAULT, "surface-evapotranspiration").PutScalar(0.0); - S_->GetRecordW(evapotranspiration_key_, Tags::DEFAULT, "surface-evapotranspiration").set_initialized(); + S_->GetW(transpiration_key_, Tags::DEFAULT, "surface-transpiration").PutScalar(0.0); + S_->GetRecordW(transpiration_key_, Tags::DEFAULT, "surface-transpiration").set_initialized(); + + S_->GetW(evaporation_canopy_key_, Tags::DEFAULT, "surface-evaporation_canopy").PutScalar(0.0); + S_->GetRecordW(evaporation_canopy_key_, Tags::DEFAULT, "surface-evaporation_canopy").set_initialized(); S_->GetW(evaporation_ground_key_, Tags::DEFAULT, "surface-evaporation_ground").PutScalar(0.0); S_->GetRecordW(evaporation_ground_key_, Tags::DEFAULT, "surface-evaporation_ground").set_initialized(); @@ -972,7 +981,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto& canopy_latent_heat = *S_->GetW(canopy_latent_heat_key_, tag_next_, canopy_latent_heat_key_).ViewComponent("cell"); auto& canopy_sensible_heat = *S_->GetW(canopy_sensible_heat_key_, tag_next_, canopy_sensible_heat_key_).ViewComponent("cell"); auto& canopy_surface_water = *S_->GetW(canopy_surface_water_key_, tag_next_, canopy_surface_water_key_).ViewComponent("cell"); - auto& evapotranspiration = *S_->GetW(evapotranspiration_key_, tag_next_, evapotranspiration_key_).ViewComponent("cell"); + auto& transpiration = *S_->GetW(transpiration_key_, tag_next_, transpiration_key_).ViewComponent("cell"); + auto& evaporation_canopy = *S_->GetW(evaporation_canopy_key_, tag_next_, evaporation_canopy_key_).ViewComponent("cell"); auto& evaporation_ground = *S_->GetW(evaporation_ground_key_, tag_next_, evaporation_ground_key_).ViewComponent("cell"); auto& evaporation_litter = *S_->GetW(evaporation_litter_key_, tag_next_, evaporation_litter_key_).ViewComponent("cell"); auto& evaporation_snow = *S_->GetW(evaporation_snow_key_, tag_next_, evaporation_snow_key_).ViewComponent("cell"); @@ -1109,7 +1119,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, state.boundary_latent_heat_flux.data[column] = canopy_latent_heat[0][column]; state.boundary_sensible_heat_flux.data[column] = canopy_sensible_heat[0][column]; state.canopy_surface_water.data[column] = canopy_surface_water[0][column]; - state.evapotranspiration.data[column] = evapotranspiration[0][column]; + state.transpiration.data[column] = transpiration[0][column]; + state.evaporation_canopy.data[column] = evaporation_canopy[0][column]; state.evaporation_bare_ground.data[column] = evaporation_ground[0][column]; state.evaporation_litter.data[column] = evaporation_litter[0][column]; state.evaporation_snow.data[column] = evaporation_snow[0][column]; @@ -1205,7 +1216,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, auto& canopy_latent_heat = *S_->GetW(canopy_latent_heat_key_, tag_next_, canopy_latent_heat_key_).ViewComponent("cell"); auto& canopy_sensible_heat = *S_->GetW(canopy_sensible_heat_key_, tag_next_, canopy_sensible_heat_key_).ViewComponent("cell"); auto& canopy_surface_water = *S_->GetW(canopy_surface_water_key_, tag_next_, canopy_surface_water_key_).ViewComponent("cell"); - auto& evapotranspiration = *S_->GetW(evapotranspiration_key_, tag_next_, evapotranspiration_key_).ViewComponent("cell"); + auto& transpiration = *S_->GetW(transpiration_key_, tag_next_, transpiration_key_).ViewComponent("cell"); + auto& evaporation_canopy = *S_->GetW(evaporation_canopy_key_, tag_next_, evaporation_canopy_key_).ViewComponent("cell"); auto& evaporation_ground = *S_->GetW(evaporation_ground_key_, tag_next_, evaporation_ground_key_).ViewComponent("cell"); auto& evaporation_litter = *S_->GetW(evaporation_litter_key_, tag_next_, evaporation_litter_key_).ViewComponent("cell"); auto& evaporation_snow = *S_->GetW(evaporation_snow_key_, tag_next_, evaporation_snow_key_).ViewComponent("cell"); @@ -1275,7 +1287,8 @@ void EcoSIM::CopyFromEcoSIM_process(const int column, canopy_latent_heat[0][col] = state.boundary_latent_heat_flux.data[col]; canopy_sensible_heat[0][col] = state.boundary_sensible_heat_flux.data[col]; canopy_surface_water[0][col] = state.canopy_surface_water.data[col]; - evapotranspiration[0][col] = state.evapotranspiration.data[col]; + transpiration[0][col] = state.transpiration.data[col]; + evaporation_canopy[0][col] = state.evaporation_canopy.data[col]; evaporation_ground[0][col] = state.evaporation_bare_ground.data[col]; evaporation_litter[0][col] = state.evaporation_litter.data[col]; evaporation_snow[0][col] = state.evaporation_snow.data[col]; diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index a3c08e9a9..961665478 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -324,7 +324,8 @@ class EcoSIM : public PK_Physical_Default { Key canopy_latent_heat_key_; Key canopy_sensible_heat_key_; Key canopy_surface_water_key_; - Key evapotranspiration_key_; + Key transpiration_key_; + Key evaporation_canopy_key_; Key evaporation_ground_key_; Key evaporation_litter_key_; Key evaporation_snow_key_; diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 4c843d46f..1f73bbcf7 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -121,7 +121,8 @@ extern const int kBGCMaxWordLength; BGCVectorDouble boundary_latent_heat_flux; BGCVectorDouble boundary_sensible_heat_flux; BGCVectorDouble canopy_surface_water; - BGCVectorDouble evapotranspiration; + BGCVectorDouble transpiration; + BGCVectorDouble evaporation_canopy; BGCVectorDouble evaporation_bare_ground; BGCVectorDouble evaporation_litter; BGCVectorDouble evaporation_snow; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 9b09b654f..1dd1b4b67 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -330,7 +330,8 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCVectorDouble(sizes->num_columns, &(state->boundary_latent_heat_flux)); AllocateBGCVectorDouble(sizes->num_columns, &(state->boundary_sensible_heat_flux)); AllocateBGCVectorDouble(sizes->num_columns, &(state->canopy_surface_water)); - AllocateBGCVectorDouble(sizes->num_columns, &(state->evapotranspiration)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->transpiration)); + AllocateBGCVectorDouble(sizes->num_columns, &(state->evaporation_canopy)); AllocateBGCVectorDouble(sizes->num_columns, &(state->evaporation_bare_ground)); AllocateBGCVectorDouble(sizes->num_columns, &(state->evaporation_litter)); AllocateBGCVectorDouble(sizes->num_columns, &(state->evaporation_snow)); @@ -360,7 +361,8 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCVectorDouble(&(state->boundary_latent_heat_flux)); FreeBGCVectorDouble(&(state->boundary_sensible_heat_flux)); FreeBGCVectorDouble(&(state->canopy_surface_water)); - FreeBGCVectorDouble(&(state->evapotranspiration)); + FreeBGCVectorDouble(&(state->transpiration)); + FreeBGCVectorDouble(&(state->evaporation_canopy)); FreeBGCVectorDouble(&(state->evaporation_bare_ground)); FreeBGCVectorDouble(&(state->evaporation_litter)); FreeBGCVectorDouble(&(state->evaporation_snow)); From 8ab2951e7f4fcfa102fa50a9867d54b33045b127 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Mon, 26 Jan 2026 15:49:33 -0800 Subject: [PATCH 579/582] Updates to coupling data structures and custom evaluators The coupling interface has been updated to correctly add in rock density to the data structures. Additionally all of the custom evaluators have been modified. Bulk density and matric pressure have been removed as the bulk density calculation is done in EcoSIM now, and the matric pressure is substituted for capillary pressure. For now hydraulic conductivity is still present, but not in use yet as I try to decide on a final way to get hydraulic conductivity correct. --- src/executables/CMakeLists.txt | 3 +- src/pks/ecosim/CMakeLists.txt | 4 +- src/pks/ecosim/EcoSIM_ATS_interface.cc | 67 ++++----- src/pks/ecosim/EcoSIM_ATS_interface.hh | 1 + .../constitutive_relations/CMakeLists.txt | 32 ++-- .../bulk_density/bulk_density.py | 27 ---- .../bulk_density/bulk_density_evaluator.cc | 127 ---------------- .../bulk_density/bulk_density_evaluator.hh | 55 ------- .../bulk_density_evaluator_reg.hh | 11 -- .../bulk_density/bulk_density_model.cc | 54 ------- .../bulk_density/bulk_density_model.hh | 41 ------ .../hydraulic_conductivity_evaluator.cc | 14 +- .../hydraulic_conductivity_model.cc | 16 +- .../hydraulic_conductivity_model.hh | 8 +- .../matric_pressure/matric_pressure.py | 26 ---- .../matric_pressure_evaluator.cc | 139 ------------------ .../matric_pressure_evaluator.hh | 57 ------- .../matric_pressure_evaluator_reg.hh | 11 -- .../matric_pressure/matric_pressure_model.cc | 53 ------- .../matric_pressure/matric_pressure_model.hh | 44 ------ src/pks/ecosim/data/BGC_containers.hh | 1 + src/pks/ecosim/data/BGC_memory.cc | 2 + 22 files changed, 75 insertions(+), 718 deletions(-) delete mode 100644 src/pks/ecosim/constitutive_relations/bulk_density/bulk_density.py delete mode 100644 src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc delete mode 100644 src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh delete mode 100644 src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh delete mode 100644 src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc delete mode 100644 src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh delete mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure.py delete mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc delete mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh delete mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh delete mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc delete mode 100644 src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh diff --git a/src/executables/CMakeLists.txt b/src/executables/CMakeLists.txt index c32994873..bcf136218 100644 --- a/src/executables/CMakeLists.txt +++ b/src/executables/CMakeLists.txt @@ -133,7 +133,8 @@ if (ENABLE_ECOSIM) list(APPEND ats_link_libs ats_ecosim ats_ecosim_data - ats_ecosim_relations) + # ats_ecosim_relations + ) endif() #In theory covered by ECOSIM_LIBRARIES: diff --git a/src/pks/ecosim/CMakeLists.txt b/src/pks/ecosim/CMakeLists.txt index 1cbe02adb..d6ccc750c 100644 --- a/src/pks/ecosim/CMakeLists.txt +++ b/src/pks/ecosim/CMakeLists.txt @@ -23,9 +23,9 @@ if(ENABLE_ECOSIM) include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/data) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) + #include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/bulk_density) include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/hydraulic_conductivity) - include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) + #include_directories(${ATS_SOURCE_DIR}/src/pks/ecosim/constitutive_relations/matric_pressure) message("At include_directories") include_directories(${ECOSIM_BUILD_PREFIX}/f90src/Utils/) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 3b149f254..520222a51 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -33,9 +33,7 @@ #include "Mesh.hh" // include custom evaluators here -#include "hydraulic_conductivity_evaluator.hh" -#include "bulk_density_evaluator.hh" -#include "matric_pressure_evaluator.hh" +// #include "hydraulic_conductivity_evaluator.hh" #include "PK_Helpers.hh" #include "EcoSIM_ATS_interface.hh" @@ -67,7 +65,8 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, saturation_ice_key_ = Keys::readKey(*plist_,domain_,"saturation ice", "saturation_ice"); water_content_key_ = Keys::readKey(*plist_,domain_,"water content","water_content"); //relative_permeability_key_ = Keys::readKey(*plist_,domain_,"relative permeability","relative_permeability"); - matric_pressure_key_ = Keys::readKey(*plist_,domain_,"matric pressure","matric_pressure"); + //matric_pressure_key_ = Keys::readKey(*plist_,domain_,"matric pressure","matric_pressure"); + cap_pres_key_ = Keys::readKey(*plist_, domain_, "capillary pressure key", "capillary_pressure_gas_liq"); //liquid_density_key_ = Keys::readKey(*plist_, domain_, "mass density liquid", "mass_density_liquid"); liquid_density_key_ = Keys::readKey(*plist_, domain_, "molar density liquid", "molar_density_liquid"); ice_density_key_ = Keys::readKey(*plist_, domain_, "mass density ice", "mass_density_ice"); @@ -105,7 +104,7 @@ EcoSIM::EcoSIM(Teuchos::ParameterList& pk_tree, //Custom Evaluator keys hydraulic_conductivity_key_ = Keys::readKey(*plist_, domain_, "hydraulic conductivity", "hydraulic_conductivity"); - bulk_density_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); + //bulk_density_key_ = Keys::readKey(*plist_, domain_, "bulk density", "bulk_density"); //Surface balance items sw_key_ = @@ -343,19 +342,6 @@ void EcoSIM::Setup() { requireEvaluatorAtCurrent(hydraulic_conductivity_key_, tag_current_, *S_, name_); - requireEvaluatorAtNext(bulk_density_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::CELL, 1); - requireEvaluatorAtCurrent(bulk_density_key_, tag_current_, *S_, name_); - - requireEvaluatorAtNext(matric_pressure_key_, tag_next_, *S_) - .SetMesh(mesh_) - ->SetGhosted() - ->AddComponent("cell", AmanziMesh::CELL, 1); - - requireEvaluatorAtCurrent(matric_pressure_key_, tag_current_, *S_, name_); - //Setup variables that were owned by ATS SEB, but now are controlled by EcoSIM // Can remove SEB from the cycle_driver requireEvaluatorAtNext(lw_key_, tag_next_, *S_) @@ -480,11 +466,11 @@ void EcoSIM::Initialize() { S_->GetW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").PutScalar(1.0); S_->GetRecordW(hydraulic_conductivity_key_, Tags::DEFAULT, "hydraulic_conductivity").set_initialized(); - S_->GetW(bulk_density_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); - S_->GetRecordW(bulk_density_key_, Tags::DEFAULT, "bulk_density").set_initialized(); + //S_->GetW(bulk_density_key_, Tags::DEFAULT, "bulk_density").PutScalar(1.0); + //S_->GetRecordW(bulk_density_key_, Tags::DEFAULT, "bulk_density").set_initialized(); - S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); - S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); + //S_->GetW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").PutScalar(1.0); + //S_->GetRecordW(matric_pressure_key_, Tags::DEFAULT, "matric_pressure").set_initialized(); int num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); @@ -552,6 +538,7 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(cell_volume_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_wp_key_, Tags::DEFAULT).Update(*S_, name_); S_->GetEvaluator(f_root_key_, Tags::DEFAULT).Update(*S_, name_); + S_->GetEvaluator(cap_pres_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(subsurface_energy_source_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(subsurface_water_source_key_, Tags::DEFAULT).Update(*S_, name_); //S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); @@ -597,16 +584,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { S_->GetEvaluator(thermal_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); //Update owned evaluators - Teuchos::RCP hydra_cond = S_->GetPtr(hydraulic_conductivity_key_, Tags::DEFAULT); + /*Teuchos::RCP hydra_cond = S_->GetPtr(hydraulic_conductivity_key_, Tags::DEFAULT); S_->GetEvaluator(hydraulic_conductivity_key_, Tags::DEFAULT).Update(*S_, name_); - - Teuchos::RCP bulk_dens = S_->GetPtr(bulk_density_key_, Tags::DEFAULT); - S_->GetEvaluator(bulk_density_key_, Tags::DEFAULT).Update(*S_, name_); - - Teuchos::RCP mat_p = S_->GetPtr(matric_pressure_key_, Tags::DEFAULT); - S_->GetEvaluator(matric_pressure_key_, Tags::DEFAULT).Update(*S_, name_); - const Epetra_MultiVector& matric_pressure = *(*S_->Get("matric_pressure", tag_next_) - .ViewComponent("cell",false))(0); + const Epetra_MultiVector& hydraulic_conductivity = *(*S_->Get("hydraulic_conductivity", tag_next_) + .ViewComponent("cell",false))(0);*/ AmanziMesh::Entity_ID num_columns_ = mesh_surf_->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED); @@ -620,6 +601,10 @@ bool EcoSIM::AdvanceStep(double t_old, double t_new, bool reinit) { const Epetra_MultiVector& liquid_saturation = *(*S_->Get("saturation_liquid", tag_next_) .ViewComponent("cell",false))(0); + S_->GetEvaluator("capillary_pressure_gas_liq", tag_next_).Update(*S_, name_); + const Epetra_MultiVector& capillary_pressure = *(*S_->Get("capillary_pressure_gas_liq", tag_next_) + .ViewComponent("cell",false))(0); + S_->GetEvaluator("water_content", tag_next_).Update(*S_, name_); const Epetra_MultiVector& water_content = *(*S_->Get("water_content", tag_next_) .ViewComponent("cell",false))(0); @@ -937,12 +922,13 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, const Epetra_Vector& rock_density = *(*S_->Get(rock_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& cell_volume = *(*S_->Get(cell_volume_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& hydraulic_conductivity = *(*S_->Get(hydraulic_conductivity_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& matric_pressure = *(*S_->Get(matric_pressure_key_, water_tag).ViewComponent("cell", false))(0); - const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& matric_pressure = *(*S_->Get(matric_pressure_key_, water_tag).ViewComponent("cell", false))(0); + //const Epetra_Vector& bulk_density = *(*S_->Get(bulk_density_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& rooting_depth_fraction = *(*S_->Get(f_root_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& plant_wilting_factor = *(*S_->Get(f_wp_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& temp = *(*S_->Get(T_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& thermal_conductivity = *(*S_->Get(thermal_conductivity_key_, water_tag).ViewComponent("cell", false))(0); + const Epetra_Vector& capillary_pressure = *(*S_->Get(cap_pres_key_, water_tag).ViewComponent("cell", false))(0); //const auto& shortwave_radiation = *S_.Get(sw_key_, water_tag).ViewComponent("cell", false); const Epetra_Vector& shortwave_radiation = *(*S_->Get(sw_key_, water_tag).ViewComponent("cell", false))(0); @@ -960,7 +946,8 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, precipitation = &(*(*S_->Get(p_rain_key_, water_tag).ViewComponent("cell", false))(0)); precipitation_snow = &(*(*S_->Get(p_snow_key_, water_tag).ViewComponent("cell", false))(0)); } - const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); + + const Epetra_Vector& elevation = *(*S_->Get(elev_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& aspect = *(*S_->Get(aspect_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& slope = *(*S_->Get(slope_key_, water_tag).ViewComponent("cell", false))(0); const Epetra_Vector& snow_albedo = *(*S_->Get(snow_albedo_key_, water_tag).ViewComponent("cell", false))(0); @@ -1014,6 +1001,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, auto col_ss_energy_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_ss_water_source = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_depth_c = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); + auto col_cap_pres = Teuchos::rcp(new Epetra_SerialDenseVector(ncells_per_col_)); auto col_mole_fraction = Teuchos::rcp(new Epetra_SerialDenseMatrix(mole_fraction_num,ncells_per_col_)); @@ -1049,14 +1037,16 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, FieldToColumn_(column,rock_density,col_r_dens.ptr()); FieldToColumn_(column,cell_volume,col_vol.ptr()); FieldToColumn_(column,hydraulic_conductivity,col_h_cond.ptr()); - FieldToColumn_(column,bulk_density,col_b_dens.ptr()); + //FieldToColumn_(column,bulk_density,col_b_dens.ptr()); FieldToColumn_(column,plant_wilting_factor,col_wp.ptr()); FieldToColumn_(column,rooting_depth_fraction,col_rf.ptr()); FieldToColumn_(column,subsurface_water_source,col_ss_water_source.ptr()); FieldToColumn_(column,subsurface_energy_source,col_ss_energy_source.ptr()); - FieldToColumn_(column,matric_pressure,col_mat_p.ptr()); + //setting matric pressure to capillary pressure here + FieldToColumn_(column,capillary_pressure,col_mat_p.ptr()); FieldToColumn_(column,temp, col_temp.ptr()); FieldToColumn_(column,thermal_conductivity,col_cond.ptr()); + //FieldToColumn_(column,capillary_pressure,col_cap_pres.ptr()); //MatrixFieldToColumn_(column, mole_fraction, col_mole_fraction.ptr()); @@ -1069,7 +1059,7 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, std::size_t ncol_cells = col_iter.size(); double column_area = mesh_->getFaceArea(f); - std::cout << "column: " << column << " column_area: " << column_area << std::endl; + //std::cout << "column: " << column << " column_area: " << column_area << std::endl; props.column_area.data[column] = column_area; VolDepthDz_(column, col_depth.ptr(), col_dz.ptr(), col_vol.ptr()); @@ -1081,10 +1071,11 @@ void EcoSIM::CopyToEcoSIM_process(int proc_rank, for (int i=0; i < ncells_per_col_; ++i) { state.liquid_density.data[column * ncells_per_col_ + i] = (*col_l_dens)[i]; + state.rock_density.data[column * ncells_per_col_ + i] = (*col_r_dens)[i]; state.porosity.data[column * ncells_per_col_ + i] = (*col_porosity)[i]; state.water_content.data[column * ncells_per_col_ + i] = (*col_wc)[i]; state.hydraulic_conductivity.data[column * ncells_per_col_ + i] = (*col_h_cond)[i]; - state.bulk_density.data[column * ncells_per_col_ + i] = (*col_b_dens)[i]; + //state.bulk_density.data[column * ncells_per_col_ + i] = (*col_b_dens)[i]; state.subsurface_water_source.data[column * ncells_per_col_ + i] = (*col_ss_water_source)[i]; state.subsurface_energy_source.data[column * ncells_per_col_ + i] = (*col_ss_energy_source)[i]; state.matric_pressure.data[column * ncells_per_col_ + i] = (*col_mat_p)[i]; diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.hh b/src/pks/ecosim/EcoSIM_ATS_interface.hh index 961665478..b7c49bb02 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.hh +++ b/src/pks/ecosim/EcoSIM_ATS_interface.hh @@ -331,6 +331,7 @@ class EcoSIM : public PK_Physical_Default { Key evaporation_snow_key_; Key sublimation_snow_key_; Key snow_temperature_key_; + Key cap_pres_key_; Teuchos::RCP bgc_engine_; diff --git a/src/pks/ecosim/constitutive_relations/CMakeLists.txt b/src/pks/ecosim/constitutive_relations/CMakeLists.txt index 4e2eae25f..62a7ba000 100644 --- a/src/pks/ecosim/constitutive_relations/CMakeLists.txt +++ b/src/pks/ecosim/constitutive_relations/CMakeLists.txt @@ -9,21 +9,21 @@ # collect all sources set(ats_ecosim_relations_src_files - bulk_density/bulk_density_evaluator.cc - bulk_density/bulk_density_model.cc +# bulk_density/bulk_density_evaluator.cc +# bulk_density/bulk_density_model.cc hydraulic_conductivity/hydraulic_conductivity_evaluator.cc hydraulic_conductivity/hydraulic_conductivity_model.cc - matric_pressure/matric_pressure_evaluator.cc - matric_pressure/matric_pressure_model.cc +# matric_pressure/matric_pressure_evaluator.cc +# matric_pressure/matric_pressure_model.cc ) set(ats_ecosim_relations_inc_files - bulk_density/bulk_density_evaluator.hh - bulk_density/bulk_density_model.hh +# bulk_density/bulk_density_evaluator.hh +# bulk_density/bulk_density_model.hh hydraulic_conductivity/hydraulic_conductivity_evaluator.hh hydraulic_conductivity/hydraulic_conductivity_model.hh - matric_pressure/matric_pressure_evaluator.hh - matric_pressure/matric_pressure_model.hh +# matric_pressure/matric_pressure_evaluator.hh +# matric_pressure/matric_pressure_model.hh ) set(ats_ecosim_relations_link_libs @@ -51,20 +51,20 @@ add_amanzi_library(ats_ecosim_relations HEADERS ${ats_ecosim_relations_inc_files} LINK_LIBS ${ats_ecosim_relations_link_libs}) -register_evaluator_with_factory( - HEADERFILE bulk_density/bulk_density_evaluator_reg.hh - LISTNAME ATS_ECOSIM_RELATIONS_REG -) +#register_evaluator_with_factory( +# HEADERFILE bulk_density/bulk_density_evaluator_reg.hh +# LISTNAME ATS_ECOSIM_RELATIONS_REG +#) register_evaluator_with_factory( HEADERFILE hydraulic_conductivity/hydraulic_conductivity_evaluator_reg.hh LISTNAME ATS_ECOSIM_RELATIONS_REG ) -register_evaluator_with_factory( - HEADERFILE matric_pressure/matric_pressure_evaluator_reg.hh - LISTNAME ATS_ECOSIM_RELATIONS_REG -) +#register_evaluator_with_factory( +# HEADERFILE matric_pressure/matric_pressure_evaluator_reg.hh +# LISTNAME ATS_ECOSIM_RELATIONS_REG +#) generate_evaluators_registration_header( HEADERFILE ats_ecosim_relations_registration.hh diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density.py b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density.py deleted file mode 100644 index 6a57923c7..000000000 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Richards water content evaluator: the standard form as a function of liquid saturation.""" - -import sys, os -sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) -from evaluator_generator import generate_evaluator - -""" Note that the density of rock could be either in mols or kg so this will - only make sense if it's given in mols """ - -deps = [("porosity", "phi"), - ("density_rock","nr"), - ("saturation_liquid", "sl"), - ("molar_density_liquid", "nl"), - ("saturation_ice", "si"), - ("molar_density_ice", "ni"), - ("saturation_gas", "sg"), - ("molar_density_gas", "ng") - ] -params = [] - -import sympy -phi, nr, sl, nl, si, ni, sg, ng = sympy.var("phi,nr,sl,nl,si,ni,sg,ng") -expression = nr*(1 - phi) + phi*(sl*nl + si*ni + sg*ng); - -generate_evaluator("bulk_density", "ecosim", - "bulk density", "bulk_density", - deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc deleted file mode 100644 index 41f1af152..000000000 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* - The bulk density evaluator is an algebraic evaluator of a given model. -Richards water content evaluator: the standard form as a function of liquid saturation. - Generated via evaluator_generator. -*/ - -#include "bulk_density_evaluator.hh" -#include "bulk_density_model.hh" - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -// Constructor from ParameterList -BulkDensityEvaluator::BulkDensityEvaluator(Teuchos::ParameterList& plist) : - EvaluatorSecondaryMonotypeCV(plist) -{ - Teuchos::ParameterList& sublist = plist_.sublist("bulk_density parameters"); - model_ = Teuchos::rcp(new BulkDensityModel(sublist)); - InitializeFromPlist_(); -} - - -// Copy constructor -//Other examples don't seem to have this copy (unneccesary?) -/*BulkDensityEvaluator::BulkDensityEvaluator(const BulkDensityEvaluator& other) : - EvaluatorSecondaryMonotypeCV(other), - phi_key_(other.phi_key_), - nr_key_(other.nr_key_), - model_(other.model_) {}*/ - - -// Virtual copy constructor -Teuchos::RCP -BulkDensityEvaluator::Clone() const -{ - return Teuchos::rcp(new BulkDensityEvaluator(*this)); -} - - -// Initialize by setting up dependencies -void -BulkDensityEvaluator::InitializeFromPlist_() -{ - // Set up my dependencies - // - defaults to prefixed via domain - // Seems to not handle keys or tags right fixing: - //Key domain_name = Keys::getDomain(my_key_); - Key domain_name = Keys::getDomain(my_keys_.front().first); - Tag tag = my_keys_.front().second; - - // - pull Keys from plist - // dependency: porosity - phi_key_ = Keys::readKey(plist_, domain_name, "porosity", "porosity"); - dependencies_.insert(KeyTag{ phi_key_, tag }); - - // dependency: density_rock - nr_key_ = Keys::readKey(plist_, domain_name, "density rock", "density_rock"); - dependencies_.insert(KeyTag{ nr_key_, tag}); -} - - -void -BulkDensityEvaluator::Evaluate_(const State& S, - const std::vector& result) -{ - Tag tag = my_keys_.front().second; - Teuchos::RCP phi = S.GetPtr(phi_key_, tag); - Teuchos::RCP nr = S.GetPtr(nr_key_, tag); - - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->BulkDensity(phi_v[0][i], nr_v[0][i]); - } - } -} - - -void -BulkDensityEvaluator::EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) -{ - Tag tag = my_keys_.front().second; - Teuchos::RCP phi = S.GetPtr(phi_key_, tag); - Teuchos::RCP nr = S.GetPtr(nr_key_, tag); - - if (wrt_key == phi_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDPorosity(phi_v[0][i], nr_v[0][i]); - } - } - - } else if (wrt_key == nr_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& nr_v = *nr->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DBulkDensityDDensityRock(phi_v[0][i], nr_v[0][i]); - } - } - - } else { - AMANZI_ASSERT(0); - } -} - - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh deleted file mode 100644 index a7eb3eed4..000000000 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator.hh +++ /dev/null @@ -1,55 +0,0 @@ -/* - The bulk density evaluator is an algebraic evaluator of a given model. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#ifndef AMANZI_ECOSIM_BULK_DENSITY_EVALUATOR_HH_ -#define AMANZI_ECOSIM_BULK_DENSITY_EVALUATOR_HH_ - -#include "Factory.hh" -#include "EvaluatorSecondaryMonotype.hh" - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -class BulkDensityModel; - -class BulkDensityEvaluator : public EvaluatorSecondaryMonotypeCV { - public: - explicit - BulkDensityEvaluator(Teuchos::ParameterList& plist); - BulkDensityEvaluator(const BulkDensityEvaluator& other) = default; - virtual Teuchos::RCP Clone() const override; - - Teuchos::RCP get_model() { return model_; } - - protected: - // Required methods from EvaluatorSecondaryMonotypeCV - virtual void Evaluate_(const State& S, - const std::vector& result) override; - virtual void EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) override; - - void InitializeFromPlist_(); - - protected: - Key phi_key_; - Key nr_key_; - - Teuchos::RCP model_; - - private: - static Utils::RegisteredFactory reg_; - -}; - -} //namespace -} //namespace -} //namespace - -#endif diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh deleted file mode 100644 index 45e7753a7..000000000 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_evaluator_reg.hh +++ /dev/null @@ -1,11 +0,0 @@ -#include "bulk_density_evaluator.hh" - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -Utils::RegisteredFactory BulkDensityEvaluator::reg_("bulk density"); - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc deleted file mode 100644 index 449e8e7f6..000000000 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - The bulk density model is an algebraic model with dependencies. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#include "Teuchos_ParameterList.hpp" -#include "dbc.hh" -#include "bulk_density_model.hh" - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -// Constructor from ParameterList -BulkDensityModel::BulkDensityModel(Teuchos::ParameterList& plist) -{ - InitializeFromPlist_(plist); -} - - -// Initialize parameters -void -BulkDensityModel::InitializeFromPlist_(Teuchos::ParameterList& plist) -{ - -} - - -// main method -double -BulkDensityModel::BulkDensity(double phi, double nr) const -{ - return nr*(1 - phi); -} - -double -BulkDensityModel::DBulkDensityDPorosity(double phi, double nr) const -{ - return -1.0*nr; -} - -double -BulkDensityModel::DBulkDensityDDensityRock(double phi, double nr) const -{ - return 1 - phi; -} - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh b/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh deleted file mode 100644 index f4ca13355..000000000 --- a/src/pks/ecosim/constitutive_relations/bulk_density/bulk_density_model.hh +++ /dev/null @@ -1,41 +0,0 @@ -/* - The bulk density model is an algebraic model with dependencies. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#ifndef AMANZI_ECOSIM_BULK_DENSITY_MODEL_HH_ -#define AMANZI_ECOSIM_BULK_DENSITY_MODEL_HH_ - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -class BulkDensityModel { - - public: - explicit - BulkDensityModel(Teuchos::ParameterList& plist); - - double BulkDensity(double phi, double nr) const; - - double DBulkDensityDPorosity(double phi, double nr) const; - double DBulkDensityDDensityRock(double phi, double nr) const; - - protected: - void InitializeFromPlist_(Teuchos::ParameterList& plist); - - protected: - - - -}; - -} //namespace -} //namespace -} //namespace - -#endif diff --git a/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc index 0e589aef8..986e0fd39 100644 --- a/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc +++ b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_evaluator.cc @@ -73,6 +73,9 @@ HydraulicConductivityEvaluator::Evaluate_(const State& S, Teuchos::RCP rho = S.GetPtr(rho_key_, tag); Teuchos::RCP mu = S.GetPtr(mu_key_, tag); + const AmanziGeometry::Point& gravity = S.Get("gravity", Tags::DEFAULT); + double gz = -gravity[2]; + for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { const Epetra_MultiVector& k_v = *k->ViewComponent(*comp, false); @@ -82,7 +85,7 @@ HydraulicConductivityEvaluator::Evaluate_(const State& S, int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->HydraulicConductivity(k_v[0][i], rho_v[0][i], mu_v[0][i]); + result_v[0][i] = model_->HydraulicConductivity(k_v[0][i], rho_v[0][i], mu_v[0][i],gz); } } } @@ -97,6 +100,9 @@ HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, Teuchos::RCP rho = S.GetPtr(rho_key_, tag); Teuchos::RCP mu = S.GetPtr(mu_key_, tag); + const AmanziGeometry::Point& gravity = S.Get("gravity", Tags::DEFAULT); + double gz = -gravity[2]; + if (wrt_key == k_key_) { for (CompositeVector::name_iterator comp=result[0]->begin(); comp!=result[0]->end(); ++comp) { @@ -107,7 +113,7 @@ HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DHydraulicConductivityDPermeability(k_v[0][i], rho_v[0][i], mu_v[0][i]); + result_v[0][i] = model_->DHydraulicConductivityDPermeability(k_v[0][i], rho_v[0][i], mu_v[0][i],gz); } } @@ -121,7 +127,7 @@ HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DHydraulicConductivityDMassDensityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); + result_v[0][i] = model_->DHydraulicConductivityDMassDensityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i],gz); } } @@ -135,7 +141,7 @@ HydraulicConductivityEvaluator::EvaluatePartialDerivative_(const State& S, int ncomp = result[0]->size(*comp, false); for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DHydraulicConductivityDViscosityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i]); + result_v[0][i] = model_->DHydraulicConductivityDViscosityLiquid(k_v[0][i], rho_v[0][i], mu_v[0][i],gz); } } diff --git a/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc index 976c73c4b..9696f36aa 100644 --- a/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc +++ b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.cc @@ -32,27 +32,27 @@ HydraulicConductivityModel::InitializeFromPlist_(Teuchos::ParameterList& plist) // main method double -HydraulicConductivityModel::HydraulicConductivity(double k, double rho, double mu) const +HydraulicConductivityModel::HydraulicConductivity(double k, double rho, double mu, double gz) const { - return k*rho; + return k*rho*gz/mu; } double -HydraulicConductivityModel::DHydraulicConductivityDPermeability(double k, double rho, double mu) const +HydraulicConductivityModel::DHydraulicConductivityDPermeability(double k, double rho, double mu, double gz) const { - return rho; + return rho*gz/mu; } double -HydraulicConductivityModel::DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const +HydraulicConductivityModel::DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu, double gz) const { - return k; + return k*gz/mu; } double -HydraulicConductivityModel::DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const +HydraulicConductivityModel::DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu, double gz) const { - return 0; + return -1.0*k*rho*gz/pow(mu,2); } } //namespace diff --git a/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh index f7a07f425..5209ef609 100644 --- a/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh +++ b/src/pks/ecosim/constitutive_relations/hydraulic_conductivity/hydraulic_conductivity_model.hh @@ -20,11 +20,11 @@ class HydraulicConductivityModel { explicit HydraulicConductivityModel(Teuchos::ParameterList& plist); - double HydraulicConductivity(double k, double rho, double mu) const; + double HydraulicConductivity(double k, double rho, double mu, double gz) const; - double DHydraulicConductivityDPermeability(double k, double rho, double mu) const; - double DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu) const; - double DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu) const; + double DHydraulicConductivityDPermeability(double k, double rho, double mu, double gz) const; + double DHydraulicConductivityDMassDensityLiquid(double k, double rho, double mu, double gz) const; + double DHydraulicConductivityDViscosityLiquid(double k, double rho, double mu, double gz) const; protected: void InitializeFromPlist_(Teuchos::ParameterList& plist); diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure.py b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure.py deleted file mode 100644 index d0adeacce..000000000 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Richards water content evaluator: the standard form as a function of liquid saturation.""" - -import sys, os -sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'], "tools", "evaluator_generator")) -from evaluator_generator import generate_evaluator - -deps = [("porosity", "phi"), - ("saturation_liquid", "sl"), - ("molar_density_liquid", "nl"), - ("cell_volume", "cv") - ] - -params = [("alpha", "double", "van genuchten alpha"), -("m", "double", "van genuchten m"), -("n", "double", "van genuchten n"), -("sr", "double", "residual saturation") -] - -import sympy -phi, sl, nl, cv = sympy.var("phi,sl,nl,cv") -alpha_, m_, n_, sr_ = sympy.var("alpha_,m_,n_,sr_") -expression = -1/(alpha_**n_) * (1 - ((sl - sr_)/(cv*nl*phi - sr_))**(1/m_))**(-n_) - -generate_evaluator("matric_pressure", "flow", - "matric pressure", "matric_pressure", - deps, params, expression=expression, doc=__doc__) diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc deleted file mode 100644 index 166c77f36..000000000 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - The matric pressure evaluator is an algebraic evaluator of a given model. -Richards water content evaluator: the standard form as a function of liquid saturation. - Generated via evaluator_generator. -*/ - -#include "matric_pressure_evaluator.hh" -#include "matric_pressure_model.hh" - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -// Constructor from ParameterList -MatricPressureEvaluator::MatricPressureEvaluator(Teuchos::ParameterList& plist) : - EvaluatorSecondaryMonotypeCV(plist) -{ - Teuchos::ParameterList& sublist = plist_.sublist("matric_pressure parameters"); - model_ = Teuchos::rcp(new MatricPressureModel(sublist)); - InitializeFromPlist_(); -} - - -// Copy constructor -//Don't seem to need this -/*MatricPressureEvaluator::MatricPressureEvaluator(const MatricPressureEvaluator& other) : - EvaluatorSecondaryMonotypeCV(other), - k_key_(other.k_key_) - rho_key_(other.rho_key_), - mu_key_(other.mu_key_), - model_(other.model_) {}*/ - - -// Virtual copy constructor -Teuchos::RCP -MatricPressureEvaluator::Clone() const -{ - return Teuchos::rcp(new MatricPressureEvaluator(*this)); -} - - -// Initialize by setting up dependencies -void -MatricPressureEvaluator::InitializeFromPlist_() -{ - // Set up my dependencies - // - defaults to prefixed via domain - //Key domain_name = Keys::getDomain(my_key_); - Key domain_name = Keys::getDomain(my_keys_.front().first); - Tag tag = my_keys_.front().second; - - // - pull Keys from plist - // dependency: permeability - porosity_key_ = Keys::readKey(plist_, domain_name, "porosity", "porosity"); - dependencies_.insert(KeyTag{ porosity_key_, tag }); - - // dependency: saturation_liquid - water_content_key_ = Keys::readKey(plist_, domain_name, "water content", "water_content"); - dependencies_.insert(KeyTag{ water_content_key_, tag}); - - // dependency: molar density liquid - mdens_liquid_key_ = Keys::readKey(plist_, domain_name, "molar density liquid", "molar_density_liquid"); - dependencies_.insert(KeyTag{ mdens_liquid_key_, tag}); - - // dependency: cell volume - cv_key_ = Keys::readKey(plist_, domain_name, "cell volume", "cell_volume"); - dependencies_.insert(KeyTag{ cv_key_, tag}); - - sl_key_ = Keys::readKey(plist_, domain_name, "liquid saturation", "saturation_liquid"); - dependencies_.insert(KeyTag{ sl_key_, tag}); -} - - -void -MatricPressureEvaluator::Evaluate_(const State& S, - const std::vector& result) -{ - Tag tag = my_keys_.front().second; - Teuchos::RCP phi = S.GetPtr(porosity_key_, tag); - Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); - Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); - Teuchos::RCP cv = S.GetPtr(cv_key_, tag); - Teuchos::RCP sl = S.GetPtr(sl_key_, tag); - - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); - const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->MatricPressure(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i], sl_v[0][i]); - } - } -} - - -void -MatricPressureEvaluator::EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) -{ - Tag tag = my_keys_.front().second; - Teuchos::RCP phi = S.GetPtr(porosity_key_, tag); - Teuchos::RCP theta = S.GetPtr(water_content_key_, tag); - Teuchos::RCP rho = S.GetPtr(mdens_liquid_key_, tag); - Teuchos::RCP cv = S.GetPtr(cv_key_, tag); - Teuchos::RCP sl = S.GetPtr(sl_key_, tag); - - if (wrt_key == porosity_key_) { - for (CompositeVector::name_iterator comp=result[0]->begin(); - comp!=result[0]->end(); ++comp) { - const Epetra_MultiVector& phi_v = *phi->ViewComponent(*comp, false); - const Epetra_MultiVector& theta_v = *theta->ViewComponent(*comp, false); - const Epetra_MultiVector& rho_v = *rho->ViewComponent(*comp, false); - const Epetra_MultiVector& cv_v = *cv->ViewComponent(*comp, false); - const Epetra_MultiVector& sl_v = *sl->ViewComponent(*comp, false); - - Epetra_MultiVector& result_v = *result[0]->ViewComponent(*comp,false); - - int ncomp = result[0]->size(*comp, false); - for (int i=0; i!=ncomp; ++i) { - result_v[0][i] = model_->DMatricPressureDPorosity(phi_v[0][i], theta_v[0][i], rho_v[0][i], cv_v[0][i], sl_v[0][i]); - } - } - - } - else { - AMANZI_ASSERT(0); - } -} - - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh deleted file mode 100644 index c8c974457..000000000 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator.hh +++ /dev/null @@ -1,57 +0,0 @@ -/* - The hydraulic conductivity evaluator is an algebraic evaluator of a given model. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#ifndef AMANZI_FLOW_MATRIC_PRESSURE_EVALUATOR_HH_ -#define AMANZI_FLOW_MATRIC_PRESSURE_EVALUATOR_HH_ - -#include "Factory.hh" -#include "EvaluatorSecondaryMonotype.hh" - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -class MatricPressureModel; - -class MatricPressureEvaluator : public EvaluatorSecondaryMonotypeCV { - public: - explicit MatricPressureEvaluator(Teuchos::ParameterList& plist); - MatricPressureEvaluator(const MatricPressureEvaluator& other) = default; - virtual Teuchos::RCP Clone() const override; - - Teuchos::RCP get_model() { return model_; } - - protected: - // Required methods from EvaluatorSecondaryMonotypeCV - virtual void Evaluate_(const State& S, - const std::vector& result) override; - virtual void EvaluatePartialDerivative_(const State& S, - const Key& wrt_key, const Tag& wrt_tag, const std::vector& result) override; - - void InitializeFromPlist_(); - - protected: - Key porosity_key_; - Key water_content_key_; - Key mdens_liquid_key_; - Key cv_key_; - Key sl_key_; - - Teuchos::RCP model_; - - private: - static Utils::RegisteredFactory reg_; - -}; - -} //namespace -} //namespace -} //namespace - -#endif diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh deleted file mode 100644 index 7609e097e..000000000 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_evaluator_reg.hh +++ /dev/null @@ -1,11 +0,0 @@ -#include "matric_pressure_evaluator.hh" - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -Utils::RegisteredFactory MatricPressureEvaluator::reg_("matric pressure"); - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc deleted file mode 100644 index b2d0b8d5a..000000000 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - The hydraulic conductivity model is an algebraic model with dependencies. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#include "Teuchos_ParameterList.hpp" -#include "dbc.hh" -#include "matric_pressure_model.hh" - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -// Constructor from ParameterList -MatricPressureModel::MatricPressureModel(Teuchos::ParameterList& plist) -{ - InitializeFromPlist_(plist); -} - - -// Initialize parameters -void MatricPressureModel::InitializeFromPlist_(Teuchos::ParameterList& plist) -{ - m_ = plist.get("van genuchten m [-]", 0.2308); - n_ = plist.get("van genuchten n [-]", 1.3); - alpha_ = plist.get("van genuchten alpha [Pa^-1]", 5e-5); - sr_ = plist.get("residual saturation [-]", 0.5); -} - - -// main method -double MatricPressureModel::MatricPressure(double phi, double theta, double rho, double cv, double sl) const -{ - //theta_r_ = cv*rho*phi*sr_; This is water content at residual saturation - //theta_s = cv*rho*phi; This is the water content at saturation - //return -1.0 / std::pow(alpha_, n_) * std::pow(1.0 - std::pow((theta - cv*rho*phi*sr_) / ((cv*rho*phi) - cv*rho*phi*sr_), 1.0 / m_), -n_); - double Se = (sl - sr_) / (1.0 - sr_); - double Mat_p = -(1.0 / alpha_) * std::pow(std::pow(Se, -1.0 / m_) - 1.0, 1.0 / n_); - return Mat_p; -} - -double MatricPressureModel::DMatricPressureDPorosity(double phi, double theta, double rho, double cv, double sl) const -{ - return 1.0; -} - -} //namespace -} //namespace -} //namespace diff --git a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh b/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh deleted file mode 100644 index 978d18468..000000000 --- a/src/pks/ecosim/constitutive_relations/matric_pressure/matric_pressure_model.hh +++ /dev/null @@ -1,44 +0,0 @@ -/* - The hydraulic conductivity model is an algebraic model with dependencies. - - Generated via evaluator_generator with: -Richards water content evaluator: the standard form as a function of liquid saturation. - - Authors: Ethan Coon (ecoon@lanl.gov) -*/ - -#ifndef AMANZI_FLOW_MATRIC_PRESSURE_MODEL_HH_ -#define AMANZI_FLOW_MATRIC_PRESSURE_MODEL_HH_ - -namespace Amanzi { -namespace Ecosim { -namespace Relations { - -class MatricPressureModel { - - public: - explicit MatricPressureModel(Teuchos::ParameterList& plist); - - double MatricPressure(double phi, double theta, double rho, double cv, double sl) const; - - double DMatricPressureDPorosity(double phi, double theta, double rho, double cv, double sl) const; - - protected: - void InitializeFromPlist_(Teuchos::ParameterList& plist); - - private: - - double m_; - double n_; - double alpha_; - double theta_r_; - double sr_; - double theta_s; - -}; - -} //namespace -} //namespace -} //namespace - -#endif diff --git a/src/pks/ecosim/data/BGC_containers.hh b/src/pks/ecosim/data/BGC_containers.hh index 1f73bbcf7..a2dc1b4e7 100644 --- a/src/pks/ecosim/data/BGC_containers.hh +++ b/src/pks/ecosim/data/BGC_containers.hh @@ -106,6 +106,7 @@ extern const int kBGCMaxWordLength; BGCMatrixDouble liquid_density; BGCMatrixDouble gas_density; BGCMatrixDouble ice_density; + BGCMatrixDouble rock_density; BGCMatrixDouble porosity; BGCMatrixDouble water_content; BGCMatrixDouble matric_pressure; diff --git a/src/pks/ecosim/data/BGC_memory.cc b/src/pks/ecosim/data/BGC_memory.cc index 1dd1b4b67..ca785cbd0 100644 --- a/src/pks/ecosim/data/BGC_memory.cc +++ b/src/pks/ecosim/data/BGC_memory.cc @@ -315,6 +315,7 @@ void AllocateBGCState(const BGCSizes* const sizes, AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->liquid_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->gas_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->ice_density)); + AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->rock_density)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->porosity)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->water_content)); AllocateBGCMatrixDouble(sizes->ncells_per_col_, sizes->num_columns, &(state->matric_pressure)); @@ -346,6 +347,7 @@ void AllocateBGCState(const BGCSizes* const sizes, FreeBGCMatrixDouble(&(state->liquid_density)); FreeBGCMatrixDouble(&(state->gas_density)); FreeBGCMatrixDouble(&(state->ice_density)); + FreeBGCMatrixDouble(&(state->rock_density)); FreeBGCMatrixDouble(&(state->porosity)); FreeBGCMatrixDouble(&(state->water_content)); FreeBGCMatrixDouble(&(state->matric_pressure)); From 8576b76bcc199110cb7666a07fa2c5b9249a88d8 Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 27 Jan 2026 10:53:55 -0800 Subject: [PATCH 580/582] cleaning old code that is no longer necessary --- src/pks/energy/energy_base_physics.cc | 1 + src/pks/flow/CMakeLists.txt | 6 ------ .../flow/constitutive_relations/CMakeLists.txt | 5 ++--- .../wrm/suction_head_evaluator.cc | 1 - .../constitutive_relations/wrm/wrm_evaluator.cc | 7 ------- .../wrm/wrm_fpd_permafrost_model.cc | 6 ------ .../wrm/wrm_fpd_permafrost_model.hh | 1 - .../wrm/wrm_permafrost_evaluator.cc | 14 -------------- .../wrm/wrm_permafrost_evaluator.hh | 1 - .../wrm/wrm_van_genuchten.cc | 5 ----- src/pks/flow/overland_pressure_pk.cc | 2 +- src/pks/flow/richards.hh | 1 - src/pks/flow/richards_pk.cc | 1 - src/pks/mpc/mpc_permafrost.cc | 2 -- .../land_cover/seb_threecomponent_evaluator.cc | 15 --------------- 15 files changed, 4 insertions(+), 64 deletions(-) diff --git a/src/pks/energy/energy_base_physics.cc b/src/pks/energy/energy_base_physics.cc index ef7ec6652..d17234a7c 100644 --- a/src/pks/energy/energy_base_physics.cc +++ b/src/pks/energy/energy_base_physics.cc @@ -134,6 +134,7 @@ EnergyBase::AddSources_(const Tag& tag, const Teuchos::Ptr& g) Teuchos::OSTab tab = vo_->getOSTab(); Epetra_MultiVector& g_c = *g->ViewComponent("cell", false); + S_->GetEvaluator(cell_vol_key_, tag_next_).Update(*S_, name_); const Epetra_MultiVector& cv = *S_->Get(cell_vol_key_, tag_next_).ViewComponent("cell", false); diff --git a/src/pks/flow/CMakeLists.txt b/src/pks/flow/CMakeLists.txt index da3610b51..749bf9930 100644 --- a/src/pks/flow/CMakeLists.txt +++ b/src/pks/flow/CMakeLists.txt @@ -12,7 +12,6 @@ include_directories(${ATS_SOURCE_DIR}/src/pks) include_directories(${ATS_SOURCE_DIR}/src/operators/advection) include_directories(${ATS_SOURCE_DIR}/src/operators/upwinding) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/water_content) -#include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/matric_pressure) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/wrm) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/overland_conductivity) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/elevation) @@ -124,8 +123,3 @@ generate_evaluators_registration_header( LISTNAME ATS_FLOW_PKS_REG INSTALL True ) - - - - - diff --git a/src/pks/flow/constitutive_relations/CMakeLists.txt b/src/pks/flow/constitutive_relations/CMakeLists.txt index 7c636cb8d..ef613d1d9 100644 --- a/src/pks/flow/constitutive_relations/CMakeLists.txt +++ b/src/pks/flow/constitutive_relations/CMakeLists.txt @@ -7,14 +7,14 @@ # collect all sources -list(APPEND subdirs elevation overland_conductivity porosity sources water_content wrm matric_pressure) +list(APPEND subdirs elevation overland_conductivity porosity sources water_content wrm) set(ats_flow_relations_src_files "") set(ats_flow_relations_inc_files "") foreach(lcv IN LISTS subdirs) include_directories(${ATS_SOURCE_DIR}/src/pks/flow/constitutive_relations/${lcv}) - + file(GLOB subdir_sources "./${lcv}/*.cc") set(ats_flow_relations_src_files ${ats_flow_relations_src_files} ${subdir_sources}) @@ -51,4 +51,3 @@ generate_evaluators_registration_header( LISTNAME ATS_FLOW_RELATIONS_REG INSTALL True ) - diff --git a/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator.cc index ff1d7d398..ffe9b37f7 100644 --- a/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/suction_head_evaluator.cc @@ -72,7 +72,6 @@ SuctionHeadEvaluator::Evaluate_(const State& S, const std::vector(sat_key_, tag)->ViewComponent("cell", false); Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); - std::cout << "Hey we're running the suction evaluator"; int ncells = res_c.MyLength(); for (unsigned int c = 0; c != ncells; ++c) { int index = (*wrms_->first)[c]; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc index 7decc32c2..df10f690f 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_evaluator.cc @@ -51,8 +51,6 @@ WRMEvaluator::InitializeFromPlist_() Tag tag = my_keys_.front().second; my_keys_.clear(); - std::cout << "In WRMEvaluator: InitializeFromPlist_"; - std::size_t liq_pos = akey.find("liquid"); std::size_t gas_pos = akey.find("gas"); if (liq_pos != std::string::npos) { @@ -91,8 +89,6 @@ WRMEvaluator::Evaluate_(const State& S, const std::vector& res wrms_->first->Verify(); } - std::cout << "In WRMEvaluator:Evaluate_"; - Tag tag = my_keys_.front().second; Epetra_MultiVector& sat_c = *results[0]->ViewComponent("cell", false); const Epetra_MultiVector& pres_c = @@ -162,9 +158,6 @@ WRMEvaluator::EvaluatePartialDerivative_(const State& S, wrms_->first->Verify(); } - std::cout << "In WRMEvaluator: Derivative"; - - Tag tag = my_keys_.front().second; Epetra_MultiVector& sat_c = *results[0]->ViewComponent("cell", false); const Epetra_MultiVector& pres_c = diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc index f8a2e86e1..d24affd0a 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc @@ -83,11 +83,5 @@ WRMFPDPermafrostModel::dsaturations_dpc_ice(double pc_liq, double pc_ice, double } } -/*void -WRMFPDPermafrostModel::suction_head(double s, double suction_head) -{ - suction_head = wrm_->suction_head(s); -}*/ - } // namespace Flow } // namespace Amanzi diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh index b43a52957..dd11c51ce 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.hh @@ -47,7 +47,6 @@ class WRMFPDPermafrostModel : public WRMPermafrostModel { virtual void dsaturations_dpc_liq(double pc_liq, double pc_ice, double (&dsats)[3]); virtual void dsaturations_dpc_ice(double pc_liq, double pc_ice, double (&dsats)[3]); - //virtual void suction_head(double s, double suction_head); protected: double deriv_regularization_; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc index 788958826..069335b20 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.cc @@ -134,10 +134,6 @@ WRMPermafrostEvaluator::InitializeFromPlist_() pc_ice_key_ = Keys::readKey( plist_, domain_name, "liquid-ice capillary pressure", "capillary_pressure_liq_ice"); dependencies_.insert(KeyTag{ pc_ice_key_, tag }); - - /*suction_head_key_ = Keys::readKey( - plist_, domain_name, "suction head", "suction_head"); - dependencies_.insert(KeyTag{ suction_head_key_, tag});*/ } @@ -162,7 +158,6 @@ WRMPermafrostEvaluator::Evaluate_(const State& S, const std::vector(pc_ice_key_, tag)->ViewComponent("cell", false); double sats[3]; - double shs; int ncells = satg_c.MyLength(); for (AmanziMesh::Entity_ID c = 0; c != ncells; ++c) { int i = (*permafrost_models_->first)[c]; @@ -170,12 +165,6 @@ WRMPermafrostEvaluator::Evaluate_(const State& S, const std::vectorsecond[i]->suction_head(s_test, shs); - std::cout << "suction head: " << shs << std::endl; - */ } // Potentially do face values as well, though only for saturation_liquid? @@ -188,9 +177,6 @@ WRMPermafrostEvaluator::Evaluate_(const State& S, const std::vector(pc_ice_key_, tag)->ViewComponent("boundary_face", false); - //const Epetra_MultiVector& suction_head = - // *S.GetPtr(suction_head_key_, tag)->ViewComponent("boundary_face", false); - // Need to get boundary face's inner cell to specify the WRM. Teuchos::RCP mesh = results[0]->Mesh(); const Epetra_Map& vandelay_map = mesh->getMap(AmanziMesh::Entity_kind::BOUNDARY_FACE, false); diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh index 5704ed4df..9d8f2862b 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh +++ b/src/pks/flow/constitutive_relations/wrm/wrm_permafrost_evaluator.hh @@ -108,7 +108,6 @@ class WRMPermafrostEvaluator : public EvaluatorSecondaryMonotypeCV { protected: Key pc_liq_key_; Key pc_ice_key_; - Key suction_head_key_; Teuchos::RCP permafrost_models_; Teuchos::RCP wrms_; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc index afe26e865..96df91f5f 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_van_genuchten.cc @@ -88,7 +88,6 @@ WRMVanGenuchten::d_k_relative(double s) double WRMVanGenuchten::saturation(double pc) { - //std::cout << "What about Saturation?"; if (pc > pc0_) { return std::pow(1.0 + std::pow(alpha_ * pc, n_), -m_) * (1.0 - sr_) + sr_; } else if (pc <= 0.) { @@ -124,8 +123,6 @@ WRMVanGenuchten::capillaryPressure(double s) double se = (s - sr_) / (1.0 - sr_); se = std::min(se, 1.0); se = std::max(se, 1.e-40); - - //std::cout << "Is Capillary pressure running?"; if (se < 1.e-8) { return std::pow(se, -1.0 / (m_ * n_)) / alpha_; } else { @@ -236,11 +233,9 @@ WRMVanGenuchten::InitializeFromPlist_() /* ****************************************************************** * Suction formula: input is liquid saturation. ****************************************************************** */ - double WRMVanGenuchten::suction_head(double s) { - std::cout << "We are in suction head in van Genuchten"; double se = (s - sr_) / (1 - sr_); if (se > FLOW_WRM_TOLERANCE) { return -(1. / alpha_) * pow(pow(se, -1. / m_) - 1, 1. - m_); diff --git a/src/pks/flow/overland_pressure_pk.cc b/src/pks/flow/overland_pressure_pk.cc index 512b3e1db..4b69ac95e 100644 --- a/src/pks/flow/overland_pressure_pk.cc +++ b/src/pks/flow/overland_pressure_pk.cc @@ -1290,6 +1290,7 @@ OverlandPressureFlow::ModifyCorrection(double h, Epetra_MultiVector& du_c = *du->Data()->ViewComponent("cell", false); const Epetra_MultiVector& u_c = *u->Data()->ViewComponent("cell", false); + for (int c = 0; c != du_c.MyLength(); ++c) { if ((u_c[0][c] < patm) && (u_c[0][c] - du_c[0][c] > patm + patm_limit_)) { du_c[0][c] = u_c[0][c] - (patm + patm_limit_); @@ -1340,7 +1341,6 @@ OverlandPressureFlow::ModifyCorrection(double h, my_limited = 0; int n_limited_change = 0; - *vo_->os() << "p_limit_ = " << p_limit_ << std::endl; if (p_limit_ > 0.) { for (CompositeVector::name_iterator comp = du->Data() ->begin(); comp != du->Data()->end(); ++comp) { diff --git a/src/pks/flow/richards.hh b/src/pks/flow/richards.hh index 60339fe8c..1431d6bd0 100644 --- a/src/pks/flow/richards.hh +++ b/src/pks/flow/richards.hh @@ -415,7 +415,6 @@ class Richards : public PK_PhysicalBDF_Default { Key sat_ice_key_; Key capillary_pressure_gas_liq_key_; Key capillary_pressure_liq_ice_key_; - Key matric_pressure_key_; Key deform_key_; Key depth_key_; diff --git a/src/pks/flow/richards_pk.cc b/src/pks/flow/richards_pk.cc index 5f653ad0e..88ef46b23 100644 --- a/src/pks/flow/richards_pk.cc +++ b/src/pks/flow/richards_pk.cc @@ -103,7 +103,6 @@ Richards::parseParameterList() Keys::readKey(*plist_, domain_, "capillary_pressure_gas_liq", "capillary_pressure_gas_liq"); capillary_pressure_liq_ice_key_ = Keys::readKey(*plist_, domain_, "capillary_pressure_liq_ice", "capillary_pressure_liq_ice"); - //matric_pressure_key_ = Keys::readKey(*plist_, domain_, "matric pressure", "matric_pressure"); depth_key_ = Keys::readKey(*plist_, domain_, "depth", "depth"); if (S_->IsDeformableMesh(domain_)) diff --git a/src/pks/mpc/mpc_permafrost.cc b/src/pks/mpc/mpc_permafrost.cc index b9563adf6..86bfb320c 100644 --- a/src/pks/mpc/mpc_permafrost.cc +++ b/src/pks/mpc/mpc_permafrost.cc @@ -414,11 +414,9 @@ MPCPermafrost::FunctionalResidual(double t_old, Teuchos::RCP u_new, Teuchos::RCP g) { - Teuchos::OSTab tab = vo_->getOSTab(); // propagate updated info into state Solution_to_State(*u_new, tag_next_); - *vo_->os() << "Computing residuals for flow and energy" << std::endl; // Evaluate the surface flow residual surf_flow_pk_->FunctionalResidual( t_old, t_new, u_old->SubVector(2), u_new->SubVector(2), g->SubVector(2)); diff --git a/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc b/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc index 53bb9cbf4..4889e87f2 100644 --- a/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc +++ b/src/pks/surface_balance/constitutive_relations/land_cover/seb_threecomponent_evaluator.cc @@ -209,8 +209,6 @@ SEBThreeComponentEvaluator::Evaluate_(const State& S, const std::vector(ss_pres_key_, tag).ViewComponent("cell", false); - - // collect output vecs auto& water_source = *results[0]->ViewComponent("cell", false); auto& energy_source = *results[1]->ViewComponent("cell", false); @@ -218,13 +216,6 @@ SEBThreeComponentEvaluator::Evaluate_(const State& S, const std::vectorViewComponent("cell", false); auto& snow_source = *results[4]->ViewComponent("cell", false); auto& new_snow = *results[5]->ViewComponent("cell", false); - - if (vo_.os_OK(Teuchos::VERB_EXTREME)) - *vo_.os() << "Water and Energy Sources Before:" - << ": energy source = " << energy_source - << ", water source = " << water_source << std::endl; - - water_source.PutScalar(0.); energy_source.PutScalar(0.); ss_water_source.PutScalar(0.); @@ -232,12 +223,6 @@ SEBThreeComponentEvaluator::Evaluate_(const State& S, const std::vector(sat_key_, tag)->ViewComponent("cell", false); Epetra_MultiVector& res_c = *result[0]->ViewComponent("cell", false); + int ncells = res_c.MyLength(); for (unsigned int c = 0; c != ncells; ++c) { int index = (*wrms_->first)[c]; diff --git a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc index d24affd0a..b10a89d19 100644 --- a/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc +++ b/src/pks/flow/constitutive_relations/wrm/wrm_fpd_permafrost_model.cc @@ -83,5 +83,6 @@ WRMFPDPermafrostModel::dsaturations_dpc_ice(double pc_liq, double pc_ice, double } } + } // namespace Flow } // namespace Amanzi diff --git a/tools/cmake/ATSVersion.cmake b/tools/cmake/ATSVersion.cmake index ecbed0f0d..e0e6bb8ea 100644 --- a/tools/cmake/ATSVersion.cmake +++ b/tools/cmake/ATSVersion.cmake @@ -2,16 +2,16 @@ # # ATS Version Information: -# -# Information about the current source is extracted from the git repository and used to -# create the version string (ATS_VERSION). +# +# Information about the current source is extracted from the git repository and used to +# create the version string (ATS_VERSION). # # NOTE: this information won't be accessible without the full repository. # So for releases we need to extract this and set it as part of the tarball creation. # # * if ats_version.hh does not exist create it # * if git is found -# use git to create version strings +# use git to create version strings # * else # use statically defined version strings # * endif @@ -31,13 +31,13 @@ message(STATUS ">>>> JDM: ${ATS_SUBMODULE_DIR}") find_package(Git) -if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) +if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) # Get the name of the current branch. set(GIT_ARGS status) execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_ARGS} WORKING_DIRECTORY ${ATS_SUBMODULE_DIR} - RESULT_VARIABLE err_occurred + RESULT_VARIABLE err_occurred OUTPUT_VARIABLE ATS_GIT_STATUS ERROR_VARIABLE err OUTPUT_STRIP_TRAILING_WHITESPACE @@ -57,10 +57,9 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) STRING(REPLACE "\n" ";" ATS_GIT_STATUS_LIST ${ATS_GIT_STATUS}) # Extract the first entry - reuse the ATS_GIT_STATUS variable LIST(GET ATS_GIT_STATUS_LIST 0 ATS_GIT_STATUS) - if (${ATS_GIT_STATUS} MATCHES "(D|d)etached") + if (${ATS_GIT_STATUS} MATCHES "(D|d)etached") # For now just set branch to detached - we could add a lookup for tags later - #set(ATS_GIT_BRANCH detached) - set(ATS_GIT_BRANCH master) + set(ATS_GIT_BRANCH detached) elseif(${ATS_GIT_STATUS} MATCHES "On branch") # Extract the branch name STRING(REPLACE "On branch " "" ATS_GIT_BRANCH ${ATS_GIT_STATUS}) @@ -74,7 +73,7 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) set(GIT_ARGS rev-parse --short HEAD) execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_ARGS} WORKING_DIRECTORY ${ATS_SUBMODULE_DIR} - RESULT_VARIABLE err_occurred + RESULT_VARIABLE err_occurred OUTPUT_VARIABLE ATS_GIT_GLOBAL_HASH ERROR_VARIABLE err OUTPUT_STRIP_TRAILING_WHITESPACE @@ -91,16 +90,16 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) set(GIT_ARGS tag -l ats-*) execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_ARGS} WORKING_DIRECTORY ${ATS_SUBMODULE_DIR} - RESULT_VARIABLE err_occurred + RESULT_VARIABLE err_occurred OUTPUT_VARIABLE ATS_GIT_LATEST_TAG ERROR_VARIABLE err OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) # Put the tags in a list - #STRING(REPLACE "\n" ";" ATS_GIT_LATEST_TAG_LIST ${ATS_GIT_LATEST_TAG}) + STRING(REPLACE "\n" ";" ATS_GIT_LATEST_TAG_LIST ${ATS_GIT_LATEST_TAG}) # Extract the lastest tag of the form ats-* - IF ( ${ATS_GIT_BRANCH} MATCHES "master" ) + IF ( ${ATS_GIT_BRANCH} MATCHES "master" ) FOREACH(atag ${ATS_GIT_LATEST_TAG_LIST}) IF ( ${atag} MATCHES "^ats-.*-dev" ) set ( ATS_GIT_LATEST_TAG ${atag} ) @@ -114,21 +113,18 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) ENDFOREACH() ENDIF() - message(STATUS ">>>> JDM: GIT_EXEC = ${GIT_EXECUTABLE}") - message(STATUS ">>>> JDM: GIT_ARGS = ${GIT_ARGS}") - message(STATUS ">>>> JDM: RESULT_VARIABLE = ${err_occurred}") - message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG = ${ATS_GIT_LATEST_TAG}") - - #STRING(REGEX REPLACE "ats-" "" ATS_GIT_LATEST_TAG_VER ${ATS_GIT_LATEST_TAG}) - #STRING(REGEX REPLACE "\\..*" "" ATS_GIT_LATEST_TAG_MAJOR ${ATS_GIT_LATEST_TAG_VER}) - #STRING(REGEX MATCH "\\.[0-9][0-9]?[\\.,-]" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_VER}) - #STRING(REGEX REPLACE "[\\.,-]" "" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_MINOR} ) + # message(STATUS ">>>> JDM: GIT_EXEC = ${GIT_EXECUTABLE}") + # message(STATUS ">>>> JDM: GIT_ARGS = ${GIT_ARGS}") + # message(STATUS ">>>> JDM: RESULT_VARIABLE = ${err_occurred}") + # message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG = ${ATS_GIT_LATEST_TAG}") - #set(ATS_VERSION_MAJOR ${ATS_GIT_LATEST_TAG_MAJOR}) - #set(ATS_VERSION_MINOR ${ATS_GIT_LATEST_TAG_MINOR}) + STRING(REGEX REPLACE "ats-" "" ATS_GIT_LATEST_TAG_VER ${ATS_GIT_LATEST_TAG}) + STRING(REGEX REPLACE "\\..*" "" ATS_GIT_LATEST_TAG_MAJOR ${ATS_GIT_LATEST_TAG_VER}) + STRING(REGEX MATCH "\\.[0-9][0-9]?[\\.,-]" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_VER}) + STRING(REGEX REPLACE "[\\.,-]" "" ATS_GIT_LATEST_TAG_MINOR ${ATS_GIT_LATEST_TAG_MINOR} ) - #message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG_MAJOR = ${ATS_GIT_LATEST_TAG_MAJOR}") - #message(STATUS ">>>> JDM: ATS_GIT_LATEST_TAG_MINOR = ${ATS_GIT_LATEST_TAG_MINOR}") + set(ATS_VERSION_MAJOR ${ATS_GIT_LATEST_TAG_MAJOR}) + set(ATS_VERSION_MINOR ${ATS_GIT_LATEST_TAG_MINOR}) # # ATS version @@ -142,7 +138,7 @@ if ( (EXISTS ${ATS_SUBMODULE_DIR}/.git) AND (GIT_FOUND) ) else() message(STATUS " >>>>>>>> Using static version information to create ats_version.hh") - if ( NOT GIT_FOUND ) + if ( NOT GIT_FOUND ) message(STATUS " >>>>>> Could not locate Git executable.") endif() if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/ ) @@ -176,10 +172,11 @@ configure_file(${version_template} ${CMAKE_CURRENT_BINARY_DIR}/extras/ats_version.hh @ONLY) -add_install_include_file(${CMAKE_CURRENT_BINARY_DIR}/ats_version.hh) +add_install_include_file(${CMAKE_CURRENT_BINARY_DIR}/ats_version.hh) message(STATUS "\t >>>>> ATS Version: ${ATS_VERSION}") message(STATUS "\t >>>>> MAJOR ${ATS_VERSION_MAJOR}") message(STATUS "\t >>>>> MINOR ${ATS_VERSION_MINOR}") message(STATUS "\t >>>>> PATCH ${ATS_VERSION_PATCH}") message(STATUS "\t >>>>> HASH ${ATS_VERSION_HASH}") + diff --git a/tools/evaluator_generator/evaluator_generator.py b/tools/evaluator_generator/evaluator_generator.py index a651867cf..19057fcca 100644 --- a/tools/evaluator_generator/evaluator_generator.py +++ b/tools/evaluator_generator/evaluator_generator.py @@ -9,21 +9,18 @@ def loadTemplate(tname): _templates[tname] = tfid.read()[:-1] # python seems to force end of file with newline character even though it is not there? def render(tname, d): - print(tname) try: template = _templates[tname] except KeyError: loadTemplate(tname) - template = _templates[tname] - - assert type(d) is dict - print("Contents of dictionary (d):", d) - #return template.format(**d) + template = _templates[tname] + assert type(d) is dict + return template.format(**d) + class EvalGen(object): def __init__(self, name, namespace, descriptor, my_key=None, expression=None, doc=None, **kwargs): - print("what is this") self.d = {} self.setName(name, **kwargs) self.setNamespace(namespace, **kwargs) @@ -79,7 +76,7 @@ def renderCopyConstructor(self): return '\n'.join([render('evaluator_keyCopyConstructor.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) def renderKeyDeclaration(self): - return '\n'.join([render('evaluator_keyDeclaration.hh', dict(arg=arg, var=var)) for arg, var in zip(self.args, self.vars)]) + return '\n'.join([render('evaluator_keyDeclaration.hh', dict(arg=arg,var=var)) for arg,var in zip(self.args, self.vars)]) def renderKeyInitialize(self): dicts = [] @@ -88,12 +85,12 @@ def renderKeyInitialize(self): return '\n\n'.join([render('evaluator_keyInitialize.cc', argdict) for argdict in dicts]) def renderKeyCompositeVector(self): - return '\n'.join([render('evaluator_keyCompositeVector.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) + return '\n'.join([render('evaluator_keyCompositeVector.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) def renderKeyEpetraVector(self): - return '\n'.join([render('evaluator_keyEpetraVector.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) + return '\n'.join([render('evaluator_keyEpetraVector.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) def renderKeyEpetraVectorIndented(self): - return '\n'.join([render('evaluator_keyEpetraVectorIndented.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) + return '\n'.join([render('evaluator_keyEpetraVectorIndented.cc', dict(arg=arg,var=var)) for arg,var in zip(self.args,self.vars)]) def renderMyMethodArgs(self): return ", ".join(["%s_v[0][i]"%var for var in self.vars]) @@ -118,7 +115,7 @@ def getDict(arg,var): d['wrtMethod'] = ''.join([word[0].upper()+word[1:] for word in arg.split("_")]) d['myMethodArgs'] = self.renderMyMethodArgs() return d - + if len(self.args) > 0: d = getDict(self.args[0], self.vars[0]) d['if_elseif'] = render('evaluator_ifWRT.cc', d) @@ -135,7 +132,7 @@ def getDict(arg,var): " }"])) return "\n\n".join(wrt_list) - + def renderModelMethodDeclaration(self): return render('model_declaration.hh', dict(myMethod=self.d['myKeyMethod'], myMethodDeclarationArgs=self.d['myMethodDeclarationArgs'])) @@ -170,7 +167,7 @@ def renderModelDerivImplementations(self): myMethodDeclarationArgs=self.d['myMethodDeclarationArgs'], myMethodImplementation=implementation))) return '\n\n'.join(impls) - + def renderModelParamDeclarations(self): return '\n'.join([' %s %s;'%p for p in self.pars]) @@ -249,7 +246,6 @@ def generate_evaluator(name, namespace, descriptor, my_key, dependencies, parame eg.addArg(*dep) for par in parameters: - print(par) eg.addParam(*par) eg.genArgs() @@ -265,8 +261,8 @@ def generate_evaluator(name, namespace, descriptor, my_key, dependencies, parame fid.write(render(outfile, eg.d)) - - + + if __name__ == "__main__": eg = EvalGen("iem", "energy", "internal energy", "internal_energy", evalClassName='IEM') eg.addArg("temperature", "temp"); @@ -277,4 +273,4 @@ def generate_evaluator(name, namespace, descriptor, my_key, dependencies, parame print (render("evaluator.cc", eg.d)) print (render("evaluator_reg.hh", eg.d)) print (render("model.hh", eg.d)) - print (render("model.cc", eg.d)) + print (render("model.cc", eg.d)) From 405f44b918bf2e7b3217487e0a3c5db5e12938ab Mon Sep 17 00:00:00 2001 From: AndrewGraus Date: Tue, 3 Feb 2026 20:04:57 -0800 Subject: [PATCH 582/582] Updating precipitation_rain When building off Lijing's Sondgrass model I found an odd issue. precipitation_rain was not being initialized correctly. Needed to add the necesary evaluator calls for precipiation_rain. The question is why did this work before? --- src/pks/ecosim/EcoSIM_ATS_interface.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pks/ecosim/EcoSIM_ATS_interface.cc b/src/pks/ecosim/EcoSIM_ATS_interface.cc index 520222a51..5b784e9cd 100644 --- a/src/pks/ecosim/EcoSIM_ATS_interface.cc +++ b/src/pks/ecosim/EcoSIM_ATS_interface.cc @@ -332,6 +332,9 @@ void EcoSIM::Setup() { S_->RequireEvaluator(p_snow_key_, tag_next_); S_->Require(p_snow_key_, tag_next_).SetMesh(mesh_surf_) ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); + S_->RequireEvaluator(p_rain_key_, tag_next_); + S_->Require(p_rain_key_, tag_next_).SetMesh(mesh_surf_) + ->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1); } //Setup custom evaluators for EcoSIM, found in constitutive relations @@ -415,6 +418,8 @@ void EcoSIM::Initialize() { } else { S_->GetW(p_snow_key_, Tags::DEFAULT, "surface-precipitation_snow").PutScalar(0.0); S_->GetRecordW(p_snow_key_, Tags::DEFAULT, "surface-precipitation_snow").set_initialized(); + S_->GetW(p_rain_key_, Tags::DEFAULT, "surface-precipitation_rain").PutScalar(0.0); + S_->GetRecordW(p_rain_key_, Tags::DEFAULT, "surface-precipitation_rain").set_initialized(); } S_->GetW(snow_depth_key_, Tags::DEFAULT, "surface-snow_depth").PutScalar(0.0);