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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/constitutive_relations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ register_evaluator_with_factory(
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE surface_subsurface_fluxes/flux_divergence_evaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)


register_evaluator_with_factory(
HEADERFILE generic_evaluators/MultiplicativeEvaluator_reg.hh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(ats_surf_subsurf_src_files
surface_top_cells_evaluator.cc
top_cells_surface_evaluator.cc
volumetric_darcy_flux_evaluator.cc
flux_divergence_evaluator.cc
)

file(GLOB ats_surf_subsurf_inc_files "*.hh")
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (coonet@ornl.gov)
*/

#include "flux_divergence_evaluator.hh"

namespace Amanzi {
namespace Relations {

FluxDivergenceEvaluator::FluxDivergenceEvaluator(Teuchos::ParameterList& plist)
: EvaluatorSecondaryMonotypeCV(plist)
{
// determine the domain
Key akey = my_keys_.front().first;
auto tag = my_keys_.front().second;
Key domain = Keys::getDomain(akey);

flux_key_ = Keys::readKey(plist, domain, "flux", "water_flux");
dependencies_.insert(KeyTag{ flux_key_, tag });
}

Teuchos::RCP<Evaluator>
FluxDivergenceEvaluator::Clone() const
{
return Teuchos::rcp(new FluxDivergenceEvaluator(*this));
}

void
FluxDivergenceEvaluator::EnsureCompatibility_ToDeps_(State& S)
{
const auto& my_fac = S.Require<CompositeVector, CompositeVectorSpace>(my_keys_.front().first, my_keys_.front().second);
if (my_fac.Mesh() != Teuchos::null) {
for (auto dep : dependencies_) {
auto& fac = S.Require<CompositeVector, CompositeVectorSpace>(dep.first, dep.second);
fac.SetMesh(my_fac.Mesh())->AddComponent("face", AmanziMesh::Entity_kind::FACE, 1);
}
}
}


void
FluxDivergenceEvaluator::Evaluate_(const State& S, const std::vector<CompositeVector*>& result)
{
auto tag = my_keys_.front().second;
const auto& flux_f = *S.Get<CompositeVector>(flux_key_, tag).ViewComponent("face", true);
const AmanziMesh::Mesh& m = *result[0]->Mesh();
auto& div_flux = *result[0]->ViewComponent("cell", false);
div_flux.PutScalar(0.);

for (AmanziMesh::Entity_ID c = 0; c != div_flux.MyLength(); ++c) {
auto [cfaces, cfdirs] = m.getCellFacesAndDirections(c);
for (int i = 0; i != cfaces.size(); ++i) {
div_flux[0][c] += flux_f[0][cfaces[i]] * cfdirs[i];
}
}
}


} // namespace Relations
} // namespace Amanzi
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
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 compute the divergence of a flux field.
*/
#pragma once

#include "dbc.hh"
#include "Evaluator_Factory.hh"
#include "EvaluatorSecondaryMonotype.hh"

namespace Amanzi {
namespace Relations {

class FluxDivergenceEvaluator : public EvaluatorSecondaryMonotypeCV {
public:
explicit FluxDivergenceEvaluator(Teuchos::ParameterList& plist);
FluxDivergenceEvaluator(const FluxDivergenceEvaluator& other) = default;
Teuchos::RCP<Evaluator> Clone() const override;

// turn off all derivatives manually
virtual bool IsDifferentiableWRT(const State& S,
const Key& wrt_key,
const Tag& wrt_tag) const override {
return false;
}

protected:
// custom ensure compatibility as all data is not just on the same components
virtual void EnsureCompatibility_ToDeps_(State& S) override;

// Required methods from EvaluatorSecondaryMonotypeCV
virtual void Evaluate_(const State& S, const std::vector<CompositeVector*>& result) override;
virtual void EvaluatePartialDerivative_(const State& S,
const Key& wrt_key,
const Tag& wrt_tag,
const std::vector<CompositeVector*>& result) override {
AMANZI_ASSERT(false);
}

protected:
Key flux_key_;

private:
static Utils::RegisteredFactory<Evaluator, FluxDivergenceEvaluator> reg_;
};


} // namespace Relations
} // namespace Amanzi


Original file line number Diff line number Diff line change
@@ -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: Ethan Coon (coonet@ornl.gov)
*/

#include "flux_divergence_evaluator.hh"

namespace Amanzi {
namespace Relations {

// registry of method
Utils::RegisteredFactory<Evaluator, FluxDivergenceEvaluator>
FluxDivergenceEvaluator::reg_("flux divergence");

} // namespace Relations
} // namespace Amanzi
9 changes: 7 additions & 2 deletions src/executables/ats_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ ATSDriver::cycle_driver()
<< "Beginning setup stage..." << std::endl
<< std::flush;
}
parseParameterList();
if (vo_->os_OK(Teuchos::VERB_LOW)) {
*vo_->os() << " ... completed: ";
reportOneTimer_("2a: parseParameterList");
}

setup();
if (vo_->os_OK(Teuchos::VERB_LOW)) {
*vo_->os() << " ... completed: ";
reportOneTimer_("2: setup");
reportOneTimer_("2b: setup");
}

//
Expand Down Expand Up @@ -182,7 +188,6 @@ ATSDriver::cycle_driver()
reportOneTimer_("4: solve");
}


// finalizing simulation
if (vo_->os_OK(Teuchos::VERB_LOW)) {
*vo_->os() << "================================================================================"
Expand Down
24 changes: 16 additions & 8 deletions src/executables/coordinator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ Coordinator::Coordinator(const Teuchos::RCP<Teuchos::ParameterList>& plist,

timers_["0: create mesh"] = Teuchos::TimeMonitor::getNewCounter("0: create mesh");
timers_["1: create run"] = Teuchos::TimeMonitor::getNewCounter("1: create run");
timers_["2: setup"] = Teuchos::TimeMonitor::getNewCounter("2: setup");
timers_["2a: parseParameterList"] = Teuchos::TimeMonitor::getNewCounter("2a: parseParameterList");
timers_["2b: setup"] = Teuchos::TimeMonitor::getNewCounter("2b: setup");
timers_["3: initialize"] = Teuchos::TimeMonitor::getNewCounter("3: initialize");
timers_["4: solve"] = Teuchos::TimeMonitor::getNewCounter("4: solve");
timers_["4a: advance step"] = Teuchos::TimeMonitor::getNewCounter("4a: advance step");
Expand Down Expand Up @@ -272,24 +273,31 @@ Coordinator::Coordinator(const Teuchos::RCP<Teuchos::ParameterList>& plist,
}


void
Coordinator::parseParameterList()
{
Teuchos::TimeMonitor monitor(*timers_.at("2a: parseParameterList"));

// require needed times -- these may be targets as dependencies
S_->require_time(Amanzi::Tags::CURRENT);
S_->require_time(Amanzi::Tags::NEXT);

pk_->set_tags(Amanzi::Tags::CURRENT, Amanzi::Tags::NEXT);
pk_->parseParameterList();
}

void
Coordinator::setup()
{
Teuchos::TimeMonitor monitor(*timers_.at("2: setup"));
Teuchos::TimeMonitor monitor(*timers_.at("2b: setup"));

// common constants
S_->Require<double>("atmospheric_pressure", Amanzi::Tags::DEFAULT, "coordinator");
S_->Require<Amanzi::AmanziGeometry::Point>("gravity", Amanzi::Tags::DEFAULT, "coordinator");

// needed other times
S_->require_time(Amanzi::Tags::CURRENT);
S_->require_time(Amanzi::Tags::NEXT);

// order matters here -- PK::Setup() set the leaves, then observations can
// use those if provided, and State::Setup finally deals with all secondaries
// and allocates memory
pk_->set_tags(Amanzi::Tags::CURRENT, Amanzi::Tags::NEXT);
pk_->parseParameterList();
pk_->Setup();
for (auto& obs : observations_) obs->Setup(S_.ptr());
S_->Setup();
Expand Down
1 change: 1 addition & 0 deletions src/executables/coordinator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Coordinator {
const Amanzi::Comm_ptr_type& comm);

// PK methods
void parseParameterList();
void setup();
void initialize();
void finalize();
Expand Down
34 changes: 34 additions & 0 deletions src/executables/elm_ats_api/ats_variables.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module ats_variables
use, intrinsic :: iso_c_binding
implicit none

type :: ats_var_id_type
integer(c_int), parameter :: NULL = 0
integer(c_int), parameter :: BASE_POROSITY = 1
integer(c_int), parameter :: HYDRAULIC_CONDUCTIVITY = 2
integer(c_int), parameter :: CLAPP_HORNBERGER_B = 3
integer(c_int), parameter :: CLAPP_HORNBERGER_PSI_SAT = 4
integer(c_int), parameter :: RESIDUAL_SATURATION = 5
integer(c_int), parameter :: EFFECTIVE_POROSITY = 6
integer(c_int), parameter :: ROOT_FRACTION = 7
integer(c_int), parameter :: SURFACE_WATER_CONTENT = 8
integer(c_int), parameter :: WATER_CONTENT = 9
integer(c_int), parameter :: PRESSURE = 10
integer(c_int), parameter :: GROSS_SURFACE_WATER_SOURCE = 11
integer(c_int), parameter :: POTENTIAL_EVAPORATION = 12
integer(c_int), parameter :: POTENTIAL_TRANSPIRATION = 13
integer(c_int), parameter :: EVAPORATION = 14
integer(c_int), parameter :: COLUMN_TRANSPIRATION = 15
integer(c_int), parameter :: RUNOFF = 16
integer(c_int), parameter :: BASEFLOW = 17
integer(c_int), parameter :: ELEVATION = 18
integer(c_int), parameter :: TIME = 19
integer(c_int), parameter :: INITIAL_WATER_CONTENT = 20
integer(c_int), parameter :: SATURATION_LIQUID = 21
integer(c_int), parameter :: PONDED_DEPTH = 22
end type ats_var_id_type

type(ats_var_id_type), parameter :: ats_var_id = ats_var_id_type()

end module ats_variables

34 changes: 34 additions & 0 deletions src/executables/elm_ats_api/ats_variables.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace ATS {
namespace ELM {

enum class VarID : int {
NO_VARIABLE = 0,
BASE_POROSITY = 1,
HYDRAULIC_CONDUCTIVITY = 2,
CLAPP_HORNBERGER_B = 3,
CLAPP_HORNBERGER_PSI_SAT = 4,
RESIDUAL_SATURATION = 5,
EFFECTIVE_POROSITY = 6,
ROOT_FRACTION = 7,
SURFACE_WATER_CONTENT = 8,
WATER_CONTENT = 9,
PRESSURE = 10,
GROSS_SURFACE_WATER_SOURCE = 11,
POTENTIAL_EVAPORATION = 12,
POTENTIAL_TRANSPIRATION = 13,
EVAPORATION = 14,
TRANSPIRATION = 15,
RUNOFF = 16,
BASEFLOW = 17,
ELEVATION = 18,
TIME = 19,
INITIAL_WATER_CONTENT = 20,
SATURATION_LIQUID = 21,
PONDED_DEPTH = 22,
DEPTH_TO_WATER_TABLE = 23,
WATER_CONTENT_OLD = 24,
SURFACE_WATER_CONTENT_OLD = 25
};

} // namespace ELM
} // namespace ATS
Loading