Skip to content

Commit

Permalink
test running, not passing, for surface balance priestley taylor
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoon committed Mar 3, 2024
1 parent 0521730 commit 9c9e7fc
Show file tree
Hide file tree
Showing 67 changed files with 1,986 additions and 1,403 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -21,7 +21,7 @@ include_directories(${PKS_SOURCE_DIR})
# operators -- layer between discretization and PK
add_subdirectory(operators)

# add_subdirectory(constitutive_relations)
add_subdirectory(constitutive_relations)

# Process Kernels
add_subdirectory(pks)
Expand Down
140 changes: 71 additions & 69 deletions src/constitutive_relations/CMakeLists.txt
@@ -1,89 +1,91 @@
# -*- mode: cmake -*-

# operators -- layer between discretization and PK
add_subdirectory(eos)
add_subdirectory(surface_subsurface_fluxes)
add_subdirectory(generic_evaluators)
#add_subdirectory(eos)
#add_subdirectory(surface_subsurface_fluxes)
#add_subdirectory(generic_evaluators)
add_subdirectory(column_integrators)

#================================================================
# register evaluators/factories/pks

# eos/

register_evaluator_with_factory(
HEADERFILE eos/eos_reg.hh
LISTNAME ATS_RELATIONS_REG
)
# register_evaluator_with_factory(
# HEADERFILE eos/eos_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# column_integrators/

register_evaluator_with_factory(
HEADERFILE column_integrators/column_integrators_reg.hh
LISTNAME ATS_RELATIONS_REG
)

# constitutive_relations/surface_subsurface_fluxes/

register_evaluator_with_factory(
HEADERFILE surface_subsurface_fluxes/volumetric_darcy_flux_evaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE surface_subsurface_fluxes/surface_top_cells_evaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE surface_subsurface_fluxes/top_cells_surface_evaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE surface_subsurface_fluxes/overland_source_from_subsurface_flux_evaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)


register_evaluator_with_factory(
HEADERFILE generic_evaluators/MultiplicativeEvaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE generic_evaluators/AdditiveEvaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE generic_evaluators/ReciprocalEvaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE generic_evaluators/SubgridDisaggregateEvaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE generic_evaluators/SubgridAggregateEvaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE generic_evaluators/TimeMaxEvaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE generic_evaluators/InitialTimeEvaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)

register_evaluator_with_factory(
HEADERFILE generic_evaluators/ExtractionEvaluator_reg.hh
LISTNAME ATS_RELATIONS_REG
)
# # surface_subsurface_fluxes/

# register_evaluator_with_factory(
# HEADERFILE surface_subsurface_fluxes/volumetric_darcy_flux_evaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE surface_subsurface_fluxes/surface_top_cells_evaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE surface_subsurface_fluxes/top_cells_surface_evaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE surface_subsurface_fluxes/overland_source_from_subsurface_flux_evaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# # generic_evaluators/

# register_evaluator_with_factory(
# HEADERFILE generic_evaluators/MultiplicativeEvaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE generic_evaluators/AdditiveEvaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE generic_evaluators/ReciprocalEvaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE generic_evaluators/SubgridDisaggregateEvaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE generic_evaluators/SubgridAggregateEvaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE generic_evaluators/TimeMaxEvaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE generic_evaluators/InitialTimeEvaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

# register_evaluator_with_factory(
# HEADERFILE generic_evaluators/ExtractionEvaluator_reg.hh
# LISTNAME ATS_RELATIONS_REG
# )

generate_evaluators_registration_header(
HEADERFILE ats_relations_registration.hh
Expand Down
8 changes: 4 additions & 4 deletions src/constitutive_relations/column_integrators/CMakeLists.txt
Expand Up @@ -5,18 +5,18 @@
#
set(ats_column_integrator_src_files
ColumnSumEvaluator.cc
activelayer_average_temp_evaluator.cc
# activelayer_average_temp_evaluator.cc
water_table_depth_evaluator.cc
thaw_depth_evaluator.cc
# thaw_depth_evaluator.cc
)


set(ats_column_integrator_inc_files
EvaluatorColumnIntegrator.hh
ColumnSumEvaluator.hh
activelayer_average_temp_evaluator.hh
# activelayer_average_temp_evaluator.hh
water_table_depth_evaluator.hh
thaw_depth_evaluator.hh
# thaw_depth_evaluator.hh
)

set(ats_column_integrator_link_libs
Expand Down
86 changes: 30 additions & 56 deletions src/constitutive_relations/column_integrators/ColumnSumEvaluator.cc
Expand Up @@ -14,45 +14,9 @@ namespace Amanzi {
namespace Relations {
namespace Impl {

ParserColumnSum::ParserColumnSum(Teuchos::ParameterList& plist, const KeyTag& key_tag)
{
Key surf_domain = Keys::getDomain(key_tag.first);
Key domain = Keys::readDomainHint(plist, surf_domain, "surface", "subsurface");
Key dep_key = Keys::readKey(plist, domain, "summed", Keys::getVarName(key_tag.first));
dependencies.insert(KeyTag{ dep_key, key_tag.second });

// dependency: cell volume, surface cell volume
bool include_vol_factor = plist.get<bool>("include volume to surface area factor", false);
if (include_vol_factor) {
Key cv_key = Keys::readKey(plist, domain, "cell volume", "cell_volume");
dependencies.insert(KeyTag{ cv_key, key_tag.second });

Key surf_cv_key = Keys::readKey(plist, surf_domain, "surface cell volume", "cell_volume");
dependencies.insert(KeyTag{ surf_cv_key, key_tag.second });
}

if (plist.get<bool>("volume averaged", false)) {
if (include_vol_factor) {
Errors::Message msg;
msg << "ColumnSumEvaluator for " << key_tag.first
<< ": cannot use both options \"include volume to surface area factor\""
<< " and \"volume averaged\"";
Exceptions::amanzi_throw(msg);
}
Key cv_key = Keys::readKey(plist, domain, "cell volume", "cell_volume");
dependencies.insert(KeyTag{ cv_key, key_tag.second });
}

if (plist.get<bool>("divide by density", false)) {
Key molar_dens_key = Keys::readKey(plist, domain, "molar density", "molar_density_liquid");
dependencies.insert(KeyTag{ molar_dens_key, key_tag.second });
}
}


IntegratorColumnSum::IntegratorColumnSum(Teuchos::ParameterList& plist,
std::vector<const Epetra_MultiVector*>& deps,
const AmanziMesh::Mesh* mesh)
std::vector<cView_type>& deps,
const AmanziMesh::Mesh& mesh)
{
int i_dep(0);
integrand_ = deps[i_dep++];
Expand Down Expand Up @@ -80,28 +44,38 @@ IntegratorColumnSum::IntegratorColumnSum(Teuchos::ParameterList& plist,
}


int
IntegratorColumnSum::scan(AmanziMesh::Entity_ID col,
AmanziMesh::Entity_ID c,
AmanziGeometry::Point& p)
ParserColumnSum::ParserColumnSum(Teuchos::ParameterList& plist, const KeyTag& key_tag)
{
double contrib = (*integrand_)[0][c];
if (volume_average_ || volume_factor_) { contrib *= (*cv_)[0][c]; }
if (divide_by_density_) { contrib /= (*dens_)[0][c]; }
p[0] += contrib;
Key surf_domain = Keys::getDomain(key_tag.first);
Key domain = Keys::readDomainHint(plist, surf_domain, "surface", "subsurface");
Key dep_key = Keys::readKey(plist, domain, "summed", Keys::getVarName(key_tag.first));
dependencies.insert(KeyTag{ dep_key, key_tag.second });

if (volume_average_) p[1] += (*cv_)[0][c];
return false;
}
// dependency: cell volume, surface cell volume
bool include_vol_factor = plist.get<bool>("include volume to surface area factor", false);
if (include_vol_factor) {
Key cv_key = Keys::readKey(plist, domain, "cell volume", "cell_volume");
dependencies.insert(KeyTag{ cv_key, key_tag.second });

Key surf_cv_key = Keys::readKey(plist, surf_domain, "surface cell volume", "cell_volume");
dependencies.insert(KeyTag{ surf_cv_key, key_tag.second });
}

double
IntegratorColumnSum::coefficient(AmanziMesh::Entity_ID col)
{
if (volume_factor_) {
return coef_ / (*surf_cv_)[0][col];
} else {
return coef_;
if (plist.get<bool>("volume averaged", false)) {
if (include_vol_factor) {
Errors::Message msg;
msg << "ColumnSumEvaluator for " << key_tag.first
<< ": cannot use both options \"include volume to surface area factor\""
<< " and \"volume averaged\"";
Exceptions::amanzi_throw(msg);
}
Key cv_key = Keys::readKey(plist, domain, "cell volume", "cell_volume");
dependencies.insert(KeyTag{ cv_key, key_tag.second });
}

if (plist.get<bool>("divide by density", false)) {
Key molar_dens_key = Keys::readKey(plist, domain, "molar density", "molar_density_liquid");
dependencies.insert(KeyTag{ molar_dens_key, key_tag.second });
}
}

Expand Down
Expand Up @@ -45,6 +45,7 @@ of summing fluxes onto the surface and converting to m/s instead of mol/m^2/s).

#include <functional>
#include "Factory.hh"
#include "BlockVector_decl.hh"
#include "EvaluatorColumnIntegrator.hh"

namespace Amanzi {
Expand All @@ -60,28 +61,62 @@ struct ParserColumnSum {

class IntegratorColumnSum {
public:
using cView_type = BlockVector<double>::cMultiVectorView_type<Amanzi::DefaultDevice>;

IntegratorColumnSum(Teuchos::ParameterList& plist,
std::vector<const Epetra_MultiVector*>& deps,
const AmanziMesh::Mesh* mesh);
int scan(AmanziMesh::Entity_ID col, AmanziMesh::Entity_ID c, AmanziGeometry::Point& p);
double coefficient(AmanziMesh::Entity_ID col);
std::vector<cView_type>& deps,
const AmanziMesh::Mesh& mesh);

KOKKOS_INLINE_FUNCTION
int scan(const AmanziMesh::Entity_ID col, const AmanziMesh::Entity_ID c, AmanziGeometry::Point& p) const;

KOKKOS_INLINE_FUNCTION
double coefficient(const AmanziMesh::Entity_ID col) const;

private:
bool volume_average_;
bool volume_factor_;
bool divide_by_density_;
double coef_;
const Epetra_MultiVector* integrand_;
const Epetra_MultiVector* cv_;
const Epetra_MultiVector* surf_cv_;
const Epetra_MultiVector* dens_;
cView_type integrand_;
cView_type cv_;
cView_type surf_cv_;
cView_type dens_;
};


KOKKOS_INLINE_FUNCTION
int
IntegratorColumnSum::scan(const AmanziMesh::Entity_ID col,
const AmanziMesh::Entity_ID c,
AmanziGeometry::Point& p) const
{
double contrib = integrand_(c, 0);
if (volume_average_ || volume_factor_) { contrib *= cv_(c, 0); }
if (divide_by_density_) { contrib /= dens_(c, 0); }
p[0] += contrib;

if (volume_average_) p[1] += cv_(c, 0);
return false;
}


KOKKOS_INLINE_FUNCTION
double
IntegratorColumnSum::coefficient(const AmanziMesh::Entity_ID col) const
{
if (volume_factor_) {
return coef_ / surf_cv_(col, 0);
} else {
return coef_;
}
}


} // namespace Impl

using ColumnSumEvaluator =
EvaluatorColumnIntegrator<Impl::ParserColumnSum, Impl::IntegratorColumnSum>;


} // namespace Relations
} // namespace Amanzi

0 comments on commit 9c9e7fc

Please sign in to comment.