Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/ats-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
else
echo "ATS_BRANCH=$GITHUB_REF_NAME" >> $GITHUB_ENV
fi
- name: Does Amanzi branch of the same name exist?
- name: Set Amanzi branch to the EcoSIM TPLs branch for now.
id: amanzi_branch
run: |
echo "AMANZI_BRANCH=$(git ls-remote --heads origin ${GITHUB_REF_NAME} | sed 's/.*refs\/heads\///')" >> $GITHUB_ENV
- name: If so, checkout Amanzi to get the right TPLs version
echo "AMANZI_BRANCH=david/ecosim-tpls" >> $GITHUB_ENV
- name: Checkout Amanzi to get the right TPLs version
id: amanzi_branch_checkout
uses: actions/checkout@v4
with:
Expand Down
25 changes: 24 additions & 1 deletion src/executables/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/deform)
include_directories(${ATS_SOURCE_DIR}/src/pks/transport)
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)
Expand All @@ -63,6 +64,12 @@ 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
coordinator.cc
Expand Down Expand Up @@ -122,6 +129,21 @@ set(ats_link_libs
ats_transport_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
# ats_ecosim_data
# ats_ecosim_relations

message(STATUS ">>>> JDM: In ATS ECOSIM_LIBRARIES = ${ECOSIM_LIBRARIES}")

# note, we can be inclusive here, because if they aren't enabled,
# these won't be defined and will result in empty strings.
Expand All @@ -137,7 +159,8 @@ set(tpl_link_libs
${HYPRE_LIBRARIES}
${HDF5_LIBRARIES}
${CLM_LIBRARIES}
)
${ECOSIM_LIBRARIES}
)

add_amanzi_library(ats_executable
SOURCE ${ats_src_files}
Expand Down
5 changes: 5 additions & 0 deletions src/executables/ats_registration_files.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@
#ifdef ALQUIMIA_ENABLED
#include "pks_chemistry_reg.hh"
#endif
#ifdef ECOSIM_ENABLED
#include "ats_ecosim_registration.hh"
#include "ats_ecosim_relations_registration.hh"
#include "ats_ecosim_data_registration.hh"
#endif
4 changes: 4 additions & 0 deletions src/pks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ add_subdirectory(deform)
add_subdirectory(surface_balance)
add_subdirectory(biogeochemistry)
add_subdirectory(mpc)

if (ENABLE_ECOSIM)
add_subdirectory(ecosim)
endif()
119 changes: 119 additions & 0 deletions src/pks/ecosim/BGCEngine.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
Basic architecture based on the Alquima interfece adapted for
use in the ATSEcoSIM PK

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.

Authors: Jeffrey Johnson
Sergi Molins <smolins@lbl.gov>

This implements the Alquimia chemistry engine.
*/

#include <iostream>
#include <cstring>
#include <cstdio>
#include <assert.h>
#include "BGCEngine.hh"
#include "errors.hh"
#include "exceptions.hh"

// Support for manipulating floating point exception handling.
#ifdef _GNU_SOURCE
#define AMANZI_USE_FENV
#include <fenv.h>
#endif

namespace Amanzi {
namespace EcoSIM {

BGCEngine::BGCEngine(const std::string& engineName,
const std::string& inputFile) :
bgc_engine_name_(engineName),
bgc_engine_inputfile_(inputFile)
{
Errors::Message msg;

CreateBGCInterface(bgc_engine_name_.c_str(),
&bgc_);

}

BGCEngine::~BGCEngine()
{
bgc_.Shutdown();

//Did I forget to implement this?
//FreeBGCProperties(&props);
//FreeBGCState(&state);
//FreeBGCAuxiliaryData(&aux_data);
//FreeAlquimiaEngineStatus(&chem_status_);
}

const BGCSizes&
BGCEngine::Sizes() const
{
return sizes_;
}

void BGCEngine::InitState(BGCProperties& properties,
BGCState& state,
BGCAuxiliaryData& aux_data,
int ncells_per_col_,
int num_components,
int num_columns)
{
AllocateBGCProperties(&sizes_, &properties, ncells_per_col_, num_columns);
AllocateBGCState(&sizes_, &state, ncells_per_col_, num_components, num_columns);
}

void BGCEngine::FreeState(BGCProperties& properties,
BGCState& state,
BGCAuxiliaryData& aux_data)
{
FreeBGCProperties(&properties);
FreeBGCState(&state);
}

void BGCEngine::DataTest() {

bgc_.DataTest();
}

bool BGCEngine::Setup(BGCProperties& properties,
BGCState& state,
BGCSizes& sizes_,
int num_iterations,
int num_columns,
int ncells_per_col_)
{
bgc_.Setup(&properties,
&state,
&sizes_,
num_iterations,
num_columns,
ncells_per_col_);

}

bool BGCEngine::Advance(const double delta_time,
BGCProperties& properties,
BGCState& state,
BGCSizes& sizes_,
int num_iterations,
int num_columns)
{
bgc_.Advance(delta_time,
&properties,
&state,
&sizes_,
num_iterations,
num_columns);

}

} // namespace
} // namespace
107 changes: 107 additions & 0 deletions src/pks/ecosim/BGCEngine.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
ATS-EcoSIM, Code Adapted for use from Alquimia

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.

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 BGC_ENGINE_HH_
#define BGC_ENGINE_HH_

#include <string>
#include <vector>
#include <map>

#include "BGC_memory.hh"
#include "BGC_containers.hh"

#include "VerboseObject.hh"

namespace Amanzi {
namespace EcoSIM {

class BGCEngine {
public:

// Constructs a chemistry engine using the given engine (backend) name and input file.
BGCEngine(const std::string& engineName, const std::string& inputFile);

// Destructor.
~BGCEngine();

// 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;

// 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 BGCSizes& Sizes() const;

// Initializes the data structures that hold the chemical state information.
void InitState(BGCProperties& properties,
BGCState& state,
BGCAuxiliaryData& aux_data,
int ncells_per_col_,
int num_components,
int num_columns);

// Frees the data structures that hold the chemical state information.
void FreeState(BGCProperties& properties,
BGCState& state,
BGCAuxiliaryData& aux_data);

void DataTest();

bool Setup(BGCProperties& properties,
BGCState& state,
BGCSizes& sizes,
int num_iterations,
int num_columns,
int ncells_per_col_);

bool Advance(const double delta_time,
BGCProperties& properties,
BGCState& state,
BGCSizes& sizes,
int num_iterations,
int num_columns);

void CopyBGCState(const BGCState* const source,
BGCState* destination);
void CopyBGCProperties(const BGCProperties* const source,
BGCProperties* destination);

private:

// bgc data structures.
bool bgc_initialized_;
void* engine_state_;
BGCSizes sizes_;
BGCInterface bgc_;

Teuchos::RCP<VerboseObject> vo_;
// Back-end engine name and input file.
std::string bgc_engine_name_;
std::string bgc_engine_inputfile_;

// forbidden.
BGCEngine();
BGCEngine(const BGCEngine&);
BGCEngine& operator=(const BGCEngine&);

};

} // namespace
} // namespace

#endif
Loading
Loading