-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into issue99_337_advection
- Loading branch information
Showing
61 changed files
with
1,000 additions
and
811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* @file PrognosticData.cpp | ||
* | ||
* @date 1 Jul 2024 | ||
* @date 21 Nov 2024 | ||
* @author Tim Spain <[email protected]> | ||
* @author Einar Ólason <[email protected]> | ||
*/ | ||
|
@@ -82,8 +82,6 @@ void PrognosticData::setData(const ModelState::DataMap& ms) | |
|
||
void PrognosticData::update(const TimestepTime& tst) | ||
{ | ||
ModelArrayRef<Shared::T_ICE, RW> ticeUpd(getStore()); | ||
|
||
pOcnBdy->updateBefore(tst); | ||
pAtmBdy->update(tst); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @file Xios.cpp | ||
* @author Tom Meltzer <[email protected]> | ||
* @author Joe Wallwork <[email protected]> | ||
* @date 01 Nov 2024 | ||
* @date 19 Nov 2024 | ||
* @brief XIOS interface implementation | ||
* @details | ||
* | ||
|
@@ -34,12 +34,26 @@ namespace Nextsim { | |
|
||
static const std::map<int, std::string> keyMap = { { Xios::ENABLED_KEY, "xios.enable" } }; | ||
|
||
//! Enable XIOS in the 'config' | ||
void enableXios() | ||
{ | ||
Configurator::clearStreams(); | ||
std::stringstream config; | ||
config << "[xios]" << std::endl << "enable = true" << std::endl; | ||
std::unique_ptr<std::istream> pcstream(new std::stringstream(config.str())); | ||
Configurator::addStream(std::move(pcstream)); | ||
} | ||
|
||
/*! | ||
* Constructor | ||
* | ||
* Configure an XIOS server | ||
*/ | ||
Xios::Xios() { configure(); } | ||
Xios::Xios(const std::string contextId) | ||
{ | ||
_contextId = contextId; | ||
configure(); | ||
} | ||
|
||
//! Destructor | ||
Xios::~Xios() { finalize(); } | ||
|
@@ -60,7 +74,7 @@ void Xios::context_finalize() | |
} | ||
} | ||
|
||
//! Close context and finialize server | ||
//! Finalize XIOS server | ||
void Xios::finalize() | ||
{ | ||
if (isEnabled) { | ||
|
@@ -98,12 +112,13 @@ void Xios::configureServer(const std::string calendarType) | |
MPI_Comm_size(clientComm, &mpi_size); | ||
|
||
// Initialize 'nextSIM-DG' context | ||
contextId = "nextSIM-DG"; | ||
cxios_context_initialize(contextId.c_str(), contextId.length(), &clientComm_F); | ||
cxios_context_initialize(_contextId.c_str(), _contextId.length(), &clientComm_F); | ||
|
||
// Initialize calendar wrapper for 'nextSIM-DG' context | ||
cxios_get_current_calendar_wrapper(&clientCalendar); | ||
cxios_set_calendar_wrapper_type(clientCalendar, calendarType.c_str(), calendarType.length()); | ||
cxios_duration timestep { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 }; | ||
cxios_set_calendar_wrapper_timestep(clientCalendar, timestep); | ||
cxios_create_calendar(clientCalendar); | ||
} | ||
|
||
|
@@ -125,7 +140,7 @@ int Xios::getClientMPIRank() { return mpi_rank; } | |
bool Xios::isInitialized() | ||
{ | ||
bool init = false; | ||
cxios_context_is_initialized(contextId.c_str(), contextId.length(), &init); | ||
cxios_context_is_initialized(_contextId.c_str(), _contextId.length(), &init); | ||
return init; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
/*! | ||
* @file ConfigurationHelp.hpp | ||
* | ||
* @date Aug 12, 2022 | ||
* @date 20 Nov 2024 | ||
* @author Tim Spain <[email protected]> | ||
*/ | ||
|
||
#ifndef CONFIGURATIONHELP_HPP | ||
#define CONFIGURATIONHELP_HPP | ||
|
||
#include <iomanip> | ||
#include <list> | ||
#include <map> | ||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
|
@@ -28,6 +30,14 @@ class ConfigurationHelp { | |
std::string defaultValue; | ||
std::string units; | ||
std::string text; | ||
|
||
// Ever so slightly better formatting than std::to_string | ||
template <typename T> static std::string toString(const T input, const int n = 6) | ||
{ | ||
std::ostringstream output; | ||
output << std::setprecision(n) << input; | ||
return output.str(); | ||
} | ||
}; | ||
|
||
} /* namespace Nextsim */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @file Xios.hpp | ||
* @author Tom Meltzer <[email protected]> | ||
* @author Joe Wallwork <[email protected]> | ||
* @date 21 August 2024 | ||
* @date 18 Nov 2024 | ||
* @brief XIOS interface header | ||
* @details | ||
* | ||
|
@@ -27,9 +27,11 @@ | |
|
||
namespace Nextsim { | ||
|
||
void enableXios(); | ||
|
||
class Xios : public Configured<Xios> { | ||
public: | ||
Xios(); | ||
Xios(const std::string contextId = "nextSIM-DG"); | ||
~Xios(); | ||
|
||
/* Initialization and finalization */ | ||
|
@@ -144,7 +146,7 @@ class Xios : public Configured<Xios> { | |
bool isEnabled; | ||
|
||
std::string clientId; | ||
std::string contextId; | ||
std::string _contextId; | ||
MPI_Comm clientComm; | ||
MPI_Fint clientComm_F; | ||
MPI_Fint nullComm_F; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* @file BBMDynamics.cpp | ||
* | ||
* @date Jul 1, 2024 | ||
* @date 20 Nov 2024 | ||
* @author Tim Spain <[email protected]> | ||
* @author Einar Ólason <[email protected]> | ||
*/ | ||
|
@@ -16,6 +16,53 @@ static const std::vector<std::string> namedFields = { hiceName, ciceName, uName, | |
static const std::map<std::string, std::pair<ModelArray::Type, double>> defaultFields = { | ||
{ damageName, { ModelArray::Type::H, 1.0 } }, | ||
}; | ||
|
||
// TODO: We should use getName() here, but it isn't static. | ||
static const std::string prefix = "BBMDynamics"; // MEVPDynamics::getName(); | ||
static const std::map<int, std::string> keyMap = { | ||
{ BBMDynamics::C_KEY, prefix + ".C" }, | ||
{ BBMDynamics::NU_KEY, prefix + ".nu" }, | ||
{ BBMDynamics::YOUNG_KEY, prefix + ".young" }, | ||
{ BBMDynamics::P0_KEY, prefix + ".P0" }, | ||
{ BBMDynamics::LAMBDA0_KEY, prefix + ".lambda0" }, | ||
{ BBMDynamics::ALPHA_KEY, prefix + ".alpha" }, | ||
{ BBMDynamics::EXPPMAX_KEY, prefix + ".exppmax" }, | ||
{ BBMDynamics::MU_KEY, prefix + ".mu" }, | ||
{ BBMDynamics::NMAX_KEY, prefix + ".namx" }, | ||
{ BBMDynamics::CLAB_KEY, prefix + ".clab" }, | ||
{ BBMDynamics::NSTEPS_KEY, prefix + ".nsteps" }, | ||
{ BBMDynamics::RHOI_KEY, prefix + ".rho_ice" }, | ||
{ BBMDynamics::RHOA_KEY, prefix + ".rho_atm" }, | ||
{ BBMDynamics::RHOO_KEY, prefix + ".rho_ocean" }, | ||
{ BBMDynamics::CATM_KEY, prefix + ".drag_atm" }, | ||
{ BBMDynamics::COCEAN_KEY, prefix + ".drag_ocean" }, | ||
{ BBMDynamics::FC_KEY, prefix + ".Coriolis_parameter" }, | ||
{ BBMDynamics::ANGLE_KEY, prefix + ".ocean_turning_angle" }, | ||
}; | ||
|
||
void BBMDynamics::configure() | ||
{ | ||
params.compactionParam = Configured::getConfiguration(keyMap.at(C_KEY), compactionParamDefault); | ||
params.nu0 = Configured::getConfiguration(keyMap.at(NU_KEY), nu0Default); | ||
params.young = Configured::getConfiguration(keyMap.at(YOUNG_KEY), youngDefault); | ||
params.P0 = Configured::getConfiguration(keyMap.at(P0_KEY), P0Default); | ||
params.lambda0 = Configured::getConfiguration(keyMap.at(LAMBDA0_KEY), lambda0Default); | ||
params.alpha = Configured::getConfiguration(keyMap.at(ALPHA_KEY), alphaDefault); | ||
params.expPMax = Configured::getConfiguration(keyMap.at(EXPPMAX_KEY), expPMaxDefault); | ||
params.mu = Configured::getConfiguration(keyMap.at(MU_KEY), muDefault); | ||
params.comprCap = Configured::getConfiguration(keyMap.at(NMAX_KEY), comprCapDefault); | ||
params.cLab = Configured::getConfiguration(keyMap.at(CLAB_KEY), cLabDefault); | ||
params.nSteps = Configured::getConfiguration(keyMap.at(NSTEPS_KEY), nStepsDefault); | ||
params.rhoIce = Configured::getConfiguration(keyMap.at(RHOI_KEY), rhoIceDefault); | ||
params.rhoAtm = Configured::getConfiguration(keyMap.at(RHOA_KEY), rhoAtmDefault); | ||
params.rhoOcean = Configured::getConfiguration(keyMap.at(RHOO_KEY), rhoOceanDefault); | ||
params.CAtm = Configured::getConfiguration(keyMap.at(CATM_KEY), CAtmDefault); | ||
params.COcean = Configured::getConfiguration(keyMap.at(COCEAN_KEY), COceanDefault); | ||
params.fc = Configured::getConfiguration(keyMap.at(FC_KEY), fcDefault); | ||
params.oceanTurningAngle | ||
= Configured::getConfiguration(keyMap.at(ANGLE_KEY), oceanTurningAngleDefault); | ||
} | ||
|
||
BBMDynamics::BBMDynamics() | ||
: IDynamics(true) | ||
, kernel(params) | ||
|
@@ -132,4 +179,60 @@ ModelState BBMDynamics::getStateRecursive(const OutputSpec& os) const | |
return state; | ||
} | ||
|
||
BBMDynamics::HelpMap& BBMDynamics::getHelpText(HelpMap& map, bool getAll) | ||
{ | ||
map["BBMDynamics"] = { | ||
{ keyMap.at(C_KEY), ConfigType::NUMERIC, { "-∞", "0" }, | ||
ConfigurationHelp::toString(compactionParamDefault), "[None]", | ||
"The compaction parameter C" }, | ||
{ keyMap.at(NU_KEY), ConfigType::NUMERIC, { "-∞", "0" }, | ||
ConfigurationHelp::toString(nu0Default), "[None]", "Poisson's ratio, 𝜈" }, | ||
{ keyMap.at(YOUNG_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(youngDefault), "Pa", "Young's modulus, Y" }, | ||
{ keyMap.at(P0_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(P0Default), "Pa", "Ice strength scaling parameter" }, | ||
{ keyMap.at(LAMBDA0_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(lambda0Default), "s", "Undamaged relaxation time scale" }, | ||
{ keyMap.at(ALPHA_KEY), ConfigType::NUMERIC, { "2", "∞" }, | ||
ConfigurationHelp::toString(alphaDefault), "[None]", "Damage parameter" }, | ||
{ keyMap.at(EXPPMAX_KEY), ConfigType::NUMERIC, { "0", "2" }, | ||
ConfigurationHelp::toString(expPMaxDefault), "[None]", | ||
"Exponent for thickness scaling of P_{max}" }, | ||
{ keyMap.at(MU_KEY), ConfigType::NUMERIC, { "0", "1" }, | ||
ConfigurationHelp::toString(expPMaxDefault), "[None]", | ||
"Internal friction coefficient, 𝜇" }, | ||
{ keyMap.at(NMAX_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(expPMaxDefault), "Pa", | ||
"Maximum compressive strength (at the lab scale)" }, | ||
{ keyMap.at(CLAB_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(cLabDefault), "Pa", "Cohesion (at the lab scale)" }, | ||
{ keyMap.at(NSTEPS_KEY), ConfigType::NUMERIC, { "1", "∞" }, | ||
ConfigurationHelp::toString(nStepsDefault), "[No unit]", | ||
"The number of sub-cycling steps" }, | ||
{ keyMap.at(RHOI_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(rhoIceDefault), "kg/m^3", "Density of sea ice" }, | ||
{ keyMap.at(RHOA_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(rhoAtmDefault), "kg/m^3", "Density of air" }, | ||
{ keyMap.at(RHOO_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(rhoOceanDefault), "kg/m^3", "Density of ocean" }, | ||
{ keyMap.at(CATM_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(CAtmDefault), "[No unit]", | ||
"Ice-atmosphere drag coefficient" }, | ||
{ keyMap.at(COCEAN_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(COceanDefault), "[No unit]", "Ice-ocean drag coefficient" }, | ||
{ keyMap.at(FC_KEY), ConfigType::NUMERIC, { "0", "∞" }, | ||
ConfigurationHelp::toString(fcDefault), "[No unit]", | ||
"Coriolis parameter (constant across the domain)" }, | ||
{ keyMap.at(ANGLE_KEY), ConfigType::NUMERIC, { "0", "90" }, | ||
ConfigurationHelp::toString(oceanTurningAngleDefault), "degrees", | ||
"Oceanic turning angle" }, | ||
}; | ||
return map; | ||
} | ||
|
||
BBMDynamics::HelpMap& BBMDynamics::getHelpRecursive(HelpMap& map, bool getAll) | ||
{ | ||
return getHelpText(map, getAll); | ||
} | ||
|
||
} /* namespace Nextsim */ |
Oops, something went wrong.