Skip to content

Commit

Permalink
Use appropriate type aliases more thoroughly
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilMiller committed Nov 26, 2024
1 parent 6f7fc16 commit 61be140
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions include/forcing/NetCDFMeshPointsDataProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ namespace data_access
* @return The value of the forcing property for the described time period, with units converted if needed.
* @throws std::out_of_range If data for the time period is not available.
*/
double get_value(const selection_type& selector, ReSampleMethod m) override;
data_type get_value(const selection_type& selector, ReSampleMethod m) override;

void get_values(const selection_type& selector, boost::span<double> data) override;
void get_values(const selection_type& selector, boost::span<data_type> data) override;

// And an implementation of the usual version using it
std::vector<data_type> get_values(const selection_type& selector, data_access::ReSampleMethod) override
Expand Down
5 changes: 2 additions & 3 deletions include/realizations/coastal/CoastalFormulation.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#pragma once

#include <forcing/DataProvider.hpp>
#include <forcing/MeshPointsSelectors.hpp>
#include <forcing/GenericDataProvider.hpp>

#include <string>
#include <boost/core/span.hpp>

class CoastalFormulation : public data_access::DataProvider<double, MeshPointsSelector>
class CoastalFormulation : public data_access::MeshPointsDataProvider
{
public:
CoastalFormulation(std::string id)
Expand Down
12 changes: 6 additions & 6 deletions include/realizations/coastal/SchismFormulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
class SchismFormulation final : public CoastalFormulation
{
public:
using MeshPointsDataProvider = data_access::DataProvider<double, MeshPointsSelector>;
using ProviderType = data_access::MeshPointsDataProvider;

SchismFormulation(
std::string const& id
, std::string const& library_path
, std::string const& init_config_path
, MPI_Comm mpi_comm
, std::shared_ptr<MeshPointsDataProvider> met_forcings
, std::shared_ptr<MeshPointsDataProvider> offshore_boundary
, std::shared_ptr<MeshPointsDataProvider> inflow_boundary
, std::shared_ptr<ProviderType> met_forcings
, std::shared_ptr<ProviderType> offshore_boundary
, std::shared_ptr<ProviderType> inflow_boundary
);

~SchismFormulation();
Expand All @@ -41,7 +42,7 @@ class SchismFormulation final : public CoastalFormulation
void finalize() override;
void update() override;

void get_values(const selection_type& selector, boost::span<double> data) override;
void get_values(const selection_type& selector, boost::span<data_type> data) override;

protected:
size_t mesh_size(std::string const& variable_name) override;
Expand Down Expand Up @@ -71,7 +72,6 @@ class SchismFormulation final : public CoastalFormulation
// area-averaged RAINRATE over elements, but we're going to make
// do with point values at the element centroids

using ProviderType = data_access::DataProvider<double, MeshPointsSelector>;
std::shared_ptr<ProviderType> meteorological_forcings_provider_;
std::shared_ptr<ProviderType> offshore_boundary_provider_;
std::shared_ptr<ProviderType> inflows_boundary_provider_;
Expand Down
6 changes: 3 additions & 3 deletions src/forcing/NetCDFMeshPointsDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ size_t NetCDFMeshPointsDataProvider::get_ts_index_for_time(const time_t &epoch_t
}
}

void NetCDFMeshPointsDataProvider::get_values(const selection_type& selector, boost::span<double> data)
void NetCDFMeshPointsDataProvider::get_values(const selection_type& selector, boost::span<data_type> data)
{
if (!boost::get<AllPoints>(&selector.points)) throw std::runtime_error("Not implemented - only all_points");

Expand All @@ -148,7 +148,7 @@ void NetCDFMeshPointsDataProvider::get_values(const selection_type& selector, bo

metadata.ncVar.getVar({time_index, 0}, {1, data.size()}, data.data());

for (double& value : data) {
for (auto& value : data) {
value = value * metadata.scale_factor + metadata.offset;
}

Expand All @@ -165,7 +165,7 @@ void NetCDFMeshPointsDataProvider::get_values(const selection_type& selector, bo
}
}

double NetCDFMeshPointsDataProvider::get_value(const selection_type& selector, ReSampleMethod m)
NetCDFMeshPointsDataProvider::data_type NetCDFMeshPointsDataProvider::get_value(const selection_type& selector, ReSampleMethod m)
{
throw std::runtime_error("Not implemented - access chunks of the mesh");

Expand Down
6 changes: 3 additions & 3 deletions src/realizations/coastal/SchismFormulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ SchismFormulation::SchismFormulation(
, std::string const& library_path
, std::string const& init_config_path
, MPI_Comm mpi_comm
, std::shared_ptr<MeshPointsDataProvider> met_forcings
, std::shared_ptr<MeshPointsDataProvider> offshore_boundary
, std::shared_ptr<MeshPointsDataProvider> inflow_boundary
, std::shared_ptr<ProviderType> met_forcings
, std::shared_ptr<ProviderType> offshore_boundary
, std::shared_ptr<ProviderType> inflow_boundary
)
: CoastalFormulation(id)
, meteorological_forcings_provider_(met_forcings)
Expand Down

0 comments on commit 61be140

Please sign in to comment.