File options_io.hxx#

Defines

OPTIONS_IO_H#

Parent class for IO to binary files and streams

Usage:

  1. Dump files, containing time history:

    auto dump = OptionsIOFactory::getInstance().createOutput(); dump->write(data);

    where data is an Options tree. By default dump files are configured with the root output section, or an Option tree can be passed to createOutput.

  2. Restart files:

    auto restart = OptionsIOFactory::getInstance().createOutput(); restart->write(data);

    where data is an Options tree. By default restart files are configured with the root restart_files section, or an Option tree can be passed to createRestart.

  3. Ad-hoc single files Note: The caller should consider how multiple processors interact with the file.

    auto file = OptionsIOFactory::getInstance().createFile("some_file.nc");
    
    or auto file = OptionsIO::create(“some_file.nc”);

namespace bout

Provides access to the Hypre library, handling initialisation and finalisation.

Usage

#include <bout/hyprelib.hxx>

class MyClass { public:

private: HypreLib lib; };

This will then automatically initialise Hypre the first time an object is created, and finalise it when the last object is destroyed.

Copyright 2012 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu

Contact: Ben Dudson, bd512@york.ac.uk

This file is part of BOUT++.

BOUT++ is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

BOUT++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with BOUT++. If not, see http://www.gnu.org/licenses/.

Information about the version of BOUT++

The build system will update this file on every commit, which may result in files that include it getting rebuilt. Therefore it should be included in as few places as possible

Information about the version of BOUT++

The build system will update this file at configure-time

SNB model

Typedefs

template<typename DerivedType>
using RegisterOptionsIO = OptionsIOFactory::RegisterInFactory<DerivedType>#

Simpler name for Factory registration helper class

Usage:

#include <bout/options_io.hxx>
namespace {
RegisterOptionsIO<MyOptionsIO> registeroptionsiomine("myoptionsio");
}

using RegisterUnavailableOptionsIO = OptionsIOFactory::RegisterUnavailableInFactory#

Simpler name for indicating that an OptionsIO implementation is unavailable.

Usage:

namespace {
RegisterUnavailableOptionsIO
    unavailablemyoptionsio("myoptiosio", "BOUT++ was not configured with MyOptionsIO");
}

class OptionsIO#

Subclassed by bout::OptionsNetCDF

Public Functions

OptionsIO() = delete#

No default constructor, as settings are required.

inline OptionsIO(Options&)#

Constructor specifies the kind of file, and options to control the name of file, mode of operation etc.

virtual ~OptionsIO() = default#
OptionsIO(const OptionsIO&) = delete#
OptionsIO(OptionsIO&&) noexcept = default#
OptionsIO &operator=(const OptionsIO&) = delete#
OptionsIO &operator=(OptionsIO&&) noexcept = default#
virtual Options read() = 0#

Read options from file.

inline void write(const Options &options)#

Write options to file.

virtual void write(const Options &options, const std::string &time_dim) = 0#
virtual void verifyTimesteps() const = 0#

NetCDF: Check that all variables with the same time dimension have the same size in that dimension. Throws BoutException if there are any differences, otherwise is silent. ADIOS: Indicate completion of an output step.

Public Static Functions

static std::unique_ptr<OptionsIO> create(const std::string &file)#

Create an OptionsIO for I/O to the given file. This uses the default file type and default options.

static std::unique_ptr<OptionsIO> create(Options &config)#

Create an OptionsIO for I/O to the given file. The file will be configured using the given config options:

  • ”type” : string The file type e.g. “netcdf” or “adios”

  • ”file” : string Name of the file

  • ”append” : bool Append to existing data (Default is false)

static inline std::unique_ptr<OptionsIO> create(Options::InitializerList config_list)#

Create an OptionsIO for I/O to the given file. The file will be configured using the given config options:

  • ”type” : string The file type e.g. “netcdf” or “adios”

  • ”file” : string Name of the file

  • ”append” : bool Append to existing data (Default is false)

Example:

auto file = OptionsIO::create({
    {"file", "some_file.nc"},
    {"type", "netcdf"},
    {"append", false}
});

class OptionsIOFactory : public Factory<OptionsIO, OptionsIOFactory, Options&>#

Public Functions

ReturnType createRestart(Options *optionsptr = nullptr) const#

Create a restart file, configured with options (if given), or root “restart_files” section.

Options:

  • ”type” The type of file e.g “netcdf” or “adios”

  • ”file” Name of the file. Default is <path>/<prefix>.[type-dependent]

  • ”path” Path to restart files. Default is root “datadir” option, that defaults to “data”

  • ”prefix” Default is “BOUT.restart”

ReturnType createOutput(Options *optionsptr = nullptr) const#

Create an output file for writing time history. Configure with options (if given), or root “output” section.

Options:

  • ”type” The type of file e.g “netcdf” or “adios”

  • ”file” Name of the file. Default is <path>/<prefix>.[type]

  • ”path” Path to output files. Default is root “datadir” option, that defaults to “data”

  • ”prefix” Default is “BOUT.dmp”

  • ”append” Append to existing file? Default is root “append” option, that defaults to false.

ReturnType createFile(const std::string &file) const#

Create a single file (e.g. mesh file) of the default type.

Public Static Attributes

static constexpr auto type_name = "OptionsIO"#
static constexpr auto section_name = "io"#
static constexpr auto option_name = "type"#
static constexpr auto default_type = "netcdf"#