Accessing the Database

This chapter explains accessing the B2000++ model database from the B2000++ code. Still in preparation.

The B2000++ Database Directory Structure

A B2000++ model database name.b2m is a directory containing

  1. The FE database archives.mc. The B2000++ applications read and write excusively to the database, except for the loggging database log.mc and the logging file log.txt.

  2. The optional FE database log.mc.

  3. The logging file log.txt.

  4. The file .index. In the present version it contains a string of the form b2000pp x.y.z.

When the B2000++ input processor b2ip++ is executed, it will delete the archives.mc because b2ip++ creates the FE model from scatch. The log.mc is never deleted, i.e new runs will append logging information.

DataBase Object

in preparation.

b2rtable

A C++ class implementation of the MemCom relational table manipulation functions (see MemCom Reference Manual.

RTable Object

The RTable object is a map of strings to RData objects, i.e the in-core version of the MemCom $ datasets or dataset descriptors. In addition, it contains set and get functions that perform error checking. In case of an error, an exception is thrown. The get functions are similar to those in the abstract Dictionary class.

Example (from the b2programming package, component rod_material):

// rtable is the C++ representation of the user-defined material as
// specified in the MDL material block and stored on the database as a
// relational table MATERIAL.<eid>

const RTable& rtable = material->get_rtable(0); // layer 0
E = rtable.get<double>("E");
ALPHA = rtable.get<double>("ALPHA", 0.);
DENSITY = rtable.get<double>("DENSITY", 0.);

The second argument in the get method is the default value returned if the key is not found.

The associated RData object is a container for a key-value pair of a relational table. Is one of

  • std::vector of int, double, or complex-double values

  • std::string

The internal fields are protected such that the object retains a valid state. Manipulation is done via the constructors and the set and get methods. For efficiency, the get methods return const references; this means that some care is required if the `` RTable`` is being modified.