EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
EBGeometry::Language::Properties Class Reference

The properties a material, subdomain, surface group, coupling or the view block carries: numbers, vectors and strings by key, passed through unread for the program to interpret. More...

#include <EBGeometry_Language.hpp>

Classes

struct  Value
 One value, and where it is written. More...
 

Public Types

enum class  Type : uint8_t { Number , Vector , String , Bool }
 The types a value can have. More...
 

Public Member Functions

 Properties ()=default
 No properties, owned by nothing written.
 
 Properties (std::string a_owner, const Span &a_span)
 No properties yet, of an owner.
 
bool has (std::string_view a_key) const noexcept
 Whether a key is set.
 
std::vector< std::string > keys () const
 The keys, in the order written.
 
bool empty () const noexcept
 Whether there are none.
 
double number (std::string_view a_key) const
 A number.
 
double number (std::string_view a_key, double a_fallback) const
 A number, or a fallback when the key is missing.
 
template<class T >
Vec3T< T > vector (std::string_view a_key) const
 A vector.
 
template<class T >
Vec3T< T > vector (std::string_view a_key, const Vec3T< T > &a_fallback) const
 A vector, or a fallback when the key is missing.
 
const std::string & string (std::string_view a_key) const
 A string.
 
const std::string & string (std::string_view a_key, const std::string &a_fallback) const
 A string, or a fallback when the key is missing.
 
bool flag (std::string_view a_key) const
 A bool, true or false.
 
bool flag (std::string_view a_key, bool a_fallback) const
 A bool, or a fallback when the key is missing.
 
uint32_t code (std::string_view a_key, std::initializer_list< std::string_view > a_names) const
 A string that is one of a set of names, as its index among them: how a solver turns a kind ("no_slip") into a code its kernels switch on.
 
Span spanOf (std::string_view a_key) const
 Where a key's value is written; where the owner is when the key is missing.
 
const Value * find (std::string_view a_key) const noexcept
 A value by key, or nullptr.
 
void set (const std::string &a_key, const Value &a_value)
 Set a key, replacing its value if it is set.
 
const std::string & owner () const noexcept
 The owner in words.
 
const Span & span () const noexcept
 Where the owner is written.
 

Detailed Description

The properties a material, subdomain, surface group, coupling or the view block carries: numbers, vectors and strings by key, passed through unread for the program to interpret.

A subdomain's properties are its own over its regions' material's, key by key. Every failure (a missing key, a value of another type, a string not among the names given) throws an Error at the key, or at the line where the owner is written when the key is missing.

Member Enumeration Documentation

◆ Type

enum class EBGeometry::Language::Properties::Type : uint8_t
strong

The types a value can have.

Enumerator
Number 

A number.

Vector 

Three numbers.

String 

A string.

Bool 

true or false.

Constructor & Destructor Documentation

◆ Properties()

EBGeometry::Language::Properties::Properties ( std::string  a_owner,
const Span &  a_span 
)
inline

No properties yet, of an owner.

Parameters
[in]a_ownerThe owner in words ("material 'air'"), for messages.
[in]a_spanWhere the owner is written.

Member Function Documentation

◆ code()

uint32_t EBGeometry::Language::Properties::code ( std::string_view  a_key,
std::initializer_list< std::string_view >  a_names 
) const

A string that is one of a set of names, as its index among them: how a solver turns a kind ("no_slip") into a code its kernels switch on.

Parameters
[in]a_keyThe key.
[in]a_namesThe names.
Returns
The index; an Error listing the names when the string is none of them, or the key is missing.

◆ empty()

bool EBGeometry::Language::Properties::empty ( ) const
inlinenoexcept

Whether there are none.

Returns
Whether.

◆ find()

const Value * EBGeometry::Language::Properties::find ( std::string_view  a_key) const
noexcept

A value by key, or nullptr.

Parameters
[in]a_keyThe key.
Returns
The value.

◆ flag() [1/2]

bool EBGeometry::Language::Properties::flag ( std::string_view  a_key) const

A bool, true or false.

Parameters
[in]a_keyThe key.
Returns
The bool; an Error when the key is missing or not true or false.

◆ flag() [2/2]

bool EBGeometry::Language::Properties::flag ( std::string_view  a_key,
bool  a_fallback 
) const

A bool, or a fallback when the key is missing.

Parameters
[in]a_keyThe key.
[in]a_fallbackThe value when the key is missing.
Returns
The bool; an Error when the key is set and not true or false.

◆ has()

bool EBGeometry::Language::Properties::has ( std::string_view  a_key) const
noexcept

Whether a key is set.

Parameters
[in]a_keyThe key.
Returns
Whether.

◆ keys()

std::vector< std::string > EBGeometry::Language::Properties::keys ( ) const

The keys, in the order written.

Returns
The keys.

◆ number() [1/2]

double EBGeometry::Language::Properties::number ( std::string_view  a_key) const

A number.

Parameters
[in]a_keyThe key.
Returns
The number; an Error when the key is missing or not a number.

◆ number() [2/2]

double EBGeometry::Language::Properties::number ( std::string_view  a_key,
double  a_fallback 
) const

A number, or a fallback when the key is missing.

Parameters
[in]a_keyThe key.
[in]a_fallbackThe value when the key is missing.
Returns
The number; an Error when the key is set and not a number.

◆ owner()

const std::string & EBGeometry::Language::Properties::owner ( ) const
inlinenoexcept

The owner in words.

Returns
It.

◆ set()

void EBGeometry::Language::Properties::set ( const std::string &  a_key,
const Value &  a_value 
)

Set a key, replacing its value if it is set.

Parameters
[in]a_keyThe key.
[in]a_valueThe value.

◆ span()

const Span & EBGeometry::Language::Properties::span ( ) const
inlinenoexcept

Where the owner is written.

Returns
The span.

◆ spanOf()

Span EBGeometry::Language::Properties::spanOf ( std::string_view  a_key) const

Where a key's value is written; where the owner is when the key is missing.

Parameters
[in]a_keyThe key.
Returns
The span.

◆ string() [1/2]

const std::string & EBGeometry::Language::Properties::string ( std::string_view  a_key) const

A string.

Parameters
[in]a_keyThe key.
Returns
The string; an Error when the key is missing or not a string.

◆ string() [2/2]

const std::string & EBGeometry::Language::Properties::string ( std::string_view  a_key,
const std::string &  a_fallback 
) const

A string, or a fallback when the key is missing.

Parameters
[in]a_keyThe key.
[in]a_fallbackThe value when the key is missing.
Returns
The string; an Error when the key is set and not a string.

◆ vector() [1/2]

template<class T >
Vec3T< T > EBGeometry::Language::Properties::vector ( std::string_view  a_key) const

A vector.

Template Parameters
TPrecision.
Parameters
[in]a_keyThe key.
Returns
The vector; an Error when the key is missing, not a vector, or too large for T.

◆ vector() [2/2]

template<class T >
Vec3T< T > EBGeometry::Language::Properties::vector ( std::string_view  a_key,
const Vec3T< T > &  a_fallback 
) const

A vector, or a fallback when the key is missing.

Template Parameters
TPrecision.
Parameters
[in]a_keyThe key.
[in]a_fallbackThe value when the key is missing.
Returns
The vector; an Error when the key is set and not a vector, or too large for T.

The documentation for this class was generated from the following file: