EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Functions
EBGeometry::Language Namespace Reference

The .ebg language: a model (geometry, its regions and materials, and the domains a solver computes in) written in a text file and read at run time, instead of composed in compiled C++. More...

Namespaces

namespace  Syntax
 The syntax of the language: tokens, the tree a file is parsed into, and the parser. Used by the reader and the printer; a user reads models through Language::read().
 

Classes

struct  Completeness
 Whether a domain is complete for a solver, and what is missing. More...
 
struct  Coupling
 A coupling of two domains: two subdomains that hold the same regions (volume), or two surface groups that cover the same pieces of surface (surface), with its properties. More...
 
struct  Diagnostic
 One error or warning, at a span. More...
 
class  DomainObject
 A domain's own object: the regions of its subdomains and their neighbors, with the domain's setup and the model's names translated to it (see Model::domainObject()). More...
 
class  Error
 What reading a model throws when it has errors: every error found (not only the first), and the warnings. More...
 
class  Model
 A model read from a .ebg file and the files it includes: its object, the names of its regions, materials and labels, its materials, domains, couplings and params, and the files it read. More...
 
class  ModelDomain
 A domain of a model: its name, its setup, and the names and properties of its subdomains and surface groups. More...
 
struct  NodeSite
 A node of the object that a shape value of the text makes: what a selector surfaces(name) names, and what a viewer writes a picked level by. More...
 
struct  Param
 A param of a model: its name, its value as text (after overrides), its type, and where it is written. More...
 
class  Properties
 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...
 
struct  ShapeSite
 A shape the model's text builds, and where: what the inventory lists and a viewer names parts by. More...
 
struct  Span
 Where a piece of text is: its file, its first and one-past-last byte, and the line and column of its first byte (both from 1). What every diagnostic points at, and what a viewer edits. More...
 
class  Table
 A table of a program's own rows in a pool, one per region, subdomain or surface group, read on the host and on a device by the numbers EBGeometry computes there (Tape::region(), Domain::subdomainAt(), Domain::surfaceGroupOf()). More...
 

Typedefs

using Overrides = std::map< std::string, std::string >
 Values for a model's params, by name, each written as in a file ("0.5", "(1, 0, 0)", "\"steel\""): what ebgstudio -D name=value gives. Overriding a value that is not a param, or a name the model does not define, is an error.
 

Functions

template<class T >
Model< T > read (const std::string &a_path, Pool &a_pool, const Overrides &a_overrides={})
 Read a model: a .ebg file, and the files it includes (a setup file includes the geometry it is a setup of).
 
template<class T >
Model< T > parse (std::string_view a_text, const std::string &a_name, Pool &a_pool, const Overrides &a_overrides={})
 Read a model from text.
 
template<class T , class... UserPrimitives>
Completeness completeness (const Model< T > &a_model, const Tape< T, UserPrimitives... > &a_tape, std::string_view a_domain)
 Check that a domain is complete for a solver: every subdomain has properties (its own or its regions' material's), and every piece of surface bounding the domain (a boundary, or an interface between two subdomains) is held by exactly one surface group. Surface couplings are checked too: both groups hold the same pieces.
 
template<class T , class... UserPrimitives>
Completeness completeness (const Model< T > &a_model, const Tape< T, UserPrimitives... > &a_tape, std::string_view a_domain, T a_resolution, uint64_t a_maxCells=ComponentOptions< T >::DefaultMaxCells)
 Check that a domain is complete (see completeness(model, tape, domain)), and look for the connected components it may not expect, at a resolution (see connectedComponents()): warnings, never errors.
 
std::vector< std::string > partNames (std::string_view a_shape, uint32_t a_sides=0)
 The part names of a built-in shape, in the order of its parts ("box": xmin, xmax, ymin, ymax, zmin, zmax).
 
template<class T >
std::string inventory (const Model< T > &a_model)
 Every name a model offers, as text: its surface labels, the parts of each shape written (with their labels), its regions and materials, and its domains with their subdomains and groups. What ebgstudio check --inventory prints.
 
template<class T >
std::string print (const Model< T > &a_model, bool a_flatten=false)
 A model as text in canonical form: one statement per line, the layout a viewer writes, comments kept.
 

Detailed Description

The .ebg language: a model (geometry, its regions and materials, and the domains a solver computes in) written in a text file and read at run time, instead of composed in compiled C++.

Host only, except Table, which a device reads. The language's reference is the Sphinx page; read() and parse() are the way in, Model what they give.

Function Documentation

◆ completeness() [1/2]

template<class T , class... UserPrimitives>
Completeness EBGeometry::Language::completeness ( const Model< T > &  a_model,
const Tape< T, UserPrimitives... > &  a_tape,
std::string_view  a_domain 
)

Check that a domain is complete for a solver: every subdomain has properties (its own or its regions' material's), and every piece of surface bounding the domain (a boundary, or an interface between two subdomains) is held by exactly one surface group. Surface couplings are checked too: both groups hold the same pieces.

The pieces are the ones the object may have (possiblePieces()); an uncovered one is an error when the tape's rays find it (findSurfacePieces()), a warning otherwise (it may not exist).

Template Parameters
TPrecision.
UserPrimitivesThe tape's user primitives.
Parameters
[in]a_modelThe model.
[in]a_tapeThe tape compiled from its object.
[in]a_domainThe domain's name.
Returns
The result.

◆ completeness() [2/2]

template<class T , class... UserPrimitives>
Completeness EBGeometry::Language::completeness ( const Model< T > &  a_model,
const Tape< T, UserPrimitives... > &  a_tape,
std::string_view  a_domain,
T  a_resolution,
uint64_t  a_maxCells = ComponentOptions< T >::DefaultMaxCells 
)

Check that a domain is complete (see completeness(model, tape, domain)), and look for the connected components it may not expect, at a resolution (see connectedComponents()): warnings, never errors.

The box searched is the tape's bounding box grown by two cells, so that the exterior, the outside around the object, is one component reaching it. Warns when a subdomain is in more than one connected component (each one listed, with a point in it, its volume, and whether it is on the object's outer boundary, touching the exterior, or enclosed, with the subdomains around it), and when an enclosed cavity of the outside (a component of region 0 other than the exterior) touches a region of the domain's subdomains. A tape whose value is not a distance, or whose object is unbounded or too long for the resolution (see connectedComponents()), or whose search reaches a_maxCells cells, is not searched; a warning says so.

Template Parameters
TPrecision.
UserPrimitivesThe tape's user primitives.
Parameters
[in]a_modelThe model.
[in]a_tapeThe tape compiled from its object, bounded.
[in]a_domainThe domain's name.
[in]a_resolutionThe resolution h of the search: the solver's cell size, positive.
[in]a_maxCellsThe most cells the search may keep (ComponentOptions::m_maxCells): a search that reaches it is a warning, not an abort.
Returns
The result.

◆ inventory()

template<class T >
std::string EBGeometry::Language::inventory ( const Model< T > &  a_model)

Every name a model offers, as text: its surface labels, the parts of each shape written (with their labels), its regions and materials, and its domains with their subdomains and groups. What ebgstudio check --inventory prints.

Template Parameters
TPrecision.
Parameters
[in]a_modelThe model.
Returns
The text.

◆ parse()

template<class T >
Model< T > EBGeometry::Language::parse ( std::string_view  a_text,
const std::string &  a_name,
Pool &  a_pool,
const Overrides &  a_overrides = {} 
)

Read a model from text.

Template Parameters
TPrecision.
Parameters
[in]a_textThe text.
[in]a_nameThe name of its file, in diagnostics; include()s and meshes are found from its folder.
[in,out]a_poolWhere meshes the model reads are built.
[in]a_overridesValues for its params.
Returns
The model. Throws Error with every diagnostic when the model has errors.

◆ partNames()

std::vector< std::string > EBGeometry::Language::partNames ( std::string_view  a_shape,
uint32_t  a_sides = 0 
)
inline

The part names of a built-in shape, in the order of its parts ("box": xmin, xmax, ymin, ymax, zmin, zmax).

Parameters
[in]a_shapeThe shape's name in the language.
[in]a_sidesA polygon prism's sides (its parts are side0, side1, ..., cap1, cap2).
Returns
The names; empty for a shape without parts or an unknown name.

◆ print()

template<class T >
std::string EBGeometry::Language::print ( const Model< T > &  a_model,
bool  a_flatten = false 
)

A model as text in canonical form: one statement per line, the layout a viewer writes, comments kept.

Template Parameters
TPrecision.
Parameters
[in]a_modelThe model.
[in]a_flattenWhether include()s are resolved into one text (they are kept otherwise, and only the model's first file is printed).
Returns
The text.

◆ read()

template<class T >
Model< T > EBGeometry::Language::read ( const std::string &  a_path,
Pool &  a_pool,
const Overrides &  a_overrides = {} 
)

Read a model: a .ebg file, and the files it includes (a setup file includes the geometry it is a setup of).

Template Parameters
TPrecision.
Parameters
[in]a_pathThe file; a folder is an error.
[in,out]a_poolWhere meshes the model reads are built; it must outlive the model's object.
[in]a_overridesValues for its params.
Returns
The model. Throws Error with every diagnostic when the model has errors.