12#ifndef EBGEOMETRY_LANGUAGE_HPP
13#define EBGEOMETRY_LANGUAGE_HPP
27#include "../EBGeometry.hpp"
40namespace LanguageDetail {
110 Properties(std::string a_owner,
const Span& a_span) : m_owner(std::move(a_owner)), m_span(a_span)
120 has(std::string_view a_key)
const noexcept;
127 std::vector<std::string>
138 return m_entries.empty();
158 number(std::string_view a_key,
double a_fallback)
const;
200 string(std::string_view a_key,
const std::string& a_fallback)
const;
209 flag(std::string_view a_key)
const;
219 flag(std::string_view a_key,
bool a_fallback)
const;
230 code(std::string_view a_key, std::initializer_list<std::string_view> a_names)
const;
248 find(std::string_view a_key)
const noexcept;
257 set(
const std::string& a_key,
const Value& a_value);
295 std::vector<std::pair<std::string, Value>> m_entries;
305 typed(std::string_view a_key,
Type a_type)
const;
314 missing(std::string_view a_key)
const;
326 narrowed(std::string_view a_key,
const Value& a_value)
const;
340 static_assert(std::is_trivially_copyable_v<S>,
"Table<S> requires a trivially copyable row type");
367 this->
attach(a_pool,
"Table");
371 for (uint32_t i = 0; i < a_rows.size(); i++) {
520 return static_cast<uint32_t
>(m_subdomainNames.size());
558 return static_cast<uint32_t
>(m_groupNames.size());
597 template <
class S,
class F>
604 for (
const Properties& properties : m_subdomainProperties) {
605 rows.push_back(a_fill(properties));
620 template <
class S,
class F>
627 for (
const Properties& properties : m_groupProperties) {
628 rows.push_back(a_fill(properties));
685 std::vector<std::string> m_subdomainNames;
690 std::vector<Properties> m_subdomainProperties;
695 std::vector<Span> m_subdomainSpans;
700 std::vector<std::string> m_groupNames;
705 std::vector<Properties> m_groupProperties;
710 std::vector<Span> m_groupSpans;
777 static constexpr uint32_t
None = 0xFFFFFFFFU;
858 return m_neighborhood.object();
880 return m_neighborhood;
907 : m_neighborhood(std::move(a_neighborhood)), m_setup(std::move(a_setup)), m_names(std::move(a_names))
969 return static_cast<uint32_t
>(m_materials.size());
989 return static_cast<uint32_t
>(m_domains.size());
1015 const std::vector<Coupling>&
1026 const std::vector<Param>&
1037 const std::vector<Diagnostic>&
1048 const std::vector<std::string>&
1070 const std::vector<ShapeSite>&
1085 return (a_leaf < m_leafSites.size() && m_leafSites[a_leaf] !=
ShapeSite::None) ? &m_shapes[m_leafSites[a_leaf]]
1100 return (a_node < m_nodeSiteOf.size() && m_nodeSiteOf[a_node] !=
ShapeSite::None)
1101 ? &m_nodeSites[m_nodeSiteOf[a_node]]
1114 return a_leaf < m_leafSites.size() ? m_leafSites[a_leaf] :
ShapeSite::None;
1122 const std::vector<Syntax::File>&
1158 template <
class S,
class F>
1163 std::vector<S> rows;
1167 for (uint32_t r = 0; r < m_index->getNumRegions(); r++) {
1170 rows.push_back(a_fill(material.
isNone() ? none : m_materials[material.
value()]));
1195 const std::vector<std::pair<const ModelDomain*, DomainSetup>>& a_domains,
1196 const std::function<uint32_t(uint32_t)>& a_wholeSurface)
const;
1201 std::optional<Expr<T>> m_object;
1206 std::shared_ptr<const ExprIndex<T>> m_index;
1211 std::vector<Properties> m_materials;
1216 std::vector<ModelDomain> m_domains;
1221 std::vector<Coupling> m_couplings;
1226 std::vector<Param> m_params;
1231 std::vector<Diagnostic> m_warnings;
1236 std::vector<std::string> m_files;
1246 std::vector<ShapeSite> m_shapes;
1251 std::vector<uint32_t> m_leafSites;
1256 std::vector<NodeSite> m_nodeSites;
1261 std::vector<uint32_t> m_nodeSiteOf;
1266 std::vector<Syntax::File> m_sources;
1294parse(std::string_view a_text,
const std::string& a_name,
Pool& a_pool,
const Overrides& a_overrides = {});
1326template <
class T,
class... UserPrimitives>
1351template <
class T,
class... UserPrimitives>
1356 std::string_view a_domain,
1367inline std::vector<std::string>
1399#include "EBGeometry_LanguageImplem.hpp"
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
The .ebg language's text: positions, diagnostics, tokens and the syntax tree a file is parsed into.
#define EBGEOMETRY_EXPECT(cond)
Runtime precondition assertion for EBGeometry.
Definition EBGeometry_Macros.hpp:269
How a domain is made: its subdomains (the regions each computes in) and its surface groups (the selec...
Definition EBGeometry_DomainSetup.hpp:39
The nodes of an expression, numbered, with the leaves below each and their labels: on the host,...
Definition EBGeometry_Expr.hpp:1058
A composed object: an immutable tree of shapes and operations, built on the host and compiled by a Ta...
Definition EBGeometry_Expr.hpp:452
A domain's own object: the regions of its subdomains and their neighbors, with the domain's setup and...
Definition EBGeometry_Language.hpp:848
const RegionNeighborhood< T > & neighborhood() const noexcept
The regions kept, and the maps of regions and surfaces to the model's.
Definition EBGeometry_Language.hpp:878
const RegionNames & names() const noexcept
The model's names for a viewer, for object(): its regions, materials and labels, the domain with the ...
Definition EBGeometry_Language.hpp:890
const DomainSetup & setup() const noexcept
The domain's setup, for a tape of object().
Definition EBGeometry_Language.hpp:867
const Expr< T > & object() const noexcept
The object, to compile into a tape.
Definition EBGeometry_Language.hpp:856
What reading a model throws when it has errors: every error found (not only the first),...
Definition EBGeometry_LanguageSyntax.hpp:111
Definition EBGeometry_Language.hpp:43
A domain of a model: its name, its setup, and the names and properties of its subdomains and surface ...
Definition EBGeometry_Language.hpp:488
const Properties & subdomainProperties(uint32_t a_subdomain) const
A subdomain's properties: its own over its regions' material's.
const DomainSetup & setup() const noexcept
How the domain is made.
Definition EBGeometry_Language.hpp:507
const std::string & surfaceGroupName(uint32_t a_group) const
A surface group's name.
uint32_t getNumSurfaceGroups() const noexcept
How many surface groups.
Definition EBGeometry_Language.hpp:556
const std::string & subdomainName(uint32_t a_subdomain) const
A subdomain's name.
Table< S > surfaces(Pool &a_pool, F &&a_fill) const
A table with one row per surface group, each filled from the group's properties: what a kernel indexe...
Definition EBGeometry_Language.hpp:623
const Span & span() const noexcept
Where the domain is written.
Definition EBGeometry_Language.hpp:640
const Properties & surfaceGroupProperties(uint32_t a_group) const
A surface group's properties.
uint32_t findSurfaceGroup(std::string_view a_name) const noexcept
A surface group by name.
uint32_t getNumSubdomains() const noexcept
How many subdomains.
Definition EBGeometry_Language.hpp:518
const Span & subdomainSpan(uint32_t a_subdomain) const
Where a subdomain is written.
const std::string & name() const noexcept
The name.
Definition EBGeometry_Language.hpp:496
const Span & surfaceGroupSpan(uint32_t a_group) const
Where a surface group is written.
uint32_t findSubdomain(std::string_view a_name) const noexcept
A subdomain by name.
Table< S > volumes(Pool &a_pool, F &&a_fill) const
A table with one row per subdomain, each filled from the subdomain's properties: what a kernel indexe...
Definition EBGeometry_Language.hpp:600
A model read from a .ebg file and the files it includes: its object, the names of its regions,...
Definition EBGeometry_Language.hpp:937
const NodeSite * siteOfNode(const uint32_t a_node) const noexcept
The shape value that makes a node of the object: its names, where its call is written,...
Definition EBGeometry_Language.hpp:1098
const Properties & materialProperties(uint32_t a_material) const
A material's properties (none for a material no material statement declares).
uint32_t siteIndexOfLeaf(const uint32_t a_leaf) const noexcept
The index among shapes() of the shape call a leaf comes from.
Definition EBGeometry_Language.hpp:1112
RegionNames names() const
The model's names for a viewer: regions, materials and labels, every domain's setup with the names of...
const std::vector< std::string > & files() const noexcept
Every file read, the model's own and the meshes: what a viewer watches to reload.
Definition EBGeometry_Language.hpp:1049
const Expr< T > & object() const noexcept
The object, to compile into a tape.
Definition EBGeometry_Language.hpp:945
uint32_t getNumMaterials() const noexcept
How many materials: every name a region uses, numbered as the index numbers them (MaterialLabelId).
Definition EBGeometry_Language.hpp:967
const std::vector< Diagnostic > & warnings() const noexcept
The warnings found reading it.
Definition EBGeometry_Language.hpp:1038
const ExprIndex< T > & index() const noexcept
The object's index: its regions, region groups, materials and surface labels by name.
Definition EBGeometry_Language.hpp:956
DomainObject< T > domainObject(std::string_view a_domain) const
A domain's own object: the regions its subdomains compute in, and their neighbors (see regionNeighbor...
const ModelDomain & domain(std::string_view a_name) const
A domain by name.
const ShapeSite * siteOfLeaf(const uint32_t a_leaf) const noexcept
The shape call a leaf of the object comes from: what a viewer names a picked surface by.
Definition EBGeometry_Language.hpp:1083
const ModelDomain & domain(uint32_t a_domain) const
A domain by number, in the order written.
const Properties & view() const noexcept
The view block's properties (camera, colors): for viewers; programs ignore them.
Definition EBGeometry_Language.hpp:1060
Table< S > regions(Pool &a_pool, F &&a_fill) const
A table with one row per region of the object (region 0, outside, first), each filled from its materi...
Definition EBGeometry_Language.hpp:1161
const std::vector< Syntax::File > & sources() const noexcept
The parsed files, the model's first.
Definition EBGeometry_Language.hpp:1123
const std::vector< Param > & params() const noexcept
The params, in the order written.
Definition EBGeometry_Language.hpp:1027
const std::vector< Coupling > & couplings() const noexcept
The couplings.
Definition EBGeometry_Language.hpp:1016
const std::vector< ShapeSite > & shapes() const noexcept
The shapes the text builds, in the order built.
Definition EBGeometry_Language.hpp:1071
uint32_t getNumDomains() const noexcept
How many domains.
Definition EBGeometry_Language.hpp:987
The properties a material, subdomain, surface group, coupling or the view block carries: numbers,...
Definition EBGeometry_Language.hpp:55
Properties()=default
No properties, owned by nothing written.
double number(std::string_view a_key) const
A number.
bool has(std::string_view a_key) const noexcept
Whether a key is set.
const Value * find(std::string_view a_key) const noexcept
A value by key, or nullptr.
bool flag(std::string_view a_key) const
A bool, true or false.
Vec3T< T > vector(std::string_view a_key) const
A vector.
std::vector< std::string > keys() const
The keys, in the order written.
Span spanOf(std::string_view a_key) const
Where a key's value is written; where the owner is when the key is missing.
Properties(std::string a_owner, const Span &a_span)
No properties yet, of an owner.
Definition EBGeometry_Language.hpp:110
double number(std::string_view a_key, double a_fallback) const
A number, 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"...
const Span & span() const noexcept
Where the owner is written.
Definition EBGeometry_Language.hpp:276
const std::string & owner() const noexcept
The owner in words.
Definition EBGeometry_Language.hpp:265
bool empty() const noexcept
Whether there are none.
Definition EBGeometry_Language.hpp:136
const std::string & string(std::string_view a_key) const
A string.
Type
The types a value can have.
Definition EBGeometry_Language.hpp:61
bool flag(std::string_view a_key, bool a_fallback) const
A bool, or a fallback when the key is missing.
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 std::string &a_fallback) const
A string, or a fallback when the key is missing.
void set(const std::string &a_key, const Value &a_value)
Set a key, replacing its value if it is set.
A table of a program's own rows in a pool, one per region, subdomain or surface group,...
Definition EBGeometry_Language.hpp:339
Table rebasedView(const Pool &a_pool) const noexcept
The same table in another pool with the same layout (a mirror).
Definition EBGeometry_Language.hpp:428
Table() noexcept=default
An empty table in no pool.
const Layout & layout() const noexcept
Where the rows are.
Definition EBGeometry_Language.hpp:416
const S & operator[](const uint32_t a_row) const noexcept
A row.
Definition EBGeometry_Language.hpp:392
uint32_t size() const noexcept
How many rows.
Definition EBGeometry_Language.hpp:405
Table(const Layout &a_layout, const PoolLocation &a_location) noexcept
A table at a location.
Definition EBGeometry_Language.hpp:382
Base of every pool-resident handle: the one PoolLocation its arrays resolve against.
Definition EBGeometry_Pool.hpp:563
PoolLocation rebasedLocation(const Pool &a_pool, uint64_t a_endByte, const char *a_who) const noexcept
The location of this handle's arrays in another pool of its mirror chain; see PoolLocation::rebasedOn...
Definition EBGeometry_Pool.hpp:680
PoolHandle() noexcept=default
An unset location; the first reservation attaches it.
void attach(const Pool &a_pool, const char *a_who, const bool a_deviceWritten=false) noexcept
Follow a_pool, as the first reservation does; see PoolLocation::attach().
Definition EBGeometry_Pool.hpp:665
void * base() noexcept
The base address this handle's offsets resolve against; see PoolLocation::base().
Definition EBGeometry_Pool.hpp:639
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:205
The names of an object's regions, materials, surfaces and surface labels, from its expression's index...
Definition EBGeometry_RegionNames.hpp:39
Some regions of an expression with their neighbors: a smaller expression in which those regions have ...
Definition EBGeometry_RegionNeighborhood.hpp:39
A composed object compiled into a pool: a trivially copyable handle that evaluates the object's signe...
Definition EBGeometry_Tape.hpp:758
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
static constexpr Vec3T< T > zeros() noexcept
Return a vector with x = y = z = 0.
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'...
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 setu...
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.
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,...
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,...
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 l...
std::map< std::string, std::string > Overrides
Values for a model's params, by name, each written as in a file ("0.5", "(1, 0, 0)",...
Definition EBGeometry_Language.hpp:449
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
How connectedComponents() resolves the space it searches.
Definition EBGeometry_ConnectedComponents.hpp:57
constexpr uint32_t value() const noexcept
The number, for indexing an array of your own.
Definition EBGeometry_LabelId.hpp:74
constexpr bool isNone() const noexcept
Whether this is no label.
Definition EBGeometry_LabelId.hpp:85
Whether a domain is complete for a solver, and what is missing.
Definition EBGeometry_Language.hpp:1300
std::vector< Diagnostic > m_findings
What is missing (errors), and what may be (warnings), at the lines to change.
Definition EBGeometry_Language.hpp:1310
bool m_complete
Whether every subdomain has properties and every piece of surface bounding the domain is in a surface...
Definition EBGeometry_Language.hpp:1305
A coupling of two domains: two subdomains that hold the same regions (volume), or two surface groups ...
Definition EBGeometry_Language.hpp:718
std::string m_partB
The second end's subdomain or surface group.
Definition EBGeometry_Language.hpp:756
std::string m_name
The name.
Definition EBGeometry_Language.hpp:731
Properties m_properties
Its properties.
Definition EBGeometry_Language.hpp:761
std::string m_domainA
The first end's domain.
Definition EBGeometry_Language.hpp:741
Kind
What is coupled.
Definition EBGeometry_Language.hpp:723
@ Surface
Two surface groups.
std::string m_domainB
The second end's domain.
Definition EBGeometry_Language.hpp:751
Kind m_kind
Volume or surface.
Definition EBGeometry_Language.hpp:736
std::string m_partA
The first end's subdomain or surface group.
Definition EBGeometry_Language.hpp:746
Span m_span
Where it is written.
Definition EBGeometry_Language.hpp:766
A node of the object that a shape value of the text makes: what a selector surfaces(name) names,...
Definition EBGeometry_Language.hpp:817
std::vector< std::string > m_names
The names of the shape values holding it, in the order defined; empty when no name does (a call writt...
Definition EBGeometry_Language.hpp:822
uint32_t m_uses
How many places of the object use it (a value used twice: 2).
Definition EBGeometry_Language.hpp:833
Span m_span
Where the call making it is written (the outermost, for a chain of calls making the same shapes); lin...
Definition EBGeometry_Language.hpp:828
A param of a model: its name, its value as text (after overrides), its type, and where it is written.
Definition EBGeometry_Language.hpp:455
std::string m_value
The value, as text in the language.
Definition EBGeometry_Language.hpp:464
std::string m_name
The name.
Definition EBGeometry_Language.hpp:459
bool m_overridden
Whether an override set its value.
Definition EBGeometry_Language.hpp:479
std::string m_type
The type: "number", "vector", "string", "bool" or "shape".
Definition EBGeometry_Language.hpp:469
Span m_span
Where the param is written.
Definition EBGeometry_Language.hpp:474
One value, and where it is written.
Definition EBGeometry_Language.hpp:72
Type m_type
Its type.
Definition EBGeometry_Language.hpp:76
Span m_span
Where the value is written.
Definition EBGeometry_Language.hpp:96
double m_number
A number (or a bool, 1 or 0).
Definition EBGeometry_Language.hpp:81
Vec3T< double > m_vector
A vector.
Definition EBGeometry_Language.hpp:86
std::string m_string
A string.
Definition EBGeometry_Language.hpp:91
A shape the model's text builds, and where: what the inventory lists and a viewer names parts by.
Definition EBGeometry_Language.hpp:773
static constexpr uint32_t None
No site (a leaf the text did not build).
Definition EBGeometry_Language.hpp:777
std::vector< std::string > m_parts
Its part names, in the order of its parts (a mesh's: its face groups).
Definition EBGeometry_Language.hpp:787
Span m_span
Where the call is written.
Definition EBGeometry_Language.hpp:809
std::vector< std::string > m_partLabels
The surface label each part gets ("" for none), as the text labels the shape where it is used; labels...
Definition EBGeometry_Language.hpp:793
std::string m_shape
The shape's name in the language ("box", "mesh").
Definition EBGeometry_Language.hpp:782
std::string m_label
The shape's own label, as the text gives it where the shape is used ("" for none); labels separated b...
Definition EBGeometry_Language.hpp:804
std::vector< bool > m_partLabeled
Whether the text labels each part (a mesh's face groups label its parts without it).
Definition EBGeometry_Language.hpp:798
Where a piece of text is: its file, its first and one-past-last byte, and the line and column of its ...
Definition EBGeometry_LanguageSyntax.hpp:34
Where the rows are in the pool.
Definition EBGeometry_Language.hpp:347
PODVector< S > m_rows
The rows.
Definition EBGeometry_Language.hpp:351
Placement-independent descriptor of a POD array inside a Pool.
Definition EBGeometry_PODVector.hpp:131
void reserveSizedFrom(Pool &a_pool, uint32_t a_count)
Reserve a_count slots from a_pool and count them all as elements.
Definition EBGeometry_PODVector.hpp:181
uint64_t endByte() const noexcept
One past the last byte this array occupies, measured from the pool base.
Definition EBGeometry_PODVector.hpp:264
T & at(void *a_base, uint32_t a_i) const noexcept
Mutable element access against a_base.
Definition EBGeometry_PODVector.hpp:220
uint32_t size() const noexcept
Number of constructed elements.
Definition EBGeometry_PODVector.hpp:248
Where a pool-resident descriptor resolves its offsets, and the rules for moving it.
Definition EBGeometry_Pool.hpp:99