EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_Language.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
12#ifndef EBGEOMETRY_LANGUAGE_HPP
13#define EBGEOMETRY_LANGUAGE_HPP
14
15// Std includes
16#include <cstdint>
17#include <functional>
18#include <map>
19#include <memory>
20#include <optional>
21#include <string>
22#include <string_view>
23#include <utility>
24#include <vector>
25
26// Our includes
27#include "../EBGeometry.hpp"
29
30namespace EBGeometry {
31
38namespace Language {
39
40namespace LanguageDetail {
41
42template <class T>
43class Reader;
44
45} // namespace LanguageDetail
46
55{
56public:
60 enum class Type : uint8_t
61 {
62 Number,
63 Vector,
64 String,
65 Bool
66 };
67
71 struct Value
72 {
77
81 double m_number = 0.0;
82
87
91 std::string m_string;
92
97 };
98
102 Properties() = default;
103
110 Properties(std::string a_owner, const Span& a_span) : m_owner(std::move(a_owner)), m_span(a_span)
111 {}
112
118 [[nodiscard]] EBGEOMETRY_HOST
119 bool
120 has(std::string_view a_key) const noexcept;
121
126 [[nodiscard]] EBGEOMETRY_HOST
127 std::vector<std::string>
128 keys() const;
129
134 [[nodiscard]] EBGEOMETRY_HOST
135 bool
136 empty() const noexcept
137 {
138 return m_entries.empty();
139 }
140
146 [[nodiscard]] EBGEOMETRY_HOST
147 double
148 number(std::string_view a_key) const;
149
156 [[nodiscard]] EBGEOMETRY_HOST
157 double
158 number(std::string_view a_key, double a_fallback) const;
159
166 template <class T>
167 [[nodiscard]] EBGEOMETRY_HOST
169 vector(std::string_view a_key) const;
170
178 template <class T>
179 [[nodiscard]] EBGEOMETRY_HOST
181 vector(std::string_view a_key, const Vec3T<T>& a_fallback) const;
182
188 [[nodiscard]] EBGEOMETRY_HOST
189 const std::string&
190 string(std::string_view a_key) const;
191
198 [[nodiscard]] EBGEOMETRY_HOST
199 const std::string&
200 string(std::string_view a_key, const std::string& a_fallback) const;
201
207 [[nodiscard]] EBGEOMETRY_HOST
208 bool
209 flag(std::string_view a_key) const;
210
217 [[nodiscard]] EBGEOMETRY_HOST
218 bool
219 flag(std::string_view a_key, bool a_fallback) const;
220
228 [[nodiscard]] EBGEOMETRY_HOST
229 uint32_t
230 code(std::string_view a_key, std::initializer_list<std::string_view> a_names) const;
231
237 [[nodiscard]] EBGEOMETRY_HOST
238 Span
239 spanOf(std::string_view a_key) const;
240
246 [[nodiscard]] EBGEOMETRY_HOST
247 const Value*
248 find(std::string_view a_key) const noexcept;
249
256 void
257 set(const std::string& a_key, const Value& a_value);
258
263 [[nodiscard]] EBGEOMETRY_HOST
264 const std::string&
265 owner() const noexcept
266 {
267 return m_owner;
268 }
269
274 [[nodiscard]] EBGEOMETRY_HOST
275 const Span&
276 span() const noexcept
277 {
278 return m_span;
279 }
280
281private:
285 std::string m_owner;
286
290 Span m_span;
291
295 std::vector<std::pair<std::string, Value>> m_entries;
296
303 [[nodiscard]] EBGEOMETRY_HOST
304 const Value*
305 typed(std::string_view a_key, Type a_type) const;
306
312 [[nodiscard]] EBGEOMETRY_HOST
313 Error
314 missing(std::string_view a_key) const;
315
323 template <class T>
324 [[nodiscard]] EBGEOMETRY_HOST
326 narrowed(std::string_view a_key, const Value& a_value) const;
327};
328
337template <class S>
338class Table : public PoolHandle
339{
340 static_assert(std::is_trivially_copyable_v<S>, "Table<S> requires a trivially copyable row type");
341
342public:
346 struct Layout
347 {
352 };
353
357 Table() noexcept = default;
358
365 Table(Pool& a_pool, const std::vector<S>& a_rows)
366 {
367 this->attach(a_pool, "Table");
368
369 m_layout.m_rows.reserveSizedFrom(a_pool, static_cast<uint32_t>(a_rows.size()));
370
371 for (uint32_t i = 0; i < a_rows.size(); i++) {
372 m_layout.m_rows.at(this->base(), i) = a_rows[i];
373 }
374 }
375
382 Table(const Layout& a_layout, const PoolLocation& a_location) noexcept : PoolHandle(a_location), m_layout(a_layout)
383 {}
384
390 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
391 inline const S&
392 operator[](const uint32_t a_row) const noexcept
393 {
394 EBGEOMETRY_EXPECT(a_row < m_layout.m_rows.size());
395
396 return m_layout.m_rows.at(this->base(), a_row);
397 }
398
403 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
404 inline uint32_t
405 size() const noexcept
406 {
407 return m_layout.m_rows.size();
408 }
409
414 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
415 inline const Layout&
416 layout() const noexcept
417 {
418 return m_layout;
419 }
420
426 [[nodiscard]] EBGEOMETRY_HOST
427 inline Table
428 rebasedView(const Pool& a_pool) const noexcept
429 {
430 Table view = *this;
431
432 view.setLocation(this->rebasedLocation(a_pool, m_layout.m_rows.endByte(), "Table"));
433
434 return view;
435 }
436
437private:
441 Layout m_layout;
442};
443
449using Overrides = std::map<std::string, std::string>;
450
454struct Param
455{
459 std::string m_name;
460
464 std::string m_value;
465
469 std::string m_type;
470
475
479 bool m_overridden = false;
480};
481
488{
489public:
494 [[nodiscard]] EBGEOMETRY_HOST
495 const std::string&
496 name() const noexcept
497 {
498 return m_name;
499 }
500
505 [[nodiscard]] EBGEOMETRY_HOST
506 const DomainSetup&
507 setup() const noexcept
508 {
509 return m_setup;
510 }
511
516 [[nodiscard]] EBGEOMETRY_HOST
517 uint32_t
518 getNumSubdomains() const noexcept
519 {
520 return static_cast<uint32_t>(m_subdomainNames.size());
521 }
522
528 [[nodiscard]] EBGEOMETRY_HOST
529 const std::string&
530 subdomainName(uint32_t a_subdomain) const;
531
537 [[nodiscard]] EBGEOMETRY_HOST
538 uint32_t
539 findSubdomain(std::string_view a_name) const noexcept;
540
546 [[nodiscard]] EBGEOMETRY_HOST
547 const Properties&
548 subdomainProperties(uint32_t a_subdomain) const;
549
554 [[nodiscard]] EBGEOMETRY_HOST
555 uint32_t
556 getNumSurfaceGroups() const noexcept
557 {
558 return static_cast<uint32_t>(m_groupNames.size());
559 }
560
566 [[nodiscard]] EBGEOMETRY_HOST
567 const std::string&
568 surfaceGroupName(uint32_t a_group) const;
569
575 [[nodiscard]] EBGEOMETRY_HOST
576 uint32_t
577 findSurfaceGroup(std::string_view a_name) const noexcept;
578
584 [[nodiscard]] EBGEOMETRY_HOST
585 const Properties&
586 surfaceGroupProperties(uint32_t a_group) const;
587
597 template <class S, class F>
598 [[nodiscard]] EBGEOMETRY_HOST
600 volumes(Pool& a_pool, F&& a_fill) const
601 {
602 std::vector<S> rows;
603
604 for (const Properties& properties : m_subdomainProperties) {
605 rows.push_back(a_fill(properties));
606 }
607
608 return Table<S>(a_pool, rows);
609 }
610
620 template <class S, class F>
621 [[nodiscard]] EBGEOMETRY_HOST
623 surfaces(Pool& a_pool, F&& a_fill) const
624 {
625 std::vector<S> rows;
626
627 for (const Properties& properties : m_groupProperties) {
628 rows.push_back(a_fill(properties));
629 }
630
631 return Table<S>(a_pool, rows);
632 }
633
638 [[nodiscard]] EBGEOMETRY_HOST
639 const Span&
640 span() const noexcept
641 {
642 return m_span;
643 }
644
650 [[nodiscard]] EBGEOMETRY_HOST
651 const Span&
652 subdomainSpan(uint32_t a_subdomain) const;
653
659 [[nodiscard]] EBGEOMETRY_HOST
660 const Span&
661 surfaceGroupSpan(uint32_t a_group) const;
662
663private:
664 template <class T>
665 friend class LanguageDetail::Reader;
666
670 std::string m_name;
671
675 Span m_span;
676
680 DomainSetup m_setup;
681
685 std::vector<std::string> m_subdomainNames;
686
690 std::vector<Properties> m_subdomainProperties;
691
695 std::vector<Span> m_subdomainSpans;
696
700 std::vector<std::string> m_groupNames;
701
705 std::vector<Properties> m_groupProperties;
706
710 std::vector<Span> m_groupSpans;
711};
712
718{
722 enum class Kind : uint8_t
723 {
724 Volume,
725 Surface
726 };
727
731 std::string m_name;
732
737
741 std::string m_domainA;
742
746 std::string m_partA;
747
751 std::string m_domainB;
752
756 std::string m_partB;
757
762
767};
768
773{
777 static constexpr uint32_t None = 0xFFFFFFFFU;
778
782 std::string m_shape;
783
787 std::vector<std::string> m_parts;
788
793 std::vector<std::string> m_partLabels;
794
798 std::vector<bool> m_partLabeled;
799
804 std::string m_label;
805
810};
811
817{
822 std::vector<std::string> m_names;
823
829
833 uint32_t m_uses = 0;
834};
835
846template <class T>
848{
849public:
854 [[nodiscard]] EBGEOMETRY_HOST
855 const Expr<T>&
856 object() const noexcept
857 {
858 return m_neighborhood.object();
859 }
860
865 [[nodiscard]] EBGEOMETRY_HOST
866 const DomainSetup&
867 setup() const noexcept
868 {
869 return m_setup;
870 }
871
876 [[nodiscard]] EBGEOMETRY_HOST
878 neighborhood() const noexcept
879 {
880 return m_neighborhood;
881 }
882
888 [[nodiscard]] EBGEOMETRY_HOST
889 const RegionNames&
890 names() const noexcept
891 {
892 return m_names;
893 }
894
895private:
896 template <class U>
897 friend class Model;
898
906 DomainObject(RegionNeighborhood<T> a_neighborhood, DomainSetup a_setup, RegionNames a_names)
907 : m_neighborhood(std::move(a_neighborhood)), m_setup(std::move(a_setup)), m_names(std::move(a_names))
908 {}
909
913 RegionNeighborhood<T> m_neighborhood;
914
918 DomainSetup m_setup;
919
923 RegionNames m_names;
924};
925
935template <class T>
936class Model
937{
938public:
943 [[nodiscard]] EBGEOMETRY_HOST
944 const Expr<T>&
945 object() const noexcept
946 {
947 return *m_object;
948 }
949
954 [[nodiscard]] EBGEOMETRY_HOST
955 const ExprIndex<T>&
956 index() const noexcept
957 {
958 return *m_index;
959 }
960
965 [[nodiscard]] EBGEOMETRY_HOST
966 uint32_t
967 getNumMaterials() const noexcept
968 {
969 return static_cast<uint32_t>(m_materials.size());
970 }
971
977 [[nodiscard]] EBGEOMETRY_HOST
978 const Properties&
979 materialProperties(uint32_t a_material) const;
980
985 [[nodiscard]] EBGEOMETRY_HOST
986 uint32_t
987 getNumDomains() const noexcept
988 {
989 return static_cast<uint32_t>(m_domains.size());
990 }
991
997 [[nodiscard]] EBGEOMETRY_HOST
998 const ModelDomain&
999 domain(uint32_t a_domain) const;
1000
1006 [[nodiscard]] EBGEOMETRY_HOST
1007 const ModelDomain&
1008 domain(std::string_view a_name) const;
1009
1014 [[nodiscard]] EBGEOMETRY_HOST
1015 const std::vector<Coupling>&
1016 couplings() const noexcept
1017 {
1018 return m_couplings;
1019 }
1020
1025 [[nodiscard]] EBGEOMETRY_HOST
1026 const std::vector<Param>&
1027 params() const noexcept
1028 {
1029 return m_params;
1030 }
1031
1036 [[nodiscard]] EBGEOMETRY_HOST
1037 const std::vector<Diagnostic>&
1038 warnings() const noexcept
1039 {
1040 return m_warnings;
1041 }
1042
1047 [[nodiscard]] EBGEOMETRY_HOST
1048 const std::vector<std::string>&
1049 files() const noexcept
1050 {
1051 return m_files;
1052 }
1053
1058 [[nodiscard]] EBGEOMETRY_HOST
1059 const Properties&
1060 view() const noexcept
1061 {
1062 return m_view;
1063 }
1064
1069 [[nodiscard]] EBGEOMETRY_HOST
1070 const std::vector<ShapeSite>&
1071 shapes() const noexcept
1072 {
1073 return m_shapes;
1074 }
1075
1081 [[nodiscard]] EBGEOMETRY_HOST
1082 const ShapeSite*
1083 siteOfLeaf(const uint32_t a_leaf) const noexcept
1084 {
1085 return (a_leaf < m_leafSites.size() && m_leafSites[a_leaf] != ShapeSite::None) ? &m_shapes[m_leafSites[a_leaf]]
1086 : nullptr;
1087 }
1088
1096 [[nodiscard]] EBGEOMETRY_HOST
1097 const NodeSite*
1098 siteOfNode(const uint32_t a_node) const noexcept
1099 {
1100 return (a_node < m_nodeSiteOf.size() && m_nodeSiteOf[a_node] != ShapeSite::None)
1101 ? &m_nodeSites[m_nodeSiteOf[a_node]]
1102 : nullptr;
1103 }
1104
1110 [[nodiscard]] EBGEOMETRY_HOST
1111 uint32_t
1112 siteIndexOfLeaf(const uint32_t a_leaf) const noexcept
1113 {
1114 return a_leaf < m_leafSites.size() ? m_leafSites[a_leaf] : ShapeSite::None;
1115 }
1116
1121 [[nodiscard]] EBGEOMETRY_HOST
1122 const std::vector<Syntax::File>&
1123 sources() const noexcept
1124 {
1125 return m_sources;
1126 }
1127
1133 [[nodiscard]] EBGEOMETRY_HOST
1135 names() const;
1136
1144 [[nodiscard]] EBGEOMETRY_HOST
1146 domainObject(std::string_view a_domain) const;
1147
1158 template <class S, class F>
1159 [[nodiscard]] EBGEOMETRY_HOST
1160 Table<S>
1161 regions(Pool& a_pool, F&& a_fill) const
1162 {
1163 std::vector<S> rows;
1164
1165 const Properties none("a region without a material", Span{});
1166
1167 for (uint32_t r = 0; r < m_index->getNumRegions(); r++) {
1168 const MaterialLabelId material = m_index->getMaterialOf(r);
1169
1170 rows.push_back(a_fill(material.isNone() ? none : m_materials[material.value()]));
1171 }
1172
1173 return Table<S>(a_pool, rows);
1174 }
1175
1176private:
1177 template <class U>
1178 friend class LanguageDetail::Reader;
1179
1183 Model() = default;
1184
1192 [[nodiscard]] EBGEOMETRY_HOST
1194 namesFor(const ExprIndex<T>& a_index,
1195 const std::vector<std::pair<const ModelDomain*, DomainSetup>>& a_domains,
1196 const std::function<uint32_t(uint32_t)>& a_wholeSurface) const;
1197
1201 std::optional<Expr<T>> m_object;
1202
1206 std::shared_ptr<const ExprIndex<T>> m_index;
1207
1211 std::vector<Properties> m_materials;
1212
1216 std::vector<ModelDomain> m_domains;
1217
1221 std::vector<Coupling> m_couplings;
1222
1226 std::vector<Param> m_params;
1227
1231 std::vector<Diagnostic> m_warnings;
1232
1236 std::vector<std::string> m_files;
1237
1241 Properties m_view;
1242
1246 std::vector<ShapeSite> m_shapes;
1247
1251 std::vector<uint32_t> m_leafSites;
1252
1256 std::vector<NodeSite> m_nodeSites;
1257
1261 std::vector<uint32_t> m_nodeSiteOf;
1262
1266 std::vector<Syntax::File> m_sources;
1267};
1268
1277template <class T>
1278[[nodiscard]] EBGEOMETRY_HOST
1279Model<T>
1280read(const std::string& a_path, Pool& a_pool, const Overrides& a_overrides = {});
1281
1291template <class T>
1292[[nodiscard]] EBGEOMETRY_HOST
1293Model<T>
1294parse(std::string_view a_text, const std::string& a_name, Pool& a_pool, const Overrides& a_overrides = {});
1295
1300{
1305 bool m_complete = true;
1306
1310 std::vector<Diagnostic> m_findings;
1311};
1312
1326template <class T, class... UserPrimitives>
1327[[nodiscard]] EBGEOMETRY_HOST
1329completeness(const Model<T>& a_model, const Tape<T, UserPrimitives...>& a_tape, std::string_view a_domain);
1330
1351template <class T, class... UserPrimitives>
1352[[nodiscard]] EBGEOMETRY_HOST
1354completeness(const Model<T>& a_model,
1355 const Tape<T, UserPrimitives...>& a_tape,
1356 std::string_view a_domain,
1357 T a_resolution,
1358 uint64_t a_maxCells = ComponentOptions<T>::DefaultMaxCells);
1359
1366[[nodiscard]] EBGEOMETRY_HOST
1367inline std::vector<std::string>
1368partNames(std::string_view a_shape, uint32_t a_sides = 0);
1369
1378template <class T>
1379[[nodiscard]] EBGEOMETRY_HOST
1380std::string
1381inventory(const Model<T>& a_model);
1382
1391template <class T>
1392[[nodiscard]] EBGEOMETRY_HOST
1393std::string
1394print(const Model<T>& a_model, bool a_flatten = false);
1395
1396} // namespace Language
1397} // namespace EBGeometry
1398
1399#include "EBGeometry_LanguageImplem.hpp"
1400
1401#endif
#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
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