11#ifndef EBGEOMETRY_REGIONNAMES_HPP
12#define EBGEOMETRY_REGIONNAMES_HPP
81 static constexpr uint32_t
None = 0xFFFFFFFFU;
103 return static_cast<uint32_t
>(
m_domains.size() - 1U);
114 return static_cast<uint32_t
>(
m_domains.size());
127 a_domain <
m_domains.size(),
"RegionNames: domain %u of %zu",
unsigned(a_domain),
m_domains.size());
142 a_domain <
m_domains.size(),
"RegionNames: domain %u of %zu",
unsigned(a_domain),
m_domains.size());
157 a_domain <
m_domains.size(),
"RegionNames: domain %u of %zu",
unsigned(a_domain),
m_domains.size());
171 a_domain <
m_domains.size(),
"RegionNames: domain %u of %zu",
unsigned(a_domain),
m_domains.size());
213 setSubdomain(
const uint32_t a_domain,
const uint32_t a_subdomain, std::string a_name)
216 a_domain <
m_domains.size(),
"RegionNames: domain %u of %zu",
unsigned(a_domain),
m_domains.size());
220 if (subdomains.size() <= a_subdomain) {
221 subdomains.resize(a_subdomain + 1U);
224 subdomains[a_subdomain] = std::move(a_name);
235 subdomain(
const uint32_t a_subdomain,
const bool a_number =
true)
const
237 static const std::vector<std::string> none;
255 m_colors[std::move(a_name)] = a_color;
271 const std::string* name =
nullptr;
273 const auto from = [&name, a_key](
const std::vector<std::string>& a_names) {
274 name = (a_key < a_names.size()) ? &a_names[a_key] :
nullptr;
277 switch (a_coloring) {
308 const auto color = (name ==
nullptr || name->empty()) ?
m_colors.end() :
m_colors.find(*name);
311 a_color = color->second;
403 std::vector<std::string>& groups = this->
groupNames();
405 if (groups.size() <= a_group) {
406 groups.resize(a_group + 1U);
409 groups[a_group] = std::move(a_name);
421 std::vector<std::string>& groups = this->
groupNames();
423 if (a_group < groups.size()) {
424 groups.erase(groups.begin() +
static_cast<std::ptrdiff_t
>(a_group));
437 region(
const uint32_t a_region,
const bool a_number =
true)
const
439 const std::string number = std::to_string(a_region);
443 : (a_region == 0U) ? (a_number ? number +
" " :
"") +
"background"
444 :
"region " + number;
463 material(
const uint32_t a_material,
const bool a_number =
true)
const
476 surface(
const uint32_t a_surface,
const bool a_number =
true)
const
542 [[nodiscard]] std::vector<std::string>&
552 [[nodiscard]]
const std::vector<std::string>&
606 [[nodiscard]]
static std::string
607 named(
const std::vector<std::string>& a_names,
const uint32_t a_index,
const char* a_kind,
const bool a_number)
609 const std::string number = std::to_string(a_index);
611 return (a_index < a_names.size() && !a_names[a_index].empty()) ? (a_number ? number +
" " :
"") + a_names[a_index]
612 : std::string(a_kind) +
" " + number;
DomainSetup: how a domain is made, as an editable value on the host (see Domain).
The tape's front end: Expr, a host-side value that describes a composed object, and the free function...
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
Utility macros for EBGeometry.
#define EBGEOMETRY_REQUIRE(cond,...)
Always-on check of user input and one-time host setup.
Definition EBGeometry_Macros.hpp:200
RegionSettings: how the regions of an object are shown (visibility, coloring, a domain's surface grou...
The pieces of surface an object with regions has, and how a domain's surface groups cover them.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
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
const Region & getRegion(uint32_t a_region) const
A region.
MaterialLabelId getMaterialOf(uint32_t a_region) const
A region's material (see Region::m_material).
uint32_t getNumSurfaces() const noexcept
The number of surfaces: Tape::getNumSurfaces() of a tape compiled from the expression.
const std::string & getMaterialLabelName(MaterialLabelId a_label) const
A material label's name.
SurfaceLabelId getSurfaceLabel(uint32_t a_leaf) const
A leaf's label: that of the nearest labeled node on its path, the leaf's own included,...
uint32_t getNumSurfaceLabels() const noexcept
The number of distinct labels.
uint32_t getLeafOfSurface(uint32_t a_surface) const
The leaf a surface belongs to: SurfaceRef::m_leaf of a tape's closestSurface() that reported it.
uint32_t getNumRegions() const noexcept
The number of regions: the background (region 0), and one per operand of the Overlays,...
const std::string & getSurfaceLabelName(SurfaceLabelId a_label) const
A label's name.
uint32_t getNumMaterialLabels() const noexcept
The number of distinct material labels.
The names of an object's regions, materials, surfaces and surface labels, from its expression's index...
Definition EBGeometry_RegionNames.hpp:39
static std::string named(const std::vector< std::string > &a_names, const uint32_t a_index, const char *a_kind, const bool a_number)
A name from a list, after its number, or the kind and the number.
Definition EBGeometry_RegionNames.hpp:607
const std::string & domainName(const uint32_t a_domain) const
A domain's name.
Definition EBGeometry_RegionNames.hpp:154
void setColor(std::string a_name, const Vec3T< double > &a_color)
Give a name a color: a region's, a material's, a surface label's or a surface group's....
Definition EBGeometry_RegionNames.hpp:253
RegionNames()=default
No names: everything is named by its number.
std::map< std::string, Vec3T< double > > m_colors
The colors given to names.
Definition EBGeometry_RegionNames.hpp:571
std::vector< std::vector< std::string > > m_domainSubdomains
Each domain's subdomains' names.
Definition EBGeometry_RegionNames.hpp:526
uint32_t getActiveDomain() const noexcept
The active domain.
Definition EBGeometry_RegionNames.hpp:182
void setActiveDomain(const uint32_t a_domain)
Make a domain the active one: the one whose surface groups setSurfaceGroup() and surfaceGroup() name.
Definition EBGeometry_RegionNames.hpp:168
std::vector< DomainSetup > m_domains
The domains, their names and their surface groups' names; and the active one, or None.
Definition EBGeometry_RegionNames.hpp:516
uint32_t materialOf(const uint32_t a_region) const noexcept
A region's material.
Definition EBGeometry_RegionNames.hpp:343
void setSurfaceGroup(const uint32_t a_group, std::string a_name)
Name a surface group of the active domain (with no domain registered, of those a viewer shows).
Definition EBGeometry_RegionNames.hpp:401
std::vector< std::vector< std::string > > m_domainGroups
Each domain's surface groups' names.
Definition EBGeometry_RegionNames.hpp:531
std::string surfaceGroup(const uint32_t a_group, const bool a_number=true) const
A surface group's name, with its number or not: "0 inlet" or "inlet"; "surface group 0".
Definition EBGeometry_RegionNames.hpp:502
const std::vector< std::string > & groupNames() const noexcept
The surface groups' names in use.
Definition EBGeometry_RegionNames.hpp:553
std::vector< std::string > m_surfaces
The surfaces' names.
Definition EBGeometry_RegionNames.hpp:581
DomainSetup & getDomain(const uint32_t a_domain)
How a domain is made, to edit.
Definition EBGeometry_RegionNames.hpp:124
bool colorOf(const RegionColoring a_coloring, const uint32_t a_key, Vec3T< double > &a_color) const
The color a key has, colored by a kind of key: by the name of the region, material,...
Definition EBGeometry_RegionNames.hpp:269
std::string surfaceLabel(const uint32_t a_label, const bool a_number=true) const
A surface label's name, with its number or not.
Definition EBGeometry_RegionNames.hpp:489
void setPickedByLabel(const uint32_t a_surface, const bool a_byLabel=true)
Pick a surface by its labels rather than its parts: a click on it picks the faces labeled as the one ...
Definition EBGeometry_RegionNames.hpp:373
std::vector< std::string > m_surfaceLabels
The surface labels' names.
Definition EBGeometry_RegionNames.hpp:591
std::vector< std::string > m_regionNames
The regions' own names (RegionName()), empty for none; the lists below too leave the unnamed empty.
Definition EBGeometry_RegionNames.hpp:561
std::string subdomain(const uint32_t a_subdomain, const bool a_number=true) const
A subdomain's name in the active domain, with its number or not: "1 solid" or "solid"; "subdomain 1".
Definition EBGeometry_RegionNames.hpp:235
std::vector< bool > m_pickedByLabel
Which surfaces are picked by their labels (see setPickedByLabel()).
Definition EBGeometry_RegionNames.hpp:586
uint32_t m_activeDomain
The active domain, or None.
Definition EBGeometry_RegionNames.hpp:536
std::vector< std::string > m_surfaceGroups
The groups' names.
Definition EBGeometry_RegionNames.hpp:596
bool pickedByLabel(const uint32_t a_surface) const noexcept
Whether a surface is picked by its labels (see setPickedByLabel()).
Definition EBGeometry_RegionNames.hpp:389
std::vector< std::string > m_domainNames
The domains' names.
Definition EBGeometry_RegionNames.hpp:521
void removeSurfaceGroup(const uint32_t a_group)
Forget a group's name; the names of the groups after it move down by one (as SurfaceGroups::removeSur...
Definition EBGeometry_RegionNames.hpp:419
std::string surface(const uint32_t a_surface, const bool a_number=true) const
A surface's name, with its number or not: its label's, or "surface 3".
Definition EBGeometry_RegionNames.hpp:476
std::vector< uint32_t > m_regionMaterials
Each region's material label number, or None.
Definition EBGeometry_RegionNames.hpp:566
uint32_t addDomain(std::string a_name, const DomainSetup &a_domain)
Register a domain: its name, and how it is made (its subdomains and surface groups,...
Definition EBGeometry_RegionNames.hpp:92
std::string region(const uint32_t a_region, const bool a_number=true) const
A region's name and material, with its number or not: "2 wall (steel)" or "wall (steel)"; the backgro...
Definition EBGeometry_RegionNames.hpp:437
const DomainSetup & getDomain(const uint32_t a_domain) const
How a domain is made.
Definition EBGeometry_RegionNames.hpp:139
void setSurface(const uint32_t a_surface, std::string a_name)
Name a surface (by default it is named by its label): where it comes from, say ("cylinder,...
Definition EBGeometry_RegionNames.hpp:355
SurfaceInventory m_inventory
The surfaces, from the index.
Definition EBGeometry_RegionNames.hpp:511
const SurfaceInventory & getInventory() const noexcept
What the index says about the surfaces: every surface, its parts, the pairs of regions it may separat...
Definition EBGeometry_RegionNames.hpp:331
void setSubdomain(const uint32_t a_domain, const uint32_t a_subdomain, std::string a_name)
Name a subdomain of a domain ("fluid", "solid").
Definition EBGeometry_RegionNames.hpp:213
RegionNames(const ExprIndex< T > &a_index)
The names an expression's index gives: a region by its name and its material ("2 wall (steel)"),...
Definition EBGeometry_RegionNames.hpp:54
std::vector< std::string > & groupNames() noexcept
The surface groups' names in use: the active domain's, or, with no domain, the names' own.
Definition EBGeometry_RegionNames.hpp:543
void setSurfaceGroup(const uint32_t a_domain, const uint32_t a_group, std::string a_name)
Name a surface group of a domain.
Definition EBGeometry_RegionNames.hpp:195
static constexpr uint32_t None
No material, no label.
Definition EBGeometry_RegionNames.hpp:81
std::vector< std::string > m_materials
The materials' names.
Definition EBGeometry_RegionNames.hpp:576
std::string material(const uint32_t a_material, const bool a_number=true) const
A material's name, with its number or not.
Definition EBGeometry_RegionNames.hpp:463
uint32_t getNumDomains() const noexcept
How many domains are registered.
Definition EBGeometry_RegionNames.hpp:112
What an expression's index says about its surfaces, kept for checking surface groups against them wit...
Definition EBGeometry_SurfacePieces.hpp:234
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
RegionColoring
What a view of regions names a surface by, the key a renderer colors by (Render::ColorBy::Primitive).
Definition EBGeometry_RegionSettings.hpp:28
@ SurfaceGroup
The surface group the surface is in (RegionSettings::m_surfaceGroups), or none.
@ Surface
The surface itself (SurfaceRef::m_surface): each shape, each member of a collection.
@ SurfaceLabel
The surface's label (SurfaceLabel()).
@ Material
That region's material.
@ Region
The region the surface belongs to, as seen.
std::string m_name
Its name (RegionName() on its operand, or on a map above it); empty for none and the background.
Definition EBGeometry_Expr.hpp:1137