https://mooseframework.inl.gov
Functions
CSGUtils Namespace Reference

Functions

CSG::CSGRegion getInnerRegion (const std::vector< std::reference_wrapper< const CSG::CSGSurface >> &surfaces, const libMesh::Point &origin)
 Get inner region of given surfaces, defined as the intersection of halfspaces of each surface. More...
 
void checkValidCSGName (const std::string &name)
 Check name of CSG component for disallowed characters and symbols. More...
 

Function Documentation

◆ checkValidCSGName()

void CSGUtils::checkValidCSGName ( const std::string &  name)

Check name of CSG component for disallowed characters and symbols.

Parameters
namename of CSG component to check

Definition at line 36 of file CSGUtils.C.

Referenced by CSG::CSGCell::CSGCell(), CSG::CSGLattice::CSGLattice(), CSG::CSGSurface::CSGSurface(), and CSG::CSGUniverse::CSGUniverse().

37 {
38  // Check if invalid symbol is present in the name. These include whitespaces and symbols
39  // for halfspaces and region operators
40  const std::regex invalid_symbols(R"([\+\-~|& ])");
41  std::smatch matches;
42 
43  if (std::regex_search(name, matches, invalid_symbols))
44  {
45  char matched_char = name[matches.position(0)];
46  if (matched_char == ' ')
47  mooseError("Detected whitespace in CSG component with name ", name, ". This is not allowed.");
48  else
49  mooseError("Invalid symbol in CSG component with name ", name, ": ", matched_char);
50  }
51 }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311

◆ getInnerRegion()

CSGRegion CSGUtils::getInnerRegion ( const std::vector< std::reference_wrapper< const CSG::CSGSurface >> &  surfaces,
const libMesh::Point origin 
)

Get inner region of given surfaces, defined as the intersection of halfspaces of each surface.

Here, the halfspace direction is determined based on the origin.

Parameters
surfacesList of references to surfaces used to define inner region. This should ideally be defined with the minimum number of surfaces needed to enclose the region
originPoint used to determine halfspace direction when defining intersected region
Returns
inner region defined by surfaces

Definition at line 19 of file CSGUtils.C.

21 {
22  CSGRegion inner_region;
23  for (const auto & surf_ref : surfaces)
24  {
25  const auto & surf = surf_ref.get();
26  const auto direction = surf.getHalfspaceFromPoint(origin);
27  auto halfspace = (direction == CSGSurface::Halfspace::POSITIVE) ? +surf : -surf;
28  inner_region = (inner_region.getRegionType() == CSGRegion::RegionType::EMPTY)
29  ? halfspace
30  : inner_region & halfspace;
31  }
32  return inner_region;
33 }
CSGRegions creates an internal representation of a CSG region, which can refer to an intersection...
Definition: CSGRegion.h:22
RegionType getRegionType() const
Get the region type.
Definition: CSGRegion.h:117