https://mooseframework.inl.gov
Protected Member Functions | Protected Attributes | Friends | List of all members
CSG::CSGSurfaceList Class Reference

CSGSurfaceList is a container for storing CSGSurface objects in the CSGBase object. More...

#include <CSGSurfaceList.h>

Protected Member Functions

 CSGSurfaceList ()
 Default constructor. More...
 
virtual ~CSGSurfaceList ()=default
 Destructor. More...
 
std::unordered_map< std::string, std::unique_ptr< CSGSurface > > & getSurfaceListMap ()
 Get map of all names to surfaces in surface list. More...
 
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces () const
 Get list of references to all surfaces in surface list. More...
 
CSGSurfacegetSurface (const std::string &name) const
 Get a surface by name. More...
 
CSGSurfaceaddSurface (std::unique_ptr< CSGSurface > surf)
 add a surface object to existing SurfaceList. More...
 
void renameSurface (const CSGSurface &surface, const std::string &name)
 rename the specified surface More...
 

Protected Attributes

std::unordered_map< std::string, std::unique_ptr< CSGSurface > > _surfaces
 Mapping of surface names to pointers of stored surface objects. More...
 

Friends

class CSGBase
 

Detailed Description

CSGSurfaceList is a container for storing CSGSurface objects in the CSGBase object.

Definition at line 20 of file CSGSurfaceList.h.

Constructor & Destructor Documentation

◆ CSGSurfaceList()

CSG::CSGSurfaceList::CSGSurfaceList ( )
protected

Default constructor.

Definition at line 20 of file CSGSurfaceList.C.

20 {}

◆ ~CSGSurfaceList()

virtual CSG::CSGSurfaceList::~CSGSurfaceList ( )
protectedvirtualdefault

Destructor.

Member Function Documentation

◆ addSurface()

CSGSurface & CSG::CSGSurfaceList::addSurface ( std::unique_ptr< CSGSurface surf)
protected

add a surface object to existing SurfaceList.

Ownership of surface will be transferred to surface list object that calls this function

Parameters
surfCSGSurface to add
Returns
reference to CSGSurface

Definition at line 42 of file CSGSurfaceList.C.

Referenced by CSG::CSGBase::addSurface(), CSG::CSGBase::joinSurfaceList(), and renameSurface().

43 {
44  auto surf_name = surf->getName();
45  auto [it, inserted] = _surfaces.emplace(surf_name, std::move(surf));
46  if (!inserted)
47  mooseError("Surface with name " + surf_name + " already exists in geometry.");
48  return *it->second;
49 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
std::unordered_map< std::string, std::unique_ptr< CSGSurface > > _surfaces
Mapping of surface names to pointers of stored surface objects.

◆ getAllSurfaces()

std::vector< std::reference_wrapper< const CSGSurface > > CSG::CSGSurfaceList::getAllSurfaces ( ) const
protected

Get list of references to all surfaces in surface list.

Returns
list of references to surfaces

Definition at line 33 of file CSGSurfaceList.C.

Referenced by CSG::CSGBase::getAllSurfaces().

34 {
35  std::vector<std::reference_wrapper<const CSGSurface>> surfaces;
36  for (auto it = _surfaces.begin(); it != _surfaces.end(); ++it)
37  surfaces.push_back(*(it->second));
38  return surfaces;
39 }
std::unordered_map< std::string, std::unique_ptr< CSGSurface > > _surfaces
Mapping of surface names to pointers of stored surface objects.

◆ getSurface()

CSGSurface & CSG::CSGSurfaceList::getSurface ( const std::string &  name) const
protected

Get a surface by name.

Parameters
namename of surface
Returns
reference to CSGSurface of the specified name

Definition at line 23 of file CSGSurfaceList.C.

Referenced by CSG::CSGBase::checkRegionSurfaces(), CSG::CSGBase::getSurface(), and CSG::CSGBase::getSurfaceByName().

24 {
25  auto surf = _surfaces.find(name);
26  if (surf == _surfaces.end())
27  mooseError("No surface by name " + name + " exists in the geometry.");
28  else
29  return *(surf->second);
30 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
std::unordered_map< std::string, std::unique_ptr< CSGSurface > > _surfaces
Mapping of surface names to pointers of stored surface objects.

◆ getSurfaceListMap()

std::unordered_map<std::string, std::unique_ptr<CSGSurface> >& CSG::CSGSurfaceList::getSurfaceListMap ( )
inlineprotected

Get map of all names to surfaces in surface list.

Returns
map of all names to CSGSurface pointers

Definition at line 38 of file CSGSurfaceList.h.

Referenced by CSG::CSGBase::joinSurfaceList().

39  {
40  return _surfaces;
41  }
std::unordered_map< std::string, std::unique_ptr< CSGSurface > > _surfaces
Mapping of surface names to pointers of stored surface objects.

◆ renameSurface()

void CSG::CSGSurfaceList::renameSurface ( const CSGSurface surface,
const std::string &  name 
)
protected

rename the specified surface

Parameters
namenew name of surface

Definition at line 52 of file CSGSurfaceList.C.

Referenced by CSG::CSGBase::renameSurface().

53 {
54  // check that this surface passed in is actually in the same surface that is in the surface list
55  auto prev_name = surface.getName();
56  auto it = _surfaces.find(prev_name);
57  if (it == _surfaces.end() || it->second.get() != &surface)
58  mooseError("Surface " + prev_name + " cannot be renamed to " + name +
59  " as it does not exist in this CSGBase instance.");
60 
61  auto existing_surface = std::move(it->second);
62  existing_surface->setName(name);
63  _surfaces.erase(prev_name);
64  addSurface(std::move(existing_surface));
65 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
std::unordered_map< std::string, std::unique_ptr< CSGSurface > > _surfaces
Mapping of surface names to pointers of stored surface objects.
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
add a surface object to existing SurfaceList.

Friends And Related Function Documentation

◆ CSGBase

friend class CSGBase
friend

Definition at line 80 of file CSGSurfaceList.h.

Member Data Documentation

◆ _surfaces

std::unordered_map<std::string, std::unique_ptr<CSGSurface> > CSG::CSGSurfaceList::_surfaces
protected

Mapping of surface names to pointers of stored surface objects.

Definition at line 77 of file CSGSurfaceList.h.

Referenced by addSurface(), getAllSurfaces(), getSurface(), getSurfaceListMap(), and renameSurface().


The documentation for this class was generated from the following files: