NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
NEM::MSH::GmshInterface Class Reference

management class for Gmsh interface More...

Detailed Description

Gmsh uses global (and static members) variables that are initialized and finalized by Gmsh API commands. This class manages geoMeshBase usage of Gmsh to guarantee finalization only when no geoMeshBase instances are left.

Definition at line 66 of file geoMeshBase.H.

Public Member Functions

 ~GmshInterface ()
 
 GmshInterface (const GmshInterface &)=delete
 
GmshInterfaceoperator= (const GmshInterface &)=delete
 
 GmshInterface (GmshInterface &&)=delete
 
GmshInterfaceoperator= (GmshInterface &&)=delete
 

Static Public Member Functions

static void Initialize ()
 Initialize Gmsh. More...
 
static void Finalize ()
 Finalize Gmsh. More...
 

Private Member Functions

 GmshInterface ()
 

Static Private Attributes

static std::shared_ptr< GmshInterfaceinstance = nullptr
 
static int count = 0
 

Constructor & Destructor Documentation

◆ ~GmshInterface()

NEM::MSH::GmshInterface::~GmshInterface ( )

Definition at line 57 of file geoMeshBase.C.

References count, and instance.

57  {
58 #ifdef HAVE_GMSH
59  gmsh::finalize();
60  std::cout << "Gmsh finalized" << std::endl;
61 #endif
62 }

◆ GmshInterface() [1/3]

NEM::MSH::GmshInterface::GmshInterface ( const GmshInterface )
delete

◆ GmshInterface() [2/3]

NEM::MSH::GmshInterface::GmshInterface ( GmshInterface &&  )
delete

◆ GmshInterface() [3/3]

NEM::MSH::GmshInterface::GmshInterface ( )
private

Definition at line 48 of file geoMeshBase.C.

Referenced by Initialize().

48  {
49 #ifdef HAVE_GMSH
50  gmsh::initialize();
51  gmsh::option::setNumber("General.Terminal", 1.0); // Gmsh errors to stderr
52  gmsh::option::setNumber("Mesh.SaveAll", 1);
53  std::cout << "Gmsh initialized" << std::endl;
54 #endif
55 }

Member Function Documentation

◆ Finalize()

void NEM::MSH::GmshInterface::Finalize ( )
static

Will only call gmsh::finalize() if count is zero.

Definition at line 72 of file geoMeshBase.C.

References count, and instance.

Referenced by NEM::MSH::geoMeshBase::~geoMeshBase(), and NEM::MSH::gmshGeoMesh::~gmshGeoMesh().

72  {
73  --count;
74  if (count == 0) instance.reset();
75 }
static std::shared_ptr< GmshInterface > instance
Definition: geoMeshBase.H:91

◆ Initialize()

void NEM::MSH::GmshInterface::Initialize ( )
static

Will only call gmsh::initialize() on first call to method.

Definition at line 67 of file geoMeshBase.C.

References count, GmshInterface(), and instance.

Referenced by NEM::MSH::foamGeoMesh::foam2GM(), NEM::MSH::geoMeshBase::geoMeshBase(), NEM::MSH::inpGeoMesh::inp2GM(), NEM::MSH::vtkGeoMesh::vtk2GM(), and NEM::MSH::vtkStandardNewMacro().

67  {
68  ++count;
69  if (!instance) instance = std::shared_ptr<GmshInterface>(new GmshInterface());
70 }
static std::shared_ptr< GmshInterface > instance
Definition: geoMeshBase.H:91

◆ operator=() [1/2]

GmshInterface& NEM::MSH::GmshInterface::operator= ( const GmshInterface )
delete

◆ operator=() [2/2]

GmshInterface& NEM::MSH::GmshInterface::operator= ( GmshInterface &&  )
delete

Member Data Documentation

◆ count

int NEM::MSH::GmshInterface::count = 0
staticprivate

Definition at line 92 of file geoMeshBase.H.

Referenced by Finalize(), Initialize(), and ~GmshInterface().

◆ instance

std::shared_ptr< GmshInterface > NEM::MSH::GmshInterface::instance = nullptr
staticprivate

Definition at line 91 of file geoMeshBase.H.

Referenced by Finalize(), Initialize(), and ~GmshInterface().


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