HIFLOW  2.0
Public Types | Public Member Functions | Protected Attributes | List of all members
hiflow::mesh::MeshDbViewBuilder Class Reference

A MeshBuilder that creates a MeshDbView. More...

#include <mesh_db_view.h>

Inheritance diagram for hiflow::mesh::MeshDbViewBuilder:
[legend]

Public Types

typedef MeshBuilder::EntityHandle EntityHandle
 
typedef MeshBuilder::VertexHandle VertexHandle
 

Public Member Functions

virtual std::vector< EntityHandleadd_entities (TDim tdim, const std::vector< VertexHandle > &vertices, const std::vector< int > &sizes)
 Add a list of entities to the Mesh under construction. More...
 
virtual EntityHandle add_entity (TDim tdim, const std::vector< VertexHandle > &vertices)
 Add an entity to the Mesh under construction. More...
 
virtual VertexHandle add_vertex (const std::vector< Coordinate > &coordinates)
 Add a vertex to the Mesh under construction. More...
 
virtual std::vector< VertexHandleadd_vertices (const std::vector< Coordinate > &coordinates)
 Add a list of vertices to the Mesh under construction. More...
 
virtual MeshPtr build ()
 Build the Mesh. More...
 
virtual void clear ()
 Clean the MeshBuilder. More...
 
GDim gdim () const
 Access the geometrical dimension of the Mesh under construction. More...
 
MeshDatabasePtr get_db () const
 
std::vector< MasterSlaveget_period () const
 Get periodicity. More...
 
 MeshDbViewBuilder (MeshDatabasePtr db, std::vector< MasterSlave > period=std::vector< MasterSlave >(0))
 Constructor to use when building a Mesh with an existing MeshDatabase. More...
 
 MeshDbViewBuilder (const MeshDbView &mesh)
 Constructor to initialize builder with existing MeshDbView mesh. More...
 
 MeshDbViewBuilder (TDim tdim, GDim gdim, std::vector< MasterSlave > period=std::vector< MasterSlave >(0))
 Constructor to use when building a Mesh without an existing MeshDatabase. More...
 
 MeshDbViewBuilder (TDim tdim, GDim gdim, int flag, std::vector< MasterSlave > period=std::vector< MasterSlave >(0))
 Dummy constructor, only use in combination with p4est mesh. More...
 
virtual void set_material_number (TDim tdim, EntityHandle entity, MaterialNumber material)
 Set the material number for an entity. More...
 
TDim tdim () const
 Access the topological dimension of the Mesh under construction. More...
 

Protected Attributes

std::vector< EntityHandlecells_
 
MeshDatabasePtr db_
 
GDim gdim_
 
std::vector< MasterSlaveperiod_
 
TDim tdim_
 

Detailed Description

A MeshBuilder that creates a MeshDbView.

See also
MeshBuilder
MeshDbView

Definition at line 186 of file mesh_db_view.h.

Member Typedef Documentation

◆ EntityHandle

Definition at line 190 of file mesh_db_view.h.

◆ VertexHandle

Definition at line 189 of file mesh_db_view.h.

Constructor & Destructor Documentation

◆ MeshDbViewBuilder() [1/4]

hiflow::mesh::MeshDbViewBuilder::MeshDbViewBuilder ( MeshDatabasePtr  db,
std::vector< MasterSlave period = std::vector<MasterSlave>( 0 ) 
)
explicit

Constructor to use when building a Mesh with an existing MeshDatabase.

Definition at line 1175 of file mesh_db_view.cc.

References db_.

Referenced by MeshDbViewBuilder().

1176  : MeshBuilder ( db->tdim ( ), db->gdim ( ), period ), db_ ( db )
1177  {
1178  assert ( db_ != 0 );
1179  }
MeshBuilder(TDim tdim, GDim gdim, std::vector< MasterSlave > period=std::vector< MasterSlave >(0))
Constructor for MeshBuilder object.
Definition: mesh_builder.h:118

◆ MeshDbViewBuilder() [2/4]

hiflow::mesh::MeshDbViewBuilder::MeshDbViewBuilder ( const MeshDbView mesh)
explicit

Constructor to initialize builder with existing MeshDbView mesh.

Definition at line 1192 of file mesh_db_view.cc.

References cells_, db_, hiflow::mesh::MeshBuilder::gdim(), hiflow::mesh::MeshDbView::get_entities(), hiflow::mesh::MeshBuilder::MeshBuilder(), MeshDbViewBuilder(), and hiflow::mesh::MeshBuilder::tdim().

1193  : MeshBuilder ( mesh.tdim ( ), mesh.gdim ( ), mesh.get_period ( ) ), db_ ( mesh.db_ )
1194  {
1195  // add cells from mesh to builder
1196  cells_ = mesh.get_entities ( tdim ( ) );
1197  }
TDim tdim() const
Access the topological dimension of the Mesh under construction.
Definition: mesh_builder.h:127
MeshBuilder(TDim tdim, GDim gdim, std::vector< MasterSlave > period=std::vector< MasterSlave >(0))
Constructor for MeshBuilder object.
Definition: mesh_builder.h:118
std::vector< EntityHandle > cells_
Definition: mesh_db_view.h:225

◆ MeshDbViewBuilder() [3/4]

hiflow::mesh::MeshDbViewBuilder::MeshDbViewBuilder ( TDim  tdim,
GDim  gdim,
std::vector< MasterSlave period = std::vector<MasterSlave>( 0 ) 
)

Constructor to use when building a Mesh without an existing MeshDatabase.

Definition at line 1181 of file mesh_db_view.cc.

References db_.

1182  : MeshBuilder ( tdim, gdim, period ), db_ ( new MeshDatabase ( tdim, gdim ) )
1183  {
1184  assert ( db_ != 0 );
1185  }
TDim tdim() const
Access the topological dimension of the Mesh under construction.
Definition: mesh_builder.h:127
GDim gdim() const
Access the geometrical dimension of the Mesh under construction.
Definition: mesh_builder.h:132
MeshBuilder(TDim tdim, GDim gdim, std::vector< MasterSlave > period=std::vector< MasterSlave >(0))
Constructor for MeshBuilder object.
Definition: mesh_builder.h:118

◆ MeshDbViewBuilder() [4/4]

hiflow::mesh::MeshDbViewBuilder::MeshDbViewBuilder ( TDim  tdim,
GDim  gdim,
int  flag,
std::vector< MasterSlave period = std::vector<MasterSlave>( 0 ) 
)

Dummy constructor, only use in combination with p4est mesh.

Definition at line 1187 of file mesh_db_view.cc.

1188  : MeshBuilder ( tdim, gdim, period )
1189  {
1190  }
TDim tdim() const
Access the topological dimension of the Mesh under construction.
Definition: mesh_builder.h:127
GDim gdim() const
Access the geometrical dimension of the Mesh under construction.
Definition: mesh_builder.h:132
MeshBuilder(TDim tdim, GDim gdim, std::vector< MasterSlave > period=std::vector< MasterSlave >(0))
Constructor for MeshBuilder object.
Definition: mesh_builder.h:118

Member Function Documentation

◆ add_entities()

std::vector< EntityHandle > hiflow::mesh::MeshDbViewBuilder::add_entities ( TDim  tdim,
const std::vector< VertexHandle > &  vertices,
const std::vector< int > &  sizes 
)
virtual

Add a list of entities to the Mesh under construction.

Parameters
tdimthe topological dimension of the added entities
verticesthe concatenated list of vertices of the entities, identified through their VertexHandle:s.
sizesa list of sizes (number of vertices) of the entities. This length of this list equals the number of entities to be added.
Returns
a list with the identifiers of the new entities

Implements hiflow::mesh::MeshBuilder.

Definition at line 1248 of file mesh_db_view.cc.

References cells_, and db_.

1251  {
1252  const EntityCount num_entities = sizes.size ( );
1253  std::vector<EntityHandle> entities ( num_entities );
1254 
1255  int offset = 0;
1256  for ( int e = 0; e < num_entities; ++e )
1257  {
1258  const int entity_size = sizes[e];
1259  entities[e] = db_->add_entity ( tdim, std::vector<VertexHandle>( vertices.begin ( ) + offset,
1260  vertices.begin ( ) + offset + entity_size ) );
1261  offset += entity_size;
1262  }
1263 
1264  if ( tdim == this->tdim ( ) )
1265  {
1266  cells_.insert ( cells_.end ( ), entities.begin ( ), entities.end ( ) );
1267  }
1268 
1269  return entities;
1270  }
TDim tdim() const
Access the topological dimension of the Mesh under construction.
Definition: mesh_builder.h:127
std::vector< EntityHandle > cells_
Definition: mesh_db_view.h:225
int EntityCount
Type for representing sizes of entity collections.
Definition: types.h:75

◆ add_entity()

EntityHandle hiflow::mesh::MeshDbViewBuilder::add_entity ( TDim  tdim,
const std::vector< VertexHandle > &  vertices 
)
virtual

Add an entity to the Mesh under construction.

Parameters
tdimthe topological dimension of the added entity
verticesthe list of vertices in the entity, identified through the VertexHandle:s returned from add_vertex or add_vertices.
Returns
the identifier of the new entity

Implements hiflow::mesh::MeshBuilder.

Definition at line 1237 of file mesh_db_view.cc.

References cells_, and db_.

Referenced by hiflow::mesh::UcdPXestReader::read_file(), and hiflow::Visualization< DataType >::Visualize().

1238  {
1239  assert ( !vertices.empty ( ) );
1240  const EntityHandle entity_id = db_->add_entity ( tdim, vertices );
1241  if ( tdim == this->tdim ( ) )
1242  {
1243  cells_.push_back ( entity_id );
1244  }
1245  return entity_id;
1246  }
TDim tdim() const
Access the topological dimension of the Mesh under construction.
Definition: mesh_builder.h:127
std::vector< EntityHandle > cells_
Definition: mesh_db_view.h:225
MeshBuilder::EntityHandle EntityHandle
Definition: mesh_db_view.h:190

◆ add_vertex()

VertexHandle hiflow::mesh::MeshDbViewBuilder::add_vertex ( const std::vector< Coordinate > &  coordinates)
virtual

Add a vertex to the Mesh under construction.

Parameters
coordinatesthe coordinates of the vertex
Returns
the identifier of the new vertex

Implements hiflow::mesh::MeshBuilder.

Definition at line 1208 of file mesh_db_view.cc.

References db_, hiflow::mesh::MeshBuilder::period_, hiflow::mesh::periodify(), and hiflow::vec2ptr().

Referenced by hiflow::mesh::UcdPXestReader::read_file(), and hiflow::Visualization< DataType >::Visualize().

1209  {
1210  assert ( !coordinates.empty ( ) );
1211  assert ( static_cast < int > ( coordinates.size ( ) ) == gdim ( ) );
1212  if ( period_.size ( ) > 0 )
1213  return db_->add_vertex ( vec2ptr ( periodify ( coordinates, gdim ( ), period_ ) ) );
1214  else
1215  return db_->add_vertex ( vec2ptr ( coordinates ) );
1216  }
GDim gdim() const
Access the geometrical dimension of the Mesh under construction.
Definition: mesh_builder.h:132
std::vector< MasterSlave > period_
Definition: mesh_builder.h:112
T * vec2ptr(std::vector< T > &vec)
Conversion from vector to pointer to first element.
Definition: pointers.h:57
std::vector< Coordinate > periodify(const std::vector< Coordinate > &coordinates, const GDim gdim, const std::vector< MasterSlave > &period)
Map points from slave boundary to master boundary. See also MasterSlave.

◆ add_vertices()

std::vector< VertexHandle > hiflow::mesh::MeshDbViewBuilder::add_vertices ( const std::vector< Coordinate > &  coordinates)
virtual

Add a list of vertices to the Mesh under construction.

Parameters
coordinatesthe coordinates of the vertices in interleaved format (x0 y0 z0 x1 y1 z1 ...)
Returns
a list with the identifiers of the new vertices

Implements hiflow::mesh::MeshBuilder.

Definition at line 1218 of file mesh_db_view.cc.

References db_, hiflow::mesh::MeshBuilder::gdim(), hiflow::mesh::MeshBuilder::period_, hiflow::mesh::periodify(), and hiflow::vec2ptr().

1219  {
1220  const EntityCount num_verts = coordinates.size ( ) / gdim ( );
1221  assert ( static_cast < int > ( coordinates.size ( ) ) == num_verts * gdim ( ) );
1222 
1223  std::vector<VertexHandle> vertices ( num_verts );
1224 
1225  for ( int v = 0; v < num_verts; ++v )
1226  {
1227  const std::vector<Coordinate> pt = std::vector<Coordinate>( coordinates.begin ( ) + gdim ( ) * v,
1228  coordinates.begin ( ) + gdim ( ) * ( v + 1 ) );
1229  if ( period_.size ( ) > 0 )
1230  vertices[v] = db_->add_vertex ( vec2ptr ( periodify ( pt, gdim ( ), period_ ) ) );
1231  else
1232  vertices[v] = db_->add_vertex ( vec2ptr ( pt ) );
1233  }
1234  return vertices;
1235  }
GDim gdim() const
Access the geometrical dimension of the Mesh under construction.
Definition: mesh_builder.h:132
std::vector< MasterSlave > period_
Definition: mesh_builder.h:112
T * vec2ptr(std::vector< T > &vec)
Conversion from vector to pointer to first element.
Definition: pointers.h:57
std::vector< Coordinate > periodify(const std::vector< Coordinate > &coordinates, const GDim gdim, const std::vector< MasterSlave > &period)
Map points from slave boundary to master boundary. See also MasterSlave.
int EntityCount
Type for representing sizes of entity collections.
Definition: types.h:75

◆ build()

MeshPtr hiflow::mesh::MeshDbViewBuilder::build ( )
virtual

Build the Mesh.

The indices of the cells in the new mesh are guaranteed to be the same as that in which they were added to the mesh. No guarantees are made about entities of lower dimension, including vertices.

Returns
a new Mesh object containing the added entities. Ownership is transferred to the caller.

Implements hiflow::mesh::MeshBuilder.

Reimplemented in hiflow::mesh::MeshPXestBuilder.

Definition at line 1282 of file mesh_db_view.cc.

References cells_, db_, and hiflow::mesh::MeshBuilder::period_.

Referenced by hiflow::Visualization< DataType >::Visualize().

1283  {
1284  if ( !cells_.empty ( ) )
1285  {
1286  return MeshPtr ( new MeshDbView ( db_->tdim ( ), db_->gdim ( ), db_, cells_, period_ ) );
1287  }
1288  else
1289  {
1290  return MeshPtr ( 0 );
1291  }
1292  }
std::vector< MasterSlave > period_
Definition: mesh_builder.h:112
std::vector< EntityHandle > cells_
Definition: mesh_db_view.h:225
boost::intrusive_ptr< Mesh > MeshPtr
Types for Mesh pointers.
Definition: types.h:58

◆ clear()

void hiflow::mesh::MeshDbViewBuilder::clear ( )
virtual

Clean the MeshBuilder.

Implements hiflow::mesh::MeshBuilder.

Definition at line 1277 of file mesh_db_view.cc.

References cells_.

1278  {
1279  cells_.clear ( );
1280  }
std::vector< EntityHandle > cells_
Definition: mesh_db_view.h:225

◆ gdim()

GDim hiflow::mesh::MeshBuilder::gdim ( ) const
inlineinherited

◆ get_db()

MeshDatabasePtr hiflow::mesh::MeshDbViewBuilder::get_db ( ) const
inline

Definition at line 218 of file mesh_db_view.h.

References hiflow::mesh::MeshDbView::db_.

Referenced by hiflow::mesh::UcdPXestReader::read_file(), and hiflow::read_partitioned_mesh().

219  {
220  return db_;
221  }

◆ get_period()

std::vector< MasterSlave > hiflow::mesh::MeshBuilder::get_period ( ) const
inlineinherited

Get periodicity.

Returns
Vector containing the information about the periodicity of the mesh

Definition at line 137 of file mesh_builder.h.

References hiflow::mesh::MeshBuilder::period_.

138  {
139  return period_;
140  }
std::vector< MasterSlave > period_
Definition: mesh_builder.h:112

◆ set_material_number()

void hiflow::mesh::MeshDbViewBuilder::set_material_number ( TDim  tdim,
EntityHandle  entity,
MaterialNumber  material 
)
virtual

Set the material number for an entity.

Parameters
tdimthe topological dimension of the entity
entityidentifier for the entity
materialnew material number for the entity

Implements hiflow::mesh::MeshBuilder.

Definition at line 1272 of file mesh_db_view.cc.

References db_.

Referenced by hiflow::mesh::UcdPXestReader::read_file().

1273  {
1274  db_->set_material_number ( tdim, entity, material );
1275  }
TDim tdim() const
Access the topological dimension of the Mesh under construction.
Definition: mesh_builder.h:127

◆ tdim()

TDim hiflow::mesh::MeshBuilder::tdim ( ) const
inlineinherited

Access the topological dimension of the Mesh under construction.

Definition at line 127 of file mesh_builder.h.

References hiflow::mesh::MeshBuilder::tdim_.

Referenced by MeshDbViewBuilder(), hiflow::mesh::UcdReader::read_file(), hiflow::mesh::VtkReader::read_file(), hiflow::mesh::UcdPXestReader::read_file(), and hiflow::mesh::unpack_entities().

128  {
129  return tdim_;
130  }

Member Data Documentation

◆ cells_

std::vector<EntityHandle> hiflow::mesh::MeshDbViewBuilder::cells_
protected

◆ db_

MeshDatabasePtr hiflow::mesh::MeshDbViewBuilder::db_
protected

◆ gdim_

GDim hiflow::mesh::MeshBuilder::gdim_
protectedinherited

Definition at line 111 of file mesh_builder.h.

Referenced by hiflow::mesh::MeshBuilder::gdim().

◆ period_

std::vector<MasterSlave> hiflow::mesh::MeshBuilder::period_
protectedinherited

◆ tdim_

TDim hiflow::mesh::MeshBuilder::tdim_
protectedinherited

Definition at line 110 of file mesh_builder.h.

Referenced by hiflow::mesh::MeshBuilder::tdim().


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