jacobi.template
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Mesh Class Reference

#include <geom.h>

Inheritance diagram for Mesh:
Mesh_2d_3_square ParMesh RefinedMesh

Public Member Functions

 Mesh (int ndim, int nvert_e=0, int ndof_e=0, int nedge_e=0)
 
 __attribute__ ((noinline)) Mesh(Mesh const &)=default
 
Meshoperator= (Mesh const &)=delete
 
virtual ~Mesh ()
 
 Mesh (std::string const &fname)
 
void ReadVertexBasedMesh (std::string const &fname)
 
int Nelems () const
 
int NverticesElements () const
 
int NdofsElement () const
 
int Nnodes () const
 
int Ndims () const
 
void Resize_Connectivity (int nelem, int nvert_e)
 
const std::vector< int > & GetConnectivity () const
 
std::vector< int > & GetConnectivity ()
 
void Resize_Coords (int nnodes, int ndim)
 
const std::vector< double > & GetCoords () const
 
std::vector< double > & GetCoords ()
 
void SetValues (std::vector< double > &v, const std::function< double(double, double)> &func) const
 
void SetBoundaryValues (std::vector< double > &v, const std::function< double(double, double)> &func) const
 
void SetDirchletValues (std::vector< double > &v, const std::function< double(double, double)> &func) const
 
void Debug () const
 
void DebugEdgeBased () const
 
virtual std::vector< int > Index_DirichletNodes () const
 
virtual std::vector< int > Index_BoundaryNodes () const
 
void Write_ascii_matlab (std::string const &fname, std::vector< double > const &v) const
 
void Export_scicomp (std::string const &basename) const
 
virtual void Visualize (std::vector< double > const &v) const
 
int Nedges () const
 
int NedgesElements () const
 
const std::vector< int > & GetEdgeConnectivity () const
 
std::vector< int > & GetEdgeConnectivity ()
 
const std::vector< int > & GetEdges () const
 
std::vector< int > & GetEdges ()
 
std::vector< std::vector< int > > Node2NodeGraph () const
 
virtual const std::vector< int > & GetFathersOfVertices () const
 
void Del_EdgeConnectivity ()
 

Protected Member Functions

void SetNelem (int nelem)
 
void SetNverticesElement (int nvert)
 
void SetNdofsElement (int ndof)
 
void SetNnode (int nnode)
 
void SetNdim (int ndim)
 
void SetNedge (int nedge)
 
void ReadVectexBasedMesh (std::string const &fname)
 
void DeriveEdgeFromVertexBased ()
 
void DeriveEdgeFromVertexBased_slow ()
 
void DeriveEdgeFromVertexBased_fast ()
 
void DeriveEdgeFromVertexBased_fast_2 ()
 
void DeriveVertexFromEdgeBased ()
 
int Nnbedges () const
 
virtual bool Check_array_dimensions () const
 
void PermuteVertices_EdgeBased (std::vector< int > const &old2new)
 

Protected Attributes

int _nelem
 number elements More...
 
int _nvert_e
 number of vertices per element More...
 
int _ndof_e
 degrees of freedom (d.o.f.) per element More...
 
int _nnode
 number nodes/vertices More...
 
int _ndim
 space dimension of the problem (1, 2, or 3) More...
 
std::vector< int > _ia
 element connectivity More...
 
std::vector< double > _xc
 coordinates More...
 
std::vector< int > _bedges
 boundary edges [nbedges][2] storing start/end vertex More...
 
std::vector< int > _sdedges
 boundary edges [nbedges][2] with left/right subdomain number More...
 
int _nedge
 number of edges in mesh More...
 
int _nedge_e
 number of edges per element More...
 
std::vector< int > _edges
 edges of mesh (vertices ordered ascending) More...
 
std::vector< int > _ea
 edge based element connectivity More...
 
std::vector< int > _ebedges
 boundary edges [nbedges] More...
 

Private Member Functions

std::vector< std::vector< int > > Node2NodeGraph_1 () const
 
std::vector< std::vector< int > > Node2NodeGraph_2 () const
 

Private Attributes

const std::vector< int > _dummy
 empty dummy vector More...
 

Detailed Description

Basis class for finite element meshes.

Definition at line 13 of file geom.h.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

Mesh::Mesh ( int  ndim,
int  nvert_e = 0,
int  ndof_e = 0,
int  nedge_e = 0 
)
explicit

Constructor initializing the members with default values.

Parameters
[in]ndimspace dimensions (dimension for coordinates)
[in]nvert_enumber of vertices per element (dimension for connectivity)
[in]ndof_edegrees of freedom per element (= nvert_e for linear elements)
[in]nedge_enumber of edges per element (= nvert_e for linear elements in 2D)

Definition at line 21 of file geom.cpp.

◆ ~Mesh()

Mesh::~Mesh ( )
virtual

Destructor.

See clang warning on weak-vtables.

Definition at line 29 of file geom.cpp.

◆ Mesh() [2/2]

Mesh::Mesh ( std::string const &  fname)
explicit

Reads mesh data from a binary file.

File format, see ascii_write_mesh.m

Parameters
[in]fnamefile name

Definition at line 701 of file geom.cpp.

Member Function Documentation

◆ __attribute__()

Mesh::__attribute__ ( (noinline)  ) const &
default

◆ Check_array_dimensions()

bool Mesh::Check_array_dimensions ( ) const
protectedvirtual

Checks whether the array dimensions fit to their appropriate size parameters

Returns
index vector.

Reimplemented in RefinedMesh.

Definition at line 782 of file geom.cpp.

◆ Debug()

void Mesh::Debug ( ) const

Prints the information for a finite element mesh

Definition at line 64 of file geom.cpp.

◆ DebugEdgeBased()

void Mesh::DebugEdgeBased ( ) const

Prints the edge based information for a finite element mesh

Definition at line 90 of file geom.cpp.

◆ Del_EdgeConnectivity()

void Mesh::Del_EdgeConnectivity ( )

Deletes all edge connectivity information (saves memory).

< number of edges in mesh

< edges of mesh (vertices ordered ascending)

< edge based element connectivity

< boundary edges [nbedges]

Definition at line 800 of file geom.cpp.

◆ DeriveEdgeFromVertexBased()

void Mesh::DeriveEdgeFromVertexBased ( )
inlineprotected

The vertex based mesh data are used to derive the edge based data.

Warning
Exactly 3 vertices, 3 edges per element are assumed (linear triangle in 2D)

Definition at line 362 of file geom.h.

◆ DeriveEdgeFromVertexBased_fast()

void Mesh::DeriveEdgeFromVertexBased_fast ( )
protected

Definition at line 412 of file geom.cpp.

◆ DeriveEdgeFromVertexBased_fast_2()

void Mesh::DeriveEdgeFromVertexBased_fast_2 ( )
protected

Definition at line 298 of file geom.cpp.

◆ DeriveEdgeFromVertexBased_slow()

void Mesh::DeriveEdgeFromVertexBased_slow ( )
protected

Definition at line 514 of file geom.cpp.

◆ DeriveVertexFromEdgeBased()

void Mesh::DeriveVertexFromEdgeBased ( )
protected

The edge based mesh data are used to derive the vertex based data.

Warning
Exactly 3 vertices, 3 edges per element are assumed (linear triangle in 2D)

Definition at line 587 of file geom.cpp.

◆ Export_scicomp()

void Mesh::Export_scicomp ( std::string const &  basename) const

Exports the mesh information to ASCii files basename + {_coords|_elements}.txt.

The data are written in C-style.

Parameters
[in]basenamefirst part of file names

Definition at line 173 of file geom.cpp.

◆ GetConnectivity() [1/2]

std::vector<int>& Mesh::GetConnectivity ( )
inline

Access/Change connectivity information (g1,g2,g3)_i.

Returns
connectivity vector [nelems*ndofs].

Definition at line 129 of file geom.h.

◆ GetConnectivity() [2/2]

const std::vector<int>& Mesh::GetConnectivity ( ) const
inline

Read connectivity information (g1,g2,g3)_i.

Returns
connectivity vector [nelems*ndofs].

Definition at line 120 of file geom.h.

◆ GetCoords() [1/2]

std::vector<double>& Mesh::GetCoords ( )
inline

Access/Change coordinates of vertices (x,y)_i.

Returns
coordinates vector [nnodes*2].

Definition at line 160 of file geom.h.

◆ GetCoords() [2/2]

const std::vector<double>& Mesh::GetCoords ( ) const
inline

Read coordinates of vertices (x,y)_i.

Returns
coordinates vector [nnodes*2].

Definition at line 151 of file geom.h.

◆ GetEdgeConnectivity() [1/2]

std::vector<int>& Mesh::GetEdgeConnectivity ( )
inline

Access/Change edge connectivity information (e1,e2,e3)_i.

Returns
edge connectivity vector [nelems*_nedge_e].

Definition at line 254 of file geom.h.

◆ GetEdgeConnectivity() [2/2]

const std::vector<int>& Mesh::GetEdgeConnectivity ( ) const
inline

Read edge connectivity information (e1,e2,e3)_i.

Returns
edge connectivity vector [nelems*_nedge_e].

Definition at line 245 of file geom.h.

◆ GetEdges() [1/2]

std::vector<int>& Mesh::GetEdges ( )
inline

Access/Change edge information (v1,v2)_i.

Returns
edge connectivity vector [_nedge*2].

Definition at line 272 of file geom.h.

◆ GetEdges() [2/2]

const std::vector<int>& Mesh::GetEdges ( ) const
inline

Read edge information (v1,v2)_i.

Returns
edge connectivity vector [_nedge*2].

Definition at line 263 of file geom.h.

◆ GetFathersOfVertices()

virtual const std::vector<int>& Mesh::GetFathersOfVertices ( ) const
inlinevirtual

Accesses the father-of-nodes relation.

Returns
vector of length 0 because no relation available.

Reimplemented in RefinedMesh.

Definition at line 306 of file geom.h.

◆ Index_BoundaryNodes()

std::vector< int > Mesh::Index_BoundaryNodes ( ) const
virtual

Reimplemented in Mesh_2d_3_square.

Definition at line 286 of file geom.cpp.

◆ Index_DirichletNodes()

std::vector< int > Mesh::Index_DirichletNodes ( ) const
virtual

Determines the indices of those vertices with Dirichlet boundary conditions

Returns
index vector.

Reimplemented in Mesh_2d_3_square.

Definition at line 260 of file geom.cpp.

◆ Ndims()

int Mesh::Ndims ( ) const
inline

Space dimension.

Returns
number of dimensions.

Definition at line 98 of file geom.h.

◆ NdofsElement()

int Mesh::NdofsElement ( ) const
inline

Global number of degrees of freedom (dof) for each finite element.

Returns
degrees of freedom per element.

Definition at line 80 of file geom.h.

◆ Nedges()

int Mesh::Nedges ( ) const
inline

Global number of edges.

Returns
number of edges in mesh.

Definition at line 227 of file geom.h.

◆ NedgesElements()

int Mesh::NedgesElements ( ) const
inline

Global number of edges for each finite element.

Returns
number of edges per element.

Definition at line 236 of file geom.h.

◆ Nelems()

int Mesh::Nelems ( ) const
inline

Number of finite elements in (sub)domain.

Returns
number of elements.

Definition at line 62 of file geom.h.

◆ Nnbedges()

int Mesh::Nnbedges ( ) const
inlineprotected

Determines the indices of those vertices with Dirichlet boundary conditions

Returns
index vector.

Definition at line 385 of file geom.h.

◆ Nnodes()

int Mesh::Nnodes ( ) const
inline

Number of vertices in mesh.

Returns
number of vertices.

Definition at line 89 of file geom.h.

◆ Node2NodeGraph()

std::vector<std::vector<int> > Mesh::Node2NodeGraph ( ) const
inline

Determines all node to node connections from the vertex based mesh.

Returns
vector[k][] containing all connections of vertex k, including to itself.

Definition at line 282 of file geom.h.

◆ Node2NodeGraph_1()

vector< vector< int > > Mesh::Node2NodeGraph_1 ( ) const
private

Determines all node to node connections from the vertex based mesh.

Returns
vector[k][] containing all connections of vertex k, including to itself.

Definition at line 672 of file geom.cpp.

◆ Node2NodeGraph_2()

vector< vector< int > > Mesh::Node2NodeGraph_2 ( ) const
private

Determines all node to node connections from the vertex based mesh.

Faster than Node2NodeGraph_1().

Returns
vector[k][] containing all connections of vertex k, including to itself.

Definition at line 631 of file geom.cpp.

◆ NverticesElements()

int Mesh::NverticesElements ( ) const
inline

Global number of vertices for each finite element.

Returns
number of vertices per element.

Definition at line 71 of file geom.h.

◆ operator=()

Mesh& Mesh::operator= ( Mesh const &  )
delete

◆ PermuteVertices_EdgeBased()

void Mesh::PermuteVertices_EdgeBased ( std::vector< int > const &  old2new)
protected

Permutes the vertex information in an edge based mesh.

Parameters
[in]old2newnew indices of original vertices.

Definition at line 1033 of file geom.cpp.

◆ ReadVectexBasedMesh()

void Mesh::ReadVectexBasedMesh ( std::string const &  fname)
protected

Reads vertex based mesh data from a binary file.

File format, see ascii_write_mesh.m

Parameters
[in]fnamefile name

◆ ReadVertexBasedMesh()

void Mesh::ReadVertexBasedMesh ( std::string const &  fname)

Reads mesh data from a binary file.

File format, see ascii_write_mesh.m

Parameters
[in]fnamefile name

Definition at line 712 of file geom.cpp.

◆ Resize_Connectivity()

void Mesh::Resize_Connectivity ( int  nelem,
int  nvert_e 
)
inline

(Re-)Allocates memory for the element connectivity and redefines the appropriate dimensions.

Parameters
[in]nelemnumber of elements
[in]nvert_enumber of vertices per element

Definition at line 109 of file geom.h.

◆ Resize_Coords()

void Mesh::Resize_Coords ( int  nnodes,
int  ndim 
)
inline

(Re-)Allocates memory for the element connectivity and redefines the appropriate dimensions.

Parameters
[in]nnodesnumber of nodes
[in]ndimspace dimension

Definition at line 140 of file geom.h.

◆ SetBoundaryValues()

void Mesh::SetBoundaryValues ( std::vector< double > &  v,
const std::function< double(double, double)> &  func 
) const

Definition at line 42 of file geom.cpp.

◆ SetDirchletValues()

void Mesh::SetDirchletValues ( std::vector< double > &  v,
const std::function< double(double, double)> &  func 
) const

Definition at line 52 of file geom.cpp.

◆ SetNdim()

void Mesh::SetNdim ( int  ndim)
inlineprotected

Definition at line 338 of file geom.h.

◆ SetNdofsElement()

void Mesh::SetNdofsElement ( int  ndof)
inlineprotected

Definition at line 328 of file geom.h.

◆ SetNedge()

void Mesh::SetNedge ( int  nedge)
inlineprotected

Definition at line 343 of file geom.h.

◆ SetNelem()

void Mesh::SetNelem ( int  nelem)
inlineprotected

Definition at line 318 of file geom.h.

◆ SetNnode()

void Mesh::SetNnode ( int  nnode)
inlineprotected

Definition at line 333 of file geom.h.

◆ SetNverticesElement()

void Mesh::SetNverticesElement ( int  nvert)
inlineprotected

Definition at line 323 of file geom.h.

◆ SetValues()

void Mesh::SetValues ( std::vector< double > &  v,
const std::function< double(double, double)> &  func 
) const

Calculate values in vector v via function func(x,y)

Parameters
[in]vvector
[in]funcfunction of (x,y) returning a double value.

Definition at line 32 of file geom.cpp.

◆ Visualize()

void Mesh::Visualize ( std::vector< double > const &  v) const
virtual

Visualize v together with its mesh information via matlab or octave.

Comment/uncomment those code lines in method Mesh:Visualize (geom.cpp) that are supported on your system.

Parameters
[in]vvector
Warning
matlab files ascii_read_meshvector.m visualize_results.m must be in the executing directory.

Reimplemented in ParMesh.

Definition at line 239 of file geom.cpp.

◆ Write_ascii_matlab()

void Mesh::Write_ascii_matlab ( std::string const &  fname,
std::vector< double > const &  v 
) const

Write vector v together with its mesh information to an ASCii file fname.

The data are written in C-style.

Parameters
[in]fnamefile name
[in]vvector

Definition at line 123 of file geom.cpp.

Member Data Documentation

◆ _bedges

std::vector<int> Mesh::_bedges
protected

boundary edges [nbedges][2] storing start/end vertex

Definition at line 432 of file geom.h.

◆ _dummy

const std::vector<int> Mesh::_dummy
private

empty dummy vector

Definition at line 447 of file geom.h.

◆ _ea

std::vector<int> Mesh::_ea
protected

edge based element connectivity

Definition at line 442 of file geom.h.

◆ _ebedges

std::vector<int> Mesh::_ebedges
protected

boundary edges [nbedges]

Definition at line 444 of file geom.h.

◆ _edges

std::vector<int> Mesh::_edges
protected

edges of mesh (vertices ordered ascending)

Definition at line 441 of file geom.h.

◆ _ia

std::vector<int> Mesh::_ia
protected

element connectivity

Definition at line 427 of file geom.h.

◆ _ndim

int Mesh::_ndim
protected

space dimension of the problem (1, 2, or 3)

Definition at line 426 of file geom.h.

◆ _ndof_e

int Mesh::_ndof_e
protected

degrees of freedom (d.o.f.) per element

Definition at line 424 of file geom.h.

◆ _nedge

int Mesh::_nedge
protected

number of edges in mesh

Definition at line 439 of file geom.h.

◆ _nedge_e

int Mesh::_nedge_e
protected

number of edges per element

Definition at line 440 of file geom.h.

◆ _nelem

int Mesh::_nelem
protected

number elements

Definition at line 422 of file geom.h.

◆ _nnode

int Mesh::_nnode
protected

number nodes/vertices

Definition at line 425 of file geom.h.

◆ _nvert_e

int Mesh::_nvert_e
protected

number of vertices per element

Definition at line 423 of file geom.h.

◆ _sdedges

std::vector<int> Mesh::_sdedges
protected

boundary edges [nbedges][2] with left/right subdomain number

Definition at line 434 of file geom.h.

◆ _xc

std::vector<double> Mesh::_xc
protected

coordinates

Definition at line 428 of file geom.h.


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