Feellgood
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Mesh::mesh Class Reference

#include <mesh.h>

Public Member Functions

 mesh (Settings &mySets, bool simplified=false)
 
 mesh (const mesh &)=delete
 
meshoperator= (const mesh &)=delete
 
int getNbNodes (void) const
 
int getNbTris (void) const
 
int getNbTets (void) const
 
const Eigen::Vector3d getNode_p (const int i) const
 
const Eigen::Vector3d getNode_u (const int i) const
 
const Eigen::Vector3d getNode_v (const int i) const
 
double getProj_ep (const int i) const
 
double getProj_eq (const int i) const
 
void set_node_u0 (const int i, const Eigen::Vector3d &val)
 
void set_node_zero_v (const int i)
 
void infos (void) const
 
void setBasis (const double r)
 
void updateNode (const int i, const double vp, const double vq, const double dt)
 
void evolution (void)
 
double readSol (bool VERBOSE, const std::string &fileName)
 
void init_distrib (const Settings &mySets)
 
double thiele (const int region) const
 
double avg (const std::function< double(Nodes::Node, Nodes::index)> &getter, Nodes::index d, int region=-1) const
 
double max_angle () const
 
void savesol (const int precision, const std::string &fileName, const std::string &metadata, bool withSpinAcc, std::vector< Eigen::Vector3d > &s) const
 
void set (const int i, const std::function< void(Nodes::Node &, const double)> &what_to_set, const double val)
 
int getNodeIndex (const int i) const
 
bool isMagnetic (const Tetra::Tet &t) const
 
bool isMagnetic (const Triangle::Tri &f)
 
bool checkTriangles ()
 

Public Attributes

Eigen::Vector3d c
 
Eigen::Vector3d l
 
double vol
 
double totalMagVol
 
std::vector< Triangle::Tritri
 
std::vector< Tetra::Tettet
 
std::vector< Tetra::prm > & paramTetra
 
std::vector< Edgeedges
 
std::vector< bool > magNode
 
std::vector< int > magTet
 
std::vector< int > magTri
 
std::vector< Eigen::Matrix< double, Nodes::DIM, Tetra::NPI > > extSpaceField
 

Private Member Functions

void checkMeshFile (const Settings &mySets)
 
void readNodes (const Settings &mySets)
 
void readTetraedrons (const Settings &mySets)
 
void readTriangles (const Settings &mySets)
 
void readMesh (const Settings &mySets)
 
double doOnNodes (const double init_val, const Nodes::index coord, const std::function< bool(double, double)> &whatToDo) const
 
double minNodes (const Nodes::index coord) const
 
double maxNodes (const Nodes::index coord) const
 
void updateDeltaMs ()
 
void sortNodes (Nodes::index long_axis)
 
bool findErrInTriangle (const int nbSurfTri, const int nbTetraFaces, const std::pair< int, int > pairIdVolRegs, const int idSurfReg)
 
double surface (std::vector< int > &triIndices) const
 
bool isInMagList (std::vector< int > &idxMagList, Triangle::Tri &f) const
 
void setExtSpaceField (Settings &s)
 

Private Attributes

std::vector< Nodes::Nodenode
 
std::vector< int > node_index
 
std::vector< std::vector< int > > volumeRegions
 

Detailed Description

class for storing the mesh, including mesh geometry values, containers for the nodes, triangles and tetrahedrons. nodes data are private. They are accessible only through getter and setter.

Constructor & Destructor Documentation

◆ mesh() [1/2]

Mesh::mesh::mesh ( Settings mySets,
bool  simplified = false 
)
inline

constructor : read mesh file, reorder indices and computes some values related to the mesh : center and length along coordinates,full volume

Parameters
[in]mySets
simplifiedpass true in the unit tests

◆ mesh() [2/2]

Mesh::mesh::mesh ( const mesh )
delete

operator copy deleted

Member Function Documentation

◆ avg()

double mesh::avg ( const std::function< double(Nodes::Node, Nodes::index)> &  getter,
Nodes::index  d,
int  region = -1 
) const

average component of either u or v through getter on the whole set of tetetrahedron

Parameters
[in]getter
[in]d
regionregion index, or -1 for all magnetic regions

◆ checkMeshFile()

void Mesh::mesh::checkMeshFile ( const Settings mySets)
private

test if mesh file contains surfaces and regions mentionned in yaml settings and their dimensions

Parameters
[in]mySets

◆ checkTriangles()

bool mesh::checkTriangles ( )

Check whether each triangle of tet and tri satisfies one of the three following conditions :

  • Is part of no surface region, but part of 2 tetraedrons of the same volume region
  • Is part of at most one surface region, and 2 tetraedrons of differents volume region
  • Is part of 1 tetraedron and at most one surface region Returns true if all triangles in one of those three cases, false otherwise.

◆ doOnNodes()

double mesh::doOnNodes ( const double  init_val,
const Nodes::index  coord,
const std::function< bool(double, double)> &  whatToDo 
) const
private

loop on nodes to apply predicate 'whatTodo'

Parameters
[in]init_val
[in]coord
[in]whatToDo

◆ evolution()

void Mesh::mesh::evolution ( void  )
inline

call evolution for all the nodes

◆ findErrInTriangle()

bool mesh::findErrInTriangle ( const int  nbSurfTri,
const int  nbTetraFaces,
const std::pair< int, int >  pairIdVolRegs,
const int  idSurfReg 
)
private

Called in checkTriangles. Returns true if a generation error is detected, false otherwise.

◆ getNbNodes()

int Mesh::mesh::getNbNodes ( void  ) const
inline

return number of nodes

◆ getNbTets()

int Mesh::mesh::getNbTets ( void  ) const
inline

return number of tetrahedrons

◆ getNbTris()

int Mesh::mesh::getNbTris ( void  ) const
inline

return number of triangles

◆ getNode_p()

const Eigen::Vector3d Mesh::mesh::getNode_p ( const int  i) const
inline

getter : return node.p

◆ getNode_u()

const Eigen::Vector3d Mesh::mesh::getNode_u ( const int  i) const
inline

getter : return node.u

◆ getNode_v()

const Eigen::Vector3d Mesh::mesh::getNode_v ( const int  i) const
inline

getter : return node.v

◆ getNodeIndex()

int Mesh::mesh::getNodeIndex ( const int  i) const
inline

getter for the node_index value at position i

◆ getProj_ep()

double Mesh::mesh::getProj_ep ( const int  i) const
inline

return projection of speed at node i along ep

◆ getProj_eq()

double Mesh::mesh::getProj_eq ( const int  i) const
inline

return projection of speed at node i along eq

◆ infos()

void mesh::infos ( void  ) const

basic informations on the mesh

◆ init_distrib()

void Mesh::mesh::init_distrib ( const Settings mySets)
inline

computes an analytical initial magnetization distribution as a starting point for the simulation. If the node is not magnetic then it is set to NAN.

Parameters
[in]mySets

◆ isInMagList()

bool Mesh::mesh::isInMagList ( std::vector< int > &  idxMagList,
Triangle::Tri f 
) const
inlineprivate

return true if triangle f is already indexed in the list idxMagList. Uses operator== for Tri.

◆ isMagnetic() [1/2]

bool Mesh::mesh::isMagnetic ( const Tetra::Tet t) const
inline

return true if this tetraedron is magnetic

◆ isMagnetic() [2/2]

bool Mesh::mesh::isMagnetic ( const Triangle::Tri f)
inline

return true if this triangle is magnetic

◆ max_angle()

double Mesh::mesh::max_angle ( ) const
inline

Compute the maximum angle of the magnetization between two adjacent nodes.

◆ maxNodes()

double Mesh::mesh::maxNodes ( const Nodes::index  coord) const
inlineprivate

return the maximum of all nodes coordinate along coord axis

Parameters
[in]coord

◆ minNodes()

double Mesh::mesh::minNodes ( const Nodes::index  coord) const
inlineprivate

return the minimum of all nodes coordinate along coord axis

Parameters
[in]coord

◆ operator=()

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

operator= deleted

◆ readMesh()

void Mesh::mesh::readMesh ( const Settings mySets)
private

reading mesh format 2.2 text file function

Parameters
[in]mySets

◆ readNodes()

void Mesh::mesh::readNodes ( const Settings mySets)
private

read Nodes from mesh file

Parameters
[in]mySets

◆ readSol()

double Mesh::mesh::readSol ( bool  VERBOSE,
const std::string &  fileName 
)

read a solution from a file (tsv formated) and initialize fem struct to restart computation from that distribution, return time

Parameters
[in]VERBOSE
[in]fileNameinput .sol text file

◆ readTetraedrons()

void Mesh::mesh::readTetraedrons ( const Settings mySets)
private

read tetraedrons of the settings volume regions

Parameters
[in]mySets

◆ readTriangles()

void Mesh::mesh::readTriangles ( const Settings mySets)
private

read triangles of the settings surface regions

Parameters
[in]mySets

◆ savesol()

void Mesh::mesh::savesol ( const int  precision,
const std::string &  fileName,
const std::string &  metadata,
bool  withSpinAcc,
std::vector< Eigen::Vector3d > &  s 
) const

text file (tsv) writing function for a solution, node indices are zero based first column is index, then magnetization components, then scalar magnetic potential. If spin accumulation was involved, there are three extra columns for the componants of the spin diffusion vector. Since some volume region might be non magnetic, magnetization is undefined on those nodes and nan is used

Parameters
[in]precisionnumeric precision in .sol output text file
[in]fileName
[in]metadata
[in]withSpinAcc
[in]sspin accumulation (might be empty)

◆ set()

void Mesh::mesh::set ( const int  i,
const std::function< void(Nodes::Node &, const double)> &  what_to_set,
const double  val 
)
inline

setter for node[i]; what_to_set will fix what is the part of the node struct to set (usefull for fmm_demag.h)

Parameters
[in]i
[in]what_to_set
[in]val

◆ set_node_u0()

void Mesh::mesh::set_node_u0 ( const int  i,
const Eigen::Vector3d &  val 
)
inline

setter for u0

◆ set_node_zero_v()

void Mesh::mesh::set_node_zero_v ( const int  i)
inline

fix to zero node[i].v

◆ setBasis()

void Mesh::mesh::setBasis ( const double  r)
inline

call setBasis for all nodes, and update P matrix for all elements

◆ setExtSpaceField()

void mesh::setExtSpaceField ( Settings s)
private

when external applied field is of field_type R4toR3 values of field_space are stored in spaceField

Parameters
[in]s

◆ sortNodes()

void mesh::sortNodes ( Nodes::index  long_axis)
private

Sort the nodes along the longest axis of the sample. This should reduce the bandwidth of the matrix we will have to solve for.

Parameters
[in]long_axis

◆ surface()

double mesh::surface ( std::vector< int > &  triIndices) const
private

returns the surface defined by the set of triangle of indices in triIndices each elementary surface triangle defined by points p0,p1,p2 is computed using norm(cross(p0p1,p0p2))/2, it is always positive

◆ thiele()

double mesh::thiele ( const int  region) const

returns Thiele length in the magnetic volume region of index region. this is an integral on a volume region of sq(grad(u).grad(u)) with usual weighted dot on each tetra. It is normalized by a surface: the average cross-section

Parameters
regionregion index, or -1 for all magnetic regions

◆ updateDeltaMs()

void mesh::updateDeltaMs ( )
private

Update dMs on each triangular element, with a sign that is consistent with the triangle's orientation.

◆ updateNode()

void Mesh::mesh::updateNode ( const int  i,
const double  vp,
const double  vq,
const double  dt 
)
inline

make_evol on i^th node

Member Data Documentation

◆ c

Eigen::Vector3d Mesh::mesh::c

isobarycenter

◆ edges

std::vector<Edge> Mesh::mesh::edges

Edges of all the tetrahedrons. Each edge is a sorted pair of indices. The list is sorted lexicographically, as per std::pair::operator<().

◆ extSpaceField

std::vector< Eigen::Matrix<double,Nodes::DIM,Tetra::NPI> > Mesh::mesh::extSpaceField

external applied space field, values on gauss points, size is number of tetraedrons

◆ l

Eigen::Vector3d Mesh::mesh::l

lengths along x,y,z axis

◆ magNode

std::vector<bool> Mesh::mesh::magNode

list of the magnetic nodes, using inner indices (non gmsh indices). If true it is magnetic. a node is magnetic if it belongs to a magnetic tetrahedron. Consequently any node on a magnetic/non magnetic interface is set to true in magNode.

◆ magTet

std::vector<int> Mesh::mesh::magTet

list of the indices of all magnetic tetrahedrons from all volume regions

◆ magTri

std::vector<int> Mesh::mesh::magTri

List of the indices of all surface triangles which can hold magnetic charges, i.e. the triangles where:

  • all the vertices are magnetic nodes
  • the suppress_charges flag is unset.

◆ node

std::vector<Nodes::Node> Mesh::mesh::node
private

node container: not initialized by constructor, but later while reading the mesh by member function init_node

◆ node_index

std::vector<int> Mesh::mesh::node_index
private

Index of a node in the node vector. This vector is itself indexed by the node position in the *.msh and *.sol files. In other words, the node found at file_idx in a file is stored as node[node_index[file_idx]].

This is the inverse of the permutation we applied when sorting the nodes.

◆ paramTetra

std::vector<Tetra::prm>& Mesh::mesh::paramTetra

Reference to the volume regions in Settings.

◆ tet

std::vector<Tetra::Tet> Mesh::mesh::tet

tetrahedron container

◆ totalMagVol

double Mesh::mesh::totalMagVol

total magnetic volume of the mesh

◆ tri

std::vector<Triangle::Tri> Mesh::mesh::tri

triangle container. Contains only those on a surface region.

◆ vol

double Mesh::mesh::vol

total volume of the mesh

◆ volumeRegions

std::vector<std::vector<int> > Mesh::mesh::volumeRegions
private

List of tetrahedrons making each volume region.


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