1#ifndef __FIBER_FIELD_CELL_HPP
2#define __FIBER_FIELD_CELL_HPP
4#include "FiberType.hpp"
5#include <vector/MultiIndex.hpp>
6#include <eagle/FixedArray.hpp>
17static const char*ComponentName(
int i)
19 static const char IJ[2][2] = {
"i",
"j" };
40template <Eagle::dimension_t DIMS, Eagle::dimension_t Elements,
class IndexType>
68template <Eagle::dimension_t Dims,
class IndexType,
class NamingConvention = IJ_CellNamingConvention>
91 return ( (i<=Dims-1)? NamingConvention::ComponentName(0) : NamingConvention::ComponentName(1) )
98template <
class IndexType>
127template <
int Dims,
class IndexType,
class NamingConvention = IJ_CellNamingConvention>
130 typedef Cell<Dims, (1<<Dims), IndexType > Base_t;
138 RegularCell(const RegularCell&RC)
143 RegularCell(const std::initializer_list<IndexType>&Init)
148static std::string coordinate_name(int i)
150 return RegularCell<Dims-1, IndexType>::coordinate_name(i>>1) +
151 NamingConvention::ComponentName( i & 1 );
155template <class IndexType, class NamingConvention>
156struct RegularCell<0, IndexType, NamingConvention>
158static std::string coordinate_name(int i)
167template <class IndexType>
170 SimplexCell<1,IndexType> Cell;
181template <class IndexType>
184 SimplexCell<2,IndexType> Cell;
201template <class IndexType>
204 SimplexCell<3,IndexType> Cell;
206 struct NamedTetrahedron
208 IndexType iii,iij,ijj,jjj;
215template <class IndexType>
218 RegularCell<2, IndexType> Cell;
222 IndexType ii,ij,ji,jj;
230template <class IndexType>
233 RegularCell<3, IndexType> Cell;
235 struct NamedHexaHedron
237 IndexType iii,iij,iji,ijj,jii,jij,jji,jjj;
243template<class IndexType, class NamingConvention = IJ_CellNamingConvention>
244struct DihedralCell : Cell< 1, 4, IndexType>
246 typedef Cell<1, 4, IndexType> Base_t;
250 DihedralCell(const DihedralCell&SC)
254 DihedralCell(const std::initializer_list<IndexType>&Init)
259static std::string coordinate_name(int i)
261 if( i == 0 ) return "i";
262 else if( i == 1 ) return "j";
263 else if( i == 2 ) return "k";
264 else if( i == 3 ) return "l";
270 if( (*this)[0] > (*this)[3] )
272 IndexType tmp = (*this)[0];
273 (*this)[0] = (*this)[3];
277 (*this)[1] = (*this)[2];
282 bool operator == (DihedralCell const& rhs) const
284 for( unsigned i = 0; i < 4; ++i)
285 if( (*this)[i] != rhs[i] )
292template <class IndexType>
295 DihedralCell<IndexType> Cell;
299 IndexType iii, iij, ijj, jjj;
313typedef SimplexCell<1, uint32_t> EdgeCell32;
315typedef SimplexCell<2, uint32_t> TriangleCell32;
317typedef SimplexCell<3, uint32_t> TetrahedronCell32;
320typedef RegularCell<2, uint32_t> QuadCell32;
322typedef RegularCell<3, uint32_t> HexahedronCell32;
325typedef SimplexCell<1, uint64_t> EdgeCell64;
326typedef SimplexCell<2, uint64_t> TriangleCell64;
327typedef SimplexCell<3, uint64_t> TetrahedronCell64;
329typedef RegularCell<2, uint64_t> QuadCell64;
330typedef RegularCell<3, uint64_t> HexahedronCell64;
334typedef EdgeCell32 EdgeCell;
336typedef TriangleCell32 TriangleCell;
338typedef TetrahedronCell32 TetrahedronCell;
341typedef QuadCell32 QuadCell;
343typedef HexahedronCell32 HexahedronCell;
350typedef SimplexCell<1, uint32_t> EdgeCell32_t;
353typedef SimplexCell<2, uint32_t> TriangleCell32_t;
356typedef SimplexCell<3, uint32_t> TetrahedronCell32_t;
358typedef RegularCell<2, uint32_t> QuadCell32_t;
359typedef RegularCell<3, uint32_t> HexahedronCell32_t;
363typedef SimplexCell<1, uint64_t> EdgeCell64_t;
364typedef SimplexCell<2, uint64_t> TriangleCell64_t;
365typedef SimplexCell<3, uint64_t> TetrahedronCell64_t;
367typedef RegularCell<2, uint64_t> QuadCell64_t;
368typedef RegularCell<3, uint64_t> HexahedronCell64_t;
371typedef DihedralCell<uint32_t> Dihedral32_t;
372typedef DihedralCell<uint64_t> Dihedral64_t;
375typedef EdgeCell32_t EdgeCell_t;
377typedef TriangleCell32_t TriangleCell_t;
379typedef TetrahedronCell32_t TetrahedronCell_t;
382typedef QuadCell32_t QuadCell_t;
384typedef HexahedronCell32_t HexahedronCell_t;
386typedef Dihedral32_t Dihedral_t;
395template <Eagle::dimension_t Dims, int Elements, class IndexType>
396struct MetaInfo<Fiber::Cell<Dims, Elements, IndexType> >
401 MULTIPLICITY = Elements,
412 typedef IndexType element_t;
415 typedef void Chart_t;
417static const element_t&getComponent(const Fiber::Cell<Dims, Elements, IndexType>&t, int i)
424template <Eagle::dimension_t Dims, class IndexType, class NamingConvention>
425struct MetaInfo<Fiber::SimplexCell<Dims,IndexType,NamingConvention> > : MetaInfo<typename Fiber::SimplexCell<Dims,IndexType,NamingConvention>::Base_t>
427 typedef Fiber::SimplexCell<Dims,IndexType> Chart_t;
430template <int Dims, class IndexType, class NamingConvention>
431struct MetaInfo<Fiber::RegularCell<Dims,IndexType,NamingConvention> > : MetaInfo<typename Fiber::RegularCell<Dims,IndexType,NamingConvention>::Base_t>
433 typedef Fiber::RegularCell<Dims,IndexType,NamingConvention> Chart_t;
443template <Eagle::dimension_t DIMS, int Elements, class IndexType>
444struct BaseClass<Fiber::Cell<DIMS, Elements, IndexType> >
447 typedef typename Fiber::Cell<DIMS, Elements, IndexType>::Base_t result;
450template <Eagle::dimension_t Dims, class IndexType, class NamingConvention>
451struct BaseClass<Fiber::SimplexCell<Dims, IndexType, NamingConvention> >
455 typedef typename Fiber::SimplexCell<Dims, IndexType, NamingConvention>::Base_t result;
458template <Eagle::dimension_t Dims, class IndexType, class NamingConvention>
459struct BaseClass<Fiber::RegularCell<Dims, IndexType, NamingConvention> >
463 typedef typename Fiber::RegularCell<Dims, IndexType, NamingConvention>::Base_t result;
475template <Eagle::dimension_t Dims, class IndexType, class NamingConvention>
476inline string to_string(const Fiber::SimplexCell<Dims, IndexType, NamingConvention>&C,
477 const char*OpenBrace = "<", const char*CloseBrace = ">",
478 const char*Separator = ",")
480 return std::to_string( C.getFixedArray(), OpenBrace, CloseBrace, Separator);
486template <Eagle::dimension_t Dims, class IndexType, class NamingConvention>
487inline string to_string(const Fiber::RegularCell<Dims, IndexType, NamingConvention>&C, const char*OpenBrace = "",
488 const char*CloseBrace = "", const char*Separator = "x")
490 return to_string( C.getFixedArray(), OpenBrace, CloseBrace, Separator);
497 string to_string( const Fiber::Dihedral_t& dihedral );
499 template <> struct hash<Fiber::Dihedral32_t>
501 size_t operator()(const Fiber::Dihedral32_t & x) const
504 constexpr uint32_t dim_max = 512;
507 constexpr uint32_t dim_max = static_cast<uint32_t>( sqrt( sqrt( std::numeric_limits<uint32_t>::max() ) ) );
509 const Fiber::MultiIndex<4> max_size = { dim_max, dim_max, dim_max, dim_max };
510 Fiber::MultiIndex<4> tmp { x[0], x[1], x[2], x[3] };
511 return tmp.linear( max_size );
basic_string< char > string
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
A type describing a cell in a cell complex.
Definition Cell.hpp:42
A naming convention for cell components using "i" and "j".
Definition Cell.hpp:16
A type describing an n-dimensional regular cell.
Definition Cell.hpp:129
A type describing an n-dimensional simplex cell.
Definition Cell.hpp:70
Definition geospeed.cpp:55