Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
FieldPointBase.h
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MODEL is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef _model_FieldPointBase_h
9#define _model_FieldPointBase_h
10
11namespace model
12{
13
25 template<typename Derived, typename FieldType>
27#ifdef _MODEL_MPI_
28 /* inheritance */ public Eigen::Map<Eigen::Matrix<typename FieldType::Scalar,FieldType::rows,FieldType::cols> >
29#else
30 /* inheritance */ public Eigen::Matrix<typename FieldType::Scalar,FieldType::rows,FieldType::cols>
31#endif
32 {
33 enum{rows=FieldType::rows};
34 enum{cols=FieldType::cols};
36 typedef typename FieldType::Scalar Scalar;
38
39 const bool enabled;
40
41
42#ifdef _MODEL_MPI_
43 static std::vector<Scalar> resultVector;
44 typedef Eigen::Map<Eigen::Matrix<typename FieldType::Scalar,FieldType::rows,FieldType::cols> > EigenMapType;
46
47
48 /**********************************************************************/
49 static void resize(const unsigned int& k, const Scalar& val = Scalar())
50 {
51 resultVector.resize(k*DataPerParticle,val);
52 }
53
54 /**********************************************************************/
55 void set_mpiID(const size_t& k)
56 {
57 new (static_cast<EigenMapType*>(this)) EigenMapType(&resultVector[k*DataPerParticle]);
58 }
59
60 /**********************************************************************/
61 FieldPointBase(const bool& enb) :
62 /* init list */ Eigen::Map<Eigen::Matrix<Scalar,rows,cols> >(NULL),
63 /* init list */ enabled(enb)
64 {/*
65 */
66 }
67
68#else
69 typedef Eigen::Matrix<typename FieldType::Scalar,FieldType::rows,FieldType::cols> BaseEigenType;
70
71 /**********************************************************************/
72 FieldPointBase(const bool& enb) :
73 /* init list */ Eigen::Matrix<Scalar,rows,cols>(Eigen::Matrix<Scalar,rows,cols>::Zero()),
74 /* init list */ enabled(enb)
75 {/*
76 */
77 }
78#endif
79
80 template<typename OtherDerived>
81 FieldPointBaseType & operator= (const Eigen::MatrixBase<OtherDerived>& other)
82 {
83 BaseEigenType::operator=(other);
84 return *this;
85 }
86
87 };
88
89 // declare statica data
90#ifdef _MODEL_MPI_
91 template<typename Derived,
92 /* */ typename FieldType>
93 std::vector<typename FieldType::Scalar> FieldPointBase<Derived,FieldType>::resultVector;
94#endif
95
96} // end namespace
97#endif
void set_mpiID(const size_t &k)
static std::vector< Scalar > resultVector
FieldPointBaseType & operator=(const Eigen::MatrixBase< OtherDerived > &other)
FieldType::Scalar Scalar
FieldPointBase(const bool &enb)
EigenMapType BaseEigenType
Eigen::Map< Eigen::Matrix< typename FieldType::Scalar, FieldType::rows, FieldType::cols > > EigenMapType
static void resize(const unsigned int &k, const Scalar &val=Scalar())
FieldPointBase< Derived, FieldType > FieldPointBaseType
int k