Registered Member
|
Hi,
I am a freshman to this c++ software and use Eigen to bulid my FEM code. Now,I have a vitrual function IniEle(),and want to initizate the element just like follow:
Unfortunately,compiler throws error and I have to try another way. Anyone can help with this problem? |
Moderator
|
One solution is to use templated code instead of runtime polymorphism. If you want to keep the current architecture, then the virtual IniElement method must always have the exact same prototype. To this end, you can use the Ref<MatrixXd> type:
void IniElement(Ref<MatrixXd> coord, ...); which can reference any matrix or block of matrix similar to a MatrixXd. In case one implementation of IniElement can benefit from compile-time sizes, then you can still cast it to a Ref of appropriate size within the method: Ref<Matrix<double,3,2> > actual_coord(coord); |
Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar