17 #include "vector_base_view.h"
21 #include <GL/freeglut.h>
33 template<
typename Scalar>
34 void VectorBaseView<Scalar>::show(SpaceSharedPtr<Scalar> space)
37 pss =
new PrecalcShapeset(space->shapeset);
38 sln =
new Solution<Scalar>();
40 ndof = space->get_num_dofs();
45 template<
typename Scalar>
46 VectorBaseView<Scalar>::VectorBaseView(
const char* title, WinGeom* wg)
47 : VectorView(title, wg) {
48 pss =
nullptr; sln =
nullptr; this->lines =
false; basic_title.assign(title);
51 template<
typename Scalar>
52 VectorBaseView<Scalar>::VectorBaseView(
char* title, WinGeom* wg)
53 : VectorView(title, wg) {
54 pss =
nullptr; sln =
nullptr; this->lines =
false; basic_title.assign(title);
57 template<
typename Scalar>
58 VectorBaseView<Scalar>::~VectorBaseView()
63 template<
typename Scalar>
64 void VectorBaseView<Scalar>::free()
66 if (pss !=
nullptr) {
delete pss; pss =
nullptr; }
70 void VectorBaseView<double>::update_solution()
72 double* coeffs = malloc_with_check<double>(ndof + 1);
73 memset(coeffs, 0,
sizeof(
double)* (ndof + 1));
74 if (base_index >= -1 && base_index < ndof)
75 coeffs[base_index + 1] = 1.0;
77 Solution<double>::vector_to_solution(coeffs, space, sln, pss);
79 VectorView::show(sln, sln, H2D_FN_VAL_0, H2D_FN_VAL_1);
82 free_with_check(coeffs);
85 void VectorBaseView<std::complex<double> >::update_solution()
87 std::complex<double>* coeffs = calloc_with_check<std::complex<double> >(ndof + 1);
88 if (base_index >= -1 && base_index < ndof)
89 coeffs[base_index + 1] = 1.0;
90 Solution<std::complex<double> >::vector_to_solution(coeffs, space, sln, pss);
94 this->VectorView::show(&filter, &filter, H2D_FN_VAL_0, H2D_FN_VAL_1);
97 free_with_check(coeffs);
100 template<
typename Scalar>
101 void VectorBaseView<Scalar>::update_title()
103 std::stringstream str;
104 str << basic_title <<
" - dof = " << base_index;
106 str <<
" (Dirichlet lift)";
107 View::set_title(str.str().c_str());
110 template<
typename Scalar>
111 void VectorBaseView<Scalar>::on_special_key(
int key,
int x,
int y)
116 if (base_index > -1) base_index--;
121 if (base_index < ndof - 1) base_index++;
126 VectorView::on_special_key(key, x, y);
130 template<
typename Scalar>
131 const char* VectorBaseView<Scalar>::get_help_text()
const
136 " Left mouse - pan\n"
137 " Right mouse - zoom\n"
138 " Left arrow - previous basis function\n"
139 " Right arrow - next basis function\n"
140 " C - center image\n"
141 " F - toggle smooth palette\n"
142 " X - toggle hexagonal grid\n"
143 " H - render high-quality frame\n"
145 " P - cycle palettes\n"
146 " S - save screenshot\n"
161 template class HERMES_API VectorBaseView < double > ;
162 template class HERMES_API VectorBaseView < std::complex<double> > ;
Common definitions for Hermes2D.
Removes the imaginary part from a function.