@@ -85,8 +85,6 @@ struct fe_de_elliptic {
8585 using DofHandler = typename FeSpace::DofHandlerType;
8686 using Triangulation = typename FeSpace::Triangulation;
8787 constexpr int embed_dim = Triangulation::embed_dim;
88- fdapde_assert (gf.n_layers () == 1 && gf[0 ].category ()[0 ] == ltype::point);
89- n_obs_ = gf[0 ].rows ();
9088 const Triangulation& triangulation = gf.template triangulation <0 >();
9189 const FeSpace& fe_space = std::get<0 >(info.penalty ).trial_space ();
9290 const DofHandler& dof_handler = fe_space.dof_handler ();
@@ -104,15 +102,6 @@ struct fe_de_elliptic {
104102 }
105103 w[i] = quad_rule.weights [i];
106104 }
107- // eval physical basis at spatial locations
108- const auto & spatial_index = geo_index_cast<0 , POINT>(gf[0 ]);
109- if (spatial_index.points_at_dofs ()) {
110- Psi_.resize (n_obs_, n_dofs_);
111- Psi_.setIdentity ();
112- } else {
113- Psi_ = point_eval_ (spatial_index.coordinates ());
114- }
115-
116105 // store handle for approximation of \int_D (e^g)
117106 int_exp_ = [&, PsiQuad, w](const vector_t & g) {
118107 double val_ = 0 ;
@@ -132,6 +121,8 @@ struct fe_de_elliptic {
132121 }
133122 return grad;
134123 };
124+
125+ analyze_data (gf);
135126 }
136127
137128 // perform finite element based numerical discretization
@@ -158,7 +149,22 @@ struct fe_de_elliptic {
158149 };
159150 return ;
160151 }
161-
152+ // fit from geoframe
153+ template <typename GeoFrame> void analyze_data (const GeoFrame& gf) {
154+ fdapde_static_assert (GeoFrame::Order == 1 , THIS_CLASS_IS_FOR_ORDER_ONE_GEOFRAMES_ONLY);
155+ fdapde_assert (gf.n_layers () == 1 && gf[0 ].category ()[0 ] == ltype::point);
156+ n_obs_ = gf[0 ].rows ();
157+
158+ // eval physical basis at spatial locations
159+ const auto & spatial_index = geo_index_cast<0 , POINT>(gf[0 ]);
160+ if (spatial_index.points_at_dofs ()) {
161+ Psi_.resize (n_obs_, n_dofs_);
162+ Psi_.setIdentity ();
163+ } else {
164+ Psi_ = point_eval_ (spatial_index.coordinates ());
165+ }
166+ return ;
167+ }
162168 // main fit entry point
163169 template <typename Optimizer> const vector_t & fit (double lambda, const vector_t & g_init, Optimizer&& opt) {
164170 g_ = opt.optimize (llik_t (*this , lambda, tol_), g_init);
0 commit comments