9#ifndef model_SplineSegmentBase_H_
10#define model_SplineSegmentBase_H_
22 template <
short unsigned int dim,
short unsigned int corder>
29 template <
short unsigned int dim>
45 typedef std::map<size_t,
46 std::pair<VectorNcoeff,VectorDim>,
53 return (
RowNcoeff()<<1.0, uin).finished();
65 return RowNcoeffuu::Zero();
75 -1.0, 1.0).finished();
100 template<
typename LinkType>
106 link. sinkP.transpose()).finished();
110 template<
typename LinkType>
113 return VectorDim::Zero();
117 template<
typename LinkType>
120 return VectorDim::Zero();
143 template<
typename LinkType>
146 Eigen::Matrix<double,dim,Ncoeff> HrCf;
147 HrCf.col(0)= link.source->get_P();
148 HrCf.col(1)= link.sink->get_P();
177 template <
short unsigned int dim>
192 typedef std::map<size_t,
193 std::pair<VectorNcoeff,VectorDim>,
199 return (
RowNcoeff()<<1.0, uin, std::pow(uin,2), std::pow(uin,3)).finished();
204 return (
RowNcoeffu()<<1.0, 2.0*uin, 3.0*std::pow(uin,2)).finished();
220 -3.0, -2.0*g, 3.0, -g,
221 2.0, g, -2.0, g).finished();
243 template<
typename LinkType>
253 link. sink->get_P().transpose(),
254 sinkT(link).transpose()).finished();
260 template<
typename LinkType>
264 for(
const auto& loopLink : link.loopLinks())
266 if(link.source->sID==loopLink->source()->sID && link.sink->sID==loopLink->sink()->sID)
268 temp+=link.source->tangents().at(loopLink->loop()->sID);
270 else if(link.source->sID==loopLink->sink()->sID && link.sink->sID==loopLink->source()->sID)
272 temp-=link.source->tangents().at(loopLink->loop()->sID);
280 return link.loopLinks().size()==0?
temp :
temp/link.loopLinks().size();
284 template<
typename LinkType>
288 for(
const auto& loopLink : link.loopLinks())
290 if(link.source->sID==loopLink->source()->sID && link.sink->sID==loopLink->sink()->sID)
292 temp+=link.sink->tangents().at(loopLink->loop()->sID);
294 else if(link.source->sID==loopLink->sink()->sID && link.sink->sID==loopLink->source()->sID)
296 temp-=link.sink->tangents().at(loopLink->loop()->sID);
304 return link.loopLinks().size()==0?
temp :
temp/link.loopLinks().size();
311 template<
typename LinkType>
312 static std::pair<Eigen::Matrix<double,Ncoeff,Eigen::Dynamic>,Eigen::Matrix<double,Eigen::Dynamic,dim>>
hermite2posMatrix(
const LinkType& link)
316 Eigen::Matrix<double,Ncoeff,Eigen::Dynamic>
m(
Ncoeff,
temp.size());
317 Eigen::Matrix<double,Eigen::Dynamic,dim> n(
temp.size(),dim);
320 for (
const auto& ele :
temp)
322 m.col(
k)=ele.second.first;
323 n.row(
k)=ele.second.second.transpose();
327 return std::make_pair(
m,n);
331 template<
typename LinkType>
342 const std::map<size_t,std::map<size_t,std::pair<double,VectorDim>>> sourceMapMap=link.source->loopTangentCoeffs();
343 const std::map<size_t,std::map<size_t,std::pair<double,VectorDim>>> sinkMapMap=link. sink->loopTangentCoeffs();
346 for(
const auto& loopLink : link.loopLinks())
349 temp.emplace(link.source->snID(),std::make_pair((
VectorNcoeff()<<1.0,0.0,0.0,0.0).finished(),link.source->get_P()));
350 temp.emplace(link. sink->snID(),std::make_pair((
VectorNcoeff()<<0.0,0.0,1.0,0.0).finished(),link. sink->get_P()));
352 const auto& sourceMap=sourceMapMap.at(loopLink->loop()->sID);
353 const auto& sinkMap= sinkMapMap.at(loopLink->loop()->sID);
355 for(
const auto& pair : sourceMap)
358 const auto mapIter=
temp.find(pair.first);
359 if(mapIter==
temp.end())
361 temp.emplace(pair.first,std::make_pair(VectorNcoeff::Zero(),pair.second.second));
364 if(link.source->sID==loopLink->source()->sID && link.sink->sID==loopLink->sink()->sID)
366 temp[pair.first].first(1)+=pair.second.first/link.loopLinks().size();
368 else if(link.source->sID==loopLink->sink()->sID && link.sink->sID==loopLink->source()->sID)
370 temp[pair.first].first(1)-=pair.second.first/link.loopLinks().size();
378 for(
const auto& pair : sinkMap)
382 const auto mapIter=
temp.find(pair.first);
383 if(mapIter==
temp.end())
385 temp.emplace(pair.first,std::make_pair(VectorNcoeff::Zero(),pair.second.second));
388 if(link.source->sID==loopLink->source()->sID && link.sink->sID==loopLink->sink()->sID)
390 temp[pair.first].first(3)+=pair.second.first/link.loopLinks().size();
392 else if(link.source->sID==loopLink->sink()->sID && link.sink->sID==loopLink->source()->sID)
394 temp[pair.first].first(3)-=pair.second.first/link.loopLinks().size();
static VectorDim sinkT(const LinkType &)
Eigen::Matrix< double, Ncoeff, 1 > VectorNcoeff
static constexpr int corder
Eigen::Matrix< double, Ncoeff, Ncoeff > MatrixNcoeff
static RowNcoeffuu powersDiff2(const double &)
Eigen::Matrix< double, 1, Ncoeff > RowNcoeff
Eigen::Matrix< double, 1, Ncoeff-2 > RowNcoeffuu
static MatrixNcoeff sfCoeffs(const double &)
std::map< size_t, std::pair< VectorNcoeff, VectorDim >, std::less< size_t > > H2PmapType
static VectorDim sourceT(const LinkType &)
static Eigen::Matrix< double, dim, Ncoeff > hermiteCoefficients(const LinkType &link)
static RowNcoeff sfDiff2(const double &uin, const double &g)
static RowNcoeffu powersDiff1(const double &)
static RowNcoeff sfDiff1(const double &uin, const double &g)
Eigen::Matrix< double, Ncoeff, dim > MatrixNcoeffDim
static MatrixNcoeffDim hermiteDofs(const LinkType &link)
static RowNcoeff powers(const double &uin)
Eigen::Matrix< double, dim, 1 > VectorDim
Eigen::Matrix< double, 1, Ncoeff-1 > RowNcoeffu
static RowNcoeff sf(const double &uin, const double &g)
Eigen::Matrix< double, dim, dim > MatrixDim
static constexpr int Ncoeff
static RowNcoeff sfDiff2(const double &uin, const double &g)
Eigen::Matrix< double, Ncoeff, dim > MatrixNcoeffDim
static RowNcoeff sf(const double &uin, const double &g)
static std::pair< Eigen::Matrix< double, Ncoeff, Eigen::Dynamic >, Eigen::Matrix< double, Eigen::Dynamic, dim > > hermite2posMatrix(const LinkType &link)
std::map< size_t, std::pair< VectorNcoeff, VectorDim >, std::less< size_t > > H2PmapType
Eigen::Matrix< double, 1, Ncoeff-1 > RowNcoeffu
Eigen::Matrix< double, dim, dim > MatrixDim
static constexpr int Ncoeff
Eigen::Matrix< double, 1, Ncoeff > RowNcoeff
static H2PmapType hermite2posMap(const LinkType &link)
static RowNcoeffu powersDiff1(const double &uin)
Eigen::Matrix< double, 1, Ncoeff-2 > RowNcoeffuu
static MatrixNcoeffDim hermiteDofs(const LinkType &link)
static MatrixNcoeff sfCoeffs(const double &g)
Eigen::Matrix< double, Ncoeff, Ncoeff > MatrixNcoeff
static RowNcoeff powers(const double &uin)
static RowNcoeff sfDiff1(const double &uin, const double &g)
static constexpr int corder
Eigen::Matrix< double, dim, 1 > VectorDim
static RowNcoeffuu powersDiff2(const double &uin)
Eigen::Matrix< double, Ncoeff, 1 > VectorNcoeff
static VectorDim sinkT(const LinkType &link)
static VectorDim sourceT(const LinkType &link)