DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes
DGtal::VectorsInHeat< TPolygonalCalculus > Class Template Reference

This class implements [109] on polygonal surfaces (using Discrete differential calculus on polygonal surfaces). More...

#include <DGtal/dec/VectorsInHeat.h>

Public Types

typedef TPolygonalCalculus PolygonalCalculus
 
typedef PolygonalCalculus::SparseMatrix SparseMatrix
 
typedef PolygonalCalculus::DenseMatrix DenseMatrix
 
typedef PolygonalCalculus::Solver Solver
 
typedef PolygonalCalculus::Vector Vector
 
typedef PolygonalCalculus::Vertex Vertex
 
typedef PolygonalCalculus::LinAlg LinAlgBackend
 
typedef DirichletConditions< LinAlgBackendConditions
 
typedef Conditions::IntegerVector IntegerVector
 

Public Member Functions

 VectorsInHeat ()=delete
 
 VectorsInHeat (ConstAlias< PolygonalCalculus > calculus)
 
 ~VectorsInHeat ()=default
 
 VectorsInHeat (const VectorsInHeat &other)=delete
 
 VectorsInHeat (VectorsInHeat &&other)=delete
 
VectorsInHeatoperator= (const VectorsInHeat &other)=delete
 
VectorsInHeatoperator= (VectorsInHeat &&other)=delete
 
void init (double dt, double lambda=1.0, bool boundary_with_mixed_solution=false)
 
void addSource (const Vertex aV, const Vector &ev)
 
void clearSource ()
 
Vector vectorSource () const
 
Vector extrinsicVectorSourceAtVertex (const Vertex aV)
 extrinsicVectorSourceAtVertex get extrinsic source at vertex More...
 
Vector intrinsicVectorSourceAtVertex (const Vertex aV)
 intrinsicVectorSourceAtVertex get intrinsic source at vertex More...
 
std::vector< Vectorcompute () const
 
bool isValid () const
 

Private Attributes

const PolygonalCalculusmyCalculus
 The underlying PolygonalCalculus instance. More...
 
SparseMatrix myScalarHeatOpe
 The operators for heat diffusion. More...
 
SparseMatrix myVectorHeatOpe
 
Solver myScalarHeatSolver
 Heat solvers. More...
 
Solver myVectorHeatSolver
 
Vector myScalarSource
 Source vectors. More...
 
Vector myDiracSource
 
Vector myVectorSource
 
bool myManageBoundary
 
IntegerVector myBoundary
 The boundary characteristic vector. More...
 
bool myIsInit
 Validitate flag. More...
 
Solver myHeatDirichletSolver
 Heat solver with Dirichlet boundary conditions. More...
 

Detailed Description

template<typename TPolygonalCalculus>
class DGtal::VectorsInHeat< TPolygonalCalculus >

This class implements [109] on polygonal surfaces (using Discrete differential calculus on polygonal surfaces).

Description of template class 'VectorsInHeat'

see Vector Heat Method using discrete polygonal calculus for details and examples.

Template Parameters
amodel of PolygonalCalculus.

Definition at line 62 of file VectorsInHeat.h.

Member Typedef Documentation

◆ Conditions

template<typename TPolygonalCalculus >
typedef DirichletConditions< LinAlgBackend > DGtal::VectorsInHeat< TPolygonalCalculus >::Conditions

Definition at line 74 of file VectorsInHeat.h.

◆ DenseMatrix

template<typename TPolygonalCalculus >
typedef PolygonalCalculus::DenseMatrix DGtal::VectorsInHeat< TPolygonalCalculus >::DenseMatrix

Definition at line 69 of file VectorsInHeat.h.

◆ IntegerVector

template<typename TPolygonalCalculus >
typedef Conditions::IntegerVector DGtal::VectorsInHeat< TPolygonalCalculus >::IntegerVector

Definition at line 75 of file VectorsInHeat.h.

◆ LinAlgBackend

template<typename TPolygonalCalculus >
typedef PolygonalCalculus::LinAlg DGtal::VectorsInHeat< TPolygonalCalculus >::LinAlgBackend

Definition at line 73 of file VectorsInHeat.h.

◆ PolygonalCalculus

template<typename TPolygonalCalculus >
typedef TPolygonalCalculus DGtal::VectorsInHeat< TPolygonalCalculus >::PolygonalCalculus

Definition at line 67 of file VectorsInHeat.h.

◆ Solver

template<typename TPolygonalCalculus >
typedef PolygonalCalculus::Solver DGtal::VectorsInHeat< TPolygonalCalculus >::Solver

Definition at line 70 of file VectorsInHeat.h.

◆ SparseMatrix

template<typename TPolygonalCalculus >
typedef PolygonalCalculus::SparseMatrix DGtal::VectorsInHeat< TPolygonalCalculus >::SparseMatrix

Definition at line 68 of file VectorsInHeat.h.

◆ Vector

template<typename TPolygonalCalculus >
typedef PolygonalCalculus::Vector DGtal::VectorsInHeat< TPolygonalCalculus >::Vector

Definition at line 71 of file VectorsInHeat.h.

◆ Vertex

template<typename TPolygonalCalculus >
typedef PolygonalCalculus::Vertex DGtal::VectorsInHeat< TPolygonalCalculus >::Vertex

Definition at line 72 of file VectorsInHeat.h.

Constructor & Destructor Documentation

◆ VectorsInHeat() [1/4]

template<typename TPolygonalCalculus >
DGtal::VectorsInHeat< TPolygonalCalculus >::VectorsInHeat ( )
delete

Default constructor.

◆ VectorsInHeat() [2/4]

template<typename TPolygonalCalculus >
DGtal::VectorsInHeat< TPolygonalCalculus >::VectorsInHeat ( ConstAlias< PolygonalCalculus calculus)
inline

Constructor from an existing polygonal calculus. T

Parameters
calculusa instance of PolygonalCalculus

Definition at line 84 of file VectorsInHeat.h.

84 : myCalculus(&calculus)
85 {
86 myIsInit=false;
87 }
bool myIsInit
Validitate flag.
const PolygonalCalculus * myCalculus
The underlying PolygonalCalculus instance.

References DGtal::VectorsInHeat< TPolygonalCalculus >::myIsInit.

◆ ~VectorsInHeat()

template<typename TPolygonalCalculus >
DGtal::VectorsInHeat< TPolygonalCalculus >::~VectorsInHeat ( )
default

Destructor.

◆ VectorsInHeat() [3/4]

template<typename TPolygonalCalculus >
DGtal::VectorsInHeat< TPolygonalCalculus >::VectorsInHeat ( const VectorsInHeat< TPolygonalCalculus > &  other)
delete

Copy constructor.

Parameters
otherthe object to clone.

◆ VectorsInHeat() [4/4]

template<typename TPolygonalCalculus >
DGtal::VectorsInHeat< TPolygonalCalculus >::VectorsInHeat ( VectorsInHeat< TPolygonalCalculus > &&  other)
delete

Move constructor.

Parameters
otherthe object to move.

Member Function Documentation

◆ addSource()

template<typename TPolygonalCalculus >
void DGtal::VectorsInHeat< TPolygonalCalculus >::addSource ( const Vertex  aV,
const Vector ev 
)
inline

Adds a source vector (3D extrinsic) at a vertex aV the vector gets projected to the tangent space

Parameters
aVthe Vertex
evthe extrinsic R3 vector to add (only keeps the tangential part)

Definition at line 182 of file VectorsInHeat.h.

183 {
184 ASSERT_MSG(aV < myCalculus->nbVertices(), "Vertex is not in the surface mesh vertex range");
185 Vector v = myCalculus->Tv(aV).transpose()*ev;
186 v = v.normalized()*ev.norm();
187 myVectorSource( 2*aV ) = v(0);
188 myVectorSource( 2*aV+1 ) = v(1);
189 myScalarSource( aV ) = v.norm();
190 myDiracSource( aV ) = 1;
191 }
Vector myScalarSource
Source vectors.
FreemanChain< int >::Vector Vector

References DGtal::VectorsInHeat< TPolygonalCalculus >::myCalculus, DGtal::VectorsInHeat< TPolygonalCalculus >::myDiracSource, DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarSource, and DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorSource.

◆ clearSource()

template<typename TPolygonalCalculus >
void DGtal::VectorsInHeat< TPolygonalCalculus >::clearSource ( )
inline

◆ compute()

template<typename TPolygonalCalculus >
std::vector< Vector > DGtal::VectorsInHeat< TPolygonalCalculus >::compute ( ) const
inline

Main computation of the Vectors In Heat

Returns
the estimated heat diffused vectors from the sources expressed

Definition at line 237 of file VectorsInHeat.h.

238 {
239 FATAL_ERROR_MSG(myIsInit, "init() method must be called first");
240 //Heat diffusion
241 Vector vectorHeatDiffusion = myVectorHeatSolver.solve(myVectorSource);
242 Vector scalarHeatDiffusion = myScalarHeatSolver.solve(myScalarSource);
243 Vector diracHeatDiffusion = myScalarHeatSolver.solve(myDiracSource);
244 auto surfmesh = myCalculus->getSurfaceMeshPtr();
245
246
247 // Take care of boundaries
248 if ( myManageBoundary )
249 {
250 Vector bValues = Vector::Zero( myCalculus->nbVertices() );
252 myBoundary, bValues );
253 Vector bSol = myHeatDirichletSolver.solve( bNormSources );
254 Vector heatDiffusionDirichlet
255 = Conditions::dirichletSolution( bSol, myBoundary, bValues );
256 scalarHeatDiffusion = 0.5 * ( scalarHeatDiffusion + heatDiffusionDirichlet );
257 }
258
259 std::vector<Vector> result(surfmesh->nbVertices());
260
261 for (auto v = 0;v<surfmesh->nbVertices();v++){
262 Vector Y(2);
263 Y(0) = vectorHeatDiffusion(2*v);
264 Y(1) = vectorHeatDiffusion(2*v+1);
265 Y = Y.normalized()*(scalarHeatDiffusion(v)/diracHeatDiffusion(v));
266 result[v] = myCalculus->toExtrinsicVector(v,Y);
267 }
268
269 return result;
270 }
static DenseVector dirichletVector(const SparseMatrix &A, const DenseVector &b, const IntegerVector &p, const DenseVector &u)
static DenseVector dirichletSolution(const DenseVector &xd, const IntegerVector &p, const DenseVector &u)
SparseMatrix myScalarHeatOpe
The operators for heat diffusion.
IntegerVector myBoundary
The boundary characteristic vector.
Solver myScalarHeatSolver
Heat solvers.
Solver myHeatDirichletSolver
Heat solver with Dirichlet boundary conditions.

References DGtal::DirichletConditions< TLinearAlgebraBackend >::dirichletSolution(), DGtal::DirichletConditions< TLinearAlgebraBackend >::dirichletVector(), DGtal::VectorsInHeat< TPolygonalCalculus >::myBoundary, DGtal::VectorsInHeat< TPolygonalCalculus >::myCalculus, DGtal::VectorsInHeat< TPolygonalCalculus >::myDiracSource, DGtal::VectorsInHeat< TPolygonalCalculus >::myHeatDirichletSolver, DGtal::VectorsInHeat< TPolygonalCalculus >::myIsInit, DGtal::VectorsInHeat< TPolygonalCalculus >::myManageBoundary, DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarHeatOpe, DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarHeatSolver, DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarSource, DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorHeatSolver, and DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorSource.

◆ extrinsicVectorSourceAtVertex()

template<typename TPolygonalCalculus >
Vector DGtal::VectorsInHeat< TPolygonalCalculus >::extrinsicVectorSourceAtVertex ( const Vertex  aV)
inline

extrinsicVectorSourceAtVertex get extrinsic source at vertex

Parameters
aVthe vertex
Returns
3D source vector

Definition at line 216 of file VectorsInHeat.h.

216 {
217 FATAL_ERROR_MSG(myIsInit, "init() method must be called first");
218 return myCalculus->toExtrinsicVector(aV,intrinsicVectorSourceAtVertex(aV));
219 }
Vector intrinsicVectorSourceAtVertex(const Vertex aV)
intrinsicVectorSourceAtVertex get intrinsic source at vertex

References DGtal::VectorsInHeat< TPolygonalCalculus >::intrinsicVectorSourceAtVertex(), DGtal::VectorsInHeat< TPolygonalCalculus >::myCalculus, and DGtal::VectorsInHeat< TPolygonalCalculus >::myIsInit.

◆ init()

template<typename TPolygonalCalculus >
void DGtal::VectorsInHeat< TPolygonalCalculus >::init ( double  dt,
double  lambda = 1.0,
bool  boundary_with_mixed_solution = false 
)
inline

Initialize the solvers with dt as timestep for the heat diffusion and lambda parameter for the polygonal calculus, which guarantee definiteness for positive lambda.

Parameters
dttimestep
lambda
boundary_with_mixed_solutionwhen 'true' and when the surface has boundaries, mix two solutions of the heat diffusion operation (Neumann and Dirichlet null conditions on boundary).

Definition at line 134 of file VectorsInHeat.h.

136 {
137 myIsInit=true;
138
139 SparseMatrix laplacian = myCalculus->globalLaplaceBeltrami( lambda );
140
141 SparseMatrix connectionLaplacian = myCalculus->globalConnectionLaplace( lambda );
142
143 SparseMatrix mass = myCalculus->globalLumpedMassMatrix();
144 SparseMatrix mass2= myCalculus->doubledGlobalLumpedMassMatrix();
145 myScalarHeatOpe = mass - dt*laplacian;
146 myVectorHeatOpe = mass2 - dt*connectionLaplacian;
147
148 //Prefactorizing
151
152 //empty sources
153 myVectorSource = Vector::Zero(2*myCalculus->nbVertices());
154 myScalarSource = Vector::Zero(myCalculus->nbVertices());
155 myDiracSource = Vector::Zero(myCalculus->nbVertices());
156
157 // Manage boundaries
158 myManageBoundary = false;
159 if ( ! boundary_with_mixed_solution ) return;
160 myBoundary = IntegerVector::Zero(myCalculus->nbVertices());
161 const auto surfmesh = myCalculus->getSurfaceMeshPtr();
162 const auto edges = surfmesh->computeManifoldBoundaryEdges();
163 for ( auto e : edges )
164 {
165 const auto vtcs = surfmesh->edgeVertices( e );
166 myBoundary[ vtcs.first ] = 1;
167 myBoundary[ vtcs.second ] = 1;
168 }
169 myManageBoundary = ! edges.empty();
170 if ( ! myManageBoundary ) return;
171 // Prepare solver for a problem with Dirichlet conditions.
173 // Prefactoring
174 myHeatDirichletSolver.compute( heatOpe_d );
175 }
static SparseMatrix dirichletOperator(const SparseMatrix &A, const IntegerVector &p)
SparseMatrix myVectorHeatOpe
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator > edges(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
void laplacian(Shape &shape, const Options &options, std::function< double(const RealPoint3D &)> input_function, std::function< double(const RealPoint3D &)> target_function, int argc, char **argv)
EigenLinearAlgebraBackend::SparseMatrix SparseMatrix

References DGtal::DirichletConditions< TLinearAlgebraBackend >::dirichletOperator(), laplacian(), DGtal::VectorsInHeat< TPolygonalCalculus >::myBoundary, DGtal::VectorsInHeat< TPolygonalCalculus >::myCalculus, DGtal::VectorsInHeat< TPolygonalCalculus >::myDiracSource, DGtal::VectorsInHeat< TPolygonalCalculus >::myHeatDirichletSolver, DGtal::VectorsInHeat< TPolygonalCalculus >::myIsInit, DGtal::VectorsInHeat< TPolygonalCalculus >::myManageBoundary, DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarHeatOpe, DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarHeatSolver, DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarSource, DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorHeatOpe, DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorHeatSolver, and DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorSource.

◆ intrinsicVectorSourceAtVertex()

template<typename TPolygonalCalculus >
Vector DGtal::VectorsInHeat< TPolygonalCalculus >::intrinsicVectorSourceAtVertex ( const Vertex  aV)
inline

intrinsicVectorSourceAtVertex get intrinsic source at vertex

Parameters
aVthe vertex
Returns
2D vector expressed in aV tangent frame

Definition at line 226 of file VectorsInHeat.h.

226 {
227 FATAL_ERROR_MSG(myIsInit, "init() method must be called first");
228 Vector s(2);
229 s(0) = myVectorSource(2*aV);
230 s(1) = myVectorSource(2*aV+1);
231 return s;
232 }

References DGtal::VectorsInHeat< TPolygonalCalculus >::myIsInit, and DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorSource.

Referenced by DGtal::VectorsInHeat< TPolygonalCalculus >::extrinsicVectorSourceAtVertex().

◆ isValid()

template<typename TPolygonalCalculus >
bool DGtal::VectorsInHeat< TPolygonalCalculus >::isValid ( ) const
inline
Returns
true if the calculus is valid.

Definition at line 274 of file VectorsInHeat.h.

275 {
276 return myIsInit && myCalculus->isValid();
277 }

References DGtal::VectorsInHeat< TPolygonalCalculus >::myCalculus, and DGtal::VectorsInHeat< TPolygonalCalculus >::myIsInit.

◆ operator=() [1/2]

template<typename TPolygonalCalculus >
VectorsInHeat & DGtal::VectorsInHeat< TPolygonalCalculus >::operator= ( const VectorsInHeat< TPolygonalCalculus > &  other)
delete

Copy assignment operator.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ operator=() [2/2]

template<typename TPolygonalCalculus >
VectorsInHeat & DGtal::VectorsInHeat< TPolygonalCalculus >::operator= ( VectorsInHeat< TPolygonalCalculus > &&  other)
delete

Move assignment operator.

Parameters
otherthe object to move.
Returns
a reference on 'this'.

◆ vectorSource()

template<typename TPolygonalCalculus >
Vector DGtal::VectorsInHeat< TPolygonalCalculus >::vectorSource ( ) const
inline
Returns
the source points vector.

Definition at line 205 of file VectorsInHeat.h.

206 {
207 FATAL_ERROR_MSG(myIsInit, "init() method must be called first");
208 return myVectorSource;
209 }

References DGtal::VectorsInHeat< TPolygonalCalculus >::myIsInit, and DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorSource.

Field Documentation

◆ myBoundary

template<typename TPolygonalCalculus >
IntegerVector DGtal::VectorsInHeat< TPolygonalCalculus >::myBoundary
private

The boundary characteristic vector.

Definition at line 304 of file VectorsInHeat.h.

Referenced by DGtal::VectorsInHeat< TPolygonalCalculus >::compute(), and DGtal::VectorsInHeat< TPolygonalCalculus >::init().

◆ myCalculus

template<typename TPolygonalCalculus >
const PolygonalCalculus* DGtal::VectorsInHeat< TPolygonalCalculus >::myCalculus
private

◆ myDiracSource

template<typename TPolygonalCalculus >
Vector DGtal::VectorsInHeat< TPolygonalCalculus >::myDiracSource
private

◆ myHeatDirichletSolver

template<typename TPolygonalCalculus >
Solver DGtal::VectorsInHeat< TPolygonalCalculus >::myHeatDirichletSolver
private

Heat solver with Dirichlet boundary conditions.

Definition at line 310 of file VectorsInHeat.h.

Referenced by DGtal::VectorsInHeat< TPolygonalCalculus >::compute(), and DGtal::VectorsInHeat< TPolygonalCalculus >::init().

◆ myIsInit

template<typename TPolygonalCalculus >
bool DGtal::VectorsInHeat< TPolygonalCalculus >::myIsInit
private

◆ myManageBoundary

template<typename TPolygonalCalculus >
bool DGtal::VectorsInHeat< TPolygonalCalculus >::myManageBoundary
private

When 'true', manage boundaries with a mixed solution of Neumann and Dirichlet conditions.

Definition at line 301 of file VectorsInHeat.h.

Referenced by DGtal::VectorsInHeat< TPolygonalCalculus >::compute(), and DGtal::VectorsInHeat< TPolygonalCalculus >::init().

◆ myScalarHeatOpe

template<typename TPolygonalCalculus >
SparseMatrix DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarHeatOpe
private

The operators for heat diffusion.

Definition at line 287 of file VectorsInHeat.h.

Referenced by DGtal::VectorsInHeat< TPolygonalCalculus >::compute(), and DGtal::VectorsInHeat< TPolygonalCalculus >::init().

◆ myScalarHeatSolver

template<typename TPolygonalCalculus >
Solver DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarHeatSolver
private

◆ myScalarSource

template<typename TPolygonalCalculus >
Vector DGtal::VectorsInHeat< TPolygonalCalculus >::myScalarSource
private

◆ myVectorHeatOpe

template<typename TPolygonalCalculus >
SparseMatrix DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorHeatOpe
private

Definition at line 288 of file VectorsInHeat.h.

Referenced by DGtal::VectorsInHeat< TPolygonalCalculus >::init().

◆ myVectorHeatSolver

template<typename TPolygonalCalculus >
Solver DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorHeatSolver
private

◆ myVectorSource

template<typename TPolygonalCalculus >
Vector DGtal::VectorsInHeat< TPolygonalCalculus >::myVectorSource
private

The documentation for this class was generated from the following file: