programmer's documentation
Functions
cs_hodge.c File Reference

Build discrete Hodge operators. More...

#include "cs_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <assert.h>
#include <bft_mem.h>
#include <bft_printf.h>
#include "cs_sort.h"
#include "cs_evaluate.h"
#include "cs_cdo_toolbox.h"
#include "cs_hodge.h"
Include dependency graph for cs_hodge.c:

Functions

static cs_sla_matrix_t_init_hodge_vertex (const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
 Allocate and initialize by default the matrix related to a discrete Hodge op. based on vertices Note: values are filled in a second step. More...
 
static cs_sla_matrix_t_init_hodge_edge (const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
 Allocate and initialize by default the matrix related to a discrete Hodge op. based on edges Note: values are filled in a second step. More...
 
static cs_sla_matrix_t_init_hodge_face (const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
 Allocate and initialize by default the matrix related to a discrete Hodge op. based on faces Note: values are filled in a second step. More...
 
static struct _cost_quant_t * _init_cost_quant (int n_max_ent)
 Allocate and initialize a _cost_quant_t structure. More...
 
static struct _cost_quant_t * _free_cost_quant (struct _cost_quant_t *hq)
 Free a cs_hodge_costq_t structure. More...
 
static void _compute_cost_quant (int n_loc_ent, const cs_real_33_t ptymat, const cs_nvec3_t *pq, const cs_nvec3_t *dq, struct _cost_quant_t *hq)
 Compute quantities used for defining the entries of the discrete Hodge for COST algo. and edge/face quantities. More...
 
static void _build_using_cost (int cid, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, cs_hodge_builder_t *hb, struct _cost_quant_t *hq)
 Build a local discrete Hodge operator using the generic COST algo. More...
 
static struct _wbs_quant_t * _init_wbs_quant (int n_ent_max, int aux_bufsize, cs_lnum_t n_vertices)
 Build a structure used to compute a discrete Hodge op. when using WBS algo. More...
 
static struct _wbs_quant_t * _free_wbs_quant (struct _wbs_quant_t *hq)
 Free a structure used to compute a discrete Hodge op. when using WBS algo. More...
 
static void _compute_wbs_face_quant (cs_lnum_t f_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, struct _wbs_quant_t *hq)
 Compute for each face a weight related to each vertex w_{v,f} This weight is equal to |dc(v) cap f|/|f| so that the sum of the weights is equal to 1. Set also the local and local numbering of the vertices of this face. More...
 
static void _build_using_wbs (int cid, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, cs_hodge_builder_t *hb, struct _wbs_quant_t *hq)
 Build a local discrete Hodge operator using a conforming algo. based on the barycentric subdivision of a polyhedron. This construction is cellwise. Note: the local matrix is stored inside hb->hloc. More...
 
static void _build_using_voronoi (cs_lnum_t c_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, cs_hodge_builder_t *hb)
 Build a local discrete Hodge op. using the Voronoi algo. More...
 
cs_hodge_builder_tcs_hodge_builder_init (const cs_cdo_connect_t *connect, cs_param_hodge_t h_info)
 Allocate and initialize a cs_hodge_builder_t structure. More...
 
cs_hodge_builder_tcs_hodge_builder_free (cs_hodge_builder_t *hb)
 Free a cs_hodge_builder_t structure. More...
 
void cs_hodge_builder_set_val (cs_hodge_builder_t *hb, cs_real_t ptyval)
 Set the value of the property attached to a hodge builder. More...
 
void cs_hodge_builder_set_tensor (cs_hodge_builder_t *hb, const cs_real_33_t ptymat)
 Set the value of the property attached to a hodge builder. More...
 
cs_locmat_tcs_hodge_build_local (int c_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, cs_hodge_builder_t *hb)
 Build a local discrete Hodge. More...
 
cs_sla_matrix_tcs_hodge_compute (const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_property_t *pty, const cs_param_hodge_t h_info)
 Build a discrete Hodge operator. More...
 

Detailed Description

Build discrete Hodge operators.

Function Documentation

static void _build_using_cost ( int  cid,
const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant,
cs_hodge_builder_t hb,
struct _cost_quant_t *  hq 
)
static

Build a local discrete Hodge operator using the generic COST algo.

Parameters
[in]cidcell id
[in]connectpointer to a cs_cdo_connect_t struct.
[in]quantpointer to a cs_cdo_quantities_t struct.
[in,out]hbpointer to a cs_hodge_builder_t struct.
[in,out]hqpointer to a _cost_quant_t structure
static void _build_using_voronoi ( cs_lnum_t  c_id,
const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant,
cs_hodge_builder_t hb 
)
static

Build a local discrete Hodge op. using the Voronoi algo.

Parameters
[in]c_idcell id
[in]connectpointer to a cs_cdo_connect_t struct.
[in]quantpointer to a cs_cdo_quantities_t struct.
[in,out]hbpointer to a cs_hodge_builder_t struct.
static void _build_using_wbs ( int  cid,
const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant,
cs_hodge_builder_t hb,
struct _wbs_quant_t *  hq 
)
static

Build a local discrete Hodge operator using a conforming algo. based on the barycentric subdivision of a polyhedron. This construction is cellwise. Note: the local matrix is stored inside hb->hloc.

Parameters
[in]cidcell id
[in]connectpointer to a cs_cdo_connect_t struct.
[in]quantpointer to a cs_cdo_quantities_t struct.
[in,out]hbpointer to a cs_hodge_builder_t struct.
[in,out]hqpointer to a _wbs_quant_t structure
static void _compute_cost_quant ( int  n_loc_ent,
const cs_real_33_t  ptymat,
const cs_nvec3_t pq,
const cs_nvec3_t dq,
struct _cost_quant_t *  hq 
)
static

Compute quantities used for defining the entries of the discrete Hodge for COST algo. and edge/face quantities.

Parameters
[in]n_loc_entnumber of local entities
[in]ptymatvalues of the tensor related to the material pty
[in]pqpointer to the first set of quantities
[in]dqpointer to the second set of quantities
[in,out]hqpointer to a _cost_quant_t structure
static void _compute_wbs_face_quant ( cs_lnum_t  f_id,
const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant,
struct _wbs_quant_t *  hq 
)
static

Compute for each face a weight related to each vertex w_{v,f} This weight is equal to |dc(v) cap f|/|f| so that the sum of the weights is equal to 1. Set also the local and local numbering of the vertices of this face.

Parameters
[in]f_idid of the face
[in]connectpointer to a cs_cdo_connect_t structure
[in]quantpointer to a cs_cdo_quantites_t structure
[in,out]hqpointer to a _wbs_quant_t structure
static struct _cost_quant_t* _free_cost_quant ( struct _cost_quant_t *  hq)
static

Free a cs_hodge_costq_t structure.

Parameters
[in]hqpointer to the cs_hodge_costq_t struct. to free
Returns
a NULL pointer
static struct _wbs_quant_t* _free_wbs_quant ( struct _wbs_quant_t *  hq)
static

Free a structure used to compute a discrete Hodge op. when using WBS algo.

Parameters
[in]hqpointer to a _wbs_quant_t structure
Returns
a NULL pointer
static struct _cost_quant_t* _init_cost_quant ( int  n_max_ent)
static

Allocate and initialize a _cost_quant_t structure.

Parameters
[in]n_max_entmax number of entities by primal cell
Returns
a pointer to a new allocated _cost_quant_t structure
static cs_sla_matrix_t* _init_hodge_edge ( const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant 
)
static

Allocate and initialize by default the matrix related to a discrete Hodge op. based on edges Note: values are filled in a second step.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]quantpointer to a cs_cdo_quantities_t structure
Returns
a pointer to a cs_sla_matrix_t structure
static cs_sla_matrix_t* _init_hodge_face ( const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant 
)
static

Allocate and initialize by default the matrix related to a discrete Hodge op. based on faces Note: values are filled in a second step.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]quantpointer to a cs_cdo_quantities_t structure
Returns
a pointer to a cs_sla_matrix_t structure
static cs_sla_matrix_t* _init_hodge_vertex ( const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant 
)
static

Allocate and initialize by default the matrix related to a discrete Hodge op. based on vertices Note: values are filled in a second step.

(end ignore by Doxygen)

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]quantpointer to a cs_cdo_quantities_t structure
Returns
a pointer to a cs_sla_matrix_t structure
static struct _wbs_quant_t* _init_wbs_quant ( int  n_ent_max,
int  aux_bufsize,
cs_lnum_t  n_vertices 
)
static

Build a structure used to compute a discrete Hodge op. when using WBS algo.

Parameters
[in]n_ent_maxmax number of local entities
[in]aux_bufsizesize of the auxiliary buffers
[in]n_verticesnumber of vertices in this mesh
Returns
a pointer to a _wbs_quant_t structure
cs_locmat_t* cs_hodge_build_local ( int  c_id,
const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant,
cs_hodge_builder_t hb 
)

Build a local discrete Hodge.

Parameters
[in]c_idcell id
[in]connectpointer to a cs_cdo_connect_t struct.
[in]quantpointer to a cs_cdo_quantities_t struct.
[in,out]hbpointer to a cs_hodge_builder_t struct.
Returns
a pointer to a cs_locmat_t struct. (local dense matrix)
cs_hodge_builder_t* cs_hodge_builder_free ( cs_hodge_builder_t hb)

Free a cs_hodge_builder_t structure.

Parameters
[in]hbpointer to the cs_hodge_builder_t struct. to free
Returns
a NULL pointer
cs_hodge_builder_t* cs_hodge_builder_init ( const cs_cdo_connect_t connect,
cs_param_hodge_t  h_info 
)

Allocate and initialize a cs_hodge_builder_t structure.

Parameters
[in]connectpointer to a cs_cdo_connect_t struct.
[in]h_infoalgorithm used to build the discrete Hodge op.
Returns
a new allocated cs_hodge_builder_t structure
void cs_hodge_builder_set_tensor ( cs_hodge_builder_t hb,
const cs_real_33_t  ptymat 
)

Set the value of the property attached to a hodge builder.

Parameters
[in,out]hbpointer to a cs_hodge_builder_t structure
[in]ptymatvalues of the tensor related to a property
void cs_hodge_builder_set_val ( cs_hodge_builder_t hb,
cs_real_t  ptyval 
)

Set the value of the property attached to a hodge builder.

Parameters
[in,out]hbpointer to a cs_hodge_builder_t structure
[in]ptyvalvalue of the property
cs_sla_matrix_t* cs_hodge_compute ( const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant,
const cs_property_t *  pty,
const cs_param_hodge_t  h_info 
)

Build a discrete Hodge operator.

Parameters
[in]connectpointer to a cs_cdo_connect_t struct.
[in]quantpointer to a cs_cdo_quantities_t struct.
[in]ptypointer to a cs_property_t struct.
[in]h_infopointer to a cs_param_hodge_t struct.
Returns
a pointer to a cs_sla_matrix_t structure