8.3
general documentation
cs_stl.cpp File Reference
#include "cs_defs.h"
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "bft_printf.h"
#include "fvm_writer.h"
#include "cs_post.h"
#include "fvm_nodal_append.h"
#include "fvm_neighborhood.h"
#include "cs_math.h"
#include "cs_mesh_headers.h"
#include "cs_order.h"
#include "cs_parall.h"
#include "cs_rotation.h"
#include "cs_stl.h"
+ Include dependency graph for cs_stl.cpp:

Functions

cs_stl_mesh_tcs_stl_mesh_add (const char *name)
 Add a new STL mesh structure. More...
 
cs_stl_mesh_tcs_stl_mesh_get_by_name (const char *name)
 Return a pointer to a STL mesh based on its name if present. More...
 
void cs_stl_mesh_destroy_all (void)
 Free all allocated STL mesh structures. More...
 
void cs_stl_file_read (cs_stl_mesh_t *stl_mesh, const char *path)
 Read a binary STL file and store its content in a STL mesh structure. More...
 
void cs_stl_mesh_transform (cs_stl_mesh_t *stl_mesh, double matrix[3][4])
 Apply a transformation matrix to a STL mesh structure. More...
 
void cs_stl_mesh_transform_from_init (cs_stl_mesh_t *stl_mesh, double matrix[3][4])
 Apply a transformation matrix to a STL mesh structure, but use. More...
 
void cs_stl_mesh_translate (cs_stl_mesh_t *stl_mesh, cs_real_t vector[3])
 Apply a translation to a STL mesh structure. More...
 
void cs_stl_mesh_rotate (cs_stl_mesh_t *stl_mesh, double theta, double axis[3], double center[3])
 Apply a rotation to a STL mesh structure. More...
 
void cs_stl_mesh_scale (cs_stl_mesh_t *stl_mesh, double scale)
 Apply a scaling to a STL mesh structure. More...
 
void cs_stl_set_porosity_seed (cs_stl_mesh_t *stl_mesh, int n_points, cs_real_t *coords)
 Set the points outside he STL geometry. Those points will be used as. More...
 
int cs_stl_post_get_writer_id (void)
 Return writer_id used for stl meshes. 0 means unused. More...
 
void cs_stl_post_init_writer (const char *case_name, const char *dir_name, const char *fmt_name, const char *fmt_opts, fvm_writer_time_dep_t time_dep, bool output_at_start, bool output_at_end, int frequency_n, double frequency_t)
 Create a new writer that will contains the STL mesh added by the user. More...
 
void cs_stl_post_add_mesh (cs_stl_mesh_t *stl_mesh)
 Associate a STL mesh to the default writer. More...
 
void cs_stl_file_write (cs_stl_mesh_t *stl_mesh, const char *path)
 Write a binary STL file according to a given STL mesh structure. More...
 
void cs_stl_intersection (cs_stl_mesh_t *stl_mesh, cs_lnum_t n_input, cs_lnum_t *input_idx, cs_lnum_t *n_selected_cells, cs_lnum_t *selected_cells, cs_lnum_t *tria_in_cell_idx, cs_lnum_t **tria_in_cell_lst, cs_lnum_t *max_size)
 Compute intersection between a STL mesh and the main mesh. More...
 
void cs_stl_refine (cs_stl_mesh_t *stl_mesh, int n_ref, int n_add_layer)
 Refine the mesh following a given STL mesh. More...
 
void cs_stl_compute_porosity (cs_stl_mesh_t *stl_mesh, cs_real_t *porosity, int *indic)
 Compute porosity field according to a given STL mesh. More...
 

Function Documentation

◆ cs_stl_compute_porosity()

void cs_stl_compute_porosity ( cs_stl_mesh_t stl_mesh,
cs_real_t porosity,
int *  indic 
)

Compute porosity field according to a given STL mesh.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[out]porosityinterpolated porosity field
[out]indicindicator of the STL location

◆ cs_stl_file_read()

void cs_stl_file_read ( cs_stl_mesh_t stl_mesh,
const char *  path 
)

Read a binary STL file and store its content in a STL mesh structure.

Each STL file composed of the following header:

uint8[80] – Header uint32 – Number of triangles

followed by 50 byte blocks for each triangle:

  • real32[3] – Normal vector
  • real32[3] – Vertex 1 coordinates
  • real32[3] – Vertex 2 coordinates
  • real32[3] – Vertex 3 coordiantes
  • uint16 – Attribute (any other information, usually void)
Parameters
[in]pathpath to the STL file
[in]stl_meshpointer to the associated STL mesh structure

◆ cs_stl_file_write()

void cs_stl_file_write ( cs_stl_mesh_t stl_mesh,
const char *  path 
)

Write a binary STL file according to a given STL mesh structure.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]pathpath to the STL file

◆ cs_stl_intersection()

void cs_stl_intersection ( cs_stl_mesh_t stl_mesh,
cs_lnum_t  n_input,
cs_lnum_t input_idx,
cs_lnum_t n_selected_cells,
cs_lnum_t selected_cells,
cs_lnum_t tria_in_cell_idx,
cs_lnum_t **  tria_in_cell_lst,
cs_lnum_t max_size 
)

Compute intersection between a STL mesh and the main mesh.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]n_inputnumber of cells on which intersection is done
[in]input_idxindex of input cells (size: input_idx)
[out]n_selected_cellsnumber of output intersecting cells
[out]selected_cellsindex of output cells (size: output_idx)
[out]tria_in_cell_idxstart index of triangle intersecting each cell (size: n_output)
[out]tria_in_cell_lstlist of triangles in intersecting cells
[in,out]max_sizemaximum size of tria_in_cell_lst array

◆ cs_stl_mesh_add()

cs_stl_mesh_t * cs_stl_mesh_add ( const char *  name)

Add a new STL mesh structure.

Parameters
[in]namename of the STL mesh
Returns
pointer to the new STL mesh structure

◆ cs_stl_mesh_destroy_all()

void cs_stl_mesh_destroy_all ( void  )

Free all allocated STL mesh structures.

◆ cs_stl_mesh_get_by_name()

cs_stl_mesh_t * cs_stl_mesh_get_by_name ( const char *  name)

Return a pointer to a STL mesh based on its name if present.

Parameters
[in]namename of the STL mesh

If no STL mesh of the given name is defined, nullptr is returned.

Returns
pointer to the STL mesh structure, or nullptr

◆ cs_stl_mesh_rotate()

void cs_stl_mesh_rotate ( cs_stl_mesh_t stl_mesh,
double  theta,
double  axis[3],
double  center[3] 
)

Apply a rotation to a STL mesh structure.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]thetarotation angle
[in]axisrotation axis
[in]centerrotation center

◆ cs_stl_mesh_scale()

void cs_stl_mesh_scale ( cs_stl_mesh_t stl_mesh,
double  scale 
)

Apply a scaling to a STL mesh structure.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]vectortranslation vector

◆ cs_stl_mesh_transform()

void cs_stl_mesh_transform ( cs_stl_mesh_t stl_mesh,
double  matrix[3][4] 
)

Apply a transformation matrix to a STL mesh structure.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]matrixtransformation matrix

◆ cs_stl_mesh_transform_from_init()

void cs_stl_mesh_transform_from_init ( cs_stl_mesh_t stl_mesh,
double  matrix[3][4] 
)

Apply a transformation matrix to a STL mesh structure, but use.

the initial coordinates as inputs

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]matrixtransformation matrix

◆ cs_stl_mesh_translate()

void cs_stl_mesh_translate ( cs_stl_mesh_t stl_mesh,
cs_real_t  vector[3] 
)

Apply a translation to a STL mesh structure.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]vectortranslation vector

◆ cs_stl_post_add_mesh()

void cs_stl_post_add_mesh ( cs_stl_mesh_t stl_mesh)

Associate a STL mesh to the default writer.

Parameters
[in]stl_meshpointer to the associated STL mesh structure

◆ cs_stl_post_get_writer_id()

int cs_stl_post_get_writer_id ( void  )

Return writer_id used for stl meshes. 0 means unused.

◆ cs_stl_post_init_writer()

void cs_stl_post_init_writer ( const char *  case_name,
const char *  dir_name,
const char *  fmt_name,
const char *  fmt_opts,
fvm_writer_time_dep_t  time_dep,
bool  output_at_start,
bool  output_at_end,
int  frequency_n,
double  frequency_t 
)

Create a new writer that will contains the STL mesh added by the user.

The writer_id is stored in the cs_glob_stl_meshes structure.

Parameters
[in]time_dep> 1 if the writer is transient, else writer is fixed

◆ cs_stl_refine()

void cs_stl_refine ( cs_stl_mesh_t stl_mesh,
int  n_ref,
int  n_add_layer 
)

Refine the mesh following a given STL mesh.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]n_reflevel of refinement
[in]n_add_layeradditional layers between two refinement stage

◆ cs_stl_set_porosity_seed()

void cs_stl_set_porosity_seed ( cs_stl_mesh_t stl_mesh,
int  n_points,
cs_real_t coords 
)

Set the points outside he STL geometry. Those points will be used as.

seeds to propagate porosity values outside the STL geometry.

Parameters
[in]stl_meshpointer to the associated STL mesh structure
[in]n_pointsnumber of points
[in]coordscoordinates (x1,y1,z1,...,xn,yn,zn) (size : 3*n_point)