Using an appropriate CAD representation, it may be possible to compute the porosity fields using "common" or "cut" boolean operations between cells in the porous zones and the CAD volume. If the CAD shape represents the actual fluid volume, the common volume between the shape and the porous mesh section's cells will be used. If the CAD shape represents the solid volume, it should be cut from the pourous mesh section's cells.
The following example uses functions from the OpenCascade Technology (OCCT) libraries (https://dev.opencascade.org/doc/overview/html/index.html), and assumes they are installed on the user's machine. As these libraries form the backbone of the SALOME platform's CAD features, they are present with any generic or common SALOME install, and are available as a package in many Linux distributions.
As the OCCT libraries provide a C++ API, interfacing them with code_saturne requires a file written in C++, so the following example uses a separate C++ file, cs_cad_intersect.cxx to to most of the work. This file is also a user example, and may be improved or modified.
To compile and link, additional compiler flags must be passed to code_saturne. They may be defined in <_ref cs_user_scripts.py, and the following values are recommended (adapting the paths to the local environment):
As the prototypes for the cs_cad_intersect.cxx are not part of the defaul code_saturne installation, do not forget to include the cs_cad_intersect.h
header in the Local headers section of the cs_user_porosity.c file:
It is recommended to use the standard zone selection mechanism to select cells which may be intersected by the CAD shape, for example:
A few local variables may allow a more concise syntax, and optional face porosity arrays may be declared as temporary work arrays if face factors are required::
The actual CAD intersection is done using the following call (adapting the file path to the actual file):
Though the cell porosity is directly set by the call above, face quantities may be computed from the face porosities. The following code also handles the cleanup op local arrays.