File: cs_lagr_geom.c

package info (click to toggle)
code-saturne 4.3.3%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 77,992 kB
  • sloc: ansic: 281,257; f90: 122,305; python: 56,490; makefile: 3,915; xml: 3,285; cpp: 3,183; sh: 1,139; lex: 176; yacc: 101; sed: 16
file content (178 lines) | stat: -rw-r--r-- 6,527 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*============================================================================
 * Methods for particle parameters
 *============================================================================*/

/*
  This file is part of Code_Saturne, a general-purpose CFD tool.

  Copyright (C) 1998-2016 EDF S.A.

  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.

  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
  Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

/*----------------------------------------------------------------------------*/

/*============================================================================
 * Functions dealing with particle tracking
 *============================================================================*/

#include "cs_defs.h"

/*----------------------------------------------------------------------------
 * Standard C library headers
 *----------------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <float.h>
#include <assert.h>

/*----------------------------------------------------------------------------
 *  Local headers
 *----------------------------------------------------------------------------*/

#include "bft_mem.h"

#include "cs_math.h"
#include "cs_mesh.h"
#include "cs_mesh_quantities.h"
#include "cs_lagr.h"

/*----------------------------------------------------------------------------
 *  Header for the current file
 *----------------------------------------------------------------------------*/

#include "cs_lagr_geom.h"

/*----------------------------------------------------------------------------*/

BEGIN_C_DECLS

/*! \cond DOXYGEN_SHOULD_SKIP_THIS */

/*=============================================================================
 * Local Macro definitions
 *============================================================================*/

/*=============================================================================
 * Local Enumeration definitions
 *============================================================================*/

/*============================================================================
 * Local structure definitions
 *============================================================================*/

/*============================================================================
 * Static global variables
 *============================================================================*/

/*============================================================================
 * Prototypes for functions intended for use only by Fortran wrappers.
 * (descriptions follow, with function bodies).
 *============================================================================*/

/*=============================================================================
 * Private function definitions
 *============================================================================*/

/*! (DOXYGEN_SHOULD_SKIP_THIS) \endcond */

/*============================================================================
 * Public function definitions
 *============================================================================*/

/*----------------------------------------------------------------------------*/
/*!
 * \brief Build geometric information needed by the deposition model.
 */
/*----------------------------------------------------------------------------*/

void
cs_lagr_geom(void)
{
  cs_mesh_t            *mesh = cs_glob_mesh;
  cs_mesh_quantities_t *fvq  = cs_glob_mesh_quantities;

  BFT_REALLOC(cs_glob_lagr_b_u_normal, mesh->n_b_faces, cs_real_4_t);
  BFT_REALLOC(cs_glob_lagr_b_face_proj, mesh->n_b_faces, cs_real_33_t);

/* ==============================================================================*/
/* 1. Boundary faces planes computation     */
/* A X + B Y + C Z + D = 0   */
/* ==============================================================================*/

  for (cs_lnum_t ifac = 0; ifac < mesh->n_b_faces; ifac++) {

    /* Recover the first face nodes */
    cs_lnum_t v_id0  = mesh->b_face_vtx_lst[mesh->b_face_vtx_idx[ifac]];
    cs_lnum_t v_id1  = mesh->b_face_vtx_lst[mesh->b_face_vtx_idx[ifac] + 1];

    cs_real_t xs1     = mesh->vtx_coord[v_id0*3];
    cs_real_t ys1     = mesh->vtx_coord[v_id0*3+1];
    cs_real_t zs1     = mesh->vtx_coord[v_id0*3+2];

    cs_real_t xs2     = mesh->vtx_coord[v_id1*3];
    cs_real_t ys2     = mesh->vtx_coord[v_id1*3+1];
    cs_real_t zs2     = mesh->vtx_coord[v_id1*3+2];

    /* Face plane equation  */

    cs_real_t xnor = cs_math_3_norm(fvq->b_face_normal + ifac*3);

    cs_real_t xn   = fvq->b_face_normal[ifac*3]   / xnor;
    cs_real_t yn   = fvq->b_face_normal[ifac*3+1] / xnor;
    cs_real_t zn   = fvq->b_face_normal[ifac*3+2] / xnor;

    cs_glob_lagr_b_u_normal[ifac][0] = xn;
    cs_glob_lagr_b_u_normal[ifac][1] = yn;
    cs_glob_lagr_b_u_normal[ifac][2] = zn;

    cs_glob_lagr_b_u_normal[ifac][3] = -(xn*xs1 + yn*ys1 + zn*zs1);

    /* Matrix of Reference frame change    */

    xnor = sqrt (  (xs2 - xs1) * (xs2 - xs1)
                 + (ys2 - ys1) * (ys2 - ys1)
                 + (zs2 - zs1) * (zs2 - zs1));

    cs_real_t xt   = (xs2 - xs1) / xnor;
    cs_real_t yt   = (ys2 - ys1) / xnor;
    cs_real_t zt   = (zs2 - zs1) / xnor;

    cs_real_t xtt  = yn * zt - zn * yt;
    cs_real_t ytt  = zn * xt - xn * zt;
    cs_real_t ztt  = xn * yt - yn * xt;

    xnor = sqrt(xtt*xtt + ytt*ytt + ztt*ztt);

    xtt  = xtt / xnor;
    ytt  = ytt / xnor;
    ztt  = ztt / xnor;

    cs_glob_lagr_b_face_proj[ifac][0][0] = xn;
    cs_glob_lagr_b_face_proj[ifac][0][1] = yn;
    cs_glob_lagr_b_face_proj[ifac][0][2] = zn;
    cs_glob_lagr_b_face_proj[ifac][1][0] = xt;
    cs_glob_lagr_b_face_proj[ifac][1][1] = yt;
    cs_glob_lagr_b_face_proj[ifac][1][2] = zt;
    cs_glob_lagr_b_face_proj[ifac][2][0] = xtt;
    cs_glob_lagr_b_face_proj[ifac][2][1] = ytt;
    cs_glob_lagr_b_face_proj[ifac][2][2] = ztt;

  }

}