16#include <Navier_Stokes_FTD_IJK_tools.h>
17#include <IJK_Shear_Periodic_helpler.h>
18#include <IJK_Navier_Stokes_tools.h>
19#include <Boundary_Conditions.h>
20#include <IJK_Interfaces.h>
22void force_upstream_velocity(IJK_Field_double& vx, IJK_Field_double& vy, IJK_Field_double& vz,
double v_imposed,
const IJK_Interfaces& interfaces,
23 double nb_diam,
int upstream_dir,
int gravity_dir,
int upstream_stencil)
26 if (upstream_dir == -1)
38 DoubleTab bounding_box;
39 Cerr <<
"Upstream Velocity - Compute Bounding box" << finl;
42 const double Dbdir = bounding_box(0, dir, 1) - bounding_box(0, dir, 0);
43 const double dirb = (bounding_box(0, dir, 1) + bounding_box(0, dir, 0)) / 2.;
46 nb_diam = (ldir / Dbdir) / 2;
47 double dirobj = dirb + nb_diam * Dbdir;
51 const double origin_dir = geom.
get_origin(dir);
57 while (dirobj < origin_dir)
59 while (dirobj > origin_dir + ldir)
64 assert(((dirobj >= origin_dir) && (dirobj <= origin_dir + ldir)));
66 const double x2 = (dirobj - origin_dir) / ddir;
67 int index_dir = (int) (floor(x2)) - offset_dir;
85 if ((index_dir >= 0) && (index_dir < ndir))
88 if (index_dir + upstream_stencil >= ndir)
91 index_dir = ndir - upstream_stencil;
97 double imposed[3] = { 0., 0., 0. };
98 imposed[dir] = v_imposed;
99 for (
int direction = 0; direction < 3; direction++)
101 IJK_Field_double& velocity = select_dir(direction, vx, vy, vz);
102 int imin, jmin, kmin;
103 int imax, jmax, kmax;
110 imax = imin + upstream_stencil;
111 jmax = velocity.
nj();
112 kmax = velocity.
nk();
118 imax = velocity.
ni();
119 jmax = jmin + upstream_stencil;
120 kmax = velocity.
nk();
126 imax = velocity.
ni();
127 jmax = velocity.
nj();
128 kmax = kmin + upstream_stencil;
134 imax = imin + upstream_stencil;
135 jmax = velocity.
nj();
136 kmax = velocity.
nk();
139 for (
int k = kmin; k < kmax; k++)
140 for (
int j = jmin; j < jmax; j++)
141 for (
int i = imin; i < imax; i++)
142 velocity(i, j, k) = imposed[direction];
145 Cerr <<
"Upstream Velocity has been forced" << finl;
148void force_upstream_velocity_shear_perio(IJK_Field_double& vx, IJK_Field_double& vy, IJK_Field_double& vz,
double v_imposed,
const IJK_Interfaces& interfaces,
double nb_diam,
Boundary_Conditions& bc,
149 double nb_diam_ortho_shear_perio,
double Ux0,
double Uy0,
double Uz0,
int epaisseur_maille)
152 DoubleTab bounding_box;
153 Cerr <<
"Upstream Velocity - Compute Bounding box" << finl;
157 const double Dbx = bounding_box(0, 0, 1) - bounding_box(0, 0, 0);
158 const double Dbz = bounding_box(0, 2, 1) - bounding_box(0, 2, 0);
159 const double xb = (bounding_box(0, 0, 1) + bounding_box(0, 0, 0)) / 2.;
160 const double zb = (bounding_box(0, 2, 1) + bounding_box(0, 2, 0)) / 2.;
163 double origin_x = geom.
get_origin(DIRECTION_I);
165 double origin_z = geom.
get_origin(DIRECTION_K);
167 double z_min = zb - (Dbz * nb_diam_ortho_shear_perio) / 2.;
168 double z_max = zb + (Dbz * nb_diam_ortho_shear_perio) / 2.;
169 double z_min_modulo = z_min;
170 double z_max_modulo = z_max;
175 z_min_modulo = std::fmod(std::fmod(z_min - origin_z, lz) + lz, lz) + origin_z;
176 z_max_modulo = std::fmod(std::fmod(z_max - origin_z, lz) + lz, lz) + origin_z;
179 double xobj = xb + nb_diam * Dbx;
182 double xobj_offsetp = xb_offsetp + nb_diam * Dbx;
185 double xobj_offsetm = xb_offsetm + nb_diam * Dbx;
191 xobj = std::fmod(std::fmod(xobj - origin_x, lx) + lx, lx) + origin_x;
192 xobj_offsetp = std::fmod(std::fmod(xobj_offsetp - origin_x, lx) + lx, lx) + origin_x;
193 xobj_offsetm = std::fmod(std::fmod(xobj_offsetm - origin_x, lx) + lx, lx) + origin_x;
204 int index_i_offsetp = (int) (round((xobj_offsetp - origin_x) / dx)) - offset_i;
205 int index_i_offsetm = (int) (round((xobj_offsetm - origin_x) / dx)) - offset_i;
206 int index_i = (int) (round((xobj - origin_x) / dx)) - offset_i;
208 int index_k_min = (int) (round((z_min_modulo - origin_z) / dz)) - offset_k;
209 int index_k_max = (int) (((z_max_modulo - origin_z) / dz)) - offset_k;
211 for (
int direction = 0; direction < 3; direction++)
213 IJK_Field_double& velocity = select_dir(direction, vx, vy, vz);
214 for (
int k = 0; k < velocity.
nk(); k++)
216 for (
int j = 0; j < velocity.
nj(); j++)
218 for (
int i = 0; i < velocity.
ni(); i++)
222 int index_i_real = index_i;
225 if (z_min_modulo > z_max_modulo)
230 if (z_min < origin_z)
234 if (k > index_k_min and index_k_min < velocity.
nk())
237 index_i_real = index_i_offsetp;
241 else if (k < index_k_max and index_k_max >= 0)
244 index_i_real = index_i;
249 else if (z_max > lz + origin_z)
253 if (k > index_k_min and index_k_min < velocity.
nk())
256 index_i_real = index_i;
259 else if (k < index_k_max and index_k_max >= 0)
262 index_i_real = index_i_offsetm;
271 if (z_max_modulo != z_max and z_min_modulo != z_min)
276 if (z_min < origin_z)
278 if ((index_k_min < velocity.
nk() and k > index_k_min) and (k < index_k_max and index_k_max >= 0))
280 index_i_real = index_i_offsetp;
284 else if (z_max > lz + origin_z)
286 if ((index_k_min < velocity.
nk() and k > index_k_min) and (k < index_k_max and index_k_max >= 0))
288 index_i_real = index_i_offsetm;
297 if ((index_k_min < velocity.
nk() and k > index_k_min) and (k < index_k_max and index_k_max >= 0))
299 index_i_real = index_i;
307 if (i == index_i_real % ni)
322 double z = dz / 2. + (k + offset_k) * dz;
323 for (
int m = 0; m < epaisseur_maille; m++)
326 else if (direction == 2)
328 for (
int m = 0; m < epaisseur_maille; m++)
329 velocity((i + m) % ni, j, k) = Uz0;
333 for (
int m = 0; m < epaisseur_maille; m++)
334 velocity((i + m) % ni, j, k) = Uy0;
344 Cerr <<
"Upstream Velocity has been forced" << finl;
double get_dU_perio(int fluctuations=0) const
int get_resolution_u_prime_() const
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
int get_offset_local(int direction) const
Returns the local offset in requested direction.
bool get_periodic_flag(int direction) const
Method returns true if periodic in this direction.
double get_domain_length(int direction) const
Returns the length of the entire domain in requested direction.
double get_constant_delta(int direction) const
Returns the size of cells in a direction.
double get_origin(int direction) const
Returns the coordinate of the first node (global) of the mesh in the requested direction.
const Domaine_IJK & get_domaine() const
int get_nb_bulles_reelles() const
void calculer_bounding_box_bulles(DoubleTab &bounding_box, int option_shear=0) const
static double shear_x_time_