Skip to content

Commit a5c9143

Browse files
committed
Improve robustness of mesh boundary layer insertion limiter.
1 parent 9e92616 commit a5c9143

File tree

2 files changed

+123
-80
lines changed

2 files changed

+123
-80
lines changed

po/fr.po

Lines changed: 22 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: code-saturne\n"
99
"Report-Msgid-Bugs-To: [email protected]\n"
10-
"POT-Creation-Date: 2018-10-04 10:08+0200\n"
10+
"POT-Creation-Date: 2018-10-15 16:26+0200\n"
1111
"PO-Revision-Date: 2012-01-26 12:00+0100\n"
1212
"Last-Translator: Code_Saturne <[email protected]>\n"
1313
"Language-Team: French <[email protected]>\n"
@@ -9689,8 +9689,9 @@ msgid ""
96899689
" Stop computing the Neumann value.\n"
96909690
msgstr ""
96919691

9692+
#, c-format
96929693
msgid ""
9693-
" Stop setting an empty cs_equation_t structure.\n"
9694+
" %s: Stop setting an empty cs_equation_t structure.\n"
96949695
" Please check your settings.\n"
96959696
msgstr ""
96969697

@@ -9921,6 +9922,9 @@ msgstr ""
99219922
msgid "HHO-P2"
99229923
msgstr ""
99239924

9925+
msgid "Steady-state"
9926+
msgstr ""
9927+
99249928
msgid "Implicit"
99259929
msgstr ""
99269930

@@ -9954,9 +9958,6 @@ msgstr ""
99549958
msgid "weak using a big penalization coefficient"
99559959
msgstr ""
99569960

9957-
msgid "strong"
9958-
msgstr ""
9959-
99609961
msgid "weak using the Nitsche method"
99619962
msgstr ""
99629963

@@ -10008,6 +10009,10 @@ msgid ""
1000810009
" Stop adding this property.\n"
1000910010
msgstr ""
1001010011

10012+
#
10013+
msgid " Key not implemented for setting a property."
10014+
msgstr " La clé n'est pas encore gérée pour les propriétés."
10015+
1001110016
#, c-format
1001210017
msgid ""
1001310018
" The definition of the tensor related to the property %s is not symmetric.\n"
@@ -11343,12 +11348,12 @@ msgid ""
1134311348
msgstr ""
1134411349

1134511350
#, c-format
11346-
msgid "Invalid xpath: %s\n"
11351+
msgid "Error: can not use evaluate property: %s\n"
1134711352
msgstr ""
1134811353

1134911354
#, c-format
11350-
msgid "Error: can not use evaluate property: %s\n"
11351-
msgstr ""
11355+
msgid "Invalid node in function %s\n"
11356+
msgstr "Noeud invalide dans la fonction : %s\n"
1135211357

1135311358
#, c-format
1135411359
msgid "Error converting profile component tag %s to integer."
@@ -11563,37 +11568,6 @@ msgstr ""
1156311568
msgid "Invalid model: %s"
1156411569
msgstr "Modèle invalide : %s"
1156511570

11566-
#, c-format
11567-
msgid ""
11568-
"The node type is not XML_ATTRIBUTE_NODE.\n"
11569-
"Xpath: %s\n"
11570-
msgstr ""
11571-
11572-
#, c-format
11573-
msgid ""
11574-
"The node type is not XML_TEXT_NODE.\n"
11575-
"Xpath: %s\n"
11576-
msgstr ""
11577-
11578-
#, c-format
11579-
msgid ""
11580-
"The node type is not XML_ELEMENT_NODE.\n"
11581-
"Xpath: %s\n"
11582-
msgstr ""
11583-
11584-
msgid "Code_Saturne has been compiled without XML support."
11585-
msgstr ""
11586-
11587-
#, c-format
11588-
msgid "Unable to parse the file: %s\n"
11589-
msgstr ""
11590-
11591-
#, c-format
11592-
msgid ""
11593-
"%s was built without XML support,\n"
11594-
"so parameter file \"%s\" may not be loaded.\n"
11595-
msgstr ""
11596-
1159711571
#, c-format
1159811572
msgid ""
1159911573
"========================================================\n"
@@ -11630,33 +11604,6 @@ msgstr ""
1163011604
" Il est recommandé de reconstruire un nouveau fichier XML.\n"
1163111605
"========================================================\n"
1163211606

11633-
#, c-format
11634-
msgid ""
11635-
"Several attributes found: %i \n"
11636-
"The first one is %s \n"
11637-
"Xpath: %s\n"
11638-
msgstr ""
11639-
11640-
#, c-format
11641-
msgid ""
11642-
"Several nodes name found: %i \n"
11643-
"The first one is %s \n"
11644-
"Xpath: %s\n"
11645-
msgstr ""
11646-
11647-
#, c-format
11648-
msgid ""
11649-
"Several text node found: %i \n"
11650-
"The first one is %s \n"
11651-
"Xpath: %s\n"
11652-
msgstr ""
11653-
11654-
#, c-format
11655-
msgid ""
11656-
"Invalid attribute value: %s \n"
11657-
"Xpath: %s\n"
11658-
msgstr ""
11659-
1166011607
#, c-format
1166111608
msgid "Expected 1 value for node %s, not %d"
1166211609
msgstr ""
@@ -13424,13 +13371,13 @@ msgid ""
1342413371
" %llu cells would have a negative volume\n"
1342513372
" %llu cells would have a volume reduced by more than %g\n"
1342613373
" (which is the user-defined threshold)\n"
13427-
" reducing insertion at adjacent boundary vertices.\n"
13374+
" reducing insertion at nearby boundary vertices.\n"
1342813375
msgstr ""
1342913376

1343013377
#, c-format
1343113378
msgid ""
1343213379
"%llu cells would have a negative volume after boundary insertion\n"
13433-
"but none of these are adjacent to an inserted boundary.\n"
13380+
"but none of these are near to an inserted boundary.\n"
1343413381
"Unable to detemine appropriate insertion limitation."
1343513382
msgstr ""
1343613383

@@ -13997,6 +13944,13 @@ msgid ""
1399713944
"cell centre and face centre.\n"
1399813945
msgstr ""
1399913946

13947+
#, c-format
13948+
msgid ""
13949+
"\n"
13950+
"%llu faces have a too large reconstruction distance.\n"
13951+
"For these faces, reconstruction are limited.\n"
13952+
msgstr ""
13953+
1400013954
#, c-format
1400113955
msgid ""
1400213956
" --- Information on the volumes\n"
@@ -15650,4 +15604,3 @@ msgstr ""
1565015604
" cssr1: %14.5e (Coef c_r1)\n"
1565115605
" cssr2: %14.5e (Coef c_r2)\n"
1565215606
" cssr3: %14.5e (Coef c_r3)\n"
15653-

src/mesh/cs_mesh_boundary_layer.c

Lines changed: 101 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ _transfer_bl_faces_selection(void *input,
146146
/*!
147147
* \brief Flag vertices for limiter.
148148
*
149+
* We mark cells using cell_vol_cmp = -3 for negative volumes, -2 for volumes
150+
* reduced below the required threshold, and -1 for cells marked through
151+
* adjacency with one of the above.
152+
*
149153
* \param[in] m mesh
150154
* \param[in] cell_vol_cmp comparative cell volume (< 0 for limit)
151155
* \param[out] vtx_flag vertex flag (0 for unlimited, 1 for limited)
@@ -282,6 +286,77 @@ _extrude_vector_limit(const char *vtx_flag,
282286
return n_limited;
283287
}
284288

289+
/*----------------------------------------------------------------------------*/
290+
/*!
291+
* \brief Expand limiter to neighboring cells.
292+
*
293+
* We mark cells using cell_vol_cmp = -3 for negative volumes, -2 for volumes
294+
* reduced below the required threshold, and -1 for cells marked through
295+
* adjacency with one of the above.
296+
*
297+
* \param[in] m mesh
298+
* \param[in] vtx_flag vertex flag (0 for unlimited, 1 for limited)
299+
* \param[in, out] cell_vol_cmp comparative cell volume (< 0 for limit)
300+
*
301+
* \return:
302+
* number of cells marked by adjacency
303+
*/
304+
/*----------------------------------------------------------------------------*/
305+
306+
static cs_lnum_t
307+
_expand_limit(const cs_mesh_t *m,
308+
cs_real_t *cell_vol_cmp,
309+
char *vtx_flag)
310+
{
311+
const cs_lnum_t n_cells = m->n_cells;
312+
const cs_lnum_t n_i_faces = m->n_i_faces;
313+
const cs_lnum_t n_b_faces = m->n_b_faces;
314+
315+
/* Use vertices flag to mark adjacent cells with bad volumes */
316+
317+
for (cs_lnum_t f_id = 0; f_id < n_i_faces; f_id++) {
318+
bool flag_cells = false;
319+
cs_lnum_t s_id = m->i_face_vtx_idx[f_id];
320+
cs_lnum_t e_id = m->i_face_vtx_idx[f_id+1];
321+
for (cs_lnum_t i = s_id; i < e_id; i++) {
322+
if (vtx_flag[m->i_face_vtx_lst[i]] != 0)
323+
flag_cells = true;
324+
}
325+
if (flag_cells) {
326+
cs_lnum_t c_id0 = m->i_face_cells[f_id][0];
327+
cs_lnum_t c_id1 = m->i_face_cells[f_id][0];
328+
if (c_id0 > -1 && c_id0 < n_cells)
329+
cell_vol_cmp[c_id0] = CS_MIN(cell_vol_cmp[c_id0], -1);
330+
if (c_id1 > -1 && c_id1 < n_cells)
331+
cell_vol_cmp[c_id1] = CS_MIN(cell_vol_cmp[c_id0], -1);
332+
}
333+
}
334+
335+
for (cs_lnum_t f_id = 0; f_id < n_b_faces; f_id++) {
336+
bool flag_cells = false;
337+
cs_lnum_t s_id = m->b_face_vtx_idx[f_id];
338+
cs_lnum_t e_id = m->b_face_vtx_idx[f_id+1];
339+
for (cs_lnum_t i = s_id; i < e_id; i++) {
340+
if (vtx_flag[m->b_face_vtx_lst[i]] != 0)
341+
flag_cells = true;
342+
}
343+
if (flag_cells) {
344+
cs_lnum_t c_id0 = m->b_face_cells[f_id];
345+
if (c_id0 > -1 && c_id0 < n_cells)
346+
cell_vol_cmp[c_id0] = CS_MIN(cell_vol_cmp[c_id0], -1);
347+
}
348+
349+
}
350+
351+
cs_lnum_t count = 0;
352+
for (cs_lnum_t c_id = 0; c_id < n_cells; c_id++) {
353+
if (fabs(cell_vol_cmp[c_id] + 1) < 0.1)
354+
count++;
355+
}
356+
357+
return count;
358+
}
359+
285360
/*! (DOXYGEN_SHOULD_SKIP_THIS) \endcond */
286361

287362
/*============================================================================
@@ -410,23 +485,26 @@ cs_mesh_boundary_layer_insert(cs_mesh_t *m,
410485
m->vtx_coord[i*3 + 2] += vd[i][2];
411486
}
412487

413-
/* Check deformation is acceptable */
488+
/* Check deformation is acceptable;
489+
* We mark cells using cell_vol_cmp = -3 for negative volumes,
490+
* -2 for volumes reduced below the required threshold, and -1 for cells
491+
* marked through adjacency with one of the above. */
414492

415493
compute_displacement = false;
416494

417495
if (min_volume_factor > 0 && min_volume_factor < 1) {
418496

419-
cs_gnum_t counts[3] = {0, 0, 0};
497+
cs_gnum_t counts[4] = {0, 0, 0, 0};
420498

421499
cs_real_t *cell_vol_cmp = cs_mesh_quantities_cell_volume(m);
422500

423501
for (cs_lnum_t i = 0; i < n_cells_ini; i++) {
424502
if (cell_vol_cmp[i] <= 0) {
425-
cell_vol_cmp[i] = -1;
503+
cell_vol_cmp[i] = -3;
426504
counts[0] += 1;
427505
}
428506
else if (cell_vol_cmp[i] < cell_vol_ref[i]*min_volume_factor) {
429-
cell_vol_cmp[i] = -1;
507+
cell_vol_cmp[i] = -2;
430508
counts[1] += 1;
431509
}
432510
}
@@ -442,36 +520,48 @@ cs_mesh_boundary_layer_insert(cs_mesh_t *m,
442520
cell_vol_cmp,
443521
vtx_flag);
444522

445-
BFT_FREE(cell_vol_cmp);
446-
447523
/* Now adjust extrusion vectors structure,
448524
removing a layer at flagged vertices */
449525

450526
counts[2] = _extrude_vector_limit(vtx_flag, e);
451527

452-
BFT_FREE(vtx_flag);
453-
454528
cs_parall_sum(3, CS_GNUM_TYPE, counts);
455529

530+
/* If bad volumes are present but not adjacent to a boundary
531+
layer insertion zone, propagate to neighboring volumes */
532+
533+
const int max_propagation_iter = 30;
534+
for (int p_iter = 0;
535+
counts[0] > 0 && counts[2] == 0 && p_iter < max_propagation_iter;
536+
p_iter++) {
537+
counts[3] = _expand_limit(m, cell_vol_cmp, vtx_flag);
538+
_flag_vertices_for_limiter(m, cell_vol_cmp, vtx_flag);
539+
counts[2] = _extrude_vector_limit(vtx_flag, e);
540+
cs_parall_sum(2, CS_GNUM_TYPE, counts+2); /* do not change initial cell counts */
541+
}
542+
543+
BFT_FREE(vtx_flag);
544+
BFT_FREE(cell_vol_cmp);
545+
456546
if (counts[2] > 0) {
457547

458548
bft_printf
459549
(_("\nBoundary layer insertion:\n"
460550
" %llu cells would have a negative volume\n"
461551
" %llu cells would have a volume reduced by more than %g\n"
462552
" (which is the user-defined threshold)\n"
463-
" reducing insertion at adjacent boundary vertices.\n"),
553+
" reducing insertion at nearby boundary vertices.\n"),
464554
(unsigned long long)counts[0], (unsigned long long)counts[1],
465555
min_volume_factor);
466556

467557
compute_displacement = true;
468558

469559
}
560+
470561
else if (counts[0] > 0) {
471-
cs_base_warn(__FILE__, __LINE__);
472562
bft_printf
473563
(_("%llu cells would have a negative volume after boundary insertion\n"
474-
"but none of these are adjacent to an inserted boundary.\n"
564+
"but none of these are near to an inserted boundary.\n"
475565
"Unable to detemine appropriate insertion limitation."),
476566
(unsigned long long)counts[0]);
477567
}

0 commit comments

Comments
 (0)