/
ref_subcommand.c
4476 lines (4113 loc) · 168 KB
/
ref_subcommand.c
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright 2014 United States Government as represented by the
* Administrator of the National Aeronautics and Space
* Administration. No copyright is claimed in the United States under
* Title 17, U.S. Code. All Other Rights Reserved.
*
* The refine platform is licensed under the Apache License, Version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ref_adapt.h"
#include "ref_args.h"
#include "ref_axi.h"
#include "ref_defs.h"
#include "ref_dist.h"
#include "ref_egads.h"
#include "ref_export.h"
#include "ref_gather.h"
#include "ref_geom.h"
#include "ref_grid.h"
#include "ref_import.h"
#include "ref_inflate.h"
#include "ref_iso.h"
#include "ref_layer.h"
#include "ref_malloc.h"
#include "ref_math.h"
#include "ref_matrix.h"
#include "ref_meshlink.h"
#include "ref_metric.h"
#include "ref_mpi.h"
#include "ref_part.h"
#include "ref_phys.h"
#include "ref_shard.h"
#include "ref_split.h"
#include "ref_validation.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#ifdef REFINE_VERSION
#define VERSION REFINE_VERSION
#else
#define VERSION "not available"
#endif
#endif
static void usage(const char *name) {
printf("usage: \n %s [--help] <subcommand> [<args>]\n", name);
printf("\n");
printf("ref subcommands:\n");
printf(" adapt Adapt a mesh\n");
printf(" bootstrap Create initial mesh from EGADS file\n");
printf(" collar Inflate surface to create swept mesh\n");
printf(" distance Calculate wall distance (for turbulence model)\n");
printf(" examine Report mesh or solution file meta data.\n");
/*printf(" grow Fills surface mesh with volume to debug
* bootstrap\n");*/
printf(" interpolate Interpolate a field from one mesh to another\n");
printf(" loop Multiscale metric, adapt, and interpolation.\n");
printf(" multiscale Compute a multiscale metric.\n");
/*printf(" node Reports location of a node by index\n");*/
/*printf(" quilt Construct effective EGADS model.\n");*/
printf(" surface Extract mesh surface.\n");
printf(" translate Convert mesh formats.\n");
printf(" visualize Convert solution formats.\n");
printf("\n");
printf("'ref <command> -h' provides details on a specific subcommand.\n");
}
static void option_uniform_help(void) {
printf(
" --uniform box {ceil,floor} h0 decay_distance xmin ymin zmin "
"xmax ymax zmax\n");
printf(
" --uniform cyl {ceil,floor} h0 decay_distance x1 y1 z1 "
"x2 y2 z2 r1 r2\n");
printf(" decay_distance is negative to increase h with distance.\n");
printf(" decay_distance is positive to decrease h with distance.\n");
}
static void option_auto_tprarms_help(void) {
printf(" --auto-tparams {or combination of options} adjust .tParams\n");
printf(" 1:single edge, 2:chord violation, 4:face width (-1:all)\n");
}
static void adapt_help(const char *name) {
printf("usage: \n %s adapt input_mesh.extension [<options>]\n", name);
printf(" -x output_mesh.extension\n");
printf(" --metric <metric.solb> (geometry feature metric when missing)\n");
printf(" --egads <geometry.egads> (ignored with EGADSlite)\n");
printf(" --implied-complexity [complexity] imply metric from input mesh\n");
printf(" and scale to complexity\n");
printf(" --spalding [y+=1] [complexity]\n");
printf(" construct a multiscale metric to control interpolation\n");
printf(" error in u+ of Spalding's Law. Requires boundary conditions\n");
printf(" via the --fun3d-mapbc or --viscous-tags options.\n");
printf(" --stepexp [h0] [h1] [h2] [s1] [s2] [width]\n");
printf(" construct an isotropic metric of constant then exponential\n");
printf(" Requires boundary conditions via the --fun3d-mapbc or\n");
printf(" --viscous-tags options.\n");
option_uniform_help();
printf(" --fun3d-mapbc fun3d_format.mapbc\n");
printf(" --viscous-tags <comma-separated list of viscous boundary tags>\n");
printf(" --partitioner selects domain decomposition method.\n");
printf(" 2: ParMETIS graph partitioning.\n");
printf(" 3: Zoltan graph partitioning.\n");
printf(" 4: Zoltan recursive bisection.\n");
printf(" 5: native recursive bisection.\n");
printf("\n");
}
static void collar_help(const char *name) {
printf(
"usage: \n %s collar input_mesh.extension "
"nlayers first_thickness total_thickness mach\n",
name);
printf(" --fun3d-mapbc fun3d_format.mapbc\n");
printf(" -x output_mesh.extension\n");
printf("\n");
}
static void bootstrap_help(const char *name) {
printf("usage: \n %s bootstrap project.egads [-t]\n", name);
printf(" -t tecplot movie of surface curvature adaptation\n");
printf(" in files ref_gather_movie.tec and ref_gather_histo.tec\n");
printf(" --mesher {tetgen|aflr} volume mesher\n");
printf(" --mesher-options \"<options>\" quoted mesher options.\n");
option_auto_tprarms_help();
printf(" --axi sets 6022 boundary condition for extruded wedge 2D.\n");
printf("\n");
}
static void distance_help(const char *name) {
printf("usage: \n %s distance input_mesh.extension distance.solb\n", name);
printf(" --fun3d-mapbc fun3d_format.mapbc\n");
printf(" --viscous-tags <comma-separated list of viscous boundary tags>\n");
printf("\n");
}
static void examine_help(const char *name) {
printf("usage: \n %s examine input_mesh_or_solb.extension\n", name);
printf("\n");
}
static void grow_help(const char *name) {
printf("usage: \n %s grow surface.meshb volume.meshb\n", name);
printf(" --mesher {tetgen|aflr} volume mesher\n");
printf(" --mesher-options \"<options>\" quoted mesher options.\n");
printf("\n");
}
static void interpolate_help(const char *name) {
printf(
"usage: \n %s interpolate donor.meshb donor.solb receptor.meshb "
"receptor.solb\n",
name);
printf("\n");
printf(" options:\n");
printf(" --extrude receptor.solb data to two planes.\n");
printf(" --face <face id> <persist>.solb\n");
printf(" where persist.solb is copied to receptor.solb\n");
printf(" and face id is replaced with donor.solb.\n");
printf("\n");
}
static void loop_help(const char *name) {
printf(
"usage: \n %s loop <input_project_name> <output_project_name>"
" complexity [<options>]\n",
name);
printf("\n");
printf(" expects:\n");
printf(
" <input_project_name>.meshb is"
" mesh with geometry association and model.\n");
printf(
" <input_project_name>_volume.solb is"
" [rho,u,v,w,p] or [rho,u,v,w,p,turb1]\n");
printf(" in FUN3D nondimensionalization.\n");
printf(" complexity is half of the target number of vertices.\n");
printf("\n");
printf(" creates:\n");
printf(
" <output_project_name>.meshb is"
" mesh with geometry association and model.\n");
printf(
" <output_project_name>.lb8.ugrid is"
" FUN3D compatible little-endian mesh.\n");
printf(
" <output_project_name>-restart.solb is"
" an interpolated solution.\n");
printf("\n");
printf(" options:\n");
printf(" --egads <geometry.egads> (ignored with EGADSlite)\n");
printf(" --norm-power <power> multiscale metric norm power.\n");
printf(" Default power is 2 (1 for goal-based metrics)\n");
printf(" --gradation <gradation> (default -1)\n");
printf(" positive: metric-space gradation stretching ratio.\n");
printf(" negative: mixed-space gradation.\n");
printf(" --partitioner <id> selects domain decomposition method.\n");
printf(" 2: ParMETIS graph partitioning.\n");
printf(" 3: Zoltan graph partitioning.\n");
printf(" 4: Zoltan recursive bisection.\n");
printf(" 5: native recursive bisection.\n");
printf(" --mesh-extension <output mesh extension> (replaces lb8.ugrid).\n");
printf(" --fixed-point <middle-string> \\\n");
printf(" <first_timestep> <timestep_increment> <last_timestep>\n");
printf(" where <input_project_name><middle-string>N.solb are\n");
printf(" scalar fields and N is the timestep index.\n");
printf(" --interpolant <type or file.solb> multiscale scalar field.\n");
printf(
" Type is mach (default), "
"incomp (incompressible vel magnitude),\n");
printf(" htot, ptot, pressure, density, or temperature.\n");
printf(" Read from file.solb, if not a recognized type.\n");
printf(" --export-metric writes <input_project_name>-metric.solb.\n");
printf(" --opt-goal metric of Loseille et al. AIAA 2007--4186.\n");
printf(" Include flow and adjoint information in volume.solb.\n");
printf(" Use --fun3d-mapbc or --viscous-tags with strong BCs.\n");
printf(" --cons-visc <mach> <re> <temperature> see AIAA 2019--2947.\n");
printf(" <mach> is reference Mach nubmer.\n");
printf(" <re> is reference Reylonds number in grid units.\n");
printf(" <temperature> is reference temperature in K.\n");
printf(" Include flow and adjoint information in volume.solb.\n");
printf(" Use --fun3d-mapbc or --viscous-tags with strong BCs.\n");
printf(" --fun3d-mapbc fun3d_format.mapbc\n");
printf(" --viscous-tags <comma-separated list of viscous boundary tags>\n");
printf(" --deforming mesh flow solve, include xyz in *_volume.solb.\n");
printf(" --mixed implies multiscale metric from mixed elements.\n");
printf(" --axi forms an extruded wedge from 2D mesh.\n");
printf(" --buffer coarsens the metric approaching the x max boundary.\n");
option_uniform_help();
printf("\n");
}
static void multiscale_help(const char *name) {
printf(
"usage: \n %s multiscale input_mesh.extension scalar.{solb,snap} "
"complexity metric.solb\n",
name);
printf(" complexity is approximately half the target number of vertices\n");
printf("\n");
printf(" options:\n");
printf(" --norm-power <power> multiscale metric norm power (default 2)\n");
printf(" --gradation <gradation> (default -1)\n");
printf(" positive: metric-space gradation stretching ratio.\n");
printf(" negative: mixed-space gradation.\n");
printf(" --buffer coarsens the metric approaching the x max boundary.\n");
option_uniform_help();
printf(" --hessian expects hessian.* in place of scalar.{solb,snap}.\n");
printf(" --pcd <project.pcd> exports isotropic spacing point cloud.\n");
printf(" --combine <scalar2.solb> <scalar2 ratio>.\n");
printf(" --aspect-ratio <aspect ratio limit>.\n");
printf("\n");
}
static void node_help(const char *name) {
printf("usage: \n %s node input.meshb node_index node_index ...\n", name);
printf(" node_index is zero-based\n");
printf("\n");
}
static void quilt_help(const char *name) {
printf("usage: \n %s quilt original.egads\n", name);
printf(" originaleff.egads is output EGADS model with EBODY\n");
option_auto_tprarms_help();
printf("\n");
}
static void surface_help(const char *name) {
printf("usage: \n %s surface input_mesh.extension [surface_mesh.tec] \n",
name);
printf("\n");
}
static void translate_help(const char *name) {
printf("usage: \n %s translate input_mesh.extension output_mesh.extension \n",
name);
printf("\n");
printf(" options:\n");
printf(" --extrude a 2D mesh to single layer of prisms.\n");
printf(" extrusion added implicitly for ugrid output files\n");
printf(" --axi convert an extruded mesh into a wedge at z=y=0 axis\n");
printf(" --planes <N> extrude a 2D mesh to N layers of prisms.\n");
printf(" --shift <dx> <dy> <dz> shift vertex locations.\n");
printf(" --scale <scale> scales vertex locations about origin.\n");
printf(" --zero-y-face <face id> explicitly set y=0 on face id.\n");
printf(" --shard converts mixed-elments to simplicies.\n");
printf(" --surface extracts surface elements (deletes volume).\n");
printf(" --enrich2 promotes elements to Q2.\n");
printf("\n");
}
static void visualize_help(const char *name) {
printf(
"usage: \n %s visualize input_mesh.extension input_solution.extension "
"output_solution.extension\n",
name);
printf("\n");
printf(
" input_solution.extension or output_solution.extension "
"can be 'none'.\n input_solution.extension can be 'degree'.\n");
printf(" options:\n");
printf(" --surface extracts surface elements (deletes volume).\n");
printf(
" --subtract <baseline_solution.extension> "
"computes (input-baseline).\n");
printf(
" --iso <0-based variable index> <threshold> <iso.extension> "
"extracts an isosurface.\n");
printf(
" --slice <nx> <ny> <nz> <offset> <slice.extension> "
"extracts a slice.\n");
printf("\n");
}
static REF_STATUS spalding_metric(REF_GRID ref_grid, REF_DICT ref_dict_bcs,
REF_DBL spalding_yplus, REF_DBL complexity,
int argc, char *argv[]) {
REF_MPI ref_mpi = ref_grid_mpi(ref_grid);
REF_DBL *metric;
REF_DBL *distance, *uplus, yplus;
REF_INT node;
REF_RECON_RECONSTRUCTION reconstruction = REF_RECON_L2PROJECTION;
REF_DBL gradation = 10.0;
REF_INT pos;
ref_malloc(metric, 6 * ref_node_max(ref_grid_node(ref_grid)), REF_DBL);
ref_malloc(distance, ref_node_max(ref_grid_node(ref_grid)), REF_DBL);
ref_malloc(uplus, ref_node_max(ref_grid_node(ref_grid)), REF_DBL);
RSS(ref_phys_wall_distance(ref_grid, ref_dict_bcs, distance), "wall dist");
ref_mpi_stopwatch_stop(ref_mpi, "wall distance");
each_ref_node_valid_node(ref_grid_node(ref_grid), node) {
RAB(ref_math_divisible(distance[node], spalding_yplus),
"\nare viscous boundarys set with --viscous-tags or --fun3d-mapbc?"
"\nwall distance not divisible by y+=1",
{
printf("distance %e yplus=1 %e\n", distance[node], spalding_yplus);
});
yplus = distance[node] / spalding_yplus;
RSS(ref_phys_spalding_uplus(yplus, &(uplus[node])), "uplus");
}
RSS(ref_recon_hessian(ref_grid, uplus, metric, reconstruction), "hess");
RSS(ref_recon_roundoff_limit(metric, ref_grid),
"floor metric eigenvalues based on grid size and solution jitter");
RSS(ref_metric_local_scale(metric, NULL, ref_grid, 4),
"local lp=4 norm scaling");
RXS(ref_args_find(argc, argv, "--aspect-ratio", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
REF_DBL aspect_ratio = atof(argv[pos + 1]);
if (ref_mpi_once(ref_mpi))
printf("limit --aspect-ratio to %f\n", aspect_ratio);
RSS(ref_metric_limit_aspect_ratio(metric, ref_grid, aspect_ratio),
"limit aspect ratio");
}
ref_mpi_stopwatch_stop(ref_mpi, "spalding metric");
RSS(ref_metric_gradation_at_complexity(metric, ref_grid, gradation,
complexity),
"set complexity");
RSS(ref_metric_parse(metric, ref_grid, argc, argv), "parse metric");
RSS(ref_metric_to_node(metric, ref_grid_node(ref_grid)), "node metric");
ref_free(uplus);
ref_free(distance);
ref_free(metric);
ref_mpi_stopwatch_stop(ref_mpi, "spalding gradation");
if (ref_geom_model_loaded(ref_grid_geom(ref_grid)) ||
ref_geom_meshlinked(ref_grid_geom(ref_grid))) {
RSS(ref_metric_constrain_curvature(ref_grid), "crv const");
ref_mpi_stopwatch_stop(ref_mpi, "crv const");
}
return REF_SUCCESS;
}
static REF_STATUS stepexp_metric_fill(REF_GRID ref_grid, REF_DICT ref_dict_bcs,
int argc, char *argv[]) {
REF_MPI ref_mpi = ref_grid_mpi(ref_grid);
REF_NODE ref_node = ref_grid_node(ref_grid);
REF_DBL *distance;
REF_INT node;
REF_INT pos;
REF_DBL h0, h1, h2, s1, s2, width;
REF_DBL aspect_ratio = 1.0;
RXS(ref_args_find(argc, argv, "--aspect-ratio", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
aspect_ratio = atof(argv[pos + 1]);
aspect_ratio = MAX(1.0, aspect_ratio);
if (ref_mpi_once(ref_mpi))
printf("limit --aspect-ratio to %f\n", aspect_ratio);
}
RSS(ref_args_find(argc, argv, "--stepexp", &pos), "arg search");
RAS(pos + 6 < argc, "not enough --stepexp args");
h0 = atof(argv[pos + 1]);
h1 = atof(argv[pos + 2]);
h2 = atof(argv[pos + 3]);
s1 = atof(argv[pos + 4]);
s2 = atof(argv[pos + 5]);
width = atof(argv[pos + 6]);
if (ref_mpi_once(ref_mpi))
printf("h0 %f h1 %f h2 %f s1 %f s2 %f width %f\n", h0, h1, h2, s1, s2,
width);
RAS(h0 > 0.0, "positive h0");
RAS(h1 > 0.0, "positive h1");
RAS(h2 > 0.0, "positive h2");
RAS(s1 > 0.0, "positive s1");
RAS(s2 > 0.0, "positive s2");
RAS(width > 0.0, "positive width");
ref_malloc(distance, ref_node_max(ref_grid_node(ref_grid)), REF_DBL);
RSS(ref_phys_wall_distance(ref_grid, ref_dict_bcs, distance), "wall dist");
ref_mpi_stopwatch_stop(ref_mpi, "wall distance");
if (aspect_ratio > 1.0) {
REF_DBL *grad_dist;
REF_RECON_RECONSTRUCTION recon = REF_RECON_L2PROJECTION;
ref_malloc(grad_dist, 3 * ref_node_max(ref_grid_node(ref_grid)), REF_DBL);
RSS(ref_recon_gradient(ref_grid, distance, grad_dist, recon), "grad dist");
each_ref_node_valid_node(ref_grid_node(ref_grid), node) {
REF_DBL m[6];
REF_DBL d[12];
REF_DBL h;
REF_DBL s = distance[node];
RSS(ref_metric_step_exp(s, &h, h0, h1, h2, s1, s2, width), "step exp");
ref_matrix_eig(d, 0) = 1.0 / (h * h);
ref_matrix_eig(d, 1) = 1.0 / (aspect_ratio * h * aspect_ratio * h);
ref_matrix_eig(d, 2) = 1.0 / (aspect_ratio * h * aspect_ratio * h);
ref_matrix_vec(d, 0, 0) = grad_dist[0 + 3 * node];
ref_matrix_vec(d, 1, 0) = grad_dist[1 + 3 * node];
ref_matrix_vec(d, 2, 0) = grad_dist[2 + 3 * node];
if (REF_SUCCESS == ref_math_normalize(&(d[3]))) {
RSS(ref_math_orthonormal_system(&(d[3]), &(d[6]), &(d[9])),
"ortho sys");
RSS(ref_matrix_form_m(d, m), "form m from d");
} else {
m[0] = 1.0 / (h * h);
m[1] = 0.0;
m[2] = 0.0;
m[3] = 1.0 / (h * h);
m[4] = 0.0;
m[5] = 1.0 / (h * h);
}
if (ref_grid_twod(ref_grid)) RSS(ref_matrix_twod_m(m), "enforce 2d");
RSS(ref_node_metric_set(ref_node, node, m), "set");
}
ref_free(grad_dist);
} else {
each_ref_node_valid_node(ref_grid_node(ref_grid), node) {
REF_DBL m[6];
REF_DBL h;
REF_DBL s = distance[node];
RSS(ref_metric_step_exp(s, &h, h0, h1, h2, s1, s2, width), "step exp");
m[0] = 1.0 / (h * h);
m[1] = 0.0;
m[2] = 0.0;
m[3] = 1.0 / (h * h);
m[4] = 0.0;
m[5] = 1.0 / (h * h);
if (ref_grid_twod(ref_grid)) RSS(ref_matrix_twod_m(m), "enforce 2d");
RSS(ref_node_metric_set(ref_node, node, m), "set");
}
}
ref_free(distance);
return REF_SUCCESS;
}
static REF_STATUS adapt(REF_MPI ref_mpi_orig, int argc, char *argv[]) {
char *in_mesh = NULL;
char *in_metric = NULL;
char *in_egads = NULL;
REF_GRID ref_grid = NULL;
REF_MPI ref_mpi = ref_mpi_orig;
REF_BOOL stepexp_metric = REF_FALSE;
REF_BOOL curvature_metric = REF_TRUE;
REF_BOOL all_done = REF_FALSE;
REF_BOOL all_done0 = REF_FALSE;
REF_BOOL all_done1 = REF_FALSE;
REF_BOOL form_quads = REF_FALSE;
REF_INT pass, passes = 30;
REF_INT opt, pos;
REF_LONG ntet;
REF_DICT ref_dict_bcs = NULL;
REF_DBL spalding_yplus = -1.0;
REF_DBL complexity = -1.0;
if (argc < 3) goto shutdown;
in_mesh = argv[2];
if (ref_mpi_para(ref_mpi)) {
if (ref_mpi_once(ref_mpi)) printf("part %s\n", in_mesh);
RSS(ref_part_by_extension(&ref_grid, ref_mpi, in_mesh), "part");
ref_mpi = ref_grid_mpi(ref_grid); /* ref_grid made a deep copy */
ref_mpi_stopwatch_stop(ref_mpi, "part");
} else {
if (ref_mpi_once(ref_mpi)) printf("import %s\n", in_mesh);
RSS(ref_import_by_extension(&ref_grid, ref_mpi, in_mesh), "import");
ref_mpi = ref_grid_mpi(ref_grid); /* ref_grid made a deep copy */
ref_mpi_stopwatch_stop(ref_mpi, "import");
}
if (ref_mpi_once(ref_mpi))
printf(" read " REF_GLOB_FMT " vertices\n",
ref_node_n_global(ref_grid_node(ref_grid)));
RXS(ref_args_find(argc, argv, "--meshlink", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
if (ref_mpi_once(ref_mpi)) printf("meshlink with %s\n", argv[pos + 1]);
RSS(ref_meshlink_open(ref_grid, argv[pos + 1]), "meshlink init");
RSS(ref_meshlink_infer_orientation(ref_grid), "meshlink orient");
} else {
RXS(ref_args_char(argc, argv, "--egads", "-g", &in_egads), REF_NOT_FOUND,
"egads arg search");
if (NULL != in_egads) {
if (ref_mpi_once(ref_mpi)) printf("load egads from %s\n", in_egads);
RSS(ref_egads_load(ref_grid_geom(ref_grid), in_egads), "load egads");
if (ref_mpi_once(ref_mpi) && ref_geom_effective(ref_grid_geom(ref_grid)))
printf("EBody Effective Body loaded\n");
ref_mpi_stopwatch_stop(ref_mpi, "load egads");
} else {
if (0 < ref_geom_cad_data_size(ref_grid_geom(ref_grid))) {
if (ref_mpi_once(ref_mpi))
printf("load egadslite from .meshb byte stream\n");
RSS(ref_egads_load(ref_grid_geom(ref_grid), NULL), "load egads");
if (ref_mpi_once(ref_mpi) &&
ref_geom_effective(ref_grid_geom(ref_grid)))
printf("EBody Effective Body loaded\n");
ref_mpi_stopwatch_stop(ref_mpi, "load egads");
} else {
if (ref_mpi_once(ref_mpi))
printf("warning: no geometry loaded, assuming planar faces.\n");
}
}
}
if (ref_geom_model_loaded(ref_grid_geom(ref_grid))) {
RSS(ref_cell_ncell(ref_grid_tet(ref_grid), ref_grid_node(ref_grid), &ntet),
"global tets");
if (0 == ntet) ref_grid_surf(ref_grid) = REF_TRUE;
RSS(ref_egads_mark_jump_degen(ref_grid), "T and UV jumps; UV degen");
}
if (ref_geom_model_loaded(ref_grid_geom(ref_grid)) ||
ref_geom_meshlinked(ref_grid_geom(ref_grid))) {
RSS(ref_geom_verify_topo(ref_grid), "geom topo");
RSS(ref_geom_verify_param(ref_grid), "geom param");
ref_mpi_stopwatch_stop(ref_mpi, "geom assoc");
}
RXS(ref_args_find(argc, argv, "--facelift", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
if (ref_mpi_once(ref_mpi)) printf("--facelift %s import\n", argv[pos + 1]);
RSS(ref_facelift_import(ref_grid, argv[pos + 1]), "attach");
ref_mpi_stopwatch_stop(ref_mpi, "facelift loaded");
}
RXS(ref_args_find(argc, argv, "--surrogate", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
if (ref_mpi_once(ref_mpi)) printf("--surrogate %s import\n", argv[pos + 1]);
RSS(ref_facelift_surrogate(ref_grid, argv[pos + 1]), "attach");
ref_mpi_stopwatch_stop(ref_mpi, "facelift loaded");
if (ref_mpi_once(ref_mpi)) printf("constrain all\n");
RSS(ref_geom_constrain_all(ref_grid), "constrain");
ref_mpi_stopwatch_stop(ref_mpi, "constrain param");
if (ref_mpi_once(ref_mpi)) printf("verify constrained param\n");
RSS(ref_geom_verify_param(ref_grid), "constrained params");
ref_mpi_stopwatch_stop(ref_mpi, "verify param");
}
RXS(ref_args_find(argc, argv, "-t", &pos), REF_NOT_FOUND, "arg search");
if (REF_EMPTY != pos)
RSS(ref_gather_tec_movie_record_button(ref_grid_gather(ref_grid), REF_TRUE),
"movie on");
RXS(ref_args_find(argc, argv, "-s", &pos), REF_NOT_FOUND, "arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
passes = atoi(argv[pos + 1]);
if (ref_mpi_once(ref_mpi)) printf("-s %d adaptation passes\n", passes);
}
RXS(ref_args_find(argc, argv, "--partitioner", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
REF_INT part_int = atoi(argv[pos + 1]);
ref_grid_partitioner(ref_grid) = (REF_MIGRATE_PARTIONER)part_int;
if (ref_mpi_once(ref_mpi))
printf("--partitioner %d partitioner\n",
(int)ref_grid_partitioner(ref_grid));
}
RXS(ref_args_find(argc, argv, "--ratio-method", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
ref_grid_node(ref_grid)->ratio_method = atoi(argv[pos + 1]);
if (ref_mpi_once(ref_mpi))
printf("--ratio-method %d\n", ref_grid_node(ref_grid)->ratio_method);
}
RXS(ref_args_find(argc, argv, "--zip-pcurve", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos) {
ref_geom_zip_pcurve(ref_grid_geom(ref_grid)) = REF_TRUE;
if (ref_mpi_once(ref_mpi)) printf("--zip-pcurve pcurve zipping\n");
}
RXS(ref_args_find(argc, argv, "--unlock", &pos), REF_NOT_FOUND, "arg search");
if (REF_EMPTY != pos) {
ref_grid_adapt(ref_grid, unlock_tet) = REF_TRUE;
if (ref_mpi_once(ref_mpi)) printf("--unlock tets from geometry\n");
}
RXS(ref_args_find(argc, argv, "--quad", &pos), REF_NOT_FOUND, "arg search");
if (ref_grid_twod(ref_grid) && REF_EMPTY != pos) {
form_quads = REF_TRUE;
if (ref_mpi_once(ref_mpi)) printf("--quad form quads on boundary\n");
}
RXS(ref_args_find(argc, argv, "--topo", &pos), REF_NOT_FOUND, "arg search");
if (REF_EMPTY != pos) {
ref_grid_adapt(ref_grid, watch_topo) = REF_TRUE;
if (ref_mpi_once(ref_mpi)) printf("--topo checks active\n");
}
RXS(ref_args_char(argc, argv, "--metric", "-m", &in_metric), REF_NOT_FOUND,
"metric arg search");
if (NULL != in_metric) {
if (ref_mpi_once(ref_mpi)) printf("part metric %s\n", in_metric);
RSS(ref_part_metric(ref_grid_node(ref_grid), in_metric), "part metric");
curvature_metric = REF_FALSE;
ref_mpi_stopwatch_stop(ref_mpi, "part metric");
}
RSS(ref_dict_create(&ref_dict_bcs), "make dict");
RXS(ref_args_find(argc, argv, "--av", &pos), REF_NOT_FOUND, "arg search");
if (REF_EMPTY != pos) {
if (ref_mpi_once(ref_mpi)) {
printf("parse AV bcs from EGADS attributes\n");
RSS(ref_phys_av_tag_attributes(ref_dict_bcs, ref_grid_geom(ref_grid)),
"unable to parse AV bcs from EGADS attribute");
}
RSS(ref_dict_bcast(ref_dict_bcs, ref_mpi), "bcast");
}
RXS(ref_args_find(argc, argv, "--fun3d-mapbc", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
const char *mapbc;
mapbc = argv[pos + 1];
if (ref_mpi_once(ref_mpi)) {
printf("reading fun3d bc map %s\n", mapbc);
RSS(ref_phys_read_mapbc(ref_dict_bcs, mapbc),
"unable to read fun3d formatted mapbc");
}
RSS(ref_dict_bcast(ref_dict_bcs, ref_mpi), "bcast");
}
RXS(ref_args_find(argc, argv, "--viscous-tags", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
const char *tags;
tags = argv[pos + 1];
if (ref_mpi_once(ref_mpi)) {
printf("parsing viscous tags\n");
RSS(ref_phys_parse_tags(ref_dict_bcs, tags),
"unable to parse viscous tags");
printf(" %d viscous tags parsed\n", ref_dict_n(ref_dict_bcs));
}
RSS(ref_dict_bcast(ref_dict_bcs, ref_mpi), "bcast");
}
RXS(ref_args_find(argc, argv, "--spalding", &pos), REF_NOT_FOUND,
"metric arg search");
if (REF_EMPTY != pos && pos < argc - 2) {
if (0 == ref_dict_n(ref_dict_bcs)) {
if (ref_mpi_once(ref_mpi))
printf(
"\nset viscous boundaries via --fun3d-mapbc or --viscous-tags "
"to use --spalding\n\n");
goto shutdown;
}
spalding_yplus = atof(argv[pos + 1]);
complexity = atof(argv[pos + 2]);
if (ref_mpi_once(ref_mpi))
printf(" --spalding %e %f law of the wall metric\n", spalding_yplus,
complexity);
curvature_metric = REF_TRUE;
}
RXS(ref_args_find(argc, argv, "--stepexp", &pos), REF_NOT_FOUND,
"metric arg search");
if (REF_EMPTY != pos && pos < argc - 6) {
if (0 == ref_dict_n(ref_dict_bcs)) {
if (ref_mpi_once(ref_mpi))
printf(
"\nset viscous boundaries via --fun3d-mapbc or --viscous-tags "
"to use --stepexp\n\n");
goto shutdown;
}
if (ref_mpi_once(ref_mpi)) printf(" --stepexp metric\n");
stepexp_metric = REF_TRUE;
curvature_metric = REF_TRUE;
}
RXS(ref_args_find(argc, argv, "--implied-complexity", &pos), REF_NOT_FOUND,
"metric arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
REF_DBL *metric;
complexity = atof(argv[pos + 1]);
if (ref_mpi_once(ref_mpi))
printf(" --implied-complexity %f implied metric scaled to complexity\n",
complexity);
ref_malloc(metric, 6 * ref_node_max(ref_grid_node(ref_grid)), REF_DBL);
RSS(ref_metric_imply_from(metric, ref_grid), "imply metric");
ref_mpi_stopwatch_stop(ref_mpi, "imply metric");
RSS(ref_metric_set_complexity(metric, ref_grid, complexity),
"scale metric");
RSS(ref_metric_parse(metric, ref_grid, argc, argv), "parse metric");
RSS(ref_metric_to_node(metric, ref_grid_node(ref_grid)), "node metric");
ref_free(metric);
curvature_metric = REF_FALSE;
}
if (curvature_metric) {
if (stepexp_metric) {
RSS(stepexp_metric_fill(ref_grid, ref_dict_bcs, argc, argv), "stepexp");
} else {
if (spalding_yplus > 0.0) {
RSS(spalding_metric(ref_grid, ref_dict_bcs, spalding_yplus, complexity,
argc, argv),
"spalding");
} else {
RSS(ref_metric_interpolated_curvature(ref_grid), "interp curve");
ref_mpi_stopwatch_stop(ref_mpi, "curvature metric");
RXS(ref_args_find(argc, argv, "--facelift-metric", &pos), REF_NOT_FOUND,
"arg search");
if (REF_EMPTY != pos && pos < argc - 1) {
complexity = atof(argv[pos + 1]);
if (ref_mpi_once(ref_mpi))
printf("--facelift-metric %f\n", complexity);
RSS(ref_facelift_multiscale(ref_grid, complexity), "metric");
ref_mpi_stopwatch_stop(ref_mpi, "facelift metric");
}
}
}
} else {
if (ref_geom_model_loaded(ref_grid_geom(ref_grid)) ||
ref_geom_meshlinked(ref_grid_geom(ref_grid))) {
RSS(ref_metric_constrain_curvature(ref_grid), "crv const");
RSS(ref_validation_cell_volume(ref_grid), "vol");
ref_mpi_stopwatch_stop(ref_mpi, "crv const");
}
RSS(ref_grid_cache_background(ref_grid), "cache");
ref_mpi_stopwatch_stop(ref_mpi, "cache background metric");
}
RSS(ref_validation_cell_volume(ref_grid), "vol");
RSS(ref_migrate_to_balance(ref_grid), "balance");
RSS(ref_grid_pack(ref_grid), "pack");
ref_mpi_stopwatch_stop(ref_mpi, "pack");
for (pass = 0; !all_done && pass < passes; pass++) {
if (ref_mpi_once(ref_mpi))
printf("\n pass %d of %d with %d ranks\n", pass + 1, passes,
ref_mpi_n(ref_mpi));
if (form_quads && pass == passes - 5)
RSS(ref_layer_align_quad(ref_grid), "quad");
all_done1 = all_done0;
RSS(ref_adapt_pass(ref_grid, &all_done0), "pass");
all_done = all_done0 && all_done1 && (pass > MIN(5, passes)) && !form_quads;
if (curvature_metric) {
if (stepexp_metric) {
RSS(stepexp_metric_fill(ref_grid, ref_dict_bcs, argc, argv), "stepexp");
} else {
if (spalding_yplus > 0.0) {
RSS(spalding_metric(ref_grid, ref_dict_bcs, spalding_yplus,
complexity, argc, argv),
"spalding");
} else {
RSS(ref_metric_interpolated_curvature(ref_grid), "interp curve");
ref_mpi_stopwatch_stop(ref_mpi, "curvature metric");
if (REF_EMPTY != pos && pos < argc - 1) {
complexity = atof(argv[pos + 1]);
if (ref_mpi_once(ref_mpi))
printf("--facelift-metric %f\n", complexity);
RSS(ref_facelift_multiscale(ref_grid, complexity), "metric");
ref_mpi_stopwatch_stop(ref_mpi, "facelift metric");
}
}
}
} else {
RSS(ref_metric_synchronize(ref_grid), "sync with background");
ref_mpi_stopwatch_stop(ref_mpi, "metric sync");
}
RSS(ref_validation_cell_volume(ref_grid), "vol");
RSS(ref_adapt_tattle_faces(ref_grid), "tattle");
ref_mpi_stopwatch_stop(ref_grid_mpi(ref_grid), "tattle faces");
RSS(ref_migrate_to_balance(ref_grid), "balance");
RSS(ref_grid_pack(ref_grid), "pack");
ref_mpi_stopwatch_stop(ref_mpi, "pack");
}
RSS(ref_node_implicit_global_from_local(ref_grid_node(ref_grid)),
"implicit global");
ref_mpi_stopwatch_stop(ref_mpi, "implicit global");
RSS(ref_geom_verify_param(ref_grid), "final params");
ref_mpi_stopwatch_stop(ref_mpi, "verify final params");
/* export via -x grid.ext and -f final-surf.tec and -q final-vol.plt */
for (opt = 0; opt < argc - 1; opt++) {
if (strcmp(argv[opt], "-x") == 0) {
if (ref_mpi_para(ref_mpi)) {
if (ref_mpi_once(ref_mpi))
printf("gather " REF_GLOB_FMT " nodes to %s\n",
ref_node_n_global(ref_grid_node(ref_grid)), argv[opt + 1]);
RSS(ref_gather_by_extension(ref_grid, argv[opt + 1]), "gather -x");
} else {
if (ref_mpi_once(ref_mpi))
printf("export " REF_GLOB_FMT " nodes to %s\n",
ref_node_n_global(ref_grid_node(ref_grid)), argv[opt + 1]);
RSS(ref_export_by_extension(ref_grid, argv[opt + 1]), "export -x");
}
}
if (strcmp(argv[opt], "-f") == 0) {
if (ref_mpi_once(ref_mpi))
printf("gather final surface status %s\n", argv[opt + 1]);
RSS(ref_gather_surf_status_tec(ref_grid, argv[opt + 1]), "gather -f");
}
if (strcmp(argv[opt], "-q") == 0) {
if (ref_mpi_once(ref_mpi))
printf("gather final volume status %s\n", argv[opt + 1]);
RSS(ref_gather_volume_status_tec(ref_grid, argv[opt + 1]), "gather -f");
}
}
RSS(ref_dict_free(ref_dict_bcs), "free");
RSS(ref_grid_free(ref_grid), "free");
return REF_SUCCESS;
shutdown:
if (ref_mpi_once(ref_mpi)) adapt_help(argv[0]);
return REF_FAILURE;
}
static REF_STATUS fossilize(REF_GRID ref_grid, const char *fossil_filename,
const char *project, const char *mesher,
const char *mesher_options) {
REF_MPI ref_mpi = ref_grid_mpi(ref_grid);
REF_GRID fossil_grid;
REF_NODE ref_node, fossil_node;
REF_CELL ref_cell, fossil_cell;
REF_INT node, new_node, *f2g;
REF_INT nodes[REF_CELL_MAX_SIZE_PER], tempnode, cell, new_cell;
REF_GLOB global;
char filename[1024];
REF_INT self_intersections;
REF_INT group, cell_node;
if (ref_mpi_para(ref_mpi)) {
if (ref_mpi_once(ref_mpi)) printf("part %s\n", fossil_filename);
RSS(ref_part_by_extension(&fossil_grid, ref_mpi, fossil_filename), "part");
ref_mpi_stopwatch_stop(ref_mpi, "part");
ref_grid_partitioner(ref_grid) = REF_MIGRATE_SINGLE;
RSS(ref_migrate_to_balance(ref_grid), "migrate to single part");
RSS(ref_grid_pack(ref_grid), "pack");
ref_mpi_stopwatch_stop(ref_mpi, "pack");
} else {
if (ref_mpi_once(ref_mpi)) printf("import %s\n", fossil_filename);
RSS(ref_import_by_extension(&fossil_grid, ref_mpi, fossil_filename),
"import");
ref_mpi_stopwatch_stop(ref_mpi, "import");
}
fossil_node = ref_grid_node(fossil_grid);
ref_node = ref_grid_node(ref_grid);
ref_malloc_init(f2g, ref_node_max(fossil_node), REF_INT, REF_EMPTY);
each_ref_node_valid_node(fossil_node, node) {
if (!ref_cell_node_empty(ref_grid_tri(fossil_grid), node)) {
RSS(ref_node_next_global(ref_node, &global), "next global");
RSS(ref_node_add(ref_node, global, &new_node), "new_node");
f2g[node] = new_node;
ref_node_xyz(ref_node, 0, new_node) = ref_node_xyz(fossil_node, 0, node);
ref_node_xyz(ref_node, 1, new_node) = ref_node_xyz(fossil_node, 1, node);
ref_node_xyz(ref_node, 2, new_node) = ref_node_xyz(fossil_node, 2, node);
}
}
fossil_cell = ref_grid_tri(fossil_grid);
ref_cell = ref_grid_tri(ref_grid);
each_ref_cell_valid_cell_with_nodes(fossil_cell, cell, nodes) {
tempnode = nodes[0];
nodes[0] = nodes[1];
nodes[1] = tempnode;
nodes[0] = f2g[nodes[0]];
nodes[1] = f2g[nodes[1]];
nodes[2] = f2g[nodes[2]];
nodes[3] = REF_EMPTY;
RSS(ref_cell_add(ref_cell, nodes, &new_cell), "insert tri");
}
if (strncmp(mesher, "t", 1) == 0) {
if (ref_mpi_once(ref_mpi)) {
printf("fill volume with TetGen\n");
RSB(ref_geom_tetgen_volume(ref_grid, project, mesher_options),
"tetgen surface to volume", {
printf("probing adapted tessellation self-intersections\n");
RSS(ref_dist_collisions(ref_grid, REF_TRUE, &self_intersections),
"bumps");
printf("%d segment-triangle intersections detected.\n",
self_intersections);
});
}
ref_mpi_stopwatch_stop(ref_mpi, "tetgen volume");
} else if (strncmp(mesher, "a", 1) == 0) {
if (ref_mpi_once(ref_mpi)) {
printf("fill volume with AFLR3\n");
RSB(ref_geom_aflr_volume(ref_grid, project, mesher_options),
"aflr surface to volume", {
printf("probing adapted tessellation self-intersections\n");
RSS(ref_dist_collisions(ref_grid, REF_TRUE, &self_intersections),
"bumps");
printf("%d segment-triangle intersections detected.\n",
self_intersections);
});
}
ref_mpi_stopwatch_stop(ref_mpi, "aflr volume");
} else {
if (ref_mpi_once(ref_mpi)) printf("mesher '%s' not implemented\n", mesher);
return REF_FAILURE;
}
ref_grid_surf(ref_grid) = REF_FALSE; /* needed until vol mesher para */
RSS(ref_validation_boundary_face(ref_grid), "boundary-interior connectivity");
ref_mpi_stopwatch_stop(ref_grid_mpi(ref_grid), "boundary-volume check");
RSS(ref_split_edge_geometry(ref_grid), "split geom");
ref_mpi_stopwatch_stop(ref_grid_mpi(ref_grid), "split geom");
RSS(ref_node_synchronize_globals(ref_grid_node(ref_grid)), "sync glob");
ref_cell = ref_grid_tri(ref_grid);
each_ref_cell_valid_cell_with_nodes(ref_cell, cell, nodes) {
if (REF_EMPTY == nodes[3]) RSS(ref_cell_remove(ref_cell, cell), "rm tri");
}
each_ref_node_valid_node(fossil_node, node) {
if (ref_cell_node_empty(ref_grid_tri(fossil_grid), node)) {
RSS(ref_node_next_global(ref_node, &global), "next global");
RSS(ref_node_add(ref_node, global, &new_node), "new_node");
f2g[node] = new_node;
ref_node_xyz(ref_node, 0, new_node) = ref_node_xyz(fossil_node, 0, node);
ref_node_xyz(ref_node, 1, new_node) = ref_node_xyz(fossil_node, 1, node);
ref_node_xyz(ref_node, 2, new_node) = ref_node_xyz(fossil_node, 2, node);
}
}
each_ref_grid_3d_ref_cell(ref_grid, group, ref_cell) {
fossil_cell = ref_grid_cell(fossil_grid, group);
each_ref_cell_valid_cell_with_nodes(fossil_cell, cell, nodes) {
each_ref_cell_cell_node(ref_cell, cell_node) {
nodes[cell_node] = f2g[nodes[cell_node]];
}
RSS(ref_cell_add(ref_cell, nodes, &new_cell), "insert vol cell");
}
}
sprintf(filename, "%s-vol.plt", project);
if (ref_mpi_once(ref_mpi))
printf("gather " REF_GLOB_FMT " nodes to %s\n",
ref_node_n_global(ref_grid_node(ref_grid)), filename);
RSS(ref_gather_by_extension(ref_grid, filename), "vol export");
ref_mpi_stopwatch_stop(ref_mpi, "export volume");
RSS(ref_validation_boundary_face(ref_grid), "boundary-interior connectivity");
ref_mpi_stopwatch_stop(ref_grid_mpi(ref_grid), "boundary-volume check");
sprintf(filename, "%s-vol.meshb", project);
if (ref_mpi_once(ref_mpi))
printf("gather " REF_GLOB_FMT " nodes to %s\n",
ref_node_n_global(ref_grid_node(ref_grid)), filename);
RSS(ref_gather_by_extension(ref_grid, filename), "vol export");
ref_mpi_stopwatch_stop(ref_mpi, "export volume");
ref_free(f2g);
return REF_SUCCESS;
}
static REF_STATUS bootstrap(REF_MPI ref_mpi, int argc, char *argv[]) {
size_t end_of_string;
char project[1000];
char filename[1024];
REF_GRID ref_grid = NULL;