38 #include "../Rocblas/include/Rocblas.h"
39 #include "../Rocsurf/include/Rocsurf.h"
41 #include "../Rocsurf/test/IM_Reader.h"
44 #include "AdaptCOMWindow.h"
68 cout <<
"Usage: " << argv[0] <<
" <surffile> <controlfile>" << std::endl;
76 steps(0), start(0), interval(0), remesh_interval(10),
77 subadapt(0.5), adapt_iter(2), do_redist(1), do_collapse(1),
78 do_flip(1), do_split(1), collapse_ratio(0),
79 split_angle(0), refine(1), edge_len(0) {}
111 double collapse_ratio;
149 is.get( buf, 255,
':');
150 if ( buf[0] ==
'\0') { is.getline( buf, 255);
continue; }
152 istringstream istr(buf);
153 string keyword; istr >> keyword;
154 is.getline( buf, 255,
':');
156 if ( keyword ==
"method")
158 else if ( keyword ==
"wavefrontal")
160 else if ( keyword ==
"normaldif")
162 else if ( keyword ==
"eigthres")
164 else if ( keyword ==
"courant")
166 else if ( keyword ==
"fangle")
168 else if ( keyword ==
"sangle")
170 else if ( keyword ==
"smoother")
172 else if ( keyword ==
"rediter")
174 else if ( keyword ==
"perturb")
176 else if ( keyword ==
"speed")
178 else if ( keyword ==
"sploc")
180 else if ( keyword ==
"timestep")
182 else if ( keyword ==
"steps")
184 else if ( keyword ==
"start")
186 else if ( keyword ==
"interval")
188 else if ( keyword ==
"remesh_interval")
190 else if ( keyword ==
"weight")
192 else if ( keyword ==
"format")
194 else if ( keyword ==
"verbose")
196 else if ( keyword ==
"verbose")
198 else if ( keyword ==
"subadapt")
200 else if ( keyword ==
"adapt_iter")
202 else if ( keyword ==
"do_redist")
204 else if ( keyword ==
"do_contract" || keyword ==
"do_collapse")
206 else if ( keyword ==
"do_flip")
208 else if ( keyword ==
"do_split")
210 else if ( keyword ==
"feature_layer")
212 else if ( keyword ==
"refine")
214 else if ( keyword ==
"edge_len")
216 else if ( keyword ==
"collapse_ratio")
218 else if ( keyword ==
"split_angle")
221 std::cerr <<
"Unknow keyword " << keyword << std::endl;
222 is.getline( buf, 255);
225 if (
rank==0) std::cout <<
" speed is " << cp.
speed << std::endl;
231 if ( !cntr_param.
method.empty()) {
234 if (
rank==0) std::cout <<
"Set propagation method to " << cntr_param.
method << std::endl;
239 if (
rank==0) std::cout <<
"Set wavefrontal to " << cntr_param.
wavefrontal << std::endl;
244 if (
rank==0) std::cout <<
"Set normaldif to " << cntr_param.
normaldif << std::endl;
247 if ( !cntr_param.
eigthres.empty()) {
249 if (
rank==0) std::cout <<
"Set eigthres to " << cntr_param.
eigthres << std::endl;
252 if ( !cntr_param.
courant.empty()) {
254 if (
rank==0) std::cout <<
"Set courant constant to " << cntr_param.
courant << std::endl;
257 if ( !cntr_param.
fangle.empty()) {
259 if (
rank==0) std::cout <<
"Set weak-feature angle to " << cntr_param.
fangle << std::endl;
261 if ( !cntr_param.
sangle.empty()) {
263 if (
rank==0) std::cout <<
"Set strong-feature angle to " << cntr_param.
sangle << std::endl;
266 if ( !cntr_param.
smoother.empty()) {
268 if (
rank==0) std::cout <<
"Set smoother to " << cntr_param.
smoother << std::endl;
271 if ( !cntr_param.
rediter.empty()) {
273 if (
rank==0) std::cout <<
"Set rediter to " << cntr_param.
rediter << std::endl;
280 std::cout <<
"Set feature_layer to " << cntr_param.
feature_layer << std::endl;
283 if ( !cntr_param.
verbose.empty()) {
286 if (
rank==0) std::cout <<
"Set verbose level to " << cntr_param.
verbose << std::endl;
289 if ( !cntr_param.
weight.empty()) {
291 if (
rank==0) std::cout <<
"Set weight to " << cntr_param.
weight << std::endl;
298 if (
rank==0) cout <<
"Reading surface mesh file \"" << fname <<
'"' << endl;
300 std::string fname_str(fname);
302 std::string::size_type pos = fname_str.find_first_of(
".");
303 const string wname = fname_str.substr( 0, pos);
305 if (
rank==0) cout <<
"Creating window \"" << wname <<
'"' << endl;
308 int npanes = im_reader.
read_winmesh( fname, wname,
false);
315 const SURF::Vector_3<double> &origin) {
318 COM::Attribute *nc=win->attribute(
"nc");
324 COM::Attribute *
x=win->attribute(
"1-nc");
325 COM::Attribute *
y=win->attribute(
"2-nc");
326 COM::Attribute *
z=win->attribute(
"3-nc");
342 int *pane_ids, npanes;
345 for (
int i=0;
i<npanes; ++
i) {
346 bool not_interacting;
351 not_interacting = (*bcflag == 2);
354 not_interacting = (pane_ids[
i] == 3);
356 if ( !not_interacting)
continue;
358 int pid = pane_ids[
i], nelems, ngelems;
359 COM_get_size( (wname+
".cnstr_types_facial").c_str(), pid, &nelems, &ngelems);
361 COM_get_array( (wname+
".cnstr_types_facial").c_str(), pid, (
void**)&cnstr_types);
365 MAP::Vector_3<double> *centers;
366 COM_get_array( (wname+
".facecenters").c_str(), pid, (
void**)¢ers);
369 for (
int j=0;
j<nelems-ngelems; ++
j) {
372 if ( centers[
j].
x() <= 1.e-10 || centers[
j].
x() > 0.047624)
375 cnstr_types[
j] =
'x';
391 COM_get_array( (wname+
".cnstr_types_panel").c_str(), 2, (
void**)&cnstr_types);
421 int *pane_ids, npanes;
424 for (
int i=0;
i<npanes; ++
i) {
425 int pid = pane_ids[
i];
426 MAP::Vector_3<double> *nrms, *centers;
427 COM_get_array( (wname+
".facenormals").c_str(), pid, (
void**)&nrms);
428 COM_get_array( (wname+
".facecenters").c_str(), pid, (
void**)¢ers);
431 int *cnstr_types, nelems;
433 pid, (
void**)&cnstr_types);
434 COM_get_size( (wname+
".facenormals").c_str(), pid, &nelems);
440 for (
int j=0;
j<nelems; ++
j) {
442 ( centers[j][2] < eps || (1-centers[j][2]) < eps)) {
443 cnstr_types[
j] =
't';
446 else if (
std::abs(nrms[j][2]) < 0.5 &&
452 spds[
j] = cntr_param.
speed;
465 int *pane_ids, npanes;
470 if ( cntr_param.
start == 0) {
472 if ( cnstr_handle_pn>0) {
473 std::cout <<
"Obtaining constraints from input file" << std::endl;
484 std::cout <<
"Did not find constraints from input file. "
485 <<
"Setting constraints from geometry." << std::endl;
501 for (
int i=0;
i<npanes; ++
i) {
502 int pid = pane_ids[
i];
503 MAP::Vector_3<double> *nrms, *centers;
504 COM_get_array( (wname+
".facenormals").c_str(), pid, (
void**)&nrms);
505 COM_get_array( (wname+
".facecenters").c_str(), pid, (
void**)¢ers);
507 int *cnstr_types, nelems, ngelems;
509 pid, (
void**)&cnstr_types);
510 COM_get_size( (wname+
".facenormals").c_str(), pid, &nelems, &ngelems);
514 for (
int j=0;
j<nelems-ngelems; ++
j) {
515 if ( centers[
j][0] < eps || centers[
j][0]+eps > 1.76314)
517 else if ( centers[
j][0] - 0.004826 < eps)
518 cnstr_types[
j] = -
'x';
519 else if ( centers[
j][0] >= 1.6962 &&
std::abs(nrms[
j][0])<0.1)
520 cnstr_types[
j] =
'x';
530 for (
int i=0;
i<npanes; ++
i) {
531 int pid = pane_ids[
i];
539 bnd[0] = -
'x'; bnd[1] = 0; bnd[2] = 0.0635;
540 bnd[3] = bnd[4] = bnd[5] = 0;
541 bnd[6] = 0; bnd[7] = bnd[8] = -0.07;
542 bnd[9] = 1.7; bnd[10] = bnd[11] = 0.07;
546 int *cnstr_types, nelems, ngelems;
550 pid, (
void**)&cnstr_types);
551 COM_get_size( (wname+
".facenormals").c_str(), pid, &nelems, &ngelems);
555 COM_get_array( (wname+
".flag_spd").c_str(), pid, (
void**)&flags);
558 for (
int j=0;
j<nelems-ngelems; ++
j) {
559 if ( cnstr_types[
j]) {
560 flags[
j] = spds[
j] = 0;
563 spds[
j] = cntr_param.
speed;
593 int *pane_ids, npanes;
601 for (
int i=0;
i<npanes; ++
i) {
602 int pid = pane_ids[
i];
603 MAP::Vector_3<double> *nrms, *centers;
604 COM_get_array( (wname+
".facenormals").c_str(), pid, (
void**)&nrms);
605 COM_get_array( (wname+
".facecenters").c_str(), pid, (
void**)¢ers);
609 pid, (
void**)&cnstr_types);
613 COM_get_array( (wname+
".flag_spd").c_str(), pid, (
void**)&flags);
616 COM_get_size( (wname+
".facenormals").c_str(), pid, &nelems, &ngelems);
619 if ( cntr_param.
start == 0) {
621 for (
int j=0;
j<nelems-ngelems; ++
j) {
624 cnstr_types[
j] =
'z';
625 flags[
j] = spds[
j]= 0;
629 flags[
j] = 1.; spds[
j]= cntr_param.
speed;
634 for (
int j=0;
j<nelems-ngelems; ++
j) {
635 if ( cnstr_types[
j] == 0) {
636 flags[
j] = 1.; spds[
j]= cntr_param.
speed;
639 flags[
j] = spds[
j]= 0;
669 int *pane_ids, npanes;
672 for (
int i=0;
i<npanes; ++
i) {
673 int pid = pane_ids[
i];
674 MAP::Vector_3<double> *nrms, *centers;
675 COM_get_array( (wname+
".facenormals").c_str(), pid, (
void**)&nrms);
676 COM_get_array( (wname+
".facecenters").c_str(), pid, (
void**)¢ers);
681 pid, (
void**)&cnstr_types);
684 COM_get_size( (wname+
".facenormals").c_str(), pid, &nelems, &ngelems);
688 for (
int j=0;
j<nelems-ngelems; ++
j) {
690 cnstr_types[
j] =
't';
703 if ( wname.substr(0,5) ==
"acmfl")
705 else if ( wname.substr(0,9) ==
"starslice")
707 else if ( wname.substr(0,7) ==
"staraft")
709 else if ( wname.substr(0,8) ==
"labscale")
711 else if ( wname.substr(0,3) ==
"acm")
715 if ( cnstr_handle>=0) {
735 COM_set_size((wname+
".cnstr_types_panel").c_str(), 0, 1);
761 int *pane_ids, npanes;
764 for (
int i=0;
i<npanes; ++
i) {
768 if ( wname.substr(0,5) ==
"acmfl" ) {
771 COM_get_array( (wname+
".bcflag").c_str(), pane_ids[i], &bcflag);
773 *flag = ( *bcflag == 1) ? cntr_param.
speed : 0.;
776 *flag = (pane_ids[
i]<=2)?cntr_param.
speed:0.;
778 else if ( wname.substr(0,4) ==
"star")
779 *flag = (i%2)?0.:cntr_param.
speed;
782 COM_get_array( (wname+
".bcflag").c_str(), pane_ids[i], &bcflag);
784 *flag = ( *bcflag == 1) ? cntr_param.
speed : 0.;
787 *flag = cntr_param.
speed;
789 std::cout <<
"Setting speed for pane " << pane_ids[
i]
790 <<
" to " << *flag << std::endl;
809 const string &format) {
810 static int OUT_write = 0, hdl;
818 if ( format !=
"HDF" && format !=
"hdf")
825 std::string fname = wname+
"_"+timelevel;
829 if ( format !=
"HDF" && format !=
"hdf")
830 fname.append(
".cgns");
833 fname.append(
".hdf");
835 else fname.append(
"_");
838 &hdl, (
char*)wname.c_str(), timelevel);
842 static int SURF_area = 0, BLAS_mul, BLAS_sum_scalar, area_hdl, flag_hdl;
863 static int SURF_vol = 0, mesh_hdl;
878 int main(
int argc,
char *argv[]) {
908 if (
rank==0) cout <<
"Propagating interface..." << endl;
918 if ( cntr_param.
start==0) {
928 std::ofstream areas, vols;
930 areas.open((wname+
"_areas.m").c_str());
931 vols.open((wname+
"_vols.m").c_str());
933 areas.precision(10); vols.precision(10); cout.precision(10);
939 std::cout <<
"Burning area is " << a
940 <<
" and total volume is " <<
v << std::endl;
941 areas << wname <<
"_as = [0 " << a <<
";..." << std::endl;
942 vols << wname <<
"_vs = [0 " <<
v <<
";..." << std::endl;
946 std::sprintf(fname,
"timedata_%03d.txt",
rank);
949 AdaptCOMWindow acw( wname.c_str());
950 acw.set_option(
"adapt_iter", 1);
951 acw.set_option(
"redist_iter", 0);
953 acw.set_option(
"do_collapse", cntr_param.
do_collapse);
954 acw.set_option(
"do_flip", cntr_param.
do_flip);
955 acw.set_option(
"do_split", cntr_param.
do_split);
956 acw.set_option(
"refine", cntr_param.
refine);
958 acw.set_option(
"edge_len", cntr_param.
edge_len);
960 if ( !cntr_param.
fangle.empty())
961 acw.set_option(
"fangle_weak",
963 if ( !cntr_param.
sangle.empty())
964 acw.set_option(
"fangle_strong",
971 acw.set_option(
"split_angle", cntr_param.
split_angle);
973 acw.set_option(
"anisotropic", cntr_param.
smoother ==
"anisotropic");
981 if (
rank==0) cout <<
"Step " <<
i << endl;
983 double local_t = 0, t_rem = cntr_param.
timestep, t_elapsed = 0;
986 if ( cntr_param.
speed==0) t_rem=0;
994 if ( !acw.adapt())
break;
1005 std::cout <<
"Perform anisotropic smoothing" << std::endl;
1007 &zero, &disps, &t_elapsed);
1016 &t_rem, &disps, &t_elapsed);
1021 local_t = cntr_param.
timestep - (t_rem-t_elapsed);
1022 t_rem = cntr_param.
timestep - local_t;
1024 if ( t_rem>0 && t_elapsed*1.e3<cntr_param.
timestep) {
1025 std::cout <<
"Time step too small. Stopping..." << std::endl;
1032 std::cout <<
"Burning area is " << a
1033 <<
" and total volume is " <<
v << std::endl;
1035 areas <<
'\t' << t <<
'\t' << a <<
";..." << std::endl;
1036 vols <<
'\t' << t <<
'\t' <<
v <<
";..." << std::endl;
1041 if ( cntr_param.
steps>=1.e6)
1042 std::sprintf( steps,
"%07d",
i);
1043 else if ( cntr_param.
steps>=1.e5)
1044 std::sprintf( steps,
"%06d",
i);
1046 std::sprintf( steps,
"%05d",
i);
1054 areas <<
"];" << std::endl;
1055 vols <<
"];" << std::endl;
int COMMPI_Comm_rank(MPI_Comm c)
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
void init_constraints_acmfrac(const string &wname)
void int int REAL REAL * y
double compute_volume(const string &wname)
#define COM_assertion_msg(EX, msg)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
This file contains the prototypes for Roccom API.
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
void rescale_object(std::string &wname, double alpha, const SURF::Vector_3< double > &origin)
int COM_get_attribute_handle(const char *waname)
void init_parameters(const Control_parameter &cntr_param)
float atof(const char *const str)
Read a float number from a C-string.
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
std::string read_in_mesh(const char *fname)
void init_constraints_staraft(const string &wname, const Control_parameter &cntr_param)
static void mul_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for multiplication with y as a scalar pointer.
void int int int REAL REAL REAL * z
double compute_area(const string &wname)
void COM_print_profile(const char *fname, const char *header)
void COM_set_profiling_barrier(int hdl, MPI_Comm comm)
void COM_window_init_done(const char *w_str, int pane_changed=true)
This file contains a set of routines for error assertion.
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
void init_constraints_acmflu(const string &wname)
void print_usage(int argc, char *argv[])
void COM_set_profiling(int i)
void COM_call_function(const int wf, int argc,...)
int main(int argc, char *argv[])
void init_constraints_myacm(const string &wname, const Control_parameter &cntr_param)
void COM_init(int *argc, char ***argv)
void init_constraints_labscale(const string &wname, const Control_parameter &cntr_param)
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
void COM_free_buffer(int **buf)
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
void init_constraints_starslice(const string &wname, const Control_parameter &cntr_param)
void init_constraints(const string &wname, const Control_parameter &cntr_param)
int read_winmesh(const char *fname, const std::string &wname, bool del=true)
double output_solution(const string &wname, const char *timelevel, double ref=0.)
void init_attributes(const string &wname, const Control_parameter &cntr_param)
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
int COM_get_function_handle(const char *wfname)
void read_control_file(const char *fname, Control_parameter &cp)
static void add_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for addition with y as a scalar pointer.
#define COM_EXTERN_MODULE(moduleName)