38 #include "../Rocblas/include/Rocblas.h"
39 #include "../Rocsurf/include/Rocsurf.h"
41 #include "../Rocsurf/test/IM_Reader.h"
45 #include "AdaptCOMWindow.h"
70 cout <<
"Usage: " << argv[0] <<
" <surffile> <controlfile>" << std::endl;
78 remesh_interval(10),
test(
"rotate"),
79 adapt_iter(2), do_redist(0), do_collapse(1), do_flip(1),
80 do_split(1), collapse_ratio(0), split_angle(0), refine(1) {}
148 is.get( buf, 255,
':');
149 if ( buf[0] ==
'\0') { is.getline( buf, 255);
continue; }
151 istringstream istr(buf);
152 string keyword; istr >> keyword;
153 is.getline( buf, 255,
':');
155 if ( keyword ==
"method")
157 else if ( keyword ==
"wavefrontal")
159 else if ( keyword ==
"normaldif")
161 else if ( keyword ==
"eigthres")
163 else if ( keyword ==
"courant")
165 else if ( keyword ==
"fangle")
167 else if ( keyword ==
"sangle")
169 else if ( keyword ==
"smoother")
171 else if ( keyword ==
"rediter")
173 else if ( keyword ==
"conserv")
175 else if ( keyword ==
"speed")
177 else if ( keyword ==
"timestep")
179 else if ( keyword ==
"steps")
181 else if ( keyword ==
"start")
183 else if ( keyword ==
"interval")
185 else if ( keyword ==
"remesh_interval")
187 else if ( keyword ==
"weight")
189 else if ( keyword ==
"test")
191 else if ( keyword ==
"verbose")
193 else if ( keyword ==
"adapt_iter")
195 else if ( keyword ==
"do_redist")
197 else if ( keyword ==
"do_contract" || keyword ==
"do_collapse")
199 else if ( keyword ==
"do_flip")
201 else if ( keyword ==
"do_split")
203 else if ( keyword ==
"refine")
205 else if ( keyword ==
"collapse_ratio")
207 else if ( keyword ==
"split_angle")
210 std::cerr <<
"Unknow keyword " << keyword << std::endl;
211 is.getline( buf, 255);
214 if (
rank==0) std::cout <<
" speed is " << cp.
speed << std::endl;
220 if ( !cntr_param.
method.empty()) {
223 if (
rank==0) std::cout <<
"Set propagation method to " << cntr_param.
method << std::endl;
228 if (
rank==0) std::cout <<
"Set wavefrontal to " << cntr_param.
wavefrontal << std::endl;
233 if (
rank==0) std::cout <<
"Set normaldif to " << cntr_param.
normaldif << std::endl;
236 if ( !cntr_param.
eigthres.empty()) {
238 if (
rank==0) std::cout <<
"Set eigthres to " << cntr_param.
eigthres << std::endl;
241 if ( !cntr_param.
courant.empty()) {
243 if (
rank==0) std::cout <<
"Set courant constant to " << cntr_param.
courant << std::endl;
246 if ( !cntr_param.
fangle.empty()) {
248 if (
rank==0) std::cout <<
"Set weak-feature angle to " << cntr_param.
fangle << std::endl;
250 if ( !cntr_param.
sangle.empty()) {
252 if (
rank==0) std::cout <<
"Set strong-feature angle to " << cntr_param.
sangle << std::endl;
255 if ( !cntr_param.
smoother.empty()) {
257 if (
rank==0) std::cout <<
"Set smoother to " << cntr_param.
smoother << std::endl;
260 if ( !cntr_param.
rediter.empty()) {
262 if (
rank==0) std::cout <<
"Set rediter to " << cntr_param.
rediter << std::endl;
265 if ( !cntr_param.
conserv.empty()) {
267 if (
rank==0) std::cout <<
"Set conserv to " << cntr_param.
conserv << std::endl;
270 if ( !cntr_param.
verbose.empty()) {
272 if (
rank==0) std::cout <<
"Set verbose level to " << cntr_param.
verbose << std::endl;
275 if ( !cntr_param.
weight.empty()) {
277 if (
rank==0) std::cout <<
"Set weight to " << cntr_param.
weight << std::endl;
284 if (
rank==0) cout <<
"Reading surface mesh file \"" << fname <<
'"' << endl;
286 std::string fname_str(fname);
288 std::string::size_type pos = fname_str.find_first_of(
".");
289 const string wname = fname_str.substr( 0, pos);
291 if (
rank==0) cout <<
"Creating window \"" << wname <<
'"' << endl;
294 int npanes = im_reader.
read_winmesh( fname, wname,
false);
301 const SURF::Vector_3<double> &origin) {
304 COM::Attribute *nc=win->attribute(
"nc");
310 COM::Attribute *
x=win->attribute(
"1-nc");
311 COM::Attribute *
y=win->attribute(
"2-nc");
312 COM::Attribute *
z=win->attribute(
"3-nc");
330 COM_set_size((wname+
".cnstr_types_panel").c_str(), 0, 1);
359 static int OUT_write = 0, hdl;
370 std::string fname = wname+
"_"+timelevel;
373 else fname.append(
"_");
376 &hdl, (
char*)wname.c_str(), timelevel);
379 static COM::Attribute *mesh=NULL;
381 mesh =
COM_get_roccom()->get_window_object( wname)->attribute(
"mesh");
384 SURF::Rocsurf::compute_signed_volumes( mesh, &vol);
386 std::cout <<
"Volume of object is " << vol << std::endl;
388 std::cout <<
"Relative error in volume is "
389 <<
std::abs((vol-ref)/ref) << std::endl;
396 static int SURF_area = 0, BLAS_mul, BLAS_sum_scalar, area_hdl;
415 static int SURF_vol = 0, mesh_hdl;
429 int main(
int argc,
char *argv[]) {
459 if (
rank==0) cout <<
"Propagating interface..." << endl;
469 bool use_quadpoints =
false;
471 std::cerr <<
"Initializing for test case " << cntr_param.
test << std::endl;
472 if ( cntr_param.
test ==
"trans") {
475 else if ( cntr_param.
test ==
"rotate") {
480 else if ( cntr_param.
test ==
"vortexcube") {
482 if ( cntr_param.
speed>0 && cntr_param.
start==0)
483 rescale_object( wname, 0.3, SURF::Vector_3<double>(0.5, 0.75, 0.5));
485 else if ( cntr_param.
test ==
"vortex") {
487 if ( cntr_param.
speed>0 && cntr_param.
start==0)
488 rescale_object( wname, 0.15, SURF::Vector_3<double>(0.5, 0.75, 0.5));
490 else if ( cntr_param.
test ==
"leveque") {
492 if ( cntr_param.
speed>0 && cntr_param.
start==0)
493 rescale_object( wname, 0.15, SURF::Vector_3<double>(0.35, 0.35, 0.35));
499 if ( cntr_param.
start==0) {
510 std::ofstream areas, vols;
511 areas.precision(10); vols.precision(10);
514 if (
rank==0) areas.open((wname+
"_areas.m").c_str());
515 if (
rank==0) vols.open((wname+
"_vols.m").c_str());
520 std::cout <<
"Area is " << a <<
" and total volume is " <<
v << std::endl;
521 areas << wname <<
"_as = [0 " << a <<
";..." << std::endl;
522 vols << wname <<
"_vs = [0 " <<
v <<
";..." << std::endl;
526 std::sprintf(fname,
"timedata_%03d.txt",
rank);
529 AdaptCOMWindow acw( wname.c_str());
531 acw.set_option(
"adapt_iter", cntr_param.
adapt_iter);
532 acw.set_option(
"redist_iter", cntr_param.
do_redist);
534 acw.set_option(
"do_collapse", cntr_param.
do_collapse);
535 acw.set_option(
"do_flip", cntr_param.
do_flip);
536 acw.set_option(
"do_split", cntr_param.
do_split);
537 acw.set_option(
"refine", cntr_param.
refine);
539 if ( !cntr_param.
fangle.empty())
540 acw.set_option(
"fangle_weak",
542 if ( !cntr_param.
sangle.empty())
543 acw.set_option(
"fangle_strong",
551 acw.set_option(
"split_angle", cntr_param.
split_angle);
556 if (
rank==0) cout <<
"Step " <<
i << endl;
558 double local_t = 0, t_rem = cntr_param.
timestep, t_elapsed;
560 if ( use_quadpoints) {
572 if ( cntr_param.
speed==0) t_rem=0;
575 &t_rem, &disps, &t_elapsed);
581 local_t = cntr_param.
timestep - (t_rem-t_elapsed);
582 if ( local_t*1.e3<cntr_param.
timestep) {
583 std::cout <<
"Time step too small. Stopping..." << std::endl;
588 if ( (t_elapsed<0.1*t_rem || t_elapsed==t_rem &&
593 if ( acw.adapt()==0)
break;
601 std::cout <<
"Perform anisotropic smoothing" << std::endl;
603 &zero, &disps, &t_elapsed);
611 t_rem = cntr_param.
timestep - local_t;
617 std::cout <<
"Area is " << a <<
" and total volume is " <<
v << std::endl;
619 areas <<
'\t' << t <<
'\t';
620 areas.precision(16); areas << a <<
";..." << std::endl;
621 vols <<
'\t' << t <<
'\t';
622 vols.precision(16); vols <<
v <<
";..." << std::endl;
627 if ( cntr_param.
steps>=1.e6)
628 std::sprintf( steps,
"%07d",
i);
629 else if ( cntr_param.
steps>=1.e5)
630 std::sprintf( steps,
"%06d",
i);
632 std::sprintf( steps,
"%05d",
i);
640 areas <<
"];" << std::endl;
641 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
static void propagate_faces(const std::string &wname, const Speed &s, double t, double dt, const std::string &vname)
void int int REAL REAL * y
double compute_volume(const string &wname)
#define COM_assertion_msg(EX, msg)
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 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)
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 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[])
static void propagate_nodes(const std::string &wname, const Speed &s, double t, double dt, const std::string &vname)
void COM_init(int *argc, char ***argv)
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
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)