26 #include "../Rocblas/include/Rocblas.h"
37 if ( _wm) {
delete _wm; _wm = NULL; }
38 if ( _buf){
delete _buf; _buf = NULL; }
40 if ( _prop) {
delete _prop; _prop = NULL; }
41 if ( _rem && _rem_owner) {
delete _rem; _rem = NULL; }
49 _win =
const_cast<COM::Window*
>(pmesh->window());
52 MPI_Comm comm = _win->get_communicator();
63 if ( _wm) {
delete _wm; _wm = NULL; }
68 if ( _prop) {
delete _prop; _prop = NULL; }
71 if ( _buf)
delete _buf;
72 _buf =
new COM::Window( _win->name()+
"-propbuffer", comm);
74 COM::Pane::INHERIT_USE,
true, NULL, 0);
76 COM::Pane::INHERIT_USE,
true, NULL, 0);
77 _buf->inherit( _win->attribute(
COM::COM_NC),
"oldnc",
78 COM::Pane::INHERIT_CLONE,
true, NULL, 0);
80 COM::Pane::INHERIT_USE,
true, NULL, 0);
89 SURF::Window_manifold_2 *wm = manifold();
91 { initialize( pmesh, _parent); wm = manifold(); }
93 wm->perturb_mesh( alpha);
98 _cnstr_types = cnstr_types;
107 COM::Attribute *spds_io,
116 SURF::Window_manifold_2 *wm = manifold();
118 { initialize( pmesh, _parent); wm = manifold(); }
121 "Rocprop was initialized for a different window");
124 if ( _prop == NULL) {
125 if ( _prop_method == PROP_FO)
132 COM::Attribute *nc = _buf->attribute(
COM::COM_NC);
133 COM::Attribute *oldnc = _buf->attribute(
"oldnc");
137 _prop->set_constraints( _cnstr_types);
138 _prop->set_bounds( _cnstr_bound);
139 _prop->set_verbose(_verb);
142 if ( _prop_method == PROP_FO) {
144 ((
FaceOffset_3*)_prop)->set_eigen_threshold( _eig_thres);
146 ((
FaceOffset_3*)_prop)->set_courant_constant( _courant);
147 if ( _fangle_strong>=0)
148 ((
FaceOffset_3*)_prop)->set_fangle_strong( _fangle_strong);
149 if ( _fangle_weak>=0)
151 if ( _fangle_turn>=0)
154 ((
FaceOffset_3*)_prop)->set_wavefrontal_expansion( _wf_expn);
156 ((
FaceOffset_3*)_prop)->set_normal_diffusion( _nrm_dfsn);
157 if ( _feature_layer>=0)
158 ((
FaceOffset_3*)_prop)->set_feature_layer( _feature_layer);
159 if ( _wght_scheme>=0)
160 ((
FaceOffset_3*)_prop)->set_weighting_scheme( _wght_scheme);
167 COM::Attribute *spd = spds_io ?
168 _buf->inherit( spds_io,
"rpr_spd_buf",
169 COM::Pane::INHERIT_USE,
true, NULL, 0) : NULL;
170 _buf->init_done(
false);
173 double t = 0, t_rem = *dt;
174 while ( t_rem > 0 || *dt==0) {
176 int smoothed=(_rediter>0);
177 double max_dt = _prop->time_stepping( spd, t_rem, du, &smoothed);
179 if ( _verb && _rank==0)
180 std::cout <<
"Rocprop: Subcycling with time step " << max_dt << std::endl;
182 t = *dt - (t_rem-max_dt);
185 if ( t_rem > 0 && max_dt < *dt * _time_lb) {
190 std::cerr <<
"Rocprop: Given time step could not be reached" << std::endl;
193 else if ( dt_elapsed==NULL) {
194 std::cerr <<
"Rocprop: Time step is smaller than the lower bound "
195 << *dt*_time_lb <<
'=' << *dt <<
'*' << _time_lb
196 <<
"\nMesh is too distorted. Stopping..." << std::endl;
200 if ( code) *code = 0;
206 if ( _cnstr_bound && spd && spd->is_elemental())
207 _prop->bound_facial_speed( spd);
211 if ( _prop_method == PROP_FO) {
212 for (
int i=smoothed;
i<_rediter; ++
i) {
213 if ( _verb && _rank==0)
214 std::cout <<
"Rocprop: Perform additional mesh smoothing" << std::endl;
215 _prop->time_stepping( NULL, 0, du, NULL);
221 if ( dt_elapsed) { *dt_elapsed = t;
break; }
222 else if ( *dt==0)
break;
230 if ( spd) _buf->delete_attribute( spd->name());
231 _buf->init_done(
false);
239 if ( opt) option = opt;
241 if ( option ==
"method") {
242 std::string value(val);
243 int old_method = _prop_method;
246 _prop_method = PROP_FO;
248 _prop_method = PROP_MP;
251 if ( _prop_method != old_method && _prop)
252 {
delete _prop; _prop=NULL; }
254 else if ( option ==
"eigthres") {
257 else if ( option ==
"smoother") {
258 std::string value(val);
259 if ( value ==
"none")
261 else if ( value ==
"centroid")
263 else if ( value ==
"anisotropic")
266 COM_assertion( value ==
"Laplacian" || value ==
"laplacian");
270 else if ( option ==
"rediter") {
271 _rediter = std::atoi( val);
273 else if ( option ==
"conserv") {
274 _conserv = std::atoi( val);
276 else if ( option ==
"courant") {
279 else if ( option ==
"wavefrontal") {
280 _wf_expn = std::atoi( val);
282 else if ( option ==
"weight") {
283 _wght_scheme = std::atoi( val);
285 else if ( option ==
"normaldif") {
286 _nrm_dfsn = std::atoi( val);
288 else if ( option ==
"feature_layer") {
289 _feature_layer = std::atoi( val);
291 else if ( option ==
"sangle" || option ==
"fangle_strong") {
294 else if ( option ==
"fangle" || option==
"fangle_weak") {
297 else if ( option ==
"tangle" || option ==
"fangle_tun") {
300 else if ( option ==
"verbose")
311 double l = lave?*lave:0.;
312 if ( l==0) compute_edge_lengths( &l, NULL, NULL);
314 _rem->remesh_serial( _wm, mesh_out, l, fangle?*fangle:0.);
318 std::cerr <<
"No remesher was registered" << std::endl;
327 std::string glb=mname+
".global";
336 glb.c_str(),
"biB", types);
340 glb.c_str(),
"bi", types);
344 glb.c_str(),
"bi", types);
349 glb.c_str(),
"bbi", types);
355 glb.c_str(),
"bibioOO", types);
360 glb.c_str(),
"bii", types);
365 glb.c_str(),
"boII", types);
370 glb.c_str(),
"biI", types);
373 std::string glb_surf=mname+
".global_surf";
381 glb_surf.c_str(),
"boOO", types);
388 std::string glb=mname+
".global";
int COMMPI_Comm_rank(MPI_Comm c)
static void sub(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for subtraction.
void set_bounds(const COM::Attribute *bnd)
Set the bounds Propagation_3::set_bounds.
int COM_Type
Indices for derived data types.
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
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
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 code(though may enhance!portability between Crays and other systems)!INTEGER MPI_TAG_UB
#define PROP_END_NAMESPACE
const char * option(const char *const name, const int argc, const char *const *const argv, const char *defaut, const char *const usage=0)
void COM_delete_window(const char *wname)
void perturb_mesh(COM::Attribute *pmesh, const double &alpha)
Perturb the given mesh by alpha times shortest edge length.
#define PROP_BEGIN_NAMESPACE
#define COM_assertion_msg(EX, msg)
void set_constraints(const COM::Attribute *cnstr_types)
Set the types and directions of constraints Propagation_3::set_constraints.
void COM_set_object(const char *wa_str, int pane_id, Type *addr)
void propagate(const COM::Attribute *pmesh, COM::Attribute *vel, const double *dt, COM::Attribute *du, double *dt_elapsed=NULL, int *code=NULL)
Propagates the interface.
void ROCPROP_LOAD_MODULE(const char *name, long int length)
void rocprop_load_module(const char *name, long int length)
float atof(const char *const str)
Read a float number from a C-string.
double length(Vector3D *const v, int n)
void COM_get_object(const char *wa_str, int pane_id, Type **addr)
void ROCPROP_UNLOAD_MODULE(const char *name, long int length)
static void add(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for addition.
void initialize(const COM::Attribute *pmesh)
Constructs the communication patterns of a distributed mesh.
static void unload(const std::string &mname)
void COM_window_init_done(const char *w_str, int pane_changed=true)
void ROCPROP_UNLOAD_MODULE_(const char *name, long int length)
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
void ROCPROP_LOAD_MODULE_(const char *name, long int length)
void remesh_serial(COM::Attribute *mesh_out, double *lave=NULL, double *fangle=NULL)
Invoke serial remeshing.
void rocprop_unload_module_(const char *name, long int length)
void set_option(const char *opt, const char *val)
Set options for propagation.
void rocprop_unload_module(const char *name, long int length)
static void copy(const Attribute *x, Attribute *y)
Wrapper for copy.
void compute_edge_lengths(double *lave, double *lmin, double *lmax)
Computes edge lengths of a given window.
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_set_member_function(const char *wf_str, Member_func_ptr func, const char *wa_str, const char *intents, const COM_Type *types)
void Rocprop_load_module(const char *name)
int validate_object() const
void set_remesher(void *rem, int *owner=0)
Register remesher. Rocprop does not own the remesher.
static void load(const std::string &mname)
void Rocprop_unload_module(const char *name)
void initialize(const COM::Attribute *pmesh, SURF::Rocsurf *rsurf=NULL)
Initialize Rocprop with given mesh.
void rocprop_load_module_(const char *name, long int length)