bool Assembly::on_render_begin( const Project& project, const BaseGroup* parent, OnRenderBeginRecorder& recorder, IAbortSwitch* abort_switch) { if (!Entity::on_render_begin(project, parent, recorder, abort_switch)) return false; if (!BaseGroup::on_render_begin(project, parent, recorder, abort_switch)) return false; bool success = true; success = success && invoke_on_render_begin(bsdfs(), project, this, recorder, abort_switch); success = success && invoke_on_render_begin(bssrdfs(), project, this, recorder, abort_switch); success = success && invoke_on_render_begin(edfs(), project, this, recorder, abort_switch); success = success && invoke_on_render_begin(surface_shaders(), project, this, recorder, abort_switch); success = success && invoke_on_render_begin(materials(), project, this, recorder, abort_switch); success = success && invoke_on_render_begin(lights(), project, this, recorder, abort_switch); success = success && invoke_on_render_begin(objects(), project, this, recorder, abort_switch); success = success && invoke_on_render_begin(object_instances(), project, this, recorder, abort_switch); success = success && invoke_on_render_begin(volumes(), project, this, recorder, abort_switch); return success; }
ScFileWidget::ScFileWidget(QWidget * parent) : QFileDialog(parent, Qt::Widget) { setSizeGripEnabled(false); setModal(false); setViewMode(QFileDialog::List); setWindowFlags(Qt::Widget); #ifdef Q_OS_MAC QList<QUrl> urls; QUrl computer(QUrl::fromLocalFile(QLatin1String(""))); if (!urls.contains(computer)) urls << computer; QUrl volumes(QUrl::fromLocalFile("/Volumes")); if (!urls.contains(volumes)) urls << volumes; //desktop too? QUrl computer(QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))); setSidebarUrls(urls); #endif QList<QPushButton *> b = findChildren<QPushButton *>(); QListIterator<QPushButton *> i(b); while (i.hasNext()) i.next()->setVisible(false); setMinimumSize(QSize(480, 310)); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); }
//********************************************************************** PHX_EVALUATE_FIELDS(GlobalStatistics,workset) { if (workset.num_cells == 0) return; Intrepid::FunctionSpaceTools::integrate<ScalarT>(volumes, ones, (this->wda(workset).int_rules[ir_index])->weighted_measure, Intrepid::COMP_BLAS); for (std::size_t cell = 0; cell < workset.num_cells; ++cell) total_volume += volumes(cell); typename std::vector<PHX::MDField<ScalarT,Cell,IP> >::size_type field_index = 0; for (typename std::vector<PHX::MDField<ScalarT,Cell,IP> >::iterator field = field_values.begin(); field != field_values.end(); ++field,++field_index) { Intrepid::FunctionSpaceTools::integrate<ScalarT>(tmp, *field, (this->wda(workset).int_rules[ir_index])->weighted_measure, Intrepid::COMP_BLAS); for (std::size_t cell = 0; cell < workset.num_cells; ++cell) { averages[field_index] += tmp(cell); for (typename PHX::MDField<ScalarT,Cell,IP>::size_type ip = 0; ip < (field->dimension(1)); ++ip) { maxs[field_index] = std::max( (*field)(cell,ip), maxs[field_index]); mins[field_index] = std::min( (*field)(cell,ip), mins[field_index]); } } } }
CollOfScalar EquelleRuntimeCPU::norm(const CollOfCell& cells) const { const int n = cells.size(); CollOfScalar::V volumes(n); for (int i = 0; i < n; ++i) { volumes[i] = grid_.cell_volumes[cells[i].index]; } return volumes; }
void Assembly::update_asset_paths(const StringDictionary& mappings) { BaseGroup::update_asset_paths(mappings); invoke_update_asset_paths(bsdfs(), mappings); invoke_update_asset_paths(bssrdfs(), mappings); invoke_update_asset_paths(edfs(), mappings); invoke_update_asset_paths(surface_shaders(), mappings); invoke_update_asset_paths(materials(), mappings); invoke_update_asset_paths(lights(), mappings); invoke_update_asset_paths(objects(), mappings); invoke_update_asset_paths(object_instances(), mappings); invoke_update_asset_paths(volumes(), mappings); }
void Assembly::collect_asset_paths(StringArray& paths) const { BaseGroup::collect_asset_paths(paths); invoke_collect_asset_paths(bsdfs(), paths); invoke_collect_asset_paths(bssrdfs(), paths); invoke_collect_asset_paths(edfs(), paths); invoke_collect_asset_paths(surface_shaders(), paths); invoke_collect_asset_paths(materials(), paths); invoke_collect_asset_paths(lights(), paths); invoke_collect_asset_paths(objects(), paths); invoke_collect_asset_paths(object_instances(), paths); invoke_collect_asset_paths(volumes(), paths); }
int main(int argc, char** argv) { if (argc < 2) { printf("usage: libstor-c CONFIG\n"); return 1; } result c = new_client(argv[1]); if (c.err) { printf("libstor-c: error: %s\n", c.err); return 1; } h client_id = *((h*)c.val); result v = volumes(client_id, 0); if (v.err) { printf("libstor-c: error: %s\n", v.err); close(client_id); return 1; } service_volume_map svm = *((service_volume_map*)v.val); for (int x = 0; x < svm.services_c; x++) { printf("service: %s\n", svm.service_names[x]); volume_map vm = *svm.volumes[x]; for (int y = 0; y < vm.volumes_c; y++) { volume vol = *vm.volumes[y]; printf("\n"); printf(" - volume: %s\n", vm.volume_ids[y]); printf(" name: %s\n", vol.name); printf(" iops: %" PRId64 "\n", vol.iops); printf(" size: %" PRId64 "\n", vol.size); printf(" type: %s\n", vol.volume_type); printf(" zone: %s\n", vol.availability_zone); printf(" status: %s\n", vol.status); printf(" netnam: %s\n", vol.network_name); } printf("\n"); } close(client_id); return 0; }
bool Assembly::on_frame_begin( const Project& project, const BaseGroup* parent, OnFrameBeginRecorder& recorder, IAbortSwitch* abort_switch) { if (!Entity::on_frame_begin(project, parent, recorder, abort_switch)) return false; if (!BaseGroup::on_frame_begin(project, parent, recorder, abort_switch)) return false; bool success = true; success = success && invoke_on_frame_begin(bsdfs(), project, this, recorder, abort_switch); success = success && invoke_on_frame_begin(bssrdfs(), project, this, recorder, abort_switch); success = success && invoke_on_frame_begin(edfs(), project, this, recorder, abort_switch); success = success && invoke_on_frame_begin(surface_shaders(), project, this, recorder, abort_switch); success = success && invoke_on_frame_begin(materials(), project, this, recorder, abort_switch); success = success && invoke_on_frame_begin(lights(), project, this, recorder, abort_switch); success = success && invoke_on_frame_begin(objects(), project, this, recorder, abort_switch); success = success && invoke_on_frame_begin(object_instances(), project, this, recorder, abort_switch); success = success && invoke_on_frame_begin(volumes(), project, this, recorder, abort_switch); if (!success) return false; // Collect procedural object instances. assert(!m_has_render_data); for (size_t i = 0, e = object_instances().size(); i < e; ++i) { const ObjectInstance* object_instance = object_instances().get_by_index(i); const Object& object = object_instance->get_object(); if (dynamic_cast<const ProceduralObject*>(&object) != nullptr) m_render_data.m_procedural_object_instances.push_back(make_pair(object_instance, i)); } m_has_render_data = true; return true; }
double StructuredMesh::getCellVolume(int cellIdx) const { int i[3]; unwrapIndex(cellIdx, i, Location::CENTER); return volumes(i[0], i[1], i[2]); }
int main() { // CGAL::Timer time; // // time.start(); cout << "Creating point cloud" << endl; simu.read(); create(); if(simu.create_points()) { // set_alpha_circle( Tp , 2); // set_alpha_under_cos( Tp ) ; cout << "Creating velocity field " << endl; set_fields_TG( Tm ) ; //set_fields_cos( Tm ) ; cout << "Numbering particles " << endl; number(Tp); number(Tm); } int Nb=sqrt( simu.no_of_particles() + 1e-12); // Set up fft, and calculate initial velocities: move_info( Tm ); move_info( Tp ); CH_FFT fft( LL , Nb ); load_fields_on_fft( Tm , fft ); FT dt=simu.dt(); FT mu=simu.mu(); fft.all_fields_NS( dt * mu ); fft.draw( "phi", 0, fft.field_f() ); fft.draw( "press", 0, fft.field_p() ); fft.draw( "vel_x", 0, fft.field_vel_x() ); fft.draw( "vel_y", 0, fft.field_vel_y() ); load_fields_from_fft( fft, Tm ); // every step areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); // just once! linear algebra(Tm); areas(Tm); quad_coeffs(Tm , simu.FEMm() ); volumes(Tm, simu.FEMm() ); cout << "Setting up diff ops " << endl; // TODO: Are these two needed at all? // if(simu.create_points()) { // nabla(Tm); // TODO, they is, too clear why Delta(Tm); // } const std::string mesh_file("mesh.dat"); const std::string particle_file("particles.dat"); // // step 0 draw.- // draw(Tm, mesh_file , true); // draw(Tp, particle_file , true); cout << "Assigning velocities to particles " << endl; #if defined FULL_FULL { Delta(Tp); linear algebra_p(Tp); from_mesh_full_v( Tm , Tp , algebra_p , kind::U); } #elif defined FULL_LUMPED from_mesh_lumped_v( Tm , Tp , kind::U); #elif defined FLIP from_mesh_v(Tm , Tp , kind::U); #else from_mesh_v(Tm , Tp , kind::U); #endif // #if defined FULL_FULL // { // Delta(Tp); // linear algebra_p(Tp); // from_mesh_full( Tm , Tp , algebra_p,kind::ALPHA); // } // #elif defined FULL_LUMPED // from_mesh_lumped( Tm , Tp , kind::ALPHA); // #elif defined FLIP // from_mesh(Tm , Tp , kind::ALPHA); // #else // from_mesh(Tm , Tp , kind::ALPHA); // #endif cout << "Moving info" << endl; move_info( Tm ); move_info( Tp ); draw(Tm, mesh_file , true); draw(Tp, particle_file , true); // return 1; simu.advance_time(); simu.next_step(); // bool first_iter=true; CGAL::Timer time; time.start(); std::ofstream log_file; log_file.open("main.log"); bool is_overdamped = ( simu.mu() > 1 ) ; // high or low Re for(; simu.current_step() <= simu.Nsteps(); simu.next_step()) { cout << "Step " << simu.current_step() << " . Time " << simu.time() << " ; t step " << simu.dt() << endl; FT dt=simu.dt(); FT dt2 = dt / 2.0 ; int iter=0; FT displ=1e10; FT min_displ=1e10; int min_iter=0; const int max_iter=8; //10; const FT max_displ= 1e-8; // < 0 : disable // leapfrog, special first step.- // if(simu.current_step() == 1) dt2 *= 0.5; // dt2 *= 0.5; move_info(Tm); move_info(Tp); // iter loop for( ; ; iter++) { // comment for no move.- cout << "Moving half step " << endl; FT d0; displ = move( Tp , dt2 , d0 ); areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); cout << "Iter " << iter << " , moved avg " << d0 << " to half point, " << displ << " from previous" << endl; if( displ < min_displ) { min_displ=displ; min_iter=iter; } if( (displ < max_displ) && (iter !=0) ) { cout << "Convergence in " << iter << " iterations " << endl; break; } if( iter == max_iter-1 ) { cout << "Exceeded " << iter-1 << " iterations " << endl; break; } cout << "Proj advected U0 velocities onto mesh " << endl; #if defined FULL onto_mesh_full_v(Tp,Tm,algebra,kind::UOLD); #elif defined FLIP flip_volumes (Tp , Tm , simu.FEMm() ); onto_mesh_flip_v(Tp,Tm,simu.FEMm(),kind::UOLD); #else onto_mesh_delta_v(Tp,Tm,kind::UOLD); #endif load_fields_on_fft( Tm , fft ); FT b = mu * dt2; fft.all_fields_NS( b ); // fft.evolve( b ); load_fields_from_fft( fft , Tm ); // Search "FLIPincr" in CH_FFT.cpp to change accordingly! // EITHER: // FLIP idea: project only increments cout << "Proj Delta U from mesh onto particles" << endl; #if defined FULL_FULL { Delta(Tp); linear algebra_p(Tp); from_mesh_full_v(Tm, Tp, algebra_p , kind::DELTAU); } #elif defined FULL_LUMPED from_mesh_lumped_v(Tm, Tp, kind::DELTAU); #elif defined FLIP from_mesh_v(Tm, Tp, kind::DELTAU); #else from_mesh_v(Tm, Tp, kind::DELTAU); #endif incr_v( Tp , kind::UOLD , kind::DELTAU , kind::U ); // OR: // project the whole velocity // cout << "Proj U from mesh onto particles" << endl; // //#if defined FULL_FULL // { // Delta(Tp); // linear algebra_p(Tp); // from_mesh_full_v(Tm, Tp, algebra_p , kind::U); // } //#elif defined FULL_LUMPED // from_mesh_lumped_v(Tm, Tp, kind::U); //#elif defined FLIP // from_mesh_v(Tm, Tp, kind::U); //#else // from_mesh_v(Tm, Tp, kind::U); //#endif // // substract spurious overall movement.- // zero_mean_v( Tm , kind::FORCE); } // iter loop cout << "Moving whole step: relative "; FT d0; displ=move( Tp , dt , d0 ); cout << displ << " from half point, " << d0 << " from previous point" << endl; // comment for no move.- update_half_velocity( Tp , is_overdamped ); update_half_alpha( Tp ); areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); // this, for the looks basically .- cout << "Proj U_t+1 , alpha_t+1 onto mesh " << endl; #if defined FULL onto_mesh_full_v(Tp,Tm,algebra,kind::U); onto_mesh_full (Tp,Tm,algebra,kind::ALPHA); #elif defined FLIP flip_volumes(Tp , Tm , simu.FEMm() ); onto_mesh_flip_v(Tp,Tm,simu.FEMm(),kind::U); onto_mesh_flip (Tp,Tm,simu.FEMm(),kind::ALPHA); #else onto_mesh_delta_v(Tp,Tm,kind::U); onto_mesh_delta (Tp,Tm,kind::ALPHA); #endif move_info( Tm ); move_info( Tp ); if(simu.current_step()%simu.every()==0) { draw(Tm, mesh_file , true); draw(Tp, particle_file , true); fft.histogram( "phi", simu.current_step() , fft.field_fq() ); } log_file << simu.current_step() << " " << simu.time() << " " ; // integrals( Tp , log_file); log_file << " "; // fidelity( Tp , log_file ); log_file << endl; simu.advance_time(); } // time loop time.stop(); log_file.close(); cout << "Total runtime: " << time.time() << endl; return 0; }
void FeSoundMenu::get_options( FeConfigContext &ctx ) { ctx.set_style( FeConfigContext::EditList, "Configure / Sound" ); std::vector<std::string> volumes(11); for ( int i=0; i<11; i++ ) volumes[i] = as_str( 100 - ( i * 10 ) ); std::string setstr, help; // // Sound, Ambient and Movie Volumes // for ( int i=0; i<3; i++ ) { int v = ctx.fe_settings.get_set_volume( (FeSoundInfo::SoundType)i ); ctx.add_optl( Opt::LIST, FeSoundInfo::settingDispStrings[i], as_str(v), "_help_volume" ); ctx.back_opt().append_vlist( volumes ); } // // Get the list of available sound files // Note the sound_list vector gets copied to each option! // std::vector<std::string> sound_list; ctx.fe_settings.get_sounds_list( sound_list ); #ifndef NO_MOVIE for ( std::vector<std::string>::iterator itr=sound_list.begin(); itr != sound_list.end(); ) { if ( !FeMedia::is_supported_media_file( *itr ) ) itr = sound_list.erase( itr ); else itr++; } #endif sound_list.push_back( "" ); // // Sounds that can be mapped to input commands. // for ( int i=0; i < FeInputMap::LAST_EVENT; i++ ) { // there is a NULL in the middle of the commandStrings list if ( FeInputMap::commandDispStrings[i] != NULL ) { std::string v; ctx.fe_settings.get_sound_file( (FeInputMap::Command)i, v, false ); ctx.add_optl( Opt::LIST, FeInputMap::commandDispStrings[i], v, "_help_sound_sel" ); ctx.back_opt().append_vlist( sound_list ); ctx.back_opt().opaque = i; } } FeBaseConfigMenu::get_options( ctx ); }
int main() { // CGAL::Timer time; // // time.start(); cout << "Creating point cloud" << endl; simu.read(); create(); if(simu.create_points()) { // set_alpha_circle( Tp , 2); // set_alpha_under_cos( Tp ) ; cout << "Creating alpha field " << endl; set_alpha_random( Tm ) ; //set_alpha_cos( Tm ); cout << "Numbering particles " << endl; number(Tp); number(Tm); } int Nb=sqrt( simu.no_of_particles() + 1e-12); // Set up fft, and calculate initial velocities: move_info( Tm ); CH_FFT fft( LL , Nb ); load_alpha_on_fft( Tm , fft ); fft.all_fields(); fft.draw( "phi", 0, fft.field_f() ); fft.draw( "mu", 0, fft.field_mu() ); fft.draw( "grad_mu_x", 0, fft.field_grad_mu_x() ); fft.draw( "grad_mu_y", 0, fft.field_grad_mu_y() ); fft.draw( "force_x", 0, fft.field_force_x() ); fft.draw( "force_y", 0, fft.field_force_y() ); fft.draw( "vel_x", 0, fft.field_vel_x() ); fft.draw( "vel_y", 0, fft.field_vel_y() ); load_fields_from_fft( fft, Tm ); // every step areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); // just once! linear algebra(Tm); areas(Tm); quad_coeffs(Tm , simu.FEMm() ); volumes(Tm, simu.FEMm() ); cout << "Setting up diff ops " << endl; // TODO: Are these two needed at all? // if(simu.create_points()) { // nabla(Tm); // TODO, they is, too clear why Delta(Tm); // } const std::string mesh_file("mesh.dat"); const std::string particle_file("particles.dat"); // // step 0 draw.- // draw(Tm, mesh_file , true); // draw(Tp, particle_file , true); cout << "Assigning alpha to particles " << endl; #if defined FULL_FULL { Delta(Tp); linear algebra_p(Tp); from_mesh_full( Tm , Tp , algebra_p,kind::ALPHA); } #elif defined FULL_LUMPED from_mesh_lumped( Tm , Tp , kind::ALPHA); #elif defined FLIP from_mesh(Tm , Tp , kind::ALPHA); #else from_mesh(Tm , Tp , kind::ALPHA); #endif // #if defined FULL_FULL // { // Delta(Tp); // linear algebra_p(Tp); // from_mesh_full( Tm , Tp , algebra_p,kind::ALPHA); // } // #elif defined FULL_LUMPED // from_mesh_lumped( Tm , Tp , kind::ALPHA); // #elif defined FLIP // from_mesh(Tm , Tp , kind::ALPHA); // #else // from_mesh(Tm , Tp , kind::ALPHA); // #endif cout << "Moving info" << endl; move_info( Tm ); move_info( Tp ); draw(Tm, mesh_file , true); draw(Tp, particle_file , true); // return 1; simu.advance_time(); simu.next_step(); // bool first_iter=true; CGAL::Timer time; time.start(); std::ofstream log_file; log_file.open("main.log"); bool is_overdamped = ( simu.mu() > 1 ) ; // high or low Re for(; simu.current_step() <= simu.Nsteps(); simu.next_step()) { cout << "Step " << simu.current_step() << " . Time " << simu.time() << " ; t step " << simu.dt() << endl; FT dt=simu.dt(); FT dt2 = dt / 2.0 ; int iter=0; FT displ=1e10; FT min_displ=1e10; int min_iter=0; const int max_iter=5; //10; const FT max_displ= 1e-8; // < 0 : disable // leapfrog, special first step.- // if(simu.current_step() == 1) dt2 *= 0.5; // dt2 *= 0.5; move_info(Tm); move_info(Tp); // iter loop for( ; iter<max_iter ; iter++) { // comment for no move.- displ = move( Tp , dt2 ); cout << "Iter " << iter << " , moved avg " << displ << " to half point" << endl; if( displ < min_displ) { min_displ=displ; min_iter=iter; } if( (displ < max_displ) && (iter !=0) ) break; areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); cout << "Proj U0, alpha0 onto mesh " << endl; #if defined FULL onto_mesh_full (Tp,Tm,algebra,kind::ALPHA); #elif defined FLIP flip_volumes(Tp , Tm , simu.FEMm() ); onto_mesh_flip (Tp,Tm,simu.FEMm(),kind::ALPHA); #else onto_mesh_delta (Tp,Tm,kind::ALPHA); #endif load_alpha_on_fft( Tm , fft ); fft.all_fields(); FT b = Db*dt2; fft.evolve( b ); load_fields_from_fft( fft, Tm ); cout << "Proj U, alpha from mesh " << endl; #if defined FULL_FULL { Delta(Tp); linear algebra_p(Tp); from_mesh_full_v(Tm, Tp, algebra_p , kind::U); from_mesh_full( Tm , Tp , algebra_p,kind::ALPHA); } #elif defined FULL_LUMPED from_mesh_lumped( Tm , Tp , kind::ALPHA); from_mesh_lumped_v(Tm, Tp, kind::U); #elif defined FLIP from_mesh(Tm , Tp , kind::ALPHA); from_mesh_v(Tm, Tp, kind::U); #else from_mesh(Tm , Tp , kind::ALPHA); from_mesh_v(Tm, Tp, kind::U); #endif // // substract spurious overall movement.- // zero_mean_v( Tm , kind::FORCE); } // iter loop // comment for no move.- displ=move( Tp , dt ); update_half_velocity( Tp , false ); // comment for no move.- // update_half_velocity( Tp , is_overdamped ); update_half_alpha( Tp ); areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); // this, for the looks basically .- cout << "Proj U_t+1 , alpha_t+1 onto mesh " << endl; #if defined FULL onto_mesh_full_v(Tp,Tm,algebra,kind::U); onto_mesh_full (Tp,Tm,algebra,kind::ALPHA); #elif defined FLIP flip_volumes(Tp , Tm , simu.FEMm() ); onto_mesh_flip_v(Tp,Tm,simu.FEMm(),kind::U); onto_mesh_flip (Tp,Tm,simu.FEMm(),kind::ALPHA); #else onto_mesh_delta_v(Tp,Tm,kind::U); onto_mesh_delta (Tp,Tm,kind::ALPHA); #endif if(simu.current_step()%simu.every()==0) { draw(Tm, mesh_file , true); draw(Tp, particle_file , true); fft.histogram( "phi", simu.current_step() , fft.field_fq() ); } log_file << simu.current_step() << " " << simu.time() << " " ; // integrals( Tp , log_file); log_file << " "; // fidelity( Tp , log_file ); log_file << endl; simu.advance_time(); } // time loop time.stop(); log_file.close(); cout << "Total runtime: " << time.time() << endl; return 0; }
int main() { // CGAL::Timer time; // // time.start(); cout << "Creating point cloud" << endl; simu.read(); create(); if(simu.create_points()) { // set_alpha_circle( Tp , 2); // set_alpha_under_cos( Tp ) ; cout << "Creating alpha field " << endl; set_alpha_random( Tp ) ; cout << "Numbering particles " << endl; number(Tp); } // areas(Tp); // quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); // volumes(Tp, simu.FEMp() ); // Delta(Tp); // linear algebra(Tp); // if(simu.create_points()) { // nabla(Tp); // Delta(Tp); // } move_info( Tp ); // /// Prev test begin //cout << "Calculating Lapl U" << endl; //algebra.laplacian_v(kind::UOLD,kind::LAPLU); //FT dt=simu.dt(); //cout << "Calculating Ustar implicitely" << endl; //algebra.ustar_inv(kind::USTAR, dt , kind::UOLD, false); //cout << "Solving PPE" << endl; //algebra.PPE( kind::USTAR, dt, kind:: P ); //cout << "Calculating grad p" << endl; //algebra.gradient(kind::P, kind::GRADP); //algebra.mass_s(kind::DIVU); //draw(); // return 1; /// Prev test end #ifdef WRITE algebra.save_matrices(); #endif // areas(Tp); // quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); // nabla(Tp); // Delta(Tp); // linear algebra(Tp); // cout << "Calculating grad alpha" << endl; // algebra.gradient(kind::ALPHA, kind::GRADALPHA); const std::string particle_file("particles.dat"); draw(Tp, particle_file , true); simu.advance_time(); simu.next_step(); // bool first_iter=true; CGAL::Timer time; time.start(); std::ofstream log_file; log_file.open("main.log"); bool is_overdamped = ( simu.mu() > 1 ) ; // high or low Re for(; simu.current_step() <= simu.Nsteps(); simu.next_step()) { cout << "Step " << simu.current_step() << " . Time " << simu.time() << " ; t step " << simu.dt() << endl; FT dt=simu.dt(); FT dt2 = dt / 2.0 ; int iter=0; FT displ=1e10; FT min_displ=1e10; int min_iter=0; const int max_iter=1; //10; const FT max_displ= 1e-8; // < 0 : disable // leapfrog, special first step.- // if(simu.current_step() == 1) dt2 *= 0.5; // dt2 *= 0.5; move_info(Tp); // iter loop for( ; iter<max_iter ; iter++) { cout << "Move iteration " << iter << " of " << max_iter << " " << endl; // comment for no move.- displ=move( Tp , dt2 ); cout << "Iter " << iter << " , moved avg " << displ << " to half point" << endl; if( (displ < max_displ) && (iter !=0) ) break; areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); nabla(Tp); Delta(Tp); linear algebra(Tp); if( displ < min_displ) { min_displ=displ; min_iter=iter; } // set_forces_Kolmo(Tp); // Reynolds number discrimination #ifdef EXPLICIT cout << "Calculating Ustar explicitely" << endl; algebra.laplacian_v(kind::UOLD,kind::LAPLU); u_star(Tp, dt2 , false ); #else // cout << "Calculating chem pot" << endl; // algebra.chempot(kind::ALPHA, kind::CHEMPOT); cout << "Calculating alpha implicitely" << endl; // partly explicit ( unstable ? ): cout << "Calculating chem pot explicitely" << endl; if (iter==0) algebra.chempot( kind::ALPHA0, kind::CHEMPOT ); else algebra.chempot( kind::ALPHA , kind::CHEMPOT ); // inner iter loop for( int alpha_it=0 ; alpha_it < 1 ; alpha_it++) { // max_iter ; alpha_it++) { cout << "Alpha loop iter " << alpha_it << endl; algebra.chempot( kind::ALPHA , kind::CHEMPOT ); algebra.alpha_inv_cp(kind::ALPHA, dt2 , kind::ALPHA0 ); } // algebra.gradient(kind::ALPHA, kind::ALPHA0); // ??? // // iterative, fully implicit (does not converge): // int alpha_it=0; // // inner iter loop // for( ; alpha_it < 10 ; alpha_it++) { // max_iter ; alpha_it++) { // cout << "Alpha loop iter " << alpha_it << endl; // algebra.alpha_inv_cp2(kind::ALPHA, dt2 , kind::ALPHA0 ); // cout << "Calculating chem pot implicitely" << endl; // algebra.chempot_inv(kind::ALPHA, dt2 , kind::ALPHA0 ); // } // // draw(Tp, particle_file , true); cout << "Settinf Ustar = force" << endl; // algebra.ustar_is_force(kind::USTAR); algebra.chem_pot_force(); // substract spurious overall movement.- zero_mean_v( Tp , kind::FORCE); #endif cout << "Solving PPE" << endl; // comment for no move.- algebra.PPE( kind::FORCE , 1 , kind:: P ); // Dt set to 1 // cout << "Calculating grad p" << endl; // // comment for no move.- // algebra.gradient(kind::P, kind::GRADP); algebra.u_inv_od(kind::U); cout << "Evolving U " << endl; // comment for no move.- u_new( Tp , dt2 ); cout << "U evolved " << endl; } // iter loop // comment for no move.- displ=move( Tp , dt ); // update_half_velocity( Tp , false ); // comment for no move.- update_half_velocity( Tp , is_overdamped ); update_half_alpha( Tp ); areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); if(simu.current_step()%simu.every()==0) draw(Tp, particle_file , true); log_file << simu.current_step() << " " << simu.time() << " " ; integrals( Tp , log_file); log_file << " "; fidelity( Tp , log_file ); log_file << endl; simu.advance_time(); } // time loop time.stop(); log_file.close(); cout << "Total runtime: " << time.time() << endl; return 0; }
int main() { // CGAL::Timer time; // // time.start(); cout << "Creating point cloud" << endl; simu.read(); create(); if(simu.create_points()) { // set_alpha_circle( Tp , 2); // set_alpha_under_cos( Tp ) ; cout << "Creating alpha field " << endl; // set_alpha_random( Tp ) ; // better take it from mesh set_alpha_random( Tm ) ; cout << "Numbering particles " << endl; number(Tp); number(Tm); } // every step areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); // just once! linear algebra(Tm); areas(Tm); quad_coeffs(Tm , simu.FEMm() ); volumes(Tm, simu.FEMm() ); cout << "Setting up diff ops " << endl; if(simu.create_points()) { nabla(Tm); Delta(Tm); } const std::string mesh_file("mesh.dat"); const std::string particle_file("particles.dat"); // step 0 draw.- // draw(Tm, mesh_file , true); // draw(Tp, particle_file , true); cout << "Assigning alpha to particles " << endl; #if defined FULL_FULL { Delta(Tp); linear algebra_p(Tp); from_mesh_full( Tm , Tp , algebra_p,kind::ALPHA); } #elif defined FULL_LUMPED from_mesh_lumped( Tm , Tp , kind::ALPHA); #elif defined FLIP from_mesh(Tm , Tp , kind::ALPHA); #else from_mesh(Tm , Tp , kind::ALPHA); #endif cout << "Moving info" << endl; move_info( Tm ); move_info( Tp ); // algebra.chempot( kind::ALPHA , kind::CHEMPOT ); // algebra.alpha_inv_cp(kind::ALPHA, simu.dt()/2.0 , kind::ALPHA0 ); // draw(Tm, mesh_file , true); // draw(Tp, particle_file , true); // /// Prev test begin //cout << "Calculating Lapl U" << endl; //algebra.laplacian_v(kind::UOLD,kind::LAPLU); //FT dt=simu.dt(); //cout << "Calculating Ustar implicitely" << endl; //algebra.ustar_inv(kind::USTAR, dt , kind::UOLD, false); //cout << "Solving PPE" << endl; //algebra.PPE( kind::USTAR, dt, kind:: P ); //cout << "Calculating grad p" << endl; //algebra.gradient(kind::P, kind::GRADP); //algebra.mass_s(kind::DIVU); //draw(); // return 1; /// Prev test end #ifdef WRITE algebra.save_matrices(); #endif // areas(Tp); // quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); // nabla(Tp); // Delta(Tp); // linear algebra(Tp); // cout << "Calculating grad alpha" << endl; // algebra.gradient(kind::ALPHA, kind::GRADALPHA); draw(Tm, mesh_file , true); draw(Tp, particle_file , true); simu.advance_time(); simu.next_step(); // bool first_iter=true; CGAL::Timer time; time.start(); std::ofstream log_file; log_file.open("main.log"); bool is_overdamped = ( simu.mu() > 1 ) ; // high or low Re for(; simu.current_step() <= simu.Nsteps(); simu.next_step()) { cout << "Step " << simu.current_step() << " . Time " << simu.time() << " ; t step " << simu.dt() << endl; FT dt=simu.dt(); FT dt2 = dt / 2.0 ; int iter=0; FT displ=1e10; FT min_displ=1e10; int min_iter=0; const int max_iter = 10; //10; const FT max_displ = 1e-8; // < 0 : disable // leapfrog, special first step.- // if(simu.current_step() == 1) dt2 *= 0.5; // dt2 *= 0.5; move_info(Tm); move_info(Tp); // cout << "Proj alpha onto mesh " << endl; // //onto_mesh_lumped(); // #if defined FULL // onto_mesh_full( Tp , Tm , algebra, kind::ALPHA); // #elif defined FLIP // flip_volumes(Tp , Tm , simu.FEMm() ); // onto_mesh_flip(Tp,Tm,simu.FEMm(),kind::ALPHA); // #else // onto_mesh_delta(Tp,Tm,kind::ALPHA); // #endif // iter loop for( ; iter<max_iter ; iter++) { // cout << "Projecting U from mesh " << endl; cout << "Projecting U , alpha0 from mesh " << endl; #if defined FULL_FULL { Delta(Tp); linear algebra_p(Tp); from_mesh_full_v(Tm, Tp, algebra_p , kind::U); from_mesh_full (Tm, Tp, algebra_p , kind::ALPHA0); from_mesh_full (Tm, Tp, algebra_p , kind::ALPHA); } #elif defined FULL_LUMPED from_mesh_lumped_v(Tm, Tp, kind::U); from_mesh_lumped (Tm, Tp, kind::ALPHA0); from_mesh_lumped (Tm, Tp, kind::ALPHA); #elif defined FLIP from_mesh_v(Tm, Tp, kind::U); from_mesh (Tm, Tp, kind::ALPHA0); from_mesh (Tm, Tp, kind::ALPHA); #else from_mesh_v(Tm, Tp, kind::U); from_mesh (Tm, Tp, kind::ALPHA0); from_mesh (Tm, Tp, kind::ALPHA); #endif // comment for no move.- displ=move( Tp , dt2 ); cout << "Iter " << iter << " , moved avg " << displ << " to half point" << endl; if( displ < min_displ) { min_displ=displ; min_iter=iter; } if( (displ < max_displ) && (iter !=0) ) break; areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); cout << "Proj U0, alpha0 onto mesh " << endl; #if defined FULL onto_mesh_full_v(Tp,Tm,algebra,kind::UOLD); onto_mesh_full (Tp,Tm,algebra,kind::ALPHA0); onto_mesh_full (Tp,Tm,algebra,kind::ALPHA); #elif defined FLIP flip_volumes(Tp , Tm , simu.FEMm() ); onto_mesh_flip_v(Tp,Tm,simu.FEMm(),kind::UOLD); onto_mesh_flip (Tp,Tm,simu.FEMm(),kind::ALPHA0); onto_mesh_flip (Tp,Tm,simu.FEMm(),kind::ALPHA); #else onto_mesh_delta_v(Tp,Tm,kind::UOLD); onto_mesh_delta (Tp,Tm,kind::ALPHA0); onto_mesh_delta (Tp,Tm,kind::ALPHA); #endif // Reynolds number discrimination // #ifdef EXPLICIT // cout << "Calculating Ustar explicitely" << endl; // algebra.laplacian_v(kind::UOLD,kind::LAPLU); // u_star(Tp, dt2 , false ); // #else // cout << "Calculating chem pot" << endl; // algebra.chempot(kind::ALPHA, kind::CHEMPOT); // cout << "Calculating alpha implicitely" << endl; // // partly explicit ( unstable ? ): cout << "Calculating chem pot explicitely" << endl; // inner iter loop for( int alpha_it=0 ; alpha_it < 1 ; alpha_it++) { // max_iter ; alpha_it++) { cout << "Alpha loop iter " << alpha_it << endl; if (iter==0) algebra.chempot( kind::ALPHA0, kind::CHEMPOT ); else algebra.chempot( kind::ALPHA , kind::CHEMPOT ); // algebra.chempot( kind::ALPHA , kind::CHEMPOT ); algebra.alpha_inv_cp(kind::ALPHA, dt2 , kind::ALPHA0 ); } // algebra.gradient(kind::ALPHA, kind::ALPHA0); // ??? // // iterative, fully implicit (does not converge): // int alpha_it=0; // // inner iter loop // for( ; alpha_it < 10 ; alpha_it++) { // max_iter ; alpha_it++) { // cout << "Alpha loop iter " << alpha_it << endl; // algebra.alpha_inv_cp2(kind::ALPHA, dt2 , kind::ALPHA0 ); // cout << "Calculating chem pot implicitely" << endl; // algebra.chempot_inv(kind::ALPHA, dt2 , kind::ALPHA0 ); // } // // draw(Tp, particle_file , true); cout << "Calculating Ustar implicitely" << endl; // algebra.ustar_inv(kind::USTAR, dt2 , kind::UOLD, false , false); // comment for no move.- algebra.ustar_inv_cp(kind::USTAR, dt2 , kind::UOLD, is_overdamped , false); // substract spurious overall movement.- zero_mean_v( Tp , kind::USTAR); //#endif cout << "Solving PPE" << endl; // comment for no move.- algebra.PPE( kind::USTAR, dt2 , kind:: P ); cout << "Calculating grad p" << endl; // comment for no move.- algebra.gradient(kind::P, kind::GRADP); cout << "Evolving U " << endl; // comment for no move.- u_new( Tm , dt2 ); cout << "U evolved " << endl; } // iter loop #if defined FULL_FULL { Delta(Tp); linear algebra_p(Tp); from_mesh_full_v(Tm, Tp, algebra_p , kind::U); from_mesh_full (Tm, Tp, algebra_p , kind::ALPHA); } #elif defined FULL_LUMPED from_mesh_lumped_v(Tm, Tp, kind::U); from_mesh_lumped (Tm, Tp, kind::ALPHA); #elif defined FLIP from_mesh_v(Tm, Tp, kind::U); from_mesh (Tm, Tp, kind::ALPHA); #else from_mesh_v(Tm, Tp, kind::U); from_mesh (Tm, Tp, kind::ALPHA); #endif // comment for no move.- displ=move( Tp , dt ); // update_half_velocity( Tp , false ); // comment for no move.- update_half_velocity( Tp , is_overdamped ); update_half_alpha( Tp ); // ?????? areas(Tp); quad_coeffs(Tp , simu.FEMp() ); volumes(Tp, simu.FEMp() ); cout << "Proj U_t+1 , alpha_t+1 onto mesh " << endl; #if defined FULL onto_mesh_full_v(Tp,Tm,algebra,kind::U); onto_mesh_full (Tp,Tm,algebra,kind::ALPHA0); onto_mesh_full (Tp,Tm,algebra,kind::ALPHA); #elif defined FLIP flip_volumes(Tp , Tm , simu.FEMm() ); onto_mesh_flip_v(Tp,Tm,simu.FEMm(),kind::U); onto_mesh_flip (Tp,Tm,simu.FEMm(),kind::ALPHA0); onto_mesh_flip (Tp,Tm,simu.FEMm(),kind::ALPHA); #else onto_mesh_delta_v(Tp,Tm,kind::U); onto_mesh_delta (Tp,Tm,kind::ALPHA); onto_mesh_delta (Tp,Tm,kind::ALPHA); #endif if(simu.current_step()%simu.every()==0) { draw(Tm, mesh_file , true); draw(Tp, particle_file , true); } log_file << simu.current_step() << " " << simu.time() << " " ; // integrals( Tp , log_file); log_file << " "; // fidelity( Tp , log_file ); log_file << endl; simu.advance_time(); } // time loop time.stop(); log_file.close(); cout << "Total runtime: " << time.time() << endl; return 0; }