deal.II version GIT relicensing-2659-g040196caa3 2025-02-18 14:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Distributed_Moving_Laser_Heating.h
Go to the documentation of this file.
1
265 *  
266 *  
267 * @endcode
268 *
269 *
270 * <a name="Distributed_Moving_Laser_Heating.cc-Includefiles"></a>
271 * <h3>Include files</h3>
272 *
273
274 *
276 *
277 * @code
278 *   #include <deal.II/dofs/dof_handler.h>
279 *   #include <deal.II/dofs/dof_renumbering.h>
280 *   #include <deal.II/grid/grid_generator.h>
281 *   #include <deal.II/grid/tria_accessor.h>
282 *   #include <deal.II/grid/tria_iterator.h>
283 *   #include <deal.II/dofs/dof_accessor.h>
284 *   #include <deal.II/fe/fe_q.h>
285 *   #include <deal.II/dofs/dof_tools.h>
286 *   #include <deal.II/fe/fe_values.h>
287 *   #include <deal.II/base/quadrature_lib.h>
288 *   #include <deal.II/base/function.h>
289 *   #include <deal.II/numerics/vector_tools.h>
290 *   #include <deal.II/numerics/matrix_tools.h>
291 *   #include <deal.II/lac/vector.h>
292 *   #include <deal.II/lac/full_matrix.h>
294 *  
295 *   #include <deal.II/grid/grid_in.h>
296 *   #include <deal.II/grid/grid_tools.h>
297 *   #include <deal.II/lac/trilinos_vector.h>
301 *  
304 *  
305 *   #include <deal.II/base/conditional_ostream.h>
306 *   #include <deal.II/base/utilities.h>
307 *   #include <deal.II/base/index_set.h>
308 *   #include <deal.II/distributed/tria.h>
309 *  
310 *   #include <deal.II/numerics/data_out.h>
313 *  
314 *  
315 *   #include <deal.II/base/logstream.h>
316 *   #include <deal.II/lac/affine_constraints.h>
317 *   #include <deal.II/base/timer.h>
318 *  
319 * @endcode
320 *
321 * grid refine
322 *
323 * @code
324 *   #include <deal.II/numerics/error_estimator.h>
325 *   #include <deal.II/distributed/grid_refinement.h>
326 *   #include <deal.II/distributed/solution_transfer.h>
327 *  
328 * @endcode
329 *
330 * remember to use the namespace dealii before
331 * defining a class that is inheritaged from Function<dim>
332 *
333 * @code
334 *   using namespace dealii;
335 *  
336 * @endcode
337 *
339 * as well as the right hand side function from a file holding all the things.
340 * To do so, in this work, the globalPara.h file defines physical constants,
343 * defines the heat source, which in this work is a moving Gaussian beam.
344 *
345
346 *
347 *
348 * @code
351 *   #include "./globalPara.h"
352 *   #include "./boundaryInit.h"
353 *   #include "./rightHandSide.h"
354 *   #endif
355 *  
356 * @endcode
357 *
359 *
360 * @code
361 *   template <int dim>
362 *   class LaserHeating
363 *   {
364 *   public:
365 *   LaserHeating ();
366 *   ~LaserHeating ();
367 *   void run ();
368 *  
369 *   private:
370 *   void make_grid ();
371 *   void setup_system();
372 *  
374 *   void dynamic_assemble_rhs_T (double time, double time_step);
375 *  
376 *   void solve_T ();
377 *  
378 *   void refine_mesh();
379 *   void output_results (int output_num) const;
380 *  
381 *   MPI_Comm mpi_communicator;
382 *  
384 *   FE_Q<dim> fe;
385 *   DoFHandler<dim> dof_handler;
386 *  
388 *  
389 *  
390 * @endcode
391 *
392 * system_matrix
393 *
394 * @code
396 *  
397 * @endcode
398 *
399 * for storing left matrix
400 *
401 * @code
403 *  
404 * @endcode
405 *
406 * for storing right matrix
407 *
408 * @code
410 *  
411 * @endcode
412 *
414 *
415 * @code
417 *  
418 * @endcode
419 *
420 * Solutions
421 * Old Solutions with ghost cells, for output
422 *
423 * @code
425 *  
426 * @endcode
427 *
429 *
430 * @code
432 *  
433 * @endcode
434 *
436 *
437 * @code
439 *  
440 * @endcode
441 *
443 *
444 * @code
446 *  
447 *  
448 *   IndexSet locally_owned_dofs;
450 *  
453 *  
454 *   double theta;
455 *  
456 *  
457 *  
458 *   };
459 *  
460 * @endcode
461 *
463 *
464 * @code
465 *   template <int dim>
467 *   :
468 *   mpi_communicator (MPI_COMM_WORLD),
469 *   triangulation (mpi_communicator),
470 *   fe (1),
471 *   dof_handler (triangulation),
472 *   pcout (std::cout,Utilities::MPI::this_mpi_process(mpi_communicator) == 0),
474 *   theta(0.5)
475 *   {}
476 *  
477 * @endcode
478 *
480 *
481 * @code
482 *   template <int dim>
484 *   {
485 *   dof_handler.clear();
486 *   }
487 *  
488 * @endcode
489 *
490 *
491 * <a name="Distributed_Moving_Laser_Heating.cc-LaserHeatingmake_grid"></a>
493 * make grid by importing msh file, and rescale
494 *
495 * @code
496 *   template <int dim>
498 *   {
499 *   TimerOutput::Scope t(computing_timer,"make_grid()");
500 *  
502 *   grid_in.attach_triangulation (triangulation);
503 *   std::ifstream input_file ("geometry.msh");
504 *   grid_in.read_msh (input_file);
506 *  
507 *   pcout << " Number of active cells: "
508 *   << triangulation.n_global_active_cells()
509 *   << std::endl
510 *   << " Total number of cells: "
511 *   << triangulation.n_cells()
512 *   << std::endl;
513 *   }
514 *  
515 * @endcode
516 *
517 *
518 * <a name="Distributed_Moving_Laser_Heating.cc-LaserHeatingsetup_system"></a>
521 *
522 * @code
523 *   template <int dim>
525 *   {
526 *  
527 *   TimerOutput::Scope t(computing_timer,"setup_system()");
528 *  
529 *   dof_handler.distribute_dofs (fe);
530 *  
531 *   pcout << " Number of degrees of freedom: "
532 *   << dof_handler.n_dofs()
533 *   << std::endl;
534 *  
535 *   locally_owned_dofs = dof_handler.locally_owned_dofs();
537 *  
538 * @endcode
539 *
540 * we want to output solution, so here should have ghost cells
541 *
542 * @code
543 *   old_solution_T.reinit (locally_owned_dofs,locally_relevant_dofs,mpi_communicator);
544 *  
545 * @endcode
546 *
547 * locally owned cells
548 *
549 * @code
550 *   old_solution_T_cal.reinit (locally_owned_dofs,mpi_communicator);
551 *   new_solution_T.reinit (locally_owned_dofs,mpi_communicator);
552 *   dynamic_rhs_T.reinit (locally_owned_dofs,mpi_communicator);
553 *   system_rhs_T.reinit (locally_owned_dofs,mpi_communicator);
554 *  
558 *   constraints_T.close();
559 *  
560 *   const unsigned int myid = Utilities::MPI::this_mpi_process (mpi_communicator);
563 *  
565 *   locally_owned_dofs,
566 *   mpi_communicator,
568 *  
569 *   left_system_matrix_T.reinit (locally_owned_dofs,locally_owned_dofs,dsp_T,mpi_communicator);
570 *   right_system_matrix_T.reinit (locally_owned_dofs,locally_owned_dofs,dsp_T,mpi_communicator);
571 *   system_matrix_T.reinit (locally_owned_dofs,locally_owned_dofs,dsp_T,mpi_communicator);
572 *  
573 *   }
574 *  
575 *  
576 * @endcode
577 *
578 *
579 * <a name="Distributed_Moving_Laser_Heating.cc-LaserHeatingassemble_system_matrix"></a>
581 *
582
583 *
584 *
585 * @code
586 *   template <int dim>
588 *   {
589 *  
590 *   TimerOutput::Scope t(computing_timer,"assemble_system_matrix_init()");
591 *  
593 *  
594 *  
596 *  
597 *  
598 *   const RhoC<dim> rho_C_fun_T;
599 *   const K_T<dim> k_fun_T;
600 *  
601 *  
602 *   FEValues<dim> fe_values (fe, quadrature_formula,
605 *  
606 *   const unsigned int dofs_per_cell = fe.dofs_per_cell;
607 *   const unsigned int n_q_points = quadrature_formula.size();
608 *  
609 *  
610 *   FullMatrix<double> local_init_matrix (dofs_per_cell, dofs_per_cell);
611 *   Vector<double> local_init_T_rhs (dofs_per_cell);
612 *  
613 *   FullMatrix<double> local_rho_c_T_matrix (dofs_per_cell, dofs_per_cell);
614 *   FullMatrix<double> local_k_T_matrix (dofs_per_cell, dofs_per_cell);
615 *  
616 *  
617 *   std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
618 *  
619 *   system_matrix_T = 0;
622 *  
623 *   system_rhs_T = 0;
624 *  
625 *   for (const auto &cell : dof_handler.active_cell_iterators())
626 *   if(cell->is_locally_owned())
627 *   {
628 *  
629 *   fe_values.reinit (cell);
630 *   local_init_matrix = 0;
631 *  
633 *   local_k_T_matrix = 0;
634 *  
635 *   local_init_T_rhs = 0;
636 *  
637 *   for (unsigned int q=0; q<n_q_points; ++q)
638 *   for (unsigned int i=0; i<dofs_per_cell; ++i)
639 *   {
640 *   const Tensor<1,dim> div_phi_i_u = fe_values.shape_grad (i,q);
641 *   const double phi_i_u = fe_values.shape_value (i,q);
642 *  
643 *   for (unsigned int j=0; j<dofs_per_cell; ++j)
644 *   {
645 *  
646 *   const Tensor<1,dim> div_phi_j_u = fe_values.shape_grad(j,q);
647 *   const double phi_j_u = fe_values.shape_value (j,q);
648 *  
649 *   local_init_matrix(i,j) += (phi_i_u *
650 *   phi_j_u *
651 *   fe_values.JxW (q));
652 *  
653 *   local_rho_c_T_matrix(i,j) += (rho_C_fun_T.value(fe_values.quadrature_point(q)) *
654 *   phi_i_u *
655 *   phi_j_u *
656 *   fe_values.JxW (q))
657 *   +
658 *   time_step * (theta) *
659 *   (k_fun_T.value(fe_values.quadrature_point(q)) *
660 *   div_phi_i_u *
661 *   div_phi_j_u *
662 *   fe_values.JxW (q));
663 *  
664 *   local_k_T_matrix(i,j) += (rho_C_fun_T.value(fe_values.quadrature_point(q)) *
665 *   phi_i_u *
666 *   phi_j_u *
667 *   fe_values.JxW (q))
668 *   -
669 *   time_step * (1.0-theta) *
670 *   (k_fun_T.value(fe_values.quadrature_point(q)) *
671 *   div_phi_i_u *
672 *   div_phi_j_u *
673 *   fe_values.JxW (q));
674 *  
675 *   }
676 *  
677 *   local_init_T_rhs(i) += (phi_i_u *
678 *   initial_value_func_T.value (fe_values.quadrature_point (q)) *
679 *   fe_values.JxW (q));
680 *  
681 *   }
682 *  
683 *   cell->get_dof_indices (local_dof_indices);
684 *  
685 * @endcode
686 *
688 *
689 * @code
690 *   constraints_T.distribute_local_to_global(local_init_matrix,
692 *   local_dof_indices,
694 *   system_rhs_T);
695 *  
696 *  
697 * @endcode
698 *
699 * store M + dt*theta*A as the left_system_matrix
700 *
701
702 *
703 *
704 * @code
705 *   constraints_T.distribute_local_to_global(local_rho_c_T_matrix,
706 *   local_dof_indices,
708 *  
709 * @endcode
710 *
711 * store M - dt*(1-theta)*A as the right_system_matrix
712 *
713 * @code
714 *   constraints_T.distribute_local_to_global(local_k_T_matrix,
715 *   local_dof_indices,
717 *  
718 *  
719 *   }
720 *  
725 *  
726 *   }
727 *  
728 *  
729 * @endcode
730 *
731 *
732 * <a name="Distributed_Moving_Laser_Heating.cc-LaserHeatingdynamic_assemble_rhs_T"></a>
734 * The right hand side is assembled each time during running, which is necessary as
736 * side assembling, the right hand side function is defined as RightHandside<dim>.
737 *
738 * @code
739 *   template <int dim>
740 *   void LaserHeating<dim>::dynamic_assemble_rhs_T (double time, double time_step)
741 *   {
742 *  
743 *   TimerOutput::Scope t(computing_timer,"assemble_rhs_T()");
744 *  
746 *  
748 *   rhs_func_T_1.set_time(time);
749 *  
751 *   rhs_func_T_2.set_time(time-time_step);
752 *  
753 *   FEValues<dim> fe_values (fe, quadrature_formula,
754 *   update_values |
756 *  
757 *  
758 *   const unsigned int dofs_per_cell = fe.dofs_per_cell;
759 *   const unsigned int n_q_points = quadrature_formula.size();
760 *  
761 *   Vector<double> local_rhs_vector_T (dofs_per_cell);
762 *  
763 *   std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
764 *  
765 *   std::vector<double> Rnp_cal_assemble (n_q_points);
766 *  
767 *  
768 *   dynamic_rhs_T = 0 ;
769 *  
771 *   cell = dof_handler.begin_active(),
772 *   endc = dof_handler.end();
773 *  
774 *   for (; cell!=endc; ++cell)
775 *   if(cell->is_locally_owned())
776 *   {
777 *   fe_values.reinit (cell);
779 *  
780 *   for (unsigned int q=0; q<n_q_points; ++q)
781 *   for (unsigned int i=0; i<dofs_per_cell; ++i)
782 *   {
783 *   const double phi_i_u = fe_values.shape_value (i,q);
784 *  
785 *  
786 *   local_rhs_vector_T(i) += time_step * theta *
787 *   (phi_i_u *
788 *   rhs_func_T_1.value_v2 (fe_values.quadrature_point (q)) *
789 *   fe_values.JxW (q))
790 *   +
791 *   time_step * (1.0 - theta) *
792 *   (phi_i_u *
793 *   rhs_func_T_2.value_v2 (fe_values.quadrature_point (q)) *
794 *   fe_values.JxW (q));
795 *   }
796 *  
797 *   cell->get_dof_indices (local_dof_indices);
798 *  
799 *  
800 *   constraints_T.distribute_local_to_global(local_rhs_vector_T,
801 *   local_dof_indices,
802 *   dynamic_rhs_T);
803 *  
804 *   }
805 *  
807 *  
808 *  
809 *   }
810 *  
811 *  
812 * @endcode
813 *
814 *
815 * <a name="Distributed_Moving_Laser_Heating.cc-LaserHeatingsolve"></a>
816 * <h4>LaserHeating::solve</h4>
819 * as the system right hand side. The vector completely_distributed_solution is used to store
820 * the obtained solution.
821 *
822 * @code
823 *   template <int dim>
825 *   {
826 *   TimerOutput::Scope t(computing_timer,"solve_T()");
827 *  
828 *   TrilinosWrappers::MPI::Vector completely_distributed_solution (locally_owned_dofs,mpi_communicator);
829 *   SolverControl solver_control (1*system_rhs_T.size(),1e-12*system_rhs_T.l2_norm(),true);
830 *  
831 *   TrilinosWrappers::SolverCG solver (solver_control);
832 *  
833 *   TrilinosWrappers::PreconditionAMG preconditioner;
835 *  
836 *   preconditioner.initialize(system_matrix_T,data);
837 *  
838 *   solver.solve (system_matrix_T,completely_distributed_solution,system_rhs_T,preconditioner);
839 *  
840 *  
841 * @endcode
842 *
843 * Print the number of iterations by hand.
844 *
845
846 *
847 *
848 * @code
849 *   pcout << " " << solver_control.last_step()
850 *   << " CG iterations needed to obtain convergence." << std::endl
851 *   << "\t initial convergence value = " << solver_control.initial_value() << std::endl
852 *   << "\t final convergence value = " << solver_control.last_value() << std::endl
853 *   << std::endl;
854 *  
857 *  
858 *   }
859 *  
860 *  
861 * @endcode
862 *
863 *
864 * <a name="Distributed_Moving_Laser_Heating.cc-LaserHeatingrefine_mesh"></a>
866 *
867
868 *
869 *
870 * @code
871 *   template <int dim>
873 *   {
874 *  
875 *   TimerOutput::Scope t(computing_timer,"refine_mesh_at_beginning");
876 *  
877 *  
879 *  
881 *  
882 *  
883 * @endcode
884 *
885 * only refine mesh 5um above the TiO2 and glass interface
886 *
887
888 *
889 *
890 * @code
892 *   cell = triangulation.begin_active();
893 *   cell != triangulation.end(); ++cell)
894 *   if(cell->is_locally_owned())
895 *   {
896 *   fe_values.reinit(cell);
897 *   if(std::abs(fe_values.quadrature_point(0)[1]) <= global_film_thickness+5e-6)
898 *   {
899 *   cell->set_refine_flag();
900 *   }
901 *   else
902 *   {
903 *   cell->clear_refine_flag();
904 *   }
905 *   }
906 *   triangulation.execute_coarsening_and_refinement();
907 *  
908 *   }
909 *  
910 *  
911 * @endcode
912 *
913 *
914 * <a name="Distributed_Moving_Laser_Heating.cc-LaserHeatinghoutput_results"></a>
916 *
917
918 *
919 *
920 * @code
921 *   template <int dim>
923 *   {
924 *  
925 *   DataOut<dim> data_out;
926 *  
927 *   data_out.attach_dof_handler (dof_handler);
928 *   data_out.add_data_vector (old_solution_T, "T");
929 *  
930 * @endcode
931 *
932 * the length of output numbering
933 *
934
935 *
936 *
937 * @code
938 *   int step_N = 7;
939 *  
940 *   data_out.build_patches ();
941 *  
942 *   const std::string filename = ("solution-" +
944 *   "." +
945 *   Utilities::int_to_string (triangulation.locally_owned_subdomain(),4) +
946 *   ".vtu");
947 *   std::ofstream output (filename.c_str());
948 *   data_out.write_vtu (output);
949 *  
950 *  
951 * @endcode
952 *
953 * output the overall solution
954 *
955
956 *
957 *
958 * @code
959 *   if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
960 *   {
961 *   std::vector<std::string> filenames;
962 *   for (unsigned int i=0;i<Utilities::MPI::n_mpi_processes(mpi_communicator);++i)
963 *   filenames.push_back ("solution-" +
965 *   "." +
967 *   ".vtu");
968 *   std::ofstream master_output (("solution-" +
970 *   ".pvtu").c_str());
971 *   data_out.write_pvtu_record (master_output,filenames);
972 *  
973 *   }
974 *  
975 *   }
976 *  
977 *  
978 *  
979 *  
980 * @endcode
981 *
982 *
983 * <a name="Distributed_Moving_Laser_Heating.cc-LaserHeatingrun"></a>
984 * <h4>LaserHeating::run</h4>
985 *
986
987 *
988 * This is the function which has the top-level control over everything. Apart
989 * from one line of additional output, it is the same as for the previous
990 * example.
991 *
992 * @code
993 *   template <int dim>
994 *   void LaserHeating<dim>::run ()
995 *   {
996 *   pcout << "Solving problem in " << dim << " space dimensions." << std::endl;
997 *  
998 *  
999 *   make_grid();
1000 *   refine_mesh();
1001 *   setup_system ();
1003 *  
1004 * @endcode
1005 *
1007 * solution stored in new_solution_T;
1008 *
1009
1010 *
1011 *
1012 * @code
1013 *   solve_T ();
1014 *  
1017 *  
1018 * @endcode
1019 *
1021 *
1022
1023 *
1024 *
1025 * @code
1026 *   system_matrix_T = 0;
1027 *   system_rhs_T = 0;
1028 *  
1029 *  
1031 *   double time = 0;
1032 *   int timestep_number = 0;
1033 *  
1034 * @endcode
1035 *
1036 * output initial values; need ghost cells
1037 *
1038 * @code
1039 *   output_results (0);
1040 *  
1041 *  
1042 *   while(time < global_simulation_end_time)
1043 *   {
1044 *  
1045 *   time += time_step;
1046 *   timestep_number ++;
1047 *  
1048 *   pcout << "Time step " << timestep_number
1049 *   << " at t=" << time
1050 *   << " time_step = " << time_step
1051 *   << std::endl;
1052 *  
1053 * @endcode
1054 *
1056 *
1057 * @code
1058 *   {
1059 *  
1061 *  
1063 *   system_rhs_T.add(1,dynamic_rhs_T);
1064 *  
1066 *  
1067 *   {
1069 *   std::map<types::global_dof_index,double> boundary_values;
1070 *  
1072 *   BOUNDARY_NUM,
1075 *  
1079 *   system_rhs_T,
1080 *   false);
1081 *   }
1082 *  
1083 *  
1084 *   solve_T ();
1085 *  
1086 * @endcode
1087 *
1088 * old_solution_T is used for output, holding ghost cells
1090 * locally owned cells.
1091 *
1092 * @code
1095 *  
1096 *   if (Utilities::MPI::n_mpi_processes(mpi_communicator) <= 96 && (timestep_number % 50 == 0 ))
1097 *   {
1100 *   }
1101 *  
1102 *   computing_timer.print_summary ();
1103 *   computing_timer.reset();
1104 *  
1105 *   pcout << std::endl;
1106 *  
1107 *   }
1108 *   }
1109 *  
1110 *   }
1111 *  
1112 *  
1113 * @endcode
1114 *
1115 *
1116 * <a name="Distributed_Moving_Laser_Heating.cc-Thecodemaincodefunction"></a>
1117 * <h3>The <code>main</code> function</h3>
1118 *
1119
1120 *
1121 *
1122 * @code
1123 *   int main (int argc, char *argv[])
1124 *   {
1125 *   try
1126 *   {
1128 *  
1130 *   laserHeating_2d.run ();
1131 *  
1132 *  
1133 *   }
1134 *   catch (std::exception &exc)
1135 *   {
1136 *   std::cerr << std::endl
1137 *   << std::endl
1138 *   << "----------------------------------------------------"
1139 *   << std::endl;
1140 *   std::cerr << "Exception on processing: " << std::endl
1141 *   << exc.what() << std::endl
1142 *   << "Aborting!" << std::endl
1143 *   << "----------------------------------------------------"
1144 *   << std::endl;
1145 *  
1146 *   return 1;
1147 *   }
1148 *   catch (...)
1149 *   {
1150 *   std::cerr << std::endl
1151 *   << std::endl
1152 *   << "----------------------------------------------------"
1153 *   << std::endl;
1154 *   std::cerr << "Unknown exception!" << std::endl
1155 *   << "Aborting!" << std::endl
1156 *   << "----------------------------------------------------"
1157 *   << std::endl;
1158 *   return 1;
1159 *   }
1160 *  
1161 *  
1162 *   return 0;
1163 *   }
1164 * @endcode
1165
1166
1167<a name="ann-boundaryInit.h"></a>
1169 *
1170 *
1171 *
1172 *
1173 * @code
1174 *   /* -----------------------------------------------------------------------------
1175 *   *
1176 *   * SPDX-License-Identifier: LGPL-2.1-or-later
1177 *   * Copyright (C) 2021 by Hongfeng Ma
1178 *   * Copyright (C) 2021 by Tatiana E. Itina
1179 *   *
1180 *   * This file is part of the deal.II code gallery.
1181 *   *
1182 *   * -----------------------------------------------------------------------------
1183 *   */
1184 *  
1185 * @endcode
1186 *
1187 * #----------------------------------------------------------
1188 * #
1189 * # This file defines the boundary and initial conditions
1190 * #
1191 * #----------------------------------------------------------
1192 *
1193
1194 *
1195 *
1196 * @code
1199 *   #include "./globalPara.h"
1200 *   #endif
1201 *  
1202 * @endcode
1203 *
1204 * #----------------------------------------------------------
1205 * # Declaration
1206 *
1207
1208 *
1209 *
1210 * @code
1211 *   template <int dim>
1212 *   class BoundaryValues : public Function<dim>
1213 *   {
1214 *   public:
1215 *   BoundaryValues () : Function<dim>() {}
1216 *  
1217 *   virtual double value (const Point<dim> &p,
1218 *   const unsigned int component = 0) const override;
1219 *   };
1220 *  
1221 *   template <int dim>
1222 *   class InitialValues : public Function<dim>
1223 *   {
1224 *   public:
1225 *   InitialValues () : Function<dim>() {}
1226 *  
1227 *   virtual double value (const Point<dim> &p,
1228 *   const unsigned int component = 0) const override;
1229 *   };
1230 *  
1231 *  
1232 * @endcode
1233 *
1234 * #----------------------------------------------------------
1235 * # Implementation
1236 *
1237
1238 *
1239 *
1240 * @code
1241 *   template <int dim>
1242 *   double BoundaryValues<dim>::value (const Point<dim> &/*p*/,
1243 *   const unsigned int /*component*/) const
1244 *   {
1245 *   return 293;
1246 *   }
1247 *  
1248 *  
1249 *   template <int dim>
1250 *   double InitialValues<dim>::value (const Point<dim> &/*p*/,
1251 *   const unsigned int /*component*/) const
1252 *   {
1253 *   return 293;
1254 *   }
1255 *  
1256 *  
1257 *  
1258 *  
1259 *  
1260 * @endcode
1261 *
1262 * #----------------------------------------------------------
1263 * # Declaration and Implementation
1264 * # mass density and heat capacity
1265 *
1266
1267 *
1268 *
1269 * @code
1270 *   template <int dim>
1271 *   class RhoC : public Function<dim>
1272 *   {
1273 *   public:
1274 *   RhoC () : Function<dim>() {}
1275 *  
1276 *   virtual double value (const Point<dim> &p,
1277 *   const unsigned int component = 0) const override;
1278 *   };
1279 *  
1280 *   template <int dim>
1281 *   double RhoC<dim>::value (const Point<dim> &p,
1282 *   const unsigned int /*component*/) const
1283 *   {
1284 * @endcode
1285 *
1286 * # p stores the xyz coordinates at each vertex
1287 * # for 2D problems in xy, we assume the non-uniform is in y-axis.
1288 *
1289 * @code
1290 *   if ( p[1] >= -global_film_thickness )
1291 *   {
1292 *   return global_rho_Tio2 * global_C_Tio2;
1293 *   }
1294 *   else
1296 *   }
1297 *  
1298 *  
1299 *  
1300 *  
1301 * @endcode
1302 *
1303 * #----------------------------------------------------------
1304 * # Declaration and Implementation
1306 *
1307
1308 *
1309 *
1310 * @code
1311 *   template <int dim>
1312 *   class K_T : public Function<dim>
1313 *   {
1314 *   public:
1315 *   K_T () : Function<dim>() {}
1316 *  
1317 *   virtual double value (const Point<dim> &p,
1318 *   const unsigned int component = 0) const override;
1319 *   };
1320 *  
1321 *   template <int dim>
1322 *   double K_T<dim>::value (const Point<dim> &p,
1323 *   const unsigned int /*component*/) const
1324 *   {
1325 * @endcode
1326 *
1327 * # p stores the xyz coordinates at each vertex
1328 * # for 2D problems in xy, we assume the non-uniform is in y-axis.
1329 *
1330 * @code
1331 *   if ( p[1] >= -global_film_thickness)
1332 *   {
1333 *   return global_k_Tio2;
1334 *   }
1335 *   else
1336 *   return global_k_glass;
1337 *   }
1338 *  
1339 * @endcode
1340
1341
1342<a name="ann-globalPara.h"></a>
1344 *
1345 *
1346 *
1347 *
1348 * @code
1349 *   /* -----------------------------------------------------------------------------
1350 *   *
1351 *   * SPDX-License-Identifier: LGPL-2.1-or-later
1352 *   * Copyright (C) 2021 by Hongfeng Ma
1353 *   * Copyright (C) 2021 by Tatiana E. Itina
1354 *   *
1355 *   * This file is part of the deal.II code gallery.
1356 *   *
1357 *   * -----------------------------------------------------------------------------
1358 *   */
1359 *  
1360 * @endcode
1361 *
1362 * # physics constants
1363 *
1364 * @code
1365 *   double global_PI = 3.1415927;
1366 *  
1367 * @endcode
1368 *
1369 * # Laser
1370 *
1371 * @code
1372 *   double global_Pow_laser = 0.4; // power [W]
1373 *   double global_spotsize_at_e_2 = 20e-6; // laser spot size at e^(-2) [m]
1374 *   double global_c_laser = global_spotsize_at_e_2 / 4.0; // C parameter in Gaussian func, [m]
1375 *   double global_c_hwhm = global_c_laser * 2.35482 / 2; // HWHM, [m]
1376 *   double global_V_scan_x = 10e-3; // scan speed, [m/s]
1377 *  
1378 *   double global_init_position_x0 = -50e-6; // initial spot center position
1379 *  
1380 * @endcode
1381 *
1382 * # material
1383 * thin film
1384 *
1385 * @code
1386 *   double global_rho_Tio2 = 4200; // mass density, [kg/m^3]
1387 *   double global_C_Tio2 = 690; // heat capacity, [J/kg/K]
1388 *   double global_k_Tio2 = 4.8; // thermal conductivity, [W/m/K]
1389 * @endcode
1390 *
1391 * substrate
1392 *
1393 * @code
1394 *   double global_rho_glass = 2200;
1395 *   double global_C_glass = 700;
1396 *   double global_k_glass = 1.8;
1397 *  
1398 *   double global_film_thickness = 400e-9; // film thickness, [m]
1399 *  
1400 * @endcode
1401 *
1402 * # simulation time
1403 *
1404 * @code
1405 *   double global_simulation_time_step = 1e-5; // 10 [us]
1406 *   double global_simulation_end_time = 100e-6 / global_V_scan_x; // 100 [um] / scan speed
1407 *  
1408 * @endcode
1409 *
1410 * # about the MESH
1411 *
1412 * @code
1413 *   #define BOUNDARY_NUM 11
1414 * @endcode
1415
1416
1417<a name="ann-rightHandSide.h"></a>
1419 *
1420 *
1421 *
1422 *
1423 * @code
1424 *   /* -----------------------------------------------------------------------------
1425 *   *
1426 *   * SPDX-License-Identifier: LGPL-2.1-or-later
1427 *   * Copyright (C) 2021 by Hongfeng Ma
1428 *   * Copyright (C) 2021 by Tatiana E. Itina
1429 *   *
1430 *   * This file is part of the deal.II code gallery.
1431 *   *
1432 *   * -----------------------------------------------------------------------------
1433 *   */
1434 *  
1435 * @endcode
1436 *
1437 * #----------------------------------------------------------
1438 * #
1439 * # This file defines the boundary and initial conditions
1440 * #
1441 * #----------------------------------------------------------
1442 *
1443
1444 *
1445 *
1446 * @code
1449 *   #include "./globalPara.h"
1450 *   #endif
1451 *  
1452 * @endcode
1453 *
1454 * #----------------------------------------------------------
1455 * # Declaration
1456 *
1457
1458 *
1459 *
1460 * @code
1461 *   template <int dim>
1462 *   class RightHandside : public Function<dim>
1463 *   {
1464 *   public:
1465 *   RightHandside () : Function<dim>() {}
1466 *  
1467 *   double value_v2 (const Point<dim> &p);
1468 *   };
1469 *  
1470 * @endcode
1471 *
1472 * #----------------------------------------------------------
1473 * # Implementation
1474 *
1475
1476 *
1477 *
1478 * @code
1479 *   template <int dim>
1480 *   double RightHandside<dim>::value_v2 (const Point<dim> &p)
1481 *   {
1482 *  
1483 *   double alpha_abs = 1e4;
1484 *  
1485 *  
1486 *   if(p[1] >= -global_film_thickness)
1487 *   {
1488 *  
1490 *  
1491 *   double I00 = P00 * std::exp(-
1492 *   (
1493 *   (p[0] - global_V_scan_x * this->get_time()-global_init_position_x0) *
1495 *   ) /
1496 *   (2.0 * global_c_laser * global_c_laser) );
1497 *  
1498 *  
1499 *   return alpha_abs * I00 * std::exp(-alpha_abs*(0 - p[1]));
1500 *  
1501 *   }
1502 *  
1503 *   else
1504 *   {
1505 * @endcode
1506 *
1507 * # no absorption
1508 *
1509 * @code
1510 *   return 0;
1511 *   }
1512 *  
1513 *   }
1514 *  
1515 *  
1516 * @endcode
1517
1518
1519*/
constexpr void clear()
friend class Tensor
Definition tensor.h:865
std::conditional_t< rank_==1, std::array< Number, dim >, std::array< Tensor< rank_ - 1, dim, Number >, dim > > values
Definition tensor.h:851
@ wall_times
Definition timer.h:651
unsigned int level
Definition grid_out.cc:4632
typename ActiveSelector::active_cell_iterator active_cell_iterator
void make_hanging_node_constraints(const DoFHandler< dim, spacedim > &dof_handler, AffineConstraints< number > &constraints)
void make_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern, const AffineConstraints< number > &constraints={}, const bool keep_constrained_dofs=true, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id)
@ update_values
Shape function values.
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
std::vector< index_type > data
Definition mpi.cc:740
const Event initial
Definition event.cc:68
IndexSet extract_locally_relevant_dofs(const DoFHandler< dim, spacedim > &dof_handler)
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)
void scale(const double scaling_factor, Triangulation< dim, spacedim > &triangulation)
@ matrix
Contents is actually a matrix.
@ general
No special properties.
constexpr char A
constexpr types::blas_int one
void apply_boundary_values(const std::map< types::global_dof_index, number > &boundary_values, SparseMatrix< number > &matrix, Vector< number > &solution, Vector< number > &right_hand_side, const bool eliminate_columns=true)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
void distribute_sparsity_pattern(DynamicSparsityPattern &dsp, const IndexSet &locally_owned_rows, const MPI_Comm mpi_comm, const IndexSet &locally_relevant_rows)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
Definition mpi.cc:97
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
Definition mpi.cc:112
std::string get_time()
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition utilities.cc:474
void interpolate_boundary_values(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const std::map< types::boundary_id, const Function< spacedim, number > * > &function_map, std::map< types::global_dof_index, number > &boundary_values, const ComponentMask &component_mask={})
void run(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length, const unsigned int chunk_size)
void copy(const T *begin, const T *end, U *dest)
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
::VectorizedArray< Number, width > exp(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation