1313#include " 4C_fem_general_node.hpp"
1414#include " 4C_global_data.hpp"
1515#include " 4C_io.hpp"
16+ #include " 4C_io_discretization_visualization_writer_mesh.hpp"
1617#include " 4C_linalg_utils_sparse_algebra_manipulation.hpp"
1718#include " 4C_linear_solver_method_linalg.hpp"
1819#include " 4C_mat_maxwell_0d_acinus_NeoHookean.hpp"
@@ -47,6 +48,12 @@ namespace ReducedLung
4748 Teuchos::getIntegralValue<Core::IO::Verbositylevel>(
4849 Global::Problem::instance ()->io_params (), " VERBOSITY" ));
4950 actdis->compute_null_space_if_necessary (solver->params ());
51+ // Create runtime output writer
52+ const auto visualization_writer =
53+ std::make_unique<Core::IO::DiscretizationVisualizationWriterMesh>(
54+ actdis, Core::IO::visualization_parameters_factory (
55+ Global::Problem::instance ()->io_params ().sublist (" RUNTIME VTK OUTPUT" ),
56+ *Global::Problem::instance ()->output_control_file (), 0 ));
5057 // The existing mpi communicator is recycled for the new data layout.
5158 const auto & comm = actdis->get_comm ();
5259
@@ -122,17 +129,17 @@ namespace ReducedLung
122129 // Assign every local element its associated global dof ids.
123130 for (auto & airway : airways)
124131 {
125- int first_dof_gid = first_global_dof_of_ele[airway.global_equation_id ];
126- int n_dof = dof_per_ele[airway.global_equation_id ];
132+ int first_dof_gid = first_global_dof_of_ele[airway.global_element_id ];
133+ int n_dof = dof_per_ele[airway.global_element_id ];
127134 for (int i = 0 ; i < n_dof; i++)
128135 {
129136 airway.global_dof_ids .insert (airway.global_dof_ids .end (), first_dof_gid + i);
130137 }
131138 }
132139 for (auto & terminal_unit : terminal_units)
133140 {
134- int first_dof_gid = first_global_dof_of_ele[terminal_unit.global_equation_id ];
135- int n_dof = dof_per_ele[terminal_unit.global_equation_id ];
141+ int first_dof_gid = first_global_dof_of_ele[terminal_unit.global_element_id ];
142+ int n_dof = dof_per_ele[terminal_unit.global_element_id ];
136143 for (int i = 0 ; i < n_dof; i++)
137144 {
138145 terminal_unit.global_dof_ids .insert (terminal_unit.global_dof_ids .end (), first_dof_gid + i);
@@ -434,7 +441,7 @@ namespace ReducedLung
434441 {
435442 const int airway_id = airway.local_airway_id ;
436443 const auto * airway_ele =
437- static_cast <Discret::Elements::RedAirway*>(actdis->g_element (airway.global_equation_id ));
444+ static_cast <Discret::Elements::RedAirway*>(actdis->g_element (airway.global_element_id ));
438445 const Discret::ReducedLung::AirwayParams airway_params = airway_ele->get_airway_params ();
439446 const std::vector<double >& coords_1 = airway_ele->nodes ()[0 ]->x ();
440447 const std::vector<double >& coords_2 = airway_ele->nodes ()[1 ]->x ();
@@ -457,7 +464,7 @@ namespace ReducedLung
457464 {
458465 const int terminal_unit_id = terminal_unit.local_terminal_unit_id ;
459466 const auto * terminal_unit_ele = static_cast <Discret::Elements::RedAcinus*>(
460- actdis->g_element (terminal_unit.global_equation_id ));
467+ actdis->g_element (terminal_unit.global_element_id ));
461468 const std::vector<double >& coords_1 = terminal_unit_ele->nodes ()[0 ]->x ();
462469 const std::vector<double >& coords_2 = terminal_unit_ele->nodes ()[1 ]->x ();
463470 const double radius = std::sqrt ((coords_1[0 ] - coords_2[0 ]) * (coords_1[0 ] - coords_2[0 ]) +
@@ -484,6 +491,7 @@ namespace ReducedLung
484491 auto sysmat = Epetra_CrsMatrix (
485492 Copy, row_map.get_epetra_map (), locally_relevant_dof_map.get_epetra_map (), 3 );
486493
494+ const int results_every = rawdyn.get <int >(" RESULTSEVERY" );
487495 // Time integration parameters.
488496 const double dt = rawdyn.get <double >(" TIMESTEP" );
489497 const int n_timesteps = rawdyn.get <int >(" NUMSTEP" );
@@ -526,15 +534,15 @@ namespace ReducedLung
526534 if (!sysmat.Filled ())
527535 {
528536 err = sysmat.InsertMyValues (
529- airway.local_equation_id , vals.size (), vals.data (), airway.local_dof_ids .data ());
537+ airway.local_element_id , vals.size (), vals.data (), airway.local_dof_ids .data ());
530538 }
531539 else
532540 {
533541 err = sysmat.ReplaceMyValues (
534- airway.local_equation_id , vals.size (), vals.data (), airway.local_dof_ids .data ());
542+ airway.local_element_id , vals.size (), vals.data (), airway.local_dof_ids .data ());
535543 }
536544 FOUR_C_ASSERT (err == 0 , " Internal error: Airway equation assembly did not work." );
537- err = rhs.replace_local_value (airway.local_equation_id , 0 , res);
545+ err = rhs.replace_local_value (airway.local_element_id , 0 , res);
538546 FOUR_C_ASSERT (err == 0 , " Internal error: Airway equation calculation did not work." );
539547 }
540548
@@ -554,16 +562,16 @@ namespace ReducedLung
554562 E * (V_tu - V0_tu) / V0_tu;
555563 if (!sysmat.Filled ())
556564 {
557- err = sysmat.InsertMyValues (terminal_unit.local_equation_id , vals.size (), vals.data (),
565+ err = sysmat.InsertMyValues (terminal_unit.local_element_id , vals.size (), vals.data (),
558566 terminal_unit.local_dof_ids .data ());
559567 }
560568 else
561569 {
562- err = sysmat.ReplaceMyValues (terminal_unit.local_equation_id , vals.size (), vals.data (),
570+ err = sysmat.ReplaceMyValues (terminal_unit.local_element_id , vals.size (), vals.data (),
563571 terminal_unit.local_dof_ids .data ());
564572 }
565573 FOUR_C_ASSERT (err == 0 , " Internal error: Terminal Unit equation assembly did not work." );
566- err = rhs.replace_local_value (terminal_unit.local_equation_id , 0 , res);
574+ err = rhs.replace_local_value (terminal_unit.local_element_id , 0 , res);
567575 FOUR_C_ASSERT (err == 0 , " Internal error: Terminal Unit equation calculation did not work." );
568576 }
569577
@@ -735,6 +743,15 @@ namespace ReducedLung
735743 // Backwards Euler: V_n+1 = V_n + q_n+1 * dt.
736744 volume[tu_id] += locally_relevant_dofs[q_id] * dt;
737745 }
746+
747+ // Runtime output
748+ if (n % results_every == 0 )
749+ {
750+ visualization_writer->reset ();
751+ collect_runtime_output_data (
752+ *visualization_writer, airways, terminal_units, dofs, actdis->element_row_map ());
753+ visualization_writer->write_to_disk (dt * n, n);
754+ }
738755 }
739756 // Print time monitor
740757 Teuchos::TimeMonitor::summarize (std::cout, false , true , false );
0 commit comments