52 =
Selection(
"DG_variant",
"Type of penalty term.")
53 .
add_value(non_symmetric,
"non-symmetric",
"non-symmetric weighted interior penalty DG method")
54 .
add_value(incomplete,
"incomplete",
"incomplete weighted interior penalty DG method")
55 .
add_value(symmetric,
"symmetric",
"symmetric weighted interior penalty DG method");
59 Selection(
"TransportDG_BC_Type",
"Types of boundary condition supported by the transport DG model (solute transport or heat transfer).")
60 .
add_value(
none,
"none",
"Homogeneous Neumann boundary condition. Zero flux")
62 "Dirichlet boundary condition."
66 .
add_value(neumann,
"neumann",
"Neumann boundary condition. Prescribe water outflow by the 'bc_flux' field.")
67 .
add_value(robin,
"robin",
"Robin boundary condition. Water outflow equal to $\\sigma (h - h^R)$. "
71 .
add_value(inflow,
"inflow",
"Prescribes the concentration in the inflow water on the inflow part of the boundary.");
75 Model::ModelEqData::get_output_selection_input_type(
"DG",
"DG solver")
76 .copy_values(EqData().make_output_field_selection(
"").close())
81 = Model::get_input_type(
"DG",
"DG solver")
83 "Linear solver for MH problem.")
85 .declare_key(
"dg_variant", TransportDG<Model>::dg_variant_selection_input_type,
Default(
"non-symmetric"),
86 "Variant of interior penalty discontinuous Galerkin method.")
88 "Polynomial order for finite element in DG method (order 0 is suitable if there is no diffusion/dispersion).")
89 .declare_key(
"output_fields",
Array(EqData::output_selection),
90 Default(Model::ModelEqData::default_output_field()),
91 "List of fields to write to output file.");
132 xprintf(
PrgErr,
"Unsupported polynomial order %d for finite elements in TransportDG ", fe_order);
152 dh_->distribute_dofs(*fe1_, *fe2_, *fe3_);
198 template<
class Model>
202 .
name(
"fracture_sigma")
204 "Coefficient of diffusive transfer through fractures (for each substance).")
212 "Penalty parameter influencing the discontinuity of the solution (for each substance). "
213 "Its default value 1 is sufficient in most cases. Higher value diminishes the inter-element jumps.")
221 "Boundary condition type, possible values: inflow, dirichlet, neumann, robin.")
229 .
description(
"Flux in Neumann boundary condition.")
234 .
name(
"bc_robin_sigma")
235 .
description(
"Conductivity coefficient in Robin boundary condition.")
248 template<
class Model>
258 static_assert(std::is_base_of<AdvectionDiffusionModel, Model>::value,
"");
276 data_.set_mesh(init_mesh);
289 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
297 int qsize = max(
feo->
q<0>()->size(), max(
feo->
q<1>()->size(), max(
feo->
q<2>()->size(),
feo->
q<3>()->size())));
302 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
309 for (
int sd=0; sd<max_edg_sides; sd++)
313 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
324 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
334 data_.output_field.set_up_components();
335 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
353 for (
unsigned int sbi = 0; sbi <
n_subst_; sbi++) {
365 if (it->val<
bool>(
"balance_on"))
376 max(
feo->
fe<1>()->n_dofs(), max(
feo->
fe<2>()->n_dofs(),
feo->
fe<3>()->n_dofs())));
381 template<
class Model>
387 if (feo->dh()->el_ds()->myp() == 0)
389 for (
unsigned int i=0; i<
n_subst_; i++)
391 VecDestroy(&output_vec[i]);
392 delete[] output_solution[i];
396 for (
unsigned int i=0; i<
n_subst_; i++)
399 MatDestroy(&stiffness_matrix[i]);
401 VecDestroy(&mass_vec[i]);
404 delete[] stiffness_matrix;
410 delete output_stream;
414 template<
class Model>
418 VecScatter output_scatter;
420 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
423 ISCreateBlock(PETSC_COMM_SELF, ls[sbi]->size(), 1, idx, PETSC_COPY_VALUES, &is);
424 VecScatterCreate(ls[sbi]->get_solution(), is, output_vec[sbi], PETSC_NULL, &output_scatter);
425 VecScatterBegin(output_scatter, ls[sbi]->get_solution(), output_vec[sbi], INSERT_VALUES, SCATTER_FORWARD);
426 VecScatterEnd(output_scatter, ls[sbi]->get_solution(), output_vec[sbi], INSERT_VALUES, SCATTER_FORWARD);
427 VecScatterDestroy(&(output_scatter));
434 template<
class Model>
443 set_initial_condition();
444 for (
unsigned int sbi = 0; sbi <
n_subst_; sbi++)
445 ( (
LinSys_PETSC *)ls[sbi] )->set_initial_guess_nonzero();
450 balance_->units(Model::balance_units());
452 if (!allocation_done) preallocate();
454 for (
unsigned int sbi=0; sbi<
n_subst_; ++sbi)
456 balance_->calculate_mass(subst_idx[sbi], ls[sbi]->get_solution());
457 balance_->calculate_source(subst_idx[sbi], ls[sbi]->get_solution());
458 balance_->calculate_flux(subst_idx[sbi], ls[sbi]->get_solution());
466 template<
class Model>
470 ls_dt->start_allocation();
471 assemble_mass_matrix();
475 for (
unsigned int i=0; i<
n_subst_; i++)
477 ls[i]->start_allocation();
478 stiffness_matrix[i] = NULL;
481 assemble_stiffness_matrix();
483 set_boundary_conditions();
485 allocation_done =
true;
490 template<
class Model>
503 if (!allocation_done) preallocate();
508 ls_dt->start_add_assembly();
509 ls_dt->mat_zero_entries();
510 assemble_mass_matrix();
511 ls_dt->finish_assembly();
514 if (mass_matrix == NULL)
516 for (
unsigned int i=0; i<
n_subst_; i++)
518 VecDuplicate(ls[i]->get_solution(), &mass_vec[i]);
519 MatMult(*(ls_dt->get_matrix()), ls[i]->get_solution(), mass_vec[i]);
523 mass_matrix = *(ls_dt->get_matrix());
527 if (stiffness_matrix[0] == NULL
529 || Model::flux_changed)
533 for (
unsigned int i=0; i<
n_subst_; i++)
535 ls[i]->start_add_assembly();
536 ls[i]->mat_zero_entries();
538 assemble_stiffness_matrix();
539 for (
unsigned int i=0; i<
n_subst_; i++)
541 ls[i]->finish_assembly();
543 if (stiffness_matrix[i] == NULL)
544 MatConvert(*( ls[i]->get_matrix() ), MATSAME, MAT_INITIAL_MATRIX, &stiffness_matrix[i]);
546 MatCopy(*( ls[i]->get_matrix() ), stiffness_matrix[i], DIFFERENT_NONZERO_PATTERN);
553 || Model::flux_changed)
555 for (
unsigned int i=0; i<
n_subst_; i++)
557 ls[i]->start_add_assembly();
558 ls[i]->rhs_zero_entries();
561 set_boundary_conditions();
562 for (
unsigned int i=0; i<
n_subst_; i++)
564 ls[i]->finish_assembly();
566 VecDuplicate(*( ls[i]->get_rhs() ), &rhs[i]);
567 VecCopy(*( ls[i]->get_rhs() ), rhs[i]);
571 Model::flux_changed =
false;
592 for (
unsigned int i=0; i<
n_subst_; i++)
594 MatConvert(stiffness_matrix[i], MATSAME, MAT_INITIAL_MATRIX, &m);
595 MatAXPY(m, 1./
time_->
dt(), mass_matrix, SUBSET_NONZERO_PATTERN);
596 ls[i]->set_matrix(m, DIFFERENT_NONZERO_PATTERN);
598 VecDuplicate(rhs[i], &w);
599 VecWAXPY(w, 1./
time_->
dt(), mass_vec[i], rhs[i]);
607 MatMult(*(ls_dt->get_matrix()), ls[i]->get_solution(), mass_vec[i]);
613 for (
unsigned int sbi=0; sbi<
n_subst_; ++sbi)
615 balance_->calculate_mass(subst_idx[sbi], ls[sbi]->get_solution());
616 balance_->calculate_source(subst_idx[sbi], ls[sbi]->get_solution());
617 balance_->calculate_flux(subst_idx[sbi], ls[sbi]->get_solution());
620 balance_->calculate_cumulative_sources(subst_idx[sbi], ls[sbi]->get_solution(),
time_->
dt());
621 balance_->calculate_cumulative_fluxes(subst_idx[sbi], ls[sbi]->get_solution(),
time_->
dt());
630 template<
class Model>
637 Model::flux_changed =
true;
642 template<
class Model>
650 output_vector_gather();
652 data_.output(output_stream);
653 output_stream->write_time_frame();
662 template<
class Model>
667 balance_->start_mass_assembly(subst_idx);
668 assemble_mass_matrix<1>();
669 assemble_mass_matrix<2>();
670 assemble_mass_matrix<3>();
672 balance_->finish_mass_assembly(subst_idx);
677 template<
class Model>
template<
unsigned int dim>
681 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim>()->size();
683 PetscScalar local_mass_matrix[ndofs*ndofs];
687 for (
unsigned int i_cell=0; i_cell<feo->dh()->el_ds()->lsize(); i_cell++)
690 if (cell->dim() != dim)
continue;
692 fe_values.reinit(cell);
693 feo->dh()->get_dof_indices(cell, (
unsigned int*)&(dof_indices[0]));
696 Model::compute_mass_matrix_coefficient(fe_values.point_list(), ele_acc, mm_coef);
699 for (
unsigned int i=0; i<ndofs; i++)
701 for (
unsigned int j=0; j<ndofs; j++)
703 local_mass_matrix[i*ndofs+j] = 0;
704 for (
unsigned int k=0; k<qsize; k++)
705 local_mass_matrix[i*ndofs+j] += mm_coef[k]*fe_values.shape_value(j,k)*fe_values.shape_value(i,k)*fe_values.JxW(k);
710 local_mass_balance_vector[i] = 0;
711 for (
unsigned int k=0; k<qsize; k++)
712 local_mass_balance_vector[i] += mm_coef[k]*fe_values.shape_value(i,k)*fe_values.JxW(k);
717 for (
unsigned int sbi=0; sbi<
n_subst_; ++sbi)
718 balance_->add_mass_matrix_values(subst_idx[sbi], ele_acc.
region().
bulk_idx(), dof_indices, local_mass_balance_vector);
720 ls_dt->mat_set_values(ndofs, &(dof_indices[0]), ndofs, &(dof_indices[0]), local_mass_matrix);
727 template<
class Model>
732 assemble_volume_integrals<1>();
733 assemble_volume_integrals<2>();
734 assemble_volume_integrals<3>();
738 assemble_fluxes_boundary<1>();
739 assemble_fluxes_boundary<2>();
740 assemble_fluxes_boundary<3>();
744 assemble_fluxes_element_element<1>();
745 assemble_fluxes_element_element<2>();
746 assemble_fluxes_element_element<3>();
750 assemble_fluxes_element_side<1>();
751 assemble_fluxes_element_side<2>();
752 assemble_fluxes_element_side<3>();
759 template<
class Model>
760 template<
unsigned int dim>
763 FEValues<dim,3> fv_rt(*feo->mapping<dim>(), *feo->q<dim>(), *feo->fe_rt<dim>(),
765 FEValues<dim,3> fe_values(*feo->mapping<dim>(), *feo->q<dim>(), *feo->fe<dim>(),
767 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim>()->size();
768 unsigned int dof_indices[ndofs];
771 PetscScalar local_matrix[ndofs*ndofs];
774 for (
unsigned int i_cell=0; i_cell<feo->dh()->el_ds()->lsize(); i_cell++)
777 if (cell->dim() != dim)
continue;
782 feo->dh()->get_dof_indices(cell, dof_indices);
784 calculate_velocity(cell, velocity, fv_rt);
785 Model::compute_advection_diffusion_coefficients(fe_values.
point_list(), velocity, ele_acc, ad_coef, dif_coef);
786 Model::compute_sources_sigma(fe_values.
point_list(), ele_acc, sources_sigma);
789 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
791 for (
unsigned int i=0; i<ndofs; i++)
792 for (
unsigned int j=0; j<ndofs; j++)
793 local_matrix[i*ndofs+j] = 0;
795 for (
unsigned int k=0; k<qsize; k++)
797 for (
unsigned int i=0; i<ndofs; i++)
800 double ad_dot_grad_i = arma::dot(ad_coef[sbi][k], fe_values.
shape_grad(i,k));
802 for (
unsigned int j=0; j<ndofs; j++)
803 local_matrix[i*ndofs+j] += (arma::dot(Kt_grad_i, fe_values.
shape_grad(j,k))
808 ls[sbi]->mat_set_values(ndofs, (
int *)dof_indices, ndofs, (
int *)dof_indices, local_matrix);
814 template<
class Model>
819 balance_->start_source_assembly(subst_idx);
824 balance_->finish_source_assembly(subst_idx);
828 template<
class Model>
829 template<
unsigned int dim>
832 FEValues<dim,3> fe_values(*feo->mapping<dim>(), *feo->q<dim>(), *feo->fe<dim>(),
834 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim>()->size();
839 PetscScalar local_rhs[ndofs];
844 for (
unsigned int i_cell=0; i_cell<feo->dh()->el_ds()->lsize(); i_cell++)
847 if (cell->dim() != dim)
continue;
849 fe_values.reinit(cell);
850 feo->dh()->get_dof_indices(cell, (
unsigned int *)&(dof_indices[0]));
852 Model::compute_source_coefficients(fe_values.point_list(), cell->element_accessor(), sources_conc, sources_density, sources_sigma);
855 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
857 fill_n(local_rhs, ndofs, 0);
858 local_source_balance_vector.assign(ndofs, 0);
859 local_source_balance_rhs.assign(ndofs, 0);
862 for (
unsigned int k=0; k<qsize; k++)
864 source = (sources_density[k][sbi] + sources_conc[k][sbi]*sources_sigma[k][sbi])*fe_values.JxW(k);
866 for (
unsigned int i=0; i<ndofs; i++)
868 local_rhs[i] += source*fe_values.shape_value(i,k);
872 local_source_balance_vector[i] -= sources_sigma[k][sbi]*fe_values.shape_value(i,k)*fe_values.JxW(k);
873 local_source_balance_rhs[i] += source*fe_values.shape_value(i,k);
877 ls[sbi]->rhs_set_values(ndofs, &(dof_indices[0]), local_rhs);
881 balance_->add_source_matrix_values(subst_idx[sbi], cell->region().bulk_idx(), dof_indices, local_source_balance_vector);
882 balance_->add_source_rhs_values(subst_idx[sbi], cell->region().bulk_idx(), dof_indices, local_source_balance_rhs);
890 template<
class Model>
891 template<
unsigned int dim>
897 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim-1>()->size(),
898 n_max_sides = ad_coef_edg.size();
900 PetscScalar local_matrix[ndofs*ndofs];
903 double gamma_l, omega[2], transport_flux;
905 for (
unsigned int sid=0; sid<n_max_sides; sid++)
907 side_dof_indices.push_back(
new unsigned int[ndofs]);
908 fe_values.push_back(
new FESideValues<dim,3>(*feo->mapping<dim>(), *feo->q<dim-1>(), *feo->fe<dim>(),
913 for (
unsigned int iedg=0; iedg<feo->dh()->n_loc_edges(); iedg++)
918 for (
int sid=0; sid<edg->
n_sides; sid++)
922 feo->dh()->get_dof_indices(cell, side_dof_indices[sid]);
923 fe_values[sid]->reinit(cell, edg->
side(sid)->
el_idx());
925 calculate_velocity(cell, side_velocity[sid], fsv_rt);
926 Model::compute_advection_diffusion_coefficients(fe_values[sid]->point_list(), side_velocity[sid], ele_acc, ad_coef_edg[sid], dif_coef_edg[sid]);
927 dg_penalty[sid] = data_.dg_penalty.value(cell->centre(), ele_acc);
931 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
934 for (
int sid=0; sid<edg->
n_sides; sid++)
937 for (
unsigned int k=0; k<qsize; k++)
938 fluxes[sid] += arma::dot(ad_coef_edg[sid][sbi][k], fe_values[sid]->normal_vector(k))*fe_values[sid]->JxW(k);
942 for (
int s1=0; s1<edg->
n_sides; s1++)
944 for (
int s2=s1+1; s2<edg->
n_sides; s2++)
950 arma::vec3 nv = fe_values[s1]->normal_vector(0);
953 set_DG_parameters_edge(*edg, s1, s2, qsize, dif_coef_edg[s1][sbi], dif_coef_edg[s2][sbi], fluxes, fe_values[0]->normal_vector(0), dg_penalty[s1][sbi], dg_penalty[s2][sbi], gamma_l, omega, transport_flux);
959 #define AVERAGE(i,k,side_id) (fe_values[sd[side_id]]->shape_value(i,k)*0.5)
960 #define WAVERAGE(i,k,side_id) (arma::dot(dif_coef_edg[sd[side_id]][sbi][k]*fe_values[sd[side_id]]->shape_grad(i,k),nv)*omega[side_id])
961 #define JUMP(i,k,side_id) ((side_id==0?1:-1)*fe_values[sd[side_id]]->shape_value(i,k))
964 for (
int n=0; n<2; n++)
968 for (
int m=0; m<2; m++)
970 for (
unsigned int i=0; i<fe_values[sd[n]]->n_dofs(); i++)
971 for (
unsigned int j=0; j<fe_values[sd[m]]->n_dofs(); j++)
972 local_matrix[i*fe_values[sd[m]]->n_dofs()+j] = 0;
974 for (
unsigned int k=0; k<qsize; k++)
976 double flux_times_JxW = transport_flux*fe_values[0]->JxW(k);
977 double gamma_times_JxW = gamma_l*fe_values[0]->JxW(k);
979 for (
unsigned int i=0; i<fe_values[sd[n]]->n_dofs(); i++)
981 double flux_JxW_jump_i = flux_times_JxW*
JUMP(i,k,n);
982 double gamma_JxW_jump_i = gamma_times_JxW*
JUMP(i,k,n);
983 double JxW_jump_i = fe_values[0]->JxW(k)*
JUMP(i,k,n);
984 double JxW_var_wavg_i = fe_values[0]->JxW(k)*
WAVERAGE(i,k,n)*dg_variant;
986 for (
unsigned int j=0; j<fe_values[sd[m]]->n_dofs(); j++)
988 int index = i*fe_values[sd[m]]->n_dofs()+j;
991 local_matrix[index] += flux_JxW_jump_i*
AVERAGE(j,k,m);
994 local_matrix[index] += gamma_JxW_jump_i*
JUMP(j,k,m);
997 local_matrix[index] -=
WAVERAGE(j,k,m)*JxW_jump_i;
998 local_matrix[index] -=
JUMP(j,k,m)*JxW_var_wavg_i;
1002 ls[sbi]->mat_set_values(fe_values[sd[n]]->n_dofs(), (
int *)side_dof_indices[sd[n]], fe_values[sd[m]]->n_dofs(), (
int *)side_dof_indices[sd[m]], local_matrix);
1013 for (
unsigned int i=0; i<n_max_sides; i++)
1015 delete fe_values[i];
1016 delete[] side_dof_indices[i];
1021 template<
class Model>
1022 template<
unsigned int dim>
1025 FESideValues<dim,3> fe_values_side(*feo->mapping<dim>(), *feo->q<dim-1>(), *feo->fe<dim>(),
1029 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim-1>()->size();
1030 unsigned int side_dof_indices[ndofs];
1031 PetscScalar local_matrix[ndofs*ndofs];
1034 arma::vec dg_penalty;
1038 for (
unsigned int iedg=0; iedg<feo->dh()->n_loc_edges(); iedg++)
1041 if (edg->
n_sides > 1)
continue;
1043 if (edg->
side(0)->
dim() != dim-1)
continue;
1045 if (edg->
side(0)->
cond() == NULL)
continue;
1050 feo->dh()->get_dof_indices(cell, side_dof_indices);
1054 calculate_velocity(cell, side_velocity, fsv_rt);
1055 Model::compute_advection_diffusion_coefficients(fe_values_side.
point_list(), side_velocity, ele_acc, ad_coef, dif_coef);
1056 dg_penalty = data_.dg_penalty.value(cell->centre(), ele_acc);
1060 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1062 for (
unsigned int i=0; i<ndofs; i++)
1063 for (
unsigned int j=0; j<ndofs; j++)
1064 local_matrix[i*ndofs+j] = 0;
1068 double side_flux = 0;
1069 for (
unsigned int k=0; k<qsize; k++)
1070 side_flux += arma::dot(ad_coef[sbi][k], fe_values_side.
normal_vector(k))*fe_values_side.
JxW(k);
1071 double transport_flux = side_flux/side->
measure();
1073 if (bc_type[sbi] == EqData::dirichlet)
1076 set_DG_parameters_boundary(side, qsize, dif_coef[sbi], transport_flux, fe_values_side.
normal_vector(0), dg_penalty[sbi], gamma_l);
1077 gamma[sbi][side->
cond_idx()] = gamma_l;
1078 transport_flux += gamma_l;
1082 for (
unsigned int k=0; k<qsize; k++)
1084 double flux_times_JxW;
1085 if (bc_type[sbi] == EqData::robin)
1086 flux_times_JxW = (transport_flux + robin_sigma[k][sbi])*fe_values_side.
JxW(k);
1087 else if (bc_type[sbi] == EqData::inflow && side_flux < 0)
1090 flux_times_JxW = transport_flux*fe_values_side.
JxW(k);
1092 for (
unsigned int i=0; i<ndofs; i++)
1094 for (
unsigned int j=0; j<ndofs; j++)
1097 local_matrix[i*ndofs+j] += flux_times_JxW*fe_values_side.
shape_value(i,k)*fe_values_side.
shape_value(j,k);
1100 if (bc_type[sbi] == EqData::dirichlet)
1103 )*fe_values_side.
JxW(k);
1108 ls[sbi]->mat_set_values(ndofs, (
int *)side_dof_indices, ndofs, (
int *)side_dof_indices, local_matrix);
1114 template<
class Model>
1115 template<
unsigned int dim>
1119 if (dim == 1)
return;
1120 FEValues<dim-1,3> fe_values_vb(*feo->mapping<dim-1>(), *feo->q<dim-1>(), *feo->
fe<dim-1>(),
1126 FEValues<dim-1,3> fv_rt(*feo->mapping<dim-1>(), *feo->q<dim-1>(), *feo->fe_rt<dim-1>(),
1130 const unsigned int ndofs = feo->fe<dim>()->n_dofs();
1131 const unsigned int qsize = feo->q<dim-1>()->size();
1132 unsigned int side_dof_indices[2*ndofs], n_dofs[2];
1135 vector<double> csection_lower(qsize), csection_higher(qsize), mm_coef_lower(qsize), mm_coef_higher(qsize);
1136 PetscScalar local_matrix[4*ndofs*ndofs];
1137 double comm_flux[2][2];
1141 fv_sb[0] = &fe_values_vb;
1142 fv_sb[1] = &fe_values_side;
1145 for (
unsigned int inb=0; inb<feo->dh()->n_loc_nb(); inb++)
1152 feo->dh()->get_dof_indices(cell_sub, side_dof_indices);
1153 fe_values_vb.
reinit(cell_sub);
1154 n_dofs[0] = fv_sb[0]->n_dofs();
1157 feo->dh()->get_dof_indices(cell, side_dof_indices+n_dofs[0]);
1159 n_dofs[1] = fv_sb[1]->n_dofs();
1163 element_id[0] = cell_sub.
index();
1164 element_id[1] = cell.
index();
1168 calculate_velocity(cell, velocity_higher, fsv_rt);
1169 calculate_velocity(cell_sub, velocity_lower, fv_rt);
1170 Model::compute_advection_diffusion_coefficients(fe_values_vb.
point_list(), velocity_lower, cell_sub->element_accessor(), ad_coef_edg[0], dif_coef_edg[0]);
1171 Model::compute_advection_diffusion_coefficients(fe_values_vb.
point_list(), velocity_higher, cell->element_accessor(), ad_coef_edg[1], dif_coef_edg[1]);
1172 Model::compute_mass_matrix_coefficient(fe_values_vb.
point_list(), cell_sub->element_accessor(), mm_coef_lower);
1173 Model::compute_mass_matrix_coefficient(fe_values_vb.
point_list(), cell->element_accessor(), mm_coef_higher);
1174 data_.cross_section.value_list(fe_values_vb.
point_list(), cell_sub->element_accessor(), csection_lower);
1175 data_.cross_section.value_list(fe_values_vb.
point_list(), cell->element_accessor(), csection_higher);
1176 data_.fracture_sigma.value_list(fe_values_vb.
point_list(), cell_sub->element_accessor(), frac_sigma);
1178 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1180 for (
unsigned int i=0; i<n_dofs[0]+n_dofs[1]; i++)
1181 for (
unsigned int j=0; j<n_dofs[0]+n_dofs[1]; j++)
1182 local_matrix[i*(n_dofs[0]+n_dofs[1])+j] = 0;
1185 for (
unsigned int k=0; k<qsize; k++)
1195 double sigma = frac_sigma[k][sbi]*arma::dot(dif_coef_edg[0][sbi][k]*fe_values_side.
normal_vector(k),fe_values_side.
normal_vector(k))*
1196 2*csection_higher[k]*csection_higher[k]/(csection_lower[k]*csection_lower[k]);
1199 double transport_flux = arma::dot(ad_coef_edg[1][sbi][k], fe_values_side.
normal_vector(k));
1200 double por_lower_over_higher = mm_coef_lower[k]*csection_higher[k]/(mm_coef_higher[k]*csection_lower[k]);
1202 comm_flux[0][0] = (sigma-min(0.,transport_flux*por_lower_over_higher))*fv_sb[0]->JxW(k);
1203 comm_flux[0][1] = -(sigma-min(0.,transport_flux*por_lower_over_higher))*fv_sb[0]->JxW(k);
1204 comm_flux[1][0] = -(sigma+max(0.,transport_flux))*fv_sb[0]->JxW(k);
1205 comm_flux[1][1] = (sigma+max(0.,transport_flux))*fv_sb[0]->JxW(k);
1207 for (
int n=0; n<2; n++)
1209 if (!feo->dh()->el_is_local(element_id[n]))
continue;
1211 for (
unsigned int i=0; i<n_dofs[n]; i++)
1212 for (
int m=0; m<2; m++)
1213 for (
unsigned int j=0; j<n_dofs[m]; j++)
1214 local_matrix[(i+n*n_dofs[0])*(n_dofs[0]+n_dofs[1]) + m*n_dofs[0] + j] +=
1215 comm_flux[m][n]*fv_sb[m]->shape_value(j,k)*fv_sb[n]->shape_value(i,k);
1218 ls[sbi]->mat_set_values(n_dofs[0]+n_dofs[1], (
int *)side_dof_indices, n_dofs[0]+n_dofs[1], (
int *)side_dof_indices, local_matrix);
1229 template<
class Model>
1234 balance_->start_flux_assembly(subst_idx);
1235 set_boundary_conditions<1>();
1236 set_boundary_conditions<2>();
1237 set_boundary_conditions<3>();
1239 balance_->finish_flux_assembly(subst_idx);
1244 template<
class Model>
1245 template<
unsigned int dim>
1248 FESideValues<dim,3> fe_values_side(*feo->mapping<dim>(), *feo->q<dim-1>(), *feo->fe<dim>(),
1252 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim-1>()->size();
1254 unsigned int loc_b=0;
1255 double local_rhs[ndofs];
1257 PetscScalar local_flux_balance_rhs;
1263 for (
unsigned int loc_el = 0; loc_el < feo->dh()->el_ds()->lsize(); loc_el++)
1266 if (elm->boundary_idx_ ==
nullptr)
continue;
1270 Edge *edg = elm->side(si)->edge();
1271 if (edg->
n_sides > 1)
continue;
1273 if (edg->
side(0)->
cond() == NULL)
continue;
1275 if (edg->
side(0)->
dim() != dim-1)
1277 if (edg->
side(0)->
cond() !=
nullptr) ++loc_b;
1285 arma::uvec bc_type = data_.bc_type.value(side->
cond()->
element()->
centre(), ele_acc);
1287 fe_values_side.reinit(cell, side->
el_idx());
1288 fsv_rt.reinit(cell, side->
el_idx());
1289 calculate_velocity(cell, velocity, fsv_rt);
1291 Model::compute_advection_diffusion_coefficients(fe_values_side.point_list(), velocity, side->
element()->element_accessor(), ad_coef, dif_coef);
1292 Model::compute_dirichlet_bc(fe_values_side.point_list(), ele_acc, bc_values);
1293 data_.bc_flux.value_list(fe_values_side.point_list(), ele_acc, bc_fluxes);
1294 data_.bc_robin_sigma.value_list(fe_values_side.point_list(), ele_acc, bc_sigma);
1296 feo->dh()->get_dof_indices(cell, (
unsigned int *)&(side_dof_indices[0]));
1298 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1300 fill_n(local_rhs, ndofs, 0);
1301 local_flux_balance_vector.assign(ndofs, 0);
1302 local_flux_balance_rhs = 0;
1304 double side_flux = 0;
1305 for (
unsigned int k=0; k<qsize; k++)
1306 side_flux += arma::dot(ad_coef[sbi][k], fe_values_side.normal_vector(k))*fe_values_side.JxW(k);
1307 double transport_flux = side_flux/side->
measure();
1309 for (
unsigned int k=0; k<qsize; k++)
1314 if (bc_type[sbi] == EqData::inflow && side_flux < 0)
1316 bc_term = -transport_flux*bc_values[k][sbi]*fe_values_side.JxW(k);
1318 else if (bc_type[sbi] == EqData::dirichlet)
1320 bc_term = gamma[sbi][side->
cond_idx()]*bc_values[k][sbi]*fe_values_side.JxW(k);
1321 bc_grad = -bc_values[k][sbi]*fe_values_side.JxW(k)*dg_variant*(arma::trans(dif_coef[sbi][k])*fe_values_side.normal_vector(k));
1323 else if (bc_type[sbi] == EqData::neumann)
1325 bc_term = -bc_fluxes[k][sbi]*fe_values_side.JxW(k);
1327 else if (bc_type[sbi] == EqData::robin)
1329 bc_term = bc_sigma[k][sbi]*bc_values[k][sbi]*fe_values_side.JxW(k);
1332 for (
unsigned int i=0; i<ndofs; i++)
1334 local_rhs[i] += bc_term*fe_values_side.shape_value(i,k)
1335 + arma::dot(bc_grad,fe_values_side.shape_grad(i,k));
1339 if (bc_type[sbi] == EqData::dirichlet)
1341 local_flux_balance_vector[i] += (arma::dot(ad_coef[sbi][k], fe_values_side.normal_vector(k))*fe_values_side.shape_value(i,k)
1342 - arma::dot(dif_coef[sbi][k]*fe_values_side.shape_grad(i,k),fe_values_side.normal_vector(k))
1343 + gamma[sbi][side->
cond_idx()]*fe_values_side.shape_value(i,k))*fe_values_side.JxW(k);
1344 local_flux_balance_rhs -= (
time_->
tlevel() == 0?0:1)*bc_term*fe_values_side.shape_value(i,k);
1346 else if (bc_type[sbi] == EqData::inflow && side_flux < 0)
1348 local_flux_balance_rhs -= bc_term*fe_values_side.shape_value(i,k);
1350 else if (bc_type[sbi] == EqData::neumann)
1352 local_flux_balance_vector[i] += arma::dot(ad_coef[sbi][k], fe_values_side.normal_vector(k))*fe_values_side.JxW(k)*fe_values_side.shape_value(i,k);
1353 local_flux_balance_rhs -= bc_term*fe_values_side.shape_value(i,k);
1355 else if (bc_type[sbi] == EqData::robin)
1357 local_flux_balance_vector[i] += (arma::dot(ad_coef[sbi][k], fe_values_side.normal_vector(k)) + bc_sigma[k][sbi])*fe_values_side.JxW(k)*fe_values_side.shape_value(i,k);
1358 local_flux_balance_rhs -= bc_term*fe_values_side.shape_value(i,k);
1362 local_flux_balance_vector[i] += arma::dot(ad_coef[sbi][k], fe_values_side.normal_vector(k))*fe_values_side.JxW(k)*fe_values_side.shape_value(i,k);
1367 ls[sbi]->rhs_set_values(ndofs, &(side_dof_indices[0]), local_rhs);
1371 balance_->add_flux_matrix_values(subst_idx[sbi], loc_b, side_dof_indices, local_flux_balance_vector);
1372 balance_->add_flux_vec_value(subst_idx[sbi], loc_b, local_flux_balance_rhs);
1387 template<
class Model>
1388 template<
unsigned int dim>
1392 for (
unsigned int i=0; i<cell->n_nodes(); i++)
1393 node_nums[cell->node[i]] = i;
1397 for (
unsigned int k=0; k<fv.
n_points(); k++)
1399 velocity[k].zeros();
1400 for (
unsigned int sid=0; sid<cell->n_sides(); sid++)
1402 if (cell->side(sid)->dim() != dim-1)
continue;
1403 int num = dim*(dim+1)/2;
1404 for (
unsigned int i=0; i<cell->side(sid)->n_nodes(); i++)
1405 num -= node_nums[cell->side(sid)->node(i)];
1415 template<
class Model>
1424 const double alpha1,
1425 const double alpha2,
1428 double &transport_flux)
1432 double local_alpha = 0;
1444 for (
unsigned int i=0; i<s->n_nodes(); i++)
1445 for (
unsigned int j=i+1; j<s->n_nodes(); j++)
1446 h = max(h, s->node(i)->distance(*s->node(j)));
1450 double pflux = 0, nflux = 0;
1451 for (
int i=0; i<edg.
n_sides; i++)
1460 if (fluxes[s2] > 0 && fluxes[s1] < 0 && s1 < s2)
1461 transport_flux = fluxes[s1]*fabs(fluxes[s2]/pflux);
1462 else if (fluxes[s2] < 0 && fluxes[s1] > 0 && s1 < s2)
1463 transport_flux = fluxes[s1]*fabs(fluxes[s2]/nflux);
1465 transport_flux = fluxes[s1];
1469 gamma = 0.5*fabs(transport_flux);
1473 local_alpha = max(alpha1, alpha2);
1481 for (
int k=0; k<K_size; k++)
1482 delta[0] += dot(K1[k]*normal_vector,normal_vector);
1485 gamma += local_alpha/h*(delta[0]);
1491 for (
int k=0; k<K_size; k++)
1493 delta[0] += dot(K1[k]*normal_vector,normal_vector);
1494 delta[1] += dot(K2[k]*normal_vector,normal_vector);
1499 double delta_sum = delta[0] + delta[1];
1503 omega[0] = delta[1]/delta_sum;
1504 omega[1] = delta[0]/delta_sum;
1505 gamma += local_alpha/h*(delta[0]*delta[1]/delta_sum);
1508 for (
int i=0; i<2; i++) omega[i] = 0;
1517 template<
class Model>
1526 double delta = 0, h = 0;
1529 if (side->
dim() == 0)
1535 for (
unsigned int i=0; i<side->
n_nodes(); i++)
1536 for (
unsigned int j=i+1; j<side->
n_nodes(); j++)
1541 for (
int k=0; k<K_size; k++)
1542 delta += dot(K[k]*normal_vector,normal_vector);
1545 gamma = 0.5*fabs(flux) + alpha/h*delta;
1552 template<
class Model>
1556 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1557 ls[sbi]->start_allocation();
1558 prepare_initial_condition<1>();
1559 prepare_initial_condition<2>();
1560 prepare_initial_condition<3>();
1562 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1563 ls[sbi]->start_add_assembly();
1564 prepare_initial_condition<1>();
1565 prepare_initial_condition<2>();
1566 prepare_initial_condition<3>();
1568 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1570 ls[sbi]->finish_assembly();
1576 template<
class Model>
1577 template<
unsigned int dim>
1580 FEValues<dim,3> fe_values(*feo->mapping<dim>(), *feo->q<dim>(), *feo->fe<dim>(),
1582 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim>()->size();
1583 unsigned int dof_indices[ndofs];
1584 double matrix[ndofs*ndofs], rhs[ndofs];
1587 for (
unsigned int k=0; k<qsize; k++)
1588 init_values[k].resize(n_subst_);
1590 for (
unsigned int i_cell=0; i_cell<feo->dh()->el_ds()->lsize(); i_cell++)
1593 if (elem->dim() != dim)
continue;
1596 feo->dh()->get_dof_indices(elem, dof_indices);
1599 Model::compute_init_cond(fe_values.
point_list(), ele_acc, init_values);
1601 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1603 for (
unsigned int i=0; i<ndofs; i++)
1606 for (
unsigned int j=0; j<ndofs; j++)
1607 matrix[i*ndofs+j] = 0;
1610 for (
unsigned int k=0; k<qsize; k++)
1612 double rhs_term = init_values[k](sbi)*fe_values.
JxW(k);
1614 for (
unsigned int i=0; i<ndofs; i++)
1616 for (
unsigned int j=0; j<ndofs; j++)
1622 ls[sbi]->set_values(ndofs, (
int *)dof_indices, ndofs, (
int *)dof_indices, matrix, rhs);
1628 template<
class Model>
1631 calc_fluxes<1>(bcd_balance, bcd_plus_balance, bcd_minus_balance);
1632 calc_fluxes<2>(bcd_balance, bcd_plus_balance, bcd_minus_balance);
1633 calc_fluxes<3>(bcd_balance, bcd_plus_balance, bcd_minus_balance);
1636 template<
class Model>
1637 template<
unsigned int dim>
1644 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim-1>()->size();
1645 unsigned int dof_indices[ndofs];
1647 vector<arma::vec> bc_values(qsize, arma::vec(n_subst_)), bc_fluxes(qsize, arma::vec(n_subst_)), bc_sigma(qsize, arma::vec(n_subst_));
1650 for (
unsigned int iedg=0; iedg<feo->dh()->n_loc_edges(); iedg++)
1653 if (edg->
n_sides > 1)
continue;
1654 if (edg->
side(0)->
dim() != dim-1)
continue;
1656 if (edg->
side(0)->
cond() == NULL)
continue;
1665 fe_values.reinit(cell, side->
el_idx());
1666 fsv_rt.reinit(cell, side->
el_idx());
1667 feo->dh()->get_dof_indices(cell, dof_indices);
1668 calculate_velocity(cell, side_velocity, fsv_rt);
1669 Model::compute_advection_diffusion_coefficients(fe_values.point_list(), side_velocity, ele_acc, ad_coef, dif_coef);
1670 Model::compute_dirichlet_bc(fe_values.point_list(), side->
cond()->
element_accessor(), bc_values);
1672 data_.bc_robin_sigma.value_list(fe_values.point_list(), side->
cond()->
element_accessor(), bc_sigma);
1675 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1677 double mass_flux = 0;
1678 double water_flux = 0;
1679 for (
unsigned int k=0; k<qsize; k++)
1680 water_flux += arma::dot(ad_coef[sbi][k], fe_values.normal_vector(k))*fe_values.JxW(k);
1681 water_flux /= side->
measure();
1683 for (
unsigned int k=0; k<qsize; k++)
1687 for (
unsigned int i=0; i<ndofs; i++)
1689 conc += fe_values.shape_value(i,k)*ls[sbi]->get_solution_array()[dof_indices[i]-feo->dh()->loffset()];
1690 conc_grad += fe_values.shape_grad(i,k)*ls[sbi]->get_solution_array()[dof_indices[i]-feo->dh()->loffset()];
1694 if (bc_type[sbi] == EqData::inflow && water_flux < 0)
1695 mass_flux += water_flux*bc_values[k][sbi]*fe_values.JxW(k);
1697 mass_flux += water_flux*conc*fe_values.JxW(k);
1699 if (bc_type[sbi] == EqData::dirichlet)
1702 mass_flux -= arma::dot(dif_coef[sbi][k]*conc_grad,fe_values.normal_vector(k))*fe_values.JxW(k);
1705 mass_flux -= gamma[sbi][side->
cond_idx()]*(bc_values[k][sbi] - conc)*fe_values.JxW(k);
1707 else if (bc_type[sbi] == EqData::neumann)
1710 mass_flux += bc_fluxes[k][sbi]*fe_values.JxW(k);
1712 else if (bc_type[sbi] == EqData::robin)
1715 mass_flux += bc_sigma[k][sbi]*(conc - bc_values[k][sbi])*fe_values.JxW(k);
1719 bcd_balance[sbi][bc_region_idx] += mass_flux;
1720 if (mass_flux >= 0) bcd_plus_balance[sbi][bc_region_idx] += mass_flux;
1721 else bcd_minus_balance[sbi][bc_region_idx] += mass_flux;
1727 template<
class Model>
1730 calc_elem_sources<1>(mass, src_balance);
1731 calc_elem_sources<2>(mass, src_balance);
1732 calc_elem_sources<3>(mass, src_balance);
1735 template<
class Model>
1736 template<
unsigned int dim>
1739 FEValues<dim,3> fe_values(*feo->mapping<dim>(), *feo->q<dim>(), *feo->fe<dim>(),
1741 const unsigned int ndofs = feo->fe<dim>()->n_dofs(), qsize = feo->q<dim>()->size();
1742 unsigned int dof_indices[ndofs];
1746 double mass_sum, sources_sum, conc, conc_diff;
1748 for (
unsigned int i_cell=0; i_cell<feo->dh()->el_ds()->lsize(); i_cell++)
1751 if (elem->dim() != dim)
continue;
1753 Region r = elem->element_accessor().region();
1755 unsigned int region_idx = r.
bulk_idx();
1758 fe_values.reinit(elem);
1759 feo->dh()->get_dof_indices(elem, dof_indices);
1761 Model::compute_mass_matrix_coefficient(fe_values.point_list(), ele_acc, mm_coef);
1762 Model::compute_source_coefficients(fe_values.point_list(), ele_acc, sources_conc, sources_density, sources_sigma);
1764 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
1769 for (
unsigned int k=0; k<qsize; k++)
1772 for (
unsigned int i=0; i<ndofs; i++)
1773 conc += fe_values.shape_value(i,k)*ls[sbi]->get_solution_array()[dof_indices[i]-feo->dh()->loffset()];
1775 mass_sum += mm_coef[k]*conc*fe_values.JxW(k);
1777 conc_diff = sources_conc[k][sbi] - conc;
1778 sources_sum += (sources_density[k][sbi] + conc_diff*sources_sigma[k][sbi])*fe_values.JxW(k);
1781 mass[sbi][region_idx] += mass_sum;
1782 src_balance[sbi][region_idx] += sources_sum;
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell...
Distribution * el_ds() const
Returns the distribution of number of element to local processes.
void assemble_fluxes_element_element()
Assembles the fluxes between elements of the same dimension.
void set_sources()
Assembles the right hand side due to volume sources.
void set_boundary_conditions()
Assembles the r.h.s. components corresponding to the Dirichlet boundary conditions.
Transformed quadrature weight for cell sides.
FiniteElement< dim, 3 > * fe()
vector< double > mm_coef
Mass matrix coefficients.
void assemble_fluxes_element_side()
Assembles the fluxes between elements of different dimensions.
static constexpr Mask in_main_matrix
A field is part of main "stiffness matrix" of the equation.
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
Input::Record output_rec
Record with output specification.
static constexpr Mask allow_output
The field can output. Is part of generated output selection. (default on)
const std::vector< std::string > & names()
Transport with dispersion implemented using discontinuous Galerkin method.
Field< 3, FieldValue< 3 >::Integer > region_id
void add_admissible_field_names(const Input::Array &in_array)
Registers names of output fields that can be written using this stream.
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
double distance(const Node &n2) const
void assemble_mass_matrix()
Assembles the mass matrix.
OutputTime * output_stream
int * get_el_4_loc() const
void next_time()
Proceed to the next time according to current estimated time step.
void update_solution() override
Computes the solution in one time instant.
const double JxW(const unsigned int point_no)
Return the product of Jacobian determinant and the quadrature weight at given quadrature point...
const arma::vec::fixed< spacedim > normal_vector(unsigned int point_no)
Returns the normal vector to a side at given quadrature point.
TimeMark::Type type_output()
int dg_variant
DG variant ((non-)symmetric/incomplete.
void prepare_initial_condition()
Assembles the auxiliary linear system to calculate the initial solution as L^2-projection of the pres...
RegionSet get_region_set(const string &set_name) const
const MH_DofHandler * mh_dh
Fields computed from the mesh data.
void set_initial_condition()
Sets the initial condition.
Class FEValues calculates finite element data on the actual cells such as shape function values...
#define FOR_ELEMENT_SIDES(i, j)
bool is_current(const TimeMark::Type &mask) const
vector< vector< arma::vec3 > > ad_coef
Advection coefficients.
static Input::Type::Record input_type
const RegionDB & region_db() const
void set_from_input(const Input::Record in_rec)
#define AVERAGE(i, k, side_id)
void assemble_stiffness_matrix()
Assembles the stiffness matrix.
const TimeStep & step(int index=-1) const
vector< vector< vector< arma::mat33 > > > dif_coef_edg
Diffusion coefficients on edges.
Discontinuous Galerkin method for equation of transport with dispersion.
vector< Boundary > boundary_
Basic time management functionality for unsteady (and steady) solvers (class Equation).
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
const arma::vec::fixed< spacedim > shape_grad(const unsigned int function_no, const unsigned int point_no)
Return the gradient of the function_no-th shape function at the point_no-th quadrature point...
unsigned int size() const
static TimeMarks & marks()
Specification of transport model interface.
void view(const char *name="") const
void assemble_fluxes_boundary()
Assembles the fluxes on the boundary.
Symmetric Gauss-Legendre quadrature formulae on simplices.
#define WAVERAGE(i, k, side_id)
const unsigned int n_points()
Returns the number of quadrature points.
unsigned int boundary_idx() const
Returns index of the region in the boundary set.
TransportDG(Mesh &init_mesh, const Input::Record &in_rec)
Constructor.
vector< double * > output_solution
Array for storing the output solution data.
vector< vector< vector< arma::vec3 > > > ad_coef_edg
Advection coefficients on edges.
Discontinuous Lagrangean finite element on dim dimensional simplex.
Transformed quadrature points.
void output_data()
Postprocesses the solution and writes to output file.
static OutputTime * create_output_stream(const Input::Record &in_rec)
This method delete all object instances of class OutputTime stored in output_streams vector...
vector< unsigned int > subst_idx
List of indices used to call balance methods for a set of quantities.
vector< vector< arma::mat33 > > dif_coef
Diffusion coefficients.
FEObjects * feo
Finite element objects.
static constexpr Mask in_time_term
A field is part of time term of the equation.
FieldCommon & input_default(const string &input_default)
TimeMark::Type equation_fixed_mark_type() const
Raviart-Thomas element of order 0.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
FieldCommon & input_selection(const Input::Type::Selection *element_selection)
static auto region_id(Mesh &mesh) -> IndexField
Mat mass_matrix
The mass matrix.
#define START_TIMER(tag)
Starts a timer with specified tag.
FiniteElement< dim, spacedim > * fe
The used finite element.
Provides the numbering of the finite element degrees of freedom on the computational mesh...
Mat * stiffness_matrix
The stiffness matrix.
Field< 3, FieldValue< 3 >::Vector > fracture_sigma
Transition parameter for diffusive transfer on fractures (for each substance).
boost::shared_ptr< Balance > balance_
(new) object for calculation and writing the mass balance to file.
unsigned int dg_order
Polynomial order of finite elements.
void output_vector_gather()
static constexpr Mask in_rhs
A field is part of the right hand side of the equation.
unsigned int n_subst_
Number of transported substances.
Affine mapping between reference and actual cell.
Shape function gradients.
void mark_output_times(const TimeGovernor &tg)
Vec * rhs
Vector of right hand side.
void set_solution(double *sol_array)
BCField< 3, FieldValue< 3 >::Vector > bc_flux
Flux in Neumann or Robin b.c.
static Input::Type::Selection bc_type_selection
DOFHandlerMultiDim * dh()
LinSys * ls_dt
Linear algebra system for the time derivative (actually it is used only for handling the matrix struc...
Discontinuous Galerkin method for equation of transport with dispersion.
const vector< arma::vec::fixed< spacedim > > & point_list()
Return coordinates of all quadrature points in the actual cell system.
void output_data() override
Write computed fields.
vector< Neighbour > vb_neighbours_
double side_flux(const Side &side) const
temporary replacement for DofHandler accessor, flux through given side
const arma::vec::fixed< spacedim > shape_vector(const unsigned int function_no, const unsigned int point_no)
Return the value of the function_no-th shape function at the point_no-th quadrature point...
FieldCommon & description(const string &description)
EqData data_
Field data for model parameters.
bool allocation_done
Indicates whether matrices have been preallocated.
unsigned int cond_idx() const
std::vector< std::vector< double > > gamma
Penalty parameters.
unsigned int max_edge_sides(unsigned int dim) const
Discontinuous Galerkin method for equation of transport with dispersion.
SubstanceList substances_
Transported substances.
ElementFullIter element() const
void calc_fluxes(vector< vector< double > > &bcd_balance, vector< vector< double > > &bcd_plus_balance, vector< vector< double > > &bcd_minus_balance)
Calculates flux through boundary of each region.
arma::vec3 centre() const
void reinit(ElementFullIter &cell, unsigned int sid)
Update cell-dependent data (gradients, Jacobians etc.)
const double shape_value(const unsigned int function_no, const unsigned int point_no)
Return the value of the function_no-th shape function at the point_no-th quadrature point...
BCField< 3, FieldValue< 3 >::EnumVector > bc_type
Type of boundary condition (see also BC_Type)
void reinit(ElementFullIter &cell)
Update cell-dependent data (gradients, Jacobians etc.)
Vec * mass_vec
Mass from previous time instant (necessary when coefficients of mass matrix change in time)...
std::vector< Edge > edges
Vector of MH edges, this should not be part of the geometrical mesh.
FullIter full_iter(Iter it)
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
Abstract linear system class.
Definitions of particular quadrature rules on simplices.
FieldCommon & name(const string &name)
void calc_elem_sources(vector< vector< double > > &mass, vector< vector< double > > &src_balance)
Calculates volume sources for each region.
vector< Vec > output_vec
Vector of solution data.
Calculates finite element data on the actual cell.
#define END_TIMER(tag)
Ends a timer with specified tag.
Discontinuous Galerkin method for equation of transport with dispersion.
virtual void set_velocity_field(const MH_DofHandler &dh)
Updates the velocity field which determines some coefficients of the transport equation.
mixed-hybrid model of linear Darcy flow, possibly unsteady.
unsigned int el_idx() const
unsigned int n_substances() override
Returns number of trnasported substances.
void assemble_volume_integrals()
Assembles the volume integrals into the stiffness matrix.
bool is_valid() const
Returns false if the region has undefined/invalid value.
FieldCommon & flags(FieldFlag::Flags::Mask mask)
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
Base class for FEValues and FESideValues.
Class for representation SI units of Fields.
const Node * node(unsigned int i) const
void calculate_velocity(const ElementFullIter &cell, std::vector< arma::vec3 > &velocity, FEValuesBase< dim, 3 > &fv)
Calculates the velocity field on a given dim dimensional cell.
Distribution * distr() const
Mapping< dim, 3 > * mapping()
static UnitSI & dimensionless()
Returns dimensionless unit.
~TransportDG()
Destructor.
LinSys ** ls
Linear algebra system for the transport equation.
void set_DG_parameters_edge(const Edge &edg, const int s1, const int s2, const int K_size, const std::vector< arma::mat33 > &K1, const std::vector< arma::mat33 > &K2, const std::vector< double > &fluxes, const arma::vec3 &normal_vector, const double alpha1, const double alpha2, double &gamma, double *omega, double &transport_flux)
Sets up some parameters of the DG method for two sides of an edge.
SideIter side(const unsigned int i) const
Field< 3, FieldValue< 3 >::Vector > dg_penalty
Penalty enforcing inter-element continuity of solution (for each substance).
#define JUMP(i, k, side_id)
void set_DG_parameters_boundary(const SideIter side, const int K_size, const std::vector< arma::mat33 > &K, const double flux, const arma::vec3 &normal_vector, const double alpha, double &gamma)
Sets up parameters of the DG method on a given boundary edge.
Definitions of Raviart-Thomas finite elements.
const unsigned int n_global_dofs() const
Getter for the number of all mesh dofs required by the given finite element.
BCField< 3, FieldValue< 3 >::Vector > bc_robin_sigma
Transition coefficient in Robin b.c.
ElementAccessor< 3 > element_accessor()
void zero_time_step() override
Initialize solution in the zero time.
FEObjects(Mesh *mesh_, unsigned int fe_order)
ElementVector element
Vector of elements of the mesh.
unsigned int n_nodes() const
Transformed quadrature weights.
Calculates finite element data on a side.
unsigned int lsize(int proc) const
get local size