3 #include "../../include/matrixFreePDE.h" 4 #include "../../include/vectorBCFunction.h" 5 #include "../../include/varBCs.h" 6 #include "../../include/nonUniformDirichletBC.h" 11 template <
int dim,
int degree>
19 unsigned int starting_BC_list_index = 0;
20 for (
unsigned int i=0; i<currentFieldIndex; i++){
21 if (userInputs.var_type[i] ==
SCALAR){
22 starting_BC_list_index++;
25 starting_BC_list_index+=dim;
29 if (userInputs.var_type[currentFieldIndex] ==
SCALAR){
30 for (
unsigned int direction = 0; direction < 2*dim; direction++){
31 if (userInputs.BC_list[starting_BC_list_index].var_BC_type[direction] ==
NEUMANN){
33 typename DoFHandler<dim>::active_cell_iterator cell = dofHandlersSet[0]->begin_active(), endc = dofHandlersSet[0]->end();
34 FESystem<dim>* fe= FESet[currentFieldIndex];
35 QGaussLobatto<dim-1> face_quadrature_formula(degree+1);
36 FEFaceValues<dim> fe_face_values (*fe, face_quadrature_formula, update_values | update_JxW_values);
37 const unsigned int n_face_q_points = face_quadrature_formula.size(), dofs_per_cell=fe->dofs_per_cell;
38 Vector<double> cell_rhs(dofs_per_cell);
39 std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
42 for (;cell!=endc; ++cell){
43 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f){
44 if (cell->face(f)->at_boundary()){
45 if (cell->face(f)->boundary_id() == direction){
46 fe_face_values.reinit (cell, f);
48 for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point){
49 double neumann_value = userInputs.BC_list[starting_BC_list_index].var_BC_val[direction];
50 for (
unsigned int i=0; i<dofs_per_cell; ++i){
51 cell_rhs(i) += (neumann_value * fe_face_values.shape_value(i,q_point) * fe_face_values.JxW(q_point));
54 cell->get_dof_indices (local_dof_indices);
56 for (
unsigned int i=0; i<dofs_per_cell; ++i){
57 (*(residualSet[currentFieldIndex]))[local_dof_indices[i]] += cell_rhs(i);
74 template <
int dim,
int degree>
77 unsigned int starting_BC_list_index = 0;
79 for (
unsigned int i=0; i<currentFieldIndex; i++){
81 if (userInputs.var_type[i] ==
SCALAR){
82 starting_BC_list_index++;
85 starting_BC_list_index+=dim;
89 if (userInputs.var_type[currentFieldIndex] ==
SCALAR){
90 for (
unsigned int direction = 0; direction < 2*dim; direction++){
91 if (userInputs.BC_list[starting_BC_list_index].var_BC_type[direction] ==
DIRICHLET){
92 VectorTools::interpolate_boundary_values (*dofHandlersSet[currentFieldIndex],\
93 direction, ConstantFunction<dim>(userInputs.BC_list[starting_BC_list_index].var_BC_val[direction],1), *(ConstraintMatrix*) \
94 constraintsDirichletSet[currentFieldIndex]);
98 VectorTools::interpolate_boundary_values (*dofHandlersSet[currentFieldIndex],\
100 constraintsDirichletSet[currentFieldIndex]);
105 for (
unsigned int direction = 0; direction < 2*dim; direction++){
107 std::vector<double> BC_values;
108 for (
unsigned int component=0; component < dim; component++){
109 BC_values.push_back(userInputs.BC_list[starting_BC_list_index+component].var_BC_val[direction]);
112 std::vector<bool> mask;
113 for (
unsigned int component=0; component < dim; component++){
114 if (userInputs.BC_list[starting_BC_list_index+component].var_BC_type[direction] ==
DIRICHLET){
115 mask.push_back(
true);
118 mask.push_back(
false);
122 VectorTools::interpolate_boundary_values (*dofHandlersSet[currentFieldIndex],\
124 constraintsDirichletSet[currentFieldIndex],mask);
128 for (
unsigned int component=0; component < dim; component++){
129 if (userInputs.BC_list[starting_BC_list_index+component].var_BC_type[direction] ==
NON_UNIFORM_DIRICHLET){
130 mask.push_back(
true);
133 mask.push_back(
false);
140 VectorTools::interpolate_boundary_values (*dofHandlersSet[currentFieldIndex],\
142 constraintsDirichletSet[currentFieldIndex],mask);
150 template <
int dim,
int degree>
152 std::vector<GridTools::PeriodicFacePair<typename parallel::distributed::Triangulation<dim>::cell_iterator> > periodicity_vector;
153 for (
int i=0; i<dim; ++i){
154 bool periodic_pair =
false;
155 for (
unsigned int field_num=0; field_num < userInputs.BC_list.size(); field_num++){
156 if (userInputs.BC_list[field_num].var_BC_type[2*i] ==
PERIODIC){
157 periodic_pair =
true;
160 if (periodic_pair ==
true){
161 GridTools::collect_periodic_faces(triangulation, 2*i, 2*i+1,
162 i, periodicity_vector);
166 triangulation.add_periodicity(periodicity_vector);
167 pcout <<
"periodic facepairs: " << periodicity_vector.size() << std::endl;
171 template <
int dim,
int degree>
174 unsigned int starting_BC_list_index = 0;
175 for (
unsigned int i=0; i<currentFieldIndex; i++){
176 if (userInputs.var_type[i] ==
SCALAR){
177 starting_BC_list_index++;
180 starting_BC_list_index+=dim;
184 std::vector<GridTools::PeriodicFacePair<typename DoFHandler<dim>::cell_iterator> > periodicity_vector;
185 for (
int i=0; i<dim; ++i){
186 if (userInputs.BC_list[starting_BC_list_index].var_BC_type[2*i] ==
PERIODIC){
187 GridTools::collect_periodic_faces(*dof_handler, 2*i, 2*i+1,
188 i, periodicity_vector);
191 DoFTools::make_periodicity_constraints<DoFHandler<dim> >(periodicity_vector, *constraints);
196 template <
int dim,
int degree>
202 unsigned int starting_BC_list_index = 0;
203 for (
unsigned int i=0; i<currentFieldIndex; i++){
204 if (userInputs.var_type[i] ==
SCALAR){
205 starting_BC_list_index++;
208 starting_BC_list_index+=dim;
213 unsigned int num_components = 1;
214 if (userInputs.var_type[currentFieldIndex] ==
VECTOR){
215 num_components = dim;
219 for (
unsigned int component=0; component < num_components; component++){
220 bool rigidBodyMode =
true;
221 for (
unsigned int direction = 0; direction < 2*dim; direction++){
223 if (userInputs.BC_list[starting_BC_list_index+component].var_BC_type[direction] ==
DIRICHLET){
224 rigidBodyMode =
false;
229 if (rigidBodyMode ==
true){
230 rigidBodyModeComponents.push_back(component);
237 template <
int dim,
int degree>
240 if ( rigidBodyModeComponents.size() > 0 ){
243 dealii::Point<dim> target_point;
245 unsigned int vertices_per_cell=GeometryInfo<dim>::vertices_per_cell;
248 typename DoFHandler<dim>::active_cell_iterator cell= dof_handler->begin_active(), endc = dof_handler->end();
250 for (; cell!=endc; ++cell){
251 if (cell->is_locally_owned()){
252 for (
unsigned int i=0; i<vertices_per_cell; ++i){
255 if (target_point.distance (cell->vertex(i)) < 1e-2 * cell->diameter()){
258 for (
unsigned int component_num = 0; component_num < rigidBodyModeComponents.size(); component_num++){
259 unsigned int nodeID=cell->vertex_dof_index(i,component_num);
260 constraints->add_line(nodeID);
261 constraints->set_inhomogeneity(nodeID,0.0);
270 #include "../../include/matrixFreePDE_template_instantiations.h" void getComponentsWithRigidBodyModes(std::vector< int > &) const
void setRigidBodyModeConstraints(const std::vector< int >, ConstraintMatrix *, const DoFHandler< dim > *) const
void setPeriodicityConstraints(ConstraintMatrix *, const DoFHandler< dim > *) const