33 #include "libmesh/dof_map.h"
34 #include "libmesh/getpot.h"
35 #include "libmesh/node.h"
36 #include "libmesh/system.h"
41 libMesh::System& system )
44 std::vector<std::string> var_sections;
48 for (std::vector<std::string>::const_iterator
49 it = var_sections.begin(); it != var_sections.end(); ++it)
51 const std::string & section_name = *it;
52 const std::string constraint_section =
54 section_name +
'/' +
"ConstrainedPoints";
56 if (input.have_section (constraint_section))
58 std::vector<std::string> point_sections =
59 input.get_subsection_names(constraint_section);
61 for (std::vector<std::string>::const_iterator
62 pt_it = point_sections.begin();
63 pt_it != point_sections.end(); ++pt_it)
69 const std::string point_section =
70 constraint_section +
'/' + pt.
name;
74 std::string constrained_var_name =
76 section_name +
'/' +
"names", std::string(),
80 constrained_var_name =
81 input(point_section +
"/constraint_var",
82 constrained_var_name);
84 pt.
var =
_sys.variable_number(constrained_var_name);
86 const unsigned int constrained_loc_dim =
87 input.vector_variable_size(point_section+
"/constraint_location");
88 libmesh_assert_less_equal(constrained_loc_dim, LIBMESH_DIM);
89 for (
unsigned int d=0; d != constrained_loc_dim; ++d)
90 pt(d) = input(point_section+
"/constraint_location", 0.0, d );
92 const unsigned int n_constraining_points_x =
93 input.vector_variable_size(point_section+
"/constraining_points_x");
96 const unsigned int n_constraining_points_y =
97 input.vector_variable_size(point_section+
"/constraining_points_y");
98 if (n_constraining_points_y)
99 libmesh_assert_equal_to(n_constraining_points_x, n_constraining_points_y);
101 const unsigned int n_constraining_points_z =
102 input.vector_variable_size(point_section+
"/constraining_points_z");
103 if (n_constraining_points_z)
104 libmesh_assert_equal_to(n_constraining_points_x, n_constraining_points_z);
106 const unsigned int n_constraining_points_var =
107 input.vector_variable_size(point_section+
"/constraining_points_var");
108 libmesh_assert_equal_to(n_constraining_points_x, n_constraining_points_var);
110 const unsigned int n_constraining_points_coeff =
111 input.vector_variable_size(point_section+
"/constraining_points_coeff");
112 if (n_constraining_points_coeff)
113 libmesh_assert_equal_to(n_constraining_points_x, n_constraining_points_coeff);
116 for (
unsigned int n=0; n != n_constraining_points_x; ++n)
119 constraining_pt(0) = input(point_section+
"/constraining_points_x", 0.0, n);
121 constraining_pt(1) = input(point_section+
"/constraining_points_y", 0.0, n);
123 constraining_pt(2) = input(point_section+
"/constraining_points_z", 0.0, n);
125 constraining_pt.
coeff =
126 input(point_section+
"/constraining_points_coeff", libMesh::Number(0), n);
128 const std::string var_name
129 (input(point_section+
"/constraining_points_var", std::string(), n));
131 constraining_pt.
var =
_sys.variable_number(var_name);
136 pt.
rhs = input(point_section+
"/constraint_rhs", 0.0);
148 libMesh::MeshBase & mesh =
_sys.get_mesh();
149 const unsigned int sys_num =
_sys.number();
151 libMesh::UniquePtr<libMesh::PointLocatorBase> locator =
152 mesh.sub_point_locator();
154 for (std::vector<ConstrainedPoint>::const_iterator
158 const libMesh::Point & pt = constrained_pt;
161 const libMesh::Node *constrained_node = locator->locate_node(pt);
166 bool found_node = constrained_node;
167 _sys.comm().max(found_node);
169 libmesh_error_msg(
"Failed to find a Node at point " << pt);
177 const libMesh::dof_id_type constrained_dof =
178 constrained_node ? constrained_node->dof_number
179 (sys_num, constrained_pt.
var, 0) : 0;
182 (
_sys.comm().semiverify (constrained_node ? &constrained_dof
185 libMesh::DofConstraintRow constraint_row;
187 for (std::vector<ConstrainingPoint>::const_iterator
192 const libMesh::Point & pt2 = constraining_pt;
194 const libMesh::Node *constraining_node =
195 locator->locate_node(pt2);
201 bool found_node = constraining_node;
202 _sys.comm().max(found_node);
205 (
"Failed to find a Node at point " << pt);
208 libMesh::dof_id_type constraining_dof =
209 constraining_node ? constraining_node->dof_number
210 (sys_num, constraining_pt.
var, 0) : 0;
213 (
_sys.comm().semiverify (constraining_node ?
217 _sys.comm().max(constraining_dof);
219 if (constrained_node)
220 constraint_row[constraining_dof] = constraining_pt.
coeff;
223 if (constrained_node)
224 _sys.get_dof_map().add_constraint_row
225 (constrained_dof, constraint_row, constrained_pt.
rhs,
std::vector< ConstrainingPoint > constrainers
static std::string variables_section()
Helper function to encapsualte the overall [Variables] section name.
ConstrainedPoints(const GetPot &input, libMesh::System &system)
static void parse_var_sections_vector(const GetPot &input, std::vector< std::string > §ions)
The same as parse_var_sections, except the result is returned in an std::vector.
std::vector< ConstrainedPoint > _constrained_pts