MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
unconstrained_dofs.hpp
Go to the documentation of this file.
1 /*
2 * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3 * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #ifndef __mast_libmesh_unconstrained_dofs_h__
21 #define __mast_libmesh_unconstrained_dofs_h__
22 
23 // MAST includes
25 #include <mast/base/exceptions.hpp>
26 
27 // libMesh includes
28 #include <libmesh/dof_map.h>
29 
30 namespace MAST {
31 namespace Numerics {
32 namespace libMeshWrapper {
33 
38 template <typename IntType>
39 void unconstrained_dofs(const libMesh::DofMap &dof_map,
40  std::vector<IntType> &dofs) {
41 
42  std::set<IntType>
43  local_non_condensed_dofs_set;
44 
45  for (IntType i=dof_map.first_dof(); i<dof_map.end_dof(); i++) {
46 
47  if (!dof_map.is_constrained_dof(i))
48  local_non_condensed_dofs_set.insert(i);
49  }
50 
51  typename std::set<IntType>::const_iterator
52  it = local_non_condensed_dofs_set.begin(),
53  end = local_non_condensed_dofs_set.end();
54 
55  dofs.clear();
56  dofs.reserve(local_non_condensed_dofs_set.size());
57 
58  for ( ; it != end; it++)
59  dofs.push_back(*it);
60 }
61 
62 } // namespace libMeshWrapper
63 } // namespace Numerics
64 } // namespace MAST
65 
66 #endif // __mast_libmesh_unconstrained_dofs_h__
void unconstrained_dofs(const libMesh::DofMap &dof_map, std::vector< IntType > &dofs)
copies the unconstrained dofs for the dof_map in the vector dofs.