NuTo
Numerics Tool
Constraints.h
Go to the documentation of this file.
1 #pragma once
2 #include <set>
3 #include <eigen3/Eigen/Sparse>
6 
7 namespace NuTo
8 {
9 namespace Constraint
10 {
11 
33 {
34  JKNumbering(Eigen::VectorXi indices, int numK)
35  : mIndices(indices)
36  , mNumJ(indices.size() - numK)
37  , mNumK(numK)
38  {
39  }
40 
41  Eigen::VectorXi mIndices;
42  int mNumJ;
43  int mNumK;
44 };
45 
48 {
49  using Equations = std::vector<Equation>;
50 
51 public:
55  void Add(DofType dof, Equation equation);
56 
60  void Add(DofType dof, std::vector<Equation> equations);
61 
66  Eigen::VectorXd GetRhs(DofType dof, double time) const;
67 
73  Eigen::SparseVector<double> GetSparseGlobalRhs(DofType dof, int numDofs, double time) const;
74 
83  JKNumbering GetJKNumbering(DofType dof, int numDofs) const;
84 
90  Eigen::SparseMatrix<double> BuildUnitConstraintMatrix(DofType dof, int numDofs) const;
91 
95  int GetNumEquations(DofType dof) const;
96 
101  const Equation& GetEquation(DofType dof, int equationNumber) const;
102 
103 private:
105  DofContainer<Equations> mEquations;
106 
107 
112  class TermChecker
113  {
114  public:
117  // - the dependent term of `e` is in any existing equation
118  // - any term of `e` is in the depenend terms of any existing equation
119  void CheckEquation(Equation e);
120 
121  private:
122  struct TermCompare
123  {
124  bool operator()(const Term& lhs, const Term& rhs) const;
125  };
126 
127  std::set<Term, TermCompare> mDependentTerms;
128  std::set<Term, TermCompare> mIndependentTerms;
129  } mTermChecker;
130 };
131 
132 
133 } /* Constaint */
134 } /* NuTo */
Eigen::VectorXi mIndices
Definition: Constraints.h:41
stores a constraint equation
Definition: Equation.h:12
Definition: DofType.h:8
stores constraint equations, separated by their dof type
Definition: Constraints.h:47
represents a numbering where first the independent dofs are consecutively numbered leaving out the de...
Definition: Constraints.h:32
JKNumbering(Eigen::VectorXi indices, int numK)
Definition: Constraints.h:34
equation
Definition: Brick8NCoupling.py:106
Definition: Exception.h:6
rhs
Definition: SparseDirectSolverMKLDSS.py:46
int mNumJ
Definition: Constraints.h:42
void Add(DofVector< double > &rResult, const DofVector< double > &v, const DofVector< int > &numbering, std::vector< DofType > dofTypes={})
adds an arbitrary contribution v to the internal DofVector
Definition: Assembler.cpp:20
stores constraint equation terms
Definition: Term.h:10
int mNumK
Definition: Constraints.h:43