KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
linear_master_slave_constraint.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Aditya Ghantasala
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
20 #include "includes/define.h"
22 
23 namespace Kratos
24 {
27 
31 
35 
39 
43 
56 class KRATOS_API(KRATOS_CORE) LinearMasterSlaveConstraint
57  : public MasterSlaveConstraint
58 {
59 public:
62 
65 
68 
71 
74 
77 
80 
83 
86 
89 
92 
96 
100 
106  : BaseType(Id)
107  {
108  }
109 
119  IndexType Id,
120  DofPointerVectorType& rMasterDofsVector,
121  DofPointerVectorType& rSlaveDofsVector,
122  const MatrixType& rRelationMatrix,
123  const VectorType& rConstantVector
124  ) : BaseType(Id),
125  mSlaveDofsVector(rSlaveDofsVector),
126  mMasterDofsVector(rMasterDofsVector),
127  mRelationMatrix(rRelationMatrix),
128  mConstantVector(rConstantVector)
129  {
130  }
131 
143  IndexType Id,
144  NodeType& rMasterNode,
145  const VariableType& rMasterVariable,
146  NodeType& rSlaveNode,
147  const VariableType& rSlaveVariable,
148  const double Weight,
149  const double Constant
150  );
151 
154  {
155 
156  }
157 
160  : BaseType(rOther),
161  mSlaveDofsVector(rOther.mSlaveDofsVector),
162  mMasterDofsVector(rOther.mMasterDofsVector),
163  mRelationMatrix(rOther.mRelationMatrix),
164  mConstantVector(rOther.mConstantVector)
165  {
166  }
167 
170  {
171  BaseType::operator=( rOther );
172  mSlaveDofsVector = rOther.mSlaveDofsVector;
173  mMasterDofsVector = rOther.mMasterDofsVector;
174  mRelationMatrix = rOther.mRelationMatrix;
175  mConstantVector = rOther.mConstantVector;
176  return *this;
177  }
178 
182 
186 
196  MasterSlaveConstraint::Pointer Create(
197  IndexType Id,
198  DofPointerVectorType& rMasterDofsVector,
199  DofPointerVectorType& rSlaveDofsVector,
200  const MatrixType& rRelationMatrix,
201  const VectorType& rConstantVector
202  ) const override
203  {
204  KRATOS_TRY
205  return Kratos::make_shared<LinearMasterSlaveConstraint>(Id, rMasterDofsVector, rSlaveDofsVector, rRelationMatrix, rConstantVector);
206  KRATOS_CATCH("");
207  }
208 
220  MasterSlaveConstraint::Pointer Create(
221  IndexType Id,
222  NodeType& rMasterNode,
223  const VariableType& rMasterVariable,
224  NodeType& rSlaveNode,
225  const VariableType& rSlaveVariable,
226  const double Weight,
227  const double Constant
228  ) const override
229  {
230  KRATOS_TRY
231  return Kratos::make_shared<LinearMasterSlaveConstraint>(Id, rMasterNode, rMasterVariable, rSlaveNode, rSlaveVariable, Weight, Constant);
232  KRATOS_CATCH("");
233  }
234 
240  MasterSlaveConstraint::Pointer Clone (IndexType NewId) const override
241  {
242  KRATOS_TRY
243 
244  MasterSlaveConstraint::Pointer p_new_const = Kratos::make_shared<LinearMasterSlaveConstraint>(*this);
245  p_new_const->SetId(NewId);
246  p_new_const->SetData(this->GetData());
247  p_new_const->Set(Flags(*this));
248  return p_new_const;
249 
250  KRATOS_CATCH("");
251  }
252 
260  DofPointerVectorType& rSlaveDofsVector,
261  DofPointerVectorType& rMasterDofsVector,
262  const ProcessInfo& rCurrentProcessInfo
263  ) const override
264  {
265  rSlaveDofsVector = mSlaveDofsVector;
266  rMasterDofsVector = mMasterDofsVector;
267  }
268 
276  const DofPointerVectorType& rSlaveDofsVector,
277  const DofPointerVectorType& rMasterDofsVector,
278  const ProcessInfo& rCurrentProcessInfo
279  ) override
280  {
281  mSlaveDofsVector = rSlaveDofsVector;
282  mMasterDofsVector = rMasterDofsVector;
283  }
284 
291  void EquationIdVector(
292  EquationIdVectorType& rSlaveEquationIds,
293  EquationIdVectorType& rMasterEquationIds,
294  const ProcessInfo& rCurrentProcessInfo
295  ) const override;
296 
301  const DofPointerVectorType& GetSlaveDofsVector() const override
302  {
303  return mSlaveDofsVector;
304  }
305 
310  void SetSlaveDofsVector(const DofPointerVectorType& rSlaveDofsVector) override
311  {
312  mSlaveDofsVector = rSlaveDofsVector;
313  }
314 
320  {
321  return mMasterDofsVector;
322  }
323 
328  void SetMasterDofsVector(const DofPointerVectorType& rMasterDofsVector) override
329  {
330  mMasterDofsVector = rMasterDofsVector;
331  }
332 
337  void ResetSlaveDofs(const ProcessInfo& rCurrentProcessInfo) override;
338 
343  void Apply(const ProcessInfo& rCurrentProcessInfo) override;
344 
351  void SetLocalSystem(
352  const MatrixType& rRelationMatrix,
353  const VectorType& rConstantVector,
354  const ProcessInfo& rCurrentProcessInfo
355  ) override;
356 
364  void CalculateLocalSystem(
365  MatrixType& rRelationMatrix,
366  VectorType& rConstantVector,
367  const ProcessInfo& rCurrentProcessInfo
368  ) const override;
369 
373 
378  std::string GetInfo() const override
379  {
380  return "Linear User Provided Master Slave Constraint class !";
381  }
382 
387  void PrintInfo(std::ostream &rOStream) const override
388  {
389  rOStream << " LinearMasterSlaveConstraint Id : " << this->Id() << std::endl;
390  rOStream << " Number of Slaves : " << mSlaveDofsVector.size() << std::endl;
391  rOStream << " Number of Masters : " << mMasterDofsVector.size() << std::endl;
392  }
393 
395 protected:
398 
402 
407 
409 
410 private:
411 
414 
415  friend class Serializer;
416 
417  void save(Serializer &rSerializer) const override;
418 
419  void load(Serializer &rSerializer) override;
420 
422 
423 };
424 
427 
429 inline std::istream& operator>>(std::istream& rIStream, LinearMasterSlaveConstraint& rThis);
430 
432 inline std::ostream& operator<<(std::ostream& rOStream,
433  const LinearMasterSlaveConstraint& rThis)
434 {
435  rThis.PrintInfo(rOStream);
436  rOStream << std::endl;
437 
438  return rOStream;
439 }
440 
442 
443 } // namespace Kratos
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
Definition: flags.h:58
This class allows to add a master-slave constraint which is of the form SlaveDofVector = T * MasterDo...
Definition: linear_master_slave_constraint.h:58
std::string GetInfo() const override
Returns the string containing a detailed description of this object.
Definition: linear_master_slave_constraint.h:378
LinearMasterSlaveConstraint(const LinearMasterSlaveConstraint &rOther)
Copy Constructor.
Definition: linear_master_slave_constraint.h:159
void SetSlaveDofsVector(const DofPointerVectorType &rSlaveDofsVector) override
This method returns the slave dof vector.
Definition: linear_master_slave_constraint.h:310
LinearMasterSlaveConstraint(IndexType Id, DofPointerVectorType &rMasterDofsVector, DofPointerVectorType &rSlaveDofsVector, const MatrixType &rRelationMatrix, const VectorType &rConstantVector)
Constructor by passing a vector of Master and slave dofs and corresponding Matrix and constant vector...
Definition: linear_master_slave_constraint.h:118
const DofPointerVectorType & GetMasterDofsVector() const override
This method returns the slave dof vector.
Definition: linear_master_slave_constraint.h:319
BaseType::MatrixType MatrixType
The matrix type definition.
Definition: linear_master_slave_constraint.h:82
BaseType::DofPointerVectorType DofPointerVectorType
The DoF pointer vector type definition.
Definition: linear_master_slave_constraint.h:73
LinearMasterSlaveConstraint & operator=(const LinearMasterSlaveConstraint &rOther)
Assignment operator.
Definition: linear_master_slave_constraint.h:169
void SetMasterDofsVector(const DofPointerVectorType &rMasterDofsVector) override
This method returns the slave dof vector.
Definition: linear_master_slave_constraint.h:328
BaseType::IndexType IndexType
The index type definition.
Definition: linear_master_slave_constraint.h:67
BaseType::VariableType VariableType
The variable type definition (double)
Definition: linear_master_slave_constraint.h:88
MasterSlaveConstraint::Pointer Create(IndexType Id, NodeType &rMasterNode, const VariableType &rMasterVariable, NodeType &rSlaveNode, const VariableType &rSlaveVariable, const double Weight, const double Constant) const override
Create method by passing a single Master and slave dofs and corresponding weight and constant for a v...
Definition: linear_master_slave_constraint.h:220
const DofPointerVectorType & GetSlaveDofsVector() const override
This method returns the slave dof vector.
Definition: linear_master_slave_constraint.h:301
BaseType::VectorType VectorType
The vector type definition.
Definition: linear_master_slave_constraint.h:85
BaseType::EquationIdVectorType EquationIdVectorType
The equation Id vector type definition.
Definition: linear_master_slave_constraint.h:79
KRATOS_CLASS_POINTER_DEFINITION(LinearMasterSlaveConstraint)
Pointer definition of DataValueContainer.
MasterSlaveConstraint BaseType
The definition of the base class, we take the rest of the definitions from the base class.
Definition: linear_master_slave_constraint.h:64
void PrintInfo(std::ostream &rOStream) const override
This method prints the current Constraint Id.
Definition: linear_master_slave_constraint.h:387
MatrixType mRelationMatrix
The DoFs of master side.
Definition: linear_master_slave_constraint.h:405
DofPointerVectorType mSlaveDofsVector
Definition: linear_master_slave_constraint.h:403
MasterSlaveConstraint::Pointer Create(IndexType Id, DofPointerVectorType &rMasterDofsVector, DofPointerVectorType &rSlaveDofsVector, const MatrixType &rRelationMatrix, const VectorType &rConstantVector) const override
Create method by passing a single Master and slave dofs and corresponding weight and constant for a v...
Definition: linear_master_slave_constraint.h:196
void GetDofList(DofPointerVectorType &rSlaveDofsVector, DofPointerVectorType &rMasterDofsVector, const ProcessInfo &rCurrentProcessInfo) const override
Determines the constrant's slvae and master list of DOFs.
Definition: linear_master_slave_constraint.h:259
~LinearMasterSlaveConstraint() override
Destructor.
Definition: linear_master_slave_constraint.h:153
DofPointerVectorType mMasterDofsVector
The DoFs of slave side.
Definition: linear_master_slave_constraint.h:404
LinearMasterSlaveConstraint(IndexType Id=0)
The default constructor.
Definition: linear_master_slave_constraint.h:105
MasterSlaveConstraint::Pointer Clone(IndexType NewId) const override
It creates a new constraint pointer and clones the previous constraint data.
Definition: linear_master_slave_constraint.h:240
VectorType mConstantVector
The relation matrix between the master/slave DoF.
Definition: linear_master_slave_constraint.h:406
void SetDofList(const DofPointerVectorType &rSlaveDofsVector, const DofPointerVectorType &rMasterDofsVector, const ProcessInfo &rCurrentProcessInfo) override
Determines the constrant's slave and master list of DOFs.
Definition: linear_master_slave_constraint.h:275
BaseType::NodeType NodeType
The node type definition.
Definition: linear_master_slave_constraint.h:76
BaseType::DofType DofType
The DoF type definition.
Definition: linear_master_slave_constraint.h:70
A class that implements the interface for different master-slave constraints to be applied on a syste...
Definition: master_slave_constraint.h:76
std::size_t IndexType
The index type definition.
Definition: master_slave_constraint.h:85
std::vector< std::size_t > EquationIdVectorType
The equation Id vector type definition.
Definition: master_slave_constraint.h:97
std::vector< DofType::Pointer > DofPointerVectorType
The DoF pointer vector type definition.
Definition: master_slave_constraint.h:91
This class defines the node.
Definition: node.h:65
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
void ResetSlaveDofs(ModelPart &rModelPart)
This method resets the values of the slave dofs.
Definition: constraint_utilities.cpp:136
Matrix MatrixType
Definition: geometrical_transformation_utilities.h:55
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
def load(f)
Definition: ode_solve.py:307