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.
node.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: Pooyan Dadvand
11 // Riccardo Rossi
12 //
13 
14 #pragma once
15 
16 // System includes
17 #include <string>
18 #include <iostream>
19 #include <sstream>
20 #include <cstddef>
21 #include <atomic>
22 
23 // External includes
24 
25 // Project includes
26 #include "includes/define.h"
27 #include "includes/lock_object.h"
28 #include "geometries/point.h"
29 #include "includes/dof.h"
32 #include "containers/flags.h"
33 #include "intrusive_ptr/intrusive_ptr.hpp"
36 #include "containers/nodal_data.h"
37 #include "includes/kratos_flags.h"
38 
39 namespace Kratos
40 {
41 
44 
48 
52 
56 
60 
62 
64 class Node : public Point, public Flags
65 {
66 public:
69 
72 
74  using NodeType = Node;
75 
77  using BaseType = Point;
78 
80  using PointType = Point;
81 
84 
86  using IndexType = std::size_t;
87 
89  using SizeType = std::size_t;
90 
92  using DofsContainerType = std::vector<std::unique_ptr<Dof<double>>>;
93 
96 
99 
103 
106  : BaseType()
107  , Flags()
108  , mNodalData(0)
109  , mDofs()
110  , mData()
111  , mInitialPosition()
112  , mNodeLock()
113  {
115  }
116 
117  explicit Node(IndexType NewId )
118  : BaseType()
119  , Flags()
120  , mNodalData(NewId)
121  , mDofs()
122  , mData()
123  , mInitialPosition()
124  , mNodeLock()
125  {
126  KRATOS_ERROR << "Calling the default constructor for the node ... illegal operation!!" << std::endl;
128  }
129 
131  Node(IndexType NewId, double const& NewX)
132  : BaseType(NewX)
133  , Flags()
134  , mNodalData(NewId)
135  , mDofs()
136  , mData()
137  , mInitialPosition(NewX)
138  , mNodeLock()
139  {
141  }
142 
144  Node(IndexType NewId, double const& NewX, double const& NewY)
145  : BaseType(NewX, NewY)
146  , Flags()
147  , mNodalData(NewId)
148  , mDofs()
149  , mData()
150  , mInitialPosition(NewX, NewY)
151  , mNodeLock()
152  {
154  }
155 
157  Node(IndexType NewId, double const& NewX, double const& NewY, double const& NewZ)
158  : BaseType(NewX, NewY, NewZ)
159  , Flags()
160  , mNodalData(NewId)
161  , mDofs()
162  , mData()
163  , mInitialPosition(NewX, NewY, NewZ)
164  , mNodeLock()
165  {
167  }
168 
170  Node(IndexType NewId, PointType const& rThisPoint)
171  : BaseType(rThisPoint)
172  , Flags()
173  , mNodalData(NewId)
174  , mDofs()
175  , mData()
176  , mInitialPosition(rThisPoint)
177  , mNodeLock()
178  {
180  }
181 
183  Node(Node const& rOtherNode) = delete;
184 
188  template<class TVectorType>
189  Node(IndexType NewId, vector_expression<TVectorType> const& rOtherCoordinates)
190  : BaseType(rOtherCoordinates)
191  , Flags()
192  , mNodalData(NewId)
193  , mDofs()
194  , mData()
195  , mInitialPosition(rOtherCoordinates)
196  , mNodeLock()
197  {
199  }
200 
201 
202 
205  Node(IndexType NewId, std::vector<double> const& rOtherCoordinates)
206  : BaseType(rOtherCoordinates)
207  , Flags()
208  , mNodalData(NewId)
209  , mDofs()
210  , mData()
211  , mInitialPosition()
212  , mNodeLock()
213  {
215  }
216 
218  Node(IndexType NewId, double const& NewX, double const& NewY, double const& NewZ, VariablesList::Pointer pVariablesList, BlockType const * ThisData, SizeType NewQueueSize = 1)
219  : BaseType(NewX, NewY, NewZ)
220  , Flags()
221  , mNodalData(NewId, pVariablesList,ThisData,NewQueueSize)
222  , mDofs()
223  , mData()
224  , mInitialPosition(NewX, NewY, NewZ)
225  , mNodeLock()
226  {
227  }
228 
229  typename Node::Pointer Clone()
230  {
231  Node::Pointer p_new_node = Kratos::make_intrusive<Node >( this->Id(), (*this)[0], (*this)[1], (*this)[2]);
232  p_new_node->mNodalData = this->mNodalData;
233 
234  Node::DofsContainerType& my_dofs = (this)->GetDofs();
235  for (typename DofsContainerType::const_iterator it_dof = my_dofs.begin(); it_dof != my_dofs.end(); it_dof++)
236  {
237  p_new_node->pAddDof(**it_dof);
238  }
239 
240  p_new_node->mData = this->mData;
241  p_new_node->mInitialPosition = this->mInitialPosition;
242 
243  p_new_node->Set(Flags(*this));
244 
245  return p_new_node;
246  }
247 
249  ~Node() override
250  {
252  }
253 
254  //*********************************************
255  //public API of intrusive_ptr
256  unsigned int use_count() const noexcept
257  {
258  return mReferenceCounter;
259  }
260  //*********************************************
261 
262  IndexType Id() const
263  {
264  return mNodalData.Id();
265  }
266 
267  IndexType GetId() const
268  {
269  return mNodalData.Id();
270  }
271 
272  void SetId(IndexType NewId)
273  {
274  mNodalData.SetId(NewId);
275  }
276 
278  {
279  return mNodeLock;
280  }
281 
282  inline void SetLock()
283  {
284  mNodeLock.lock();
285  }
286 
287  inline void UnSetLock()
288  {
289  mNodeLock.unlock();
290  }
291 
295 
297  Node& operator=(const Node& rOther)
298  {
299  BaseType::operator=(rOther);
300  Flags::operator =(rOther);
301 
302  mNodalData = rOther.mNodalData;
303 
304  // Deep copying the dofs
305  for(typename DofsContainerType::const_iterator it_dof = rOther.mDofs.begin() ; it_dof != rOther.mDofs.end() ; it_dof++)
306  {
307  pAddDof(**it_dof);
308  }
309 
310  mData = rOther.mData;
311  mInitialPosition = rOther.mInitialPosition;
312 
313  return *this;
314  }
315 
316  bool operator==(const Node& rOther)
317  {
318  return PointType::operator ==(rOther);
319  }
320 
321  template<class TVariableType> typename TVariableType::Type& operator()(const TVariableType& rThisVariable, IndexType SolutionStepIndex)
322  {
323  return GetSolutionStepValue(rThisVariable, SolutionStepIndex);
324  }
325 
326  template<class TVariableType> typename TVariableType::Type& operator()(const TVariableType& rThisVariable)
327  {
328  return GetSolutionStepValue(rThisVariable);
329  }
330 
331  template<class TDataType> TDataType& operator[](const Variable<TDataType>& rThisVariable)
332  {
333  return GetValue(rThisVariable);
334  }
335 
336  template<class TDataType> const TDataType& operator[](const Variable<TDataType>& rThisVariable) const
337  {
338  return GetValue(rThisVariable);
339  }
340 
341  double& operator[](IndexType ThisIndex)
342  {
343  return BaseType::operator[](ThisIndex);
344  }
345 
346  double operator[](IndexType ThisIndex) const
347  {
348  return BaseType::operator[](ThisIndex);
349  }
350 
354 
356  {
358  }
359 
361  {
363  }
364 
365  void OverwriteSolutionStepData(IndexType SourceSolutionStepIndex, IndexType DestinationSourceSolutionStepIndex)
366  {
367  SolutionStepData().AssignData(SolutionStepData().Data(SourceSolutionStepIndex), DestinationSourceSolutionStepIndex);
368  }
369 
371  {
373  }
374 
375  void SetSolutionStepVariablesList(VariablesList::Pointer pVariablesList)
376  {
377  SolutionStepData().SetVariablesList(pVariablesList);
378  }
379 
381  {
382  return mNodalData.GetSolutionStepData();
383  }
384 
386  {
387  return mNodalData.GetSolutionStepData();
388  }
389 
390  KRATOS_DEPRECATED_MESSAGE("This method is deprecated. Use 'GetData()' instead.")
392  {
393  return mData;
394  }
395 
397  {
398  return mData;
399  }
400 
402  {
403  return mData;
404  }
405 
406  template<class TVariableType> typename TVariableType::Type& GetSolutionStepValue(const TVariableType& rThisVariable)
407  {
408  return SolutionStepData().GetValue(rThisVariable);
409  }
410 
411  template<class TVariableType> typename TVariableType::Type const& GetSolutionStepValue(const TVariableType& rThisVariable) const
412  {
413  return SolutionStepData().GetValue(rThisVariable);
414  }
415 
416  template<class TVariableType> typename TVariableType::Type& GetSolutionStepValue(const TVariableType& rThisVariable, IndexType SolutionStepIndex)
417  {
418  return SolutionStepData().GetValue(rThisVariable, SolutionStepIndex);
419  }
420 
421  template<class TVariableType> typename TVariableType::Type const& GetSolutionStepValue(const TVariableType& rThisVariable, IndexType SolutionStepIndex) const
422  {
423  return SolutionStepData().GetValue(rThisVariable, SolutionStepIndex);
424  }
425 
426 
427  bool SolutionStepsDataHas(const VariableData& rThisVariable) const
428  {
429  return SolutionStepData().Has(rThisVariable);
430  }
431 
432  //*******************************************************************************************
433  //By Riccardo
434  //very similar to the one before BUT throws an error if the variable does not exist
435  template<class TVariableType> typename TVariableType::Type& FastGetSolutionStepValue(const TVariableType& rThisVariable)
436  {
437  return SolutionStepData().FastGetValue(rThisVariable);
438  }
439 
440  template<class TVariableType> const typename TVariableType::Type& FastGetSolutionStepValue(const TVariableType& rThisVariable) const
441  {
442  return SolutionStepData().FastGetValue(rThisVariable);
443  }
444 
445  template<class TVariableType> typename TVariableType::Type& FastGetSolutionStepValue(const TVariableType& rThisVariable, IndexType SolutionStepIndex)
446  {
447  return SolutionStepData().FastGetValue(rThisVariable, SolutionStepIndex);
448  }
449 
450  template<class TVariableType> const typename TVariableType::Type& FastGetSolutionStepValue(const TVariableType& rThisVariable, IndexType SolutionStepIndex) const
451  {
452  return SolutionStepData().FastGetValue(rThisVariable, SolutionStepIndex);
453  }
454 
455  template<class TVariableType> typename TVariableType::Type& FastGetSolutionStepValue(const TVariableType& rThisVariable, IndexType SolutionStepIndex, IndexType ThisPosition)
456  {
457  return SolutionStepData().FastGetValue(rThisVariable, SolutionStepIndex, ThisPosition);
458  }
459 
460  template<class TVariableType> typename TVariableType::Type& FastGetCurrentSolutionStepValue(const TVariableType& rThisVariable, IndexType ThisPosition)
461  {
462  return SolutionStepData().FastGetCurrentValue(rThisVariable, ThisPosition);
463  }
464 //*******************************************************************************************
465 
466  template<class TVariableType> typename TVariableType::Type& GetValue(const TVariableType& rThisVariable)
467  {
468  return mData.GetValue(rThisVariable);
469  }
470 
471  template<class TVariableType> typename TVariableType::Type const& GetValue(const TVariableType& rThisVariable) const
472  {
473  return mData.GetValue(rThisVariable);
474  }
475 
476  template<class TVariableType> typename TVariableType::Type& GetValue(const TVariableType& rThisVariable, IndexType SolutionStepIndex)
477  {
478  if(!mData.Has(rThisVariable))
479  return SolutionStepData().GetValue(rThisVariable, SolutionStepIndex);
480 
481  return mData.GetValue(rThisVariable);
482  }
483 
484  template<class TVariableType> typename TVariableType::Type const& GetValue(const TVariableType& rThisVariable, IndexType SolutionStepIndex) const
485  {
486  if(!mData.Has(rThisVariable))
487  return SolutionStepData().GetValue(rThisVariable, SolutionStepIndex);
488 
489  return mData.GetValue(rThisVariable);
490  }
491 
492  template<class TVariableType>
493  void SetValue(const TVariableType& rThisVariable, typename TVariableType::Type const& rValue)
494  {
495  mData.SetValue(rThisVariable, rValue);
496  }
497 
498  template<class TDataType> bool Has(const Variable<TDataType>& rThisVariable) const
499  {
500  return mData.Has(rThisVariable);
501  }
502 
506 
507  template<class TVariableType>
508  inline void Fix(const TVariableType& rDofVariable)
509  {
510  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
511  if((*it_dof)->GetVariable() == rDofVariable){
512  (*it_dof)->FixDof();
513  return;
514  }
515  }
516 
517 #ifdef KRATOS_DEBUG
518  if(OpenMPUtils::IsInParallel() != 0)
519  {
520  KRATOS_ERROR << "Attempting to Fix the variable: " << rDofVariable << " within a parallel region. This is not permitted. Create the Dof first by pAddDof" << std::endl;
521  }
522 #endif
523  pAddDof(rDofVariable)->FixDof();
524  }
525 
526  template<class TVariableType>
527  inline void Free(const TVariableType& rDofVariable)
528  {
529  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
530  if((*it_dof)->GetVariable() == rDofVariable){
531  (*it_dof)->FreeDof();
532  return;
533  }
534  }
535 
536 #ifdef KRATOS_DEBUG
537  if(OpenMPUtils::IsInParallel() != 0)
538  {
539  KRATOS_ERROR << "Attempting to Free the variable: " << rDofVariable << " within a parallel region. This is not permitted. Create the Dof first by pAddDof" << std::endl;
540  }
541 #endif
542  pAddDof(rDofVariable)->FreeDof();
543  }
544 
546  {
547  return SolutionStepData().QueueSize();
548  }
549 
550  void SetBufferSize(IndexType NewBufferSize)
551  {
552  SolutionStepData().Resize(NewBufferSize);
553  }
554 
558 
560  {
561  return mInitialPosition;
562  }
564  {
565  return mInitialPosition;
566  }
567 
568  double& X0()
569  {
570  return mInitialPosition.X();
571  }
572  double& Y0()
573  {
574  return mInitialPosition.Y();
575  }
576  double& Z0()
577  {
578  return mInitialPosition.Z();
579  }
580 
581  double X0() const
582  {
583  return mInitialPosition.X();
584  }
585  double Y0() const
586  {
587  return mInitialPosition.Y();
588  }
589  double Z0() const
590  {
591  return mInitialPosition.Z();
592  }
593 
594  void SetInitialPosition(const PointType& NewInitialPosition)
595  {
596  mInitialPosition.X() = NewInitialPosition.X();
597  mInitialPosition.Y() = NewInitialPosition.Y();
598  mInitialPosition.Z() = NewInitialPosition.Z();
599  }
600 
601  void SetInitialPosition(double X,double Y, double Z)
602  {
603  mInitialPosition.X() = X;
604  mInitialPosition.Y() = Y;
605  mInitialPosition.Z() = Z;
606  }
607 
608  VariablesList::Pointer pGetVariablesList()
609  {
611  }
612 
613  const VariablesList::Pointer pGetVariablesList() const
614  {
616  }
617 
621 
628  template<class TVariableType>
629  inline unsigned int GetDofPosition(TVariableType const& rDofVariable) const
630  {
631  typename DofsContainerType::const_iterator it_dof = mDofs.end();
632  for(it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
633  if((*it_dof)->GetVariable() == rDofVariable){
634  break;
635  }
636  }
637 
638  return it_dof - mDofs.begin();
639  }
640 
648  template<class TVariableType>
649  inline const DofType& GetDof(TVariableType const& rDofVariable, int pos) const
650  {
651  typename DofsContainerType::const_iterator it_begin = mDofs.begin();
652  typename DofsContainerType::const_iterator it_end = mDofs.end();
653  typename DofsContainerType::const_iterator it;
654  //if the guess is exact return the guess
655  if(pos < it_end-it_begin)
656  {
657  it = it_begin + pos;
658  if( (*it)->GetVariable() == rDofVariable)
659  {
660  return **it;
661  }
662  }
663 
664  // Otherwise do a find
665  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
666  if((*it_dof)->GetVariable() == rDofVariable){
667  return **it_dof;
668  }
669  }
670 
671  KRATOS_ERROR << "Non-existent DOF in node #" << Id() << " for variable : " << rDofVariable.Name() << std::endl;
672  }
673 
680  template<class TVariableType>
681  inline const DofType& GetDof(TVariableType const& rDofVariable) const
682  {
683  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
684  if((*it_dof)->GetVariable() == rDofVariable){
685  return **it_dof;
686  }
687  }
688 
689  KRATOS_ERROR << "Non-existent DOF in node #" << Id() << " for variable : " << rDofVariable.Name() << std::endl;
690 
691  }
692 
695  {
696  return mDofs;
697  }
698 
699  const DofsContainerType& GetDofs() const
700  {
701  return mDofs;
702  }
703 
710  template<class TVariableType>
711  inline typename DofType::Pointer pGetDof(TVariableType const& rDofVariable) const
712  {
713  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
714  if((*it_dof)->GetVariable() == rDofVariable){
715  return (*it_dof).get();
716  }
717  }
718 
719  KRATOS_ERROR << "Non-existent DOF in node #" << Id() << " for variable : " << rDofVariable.Name() << std::endl;
720 
721  }
722 
730  template<class TVariableType>
731  inline typename DofType::Pointer pGetDof(
732  TVariableType const& rDofVariable,
733  int Position
734  ) const
735  {
736  const auto it_begin = mDofs.begin();
737  const auto it_end = mDofs.end();
738  // If the guess is exact return the guess
739  if(Position < it_end-it_begin) {
740  auto it_dof = it_begin + Position;
741  if( (*it_dof)->GetVariable() == rDofVariable) {
742  return (*it_dof).get();
743  }
744  }
745 
746  // Otherwise do a find
747  for(auto it_dof = it_begin; it_dof != it_end; ++it_dof){
748  if((*it_dof)->GetVariable() == rDofVariable){
749  return (*it_dof).get();
750  }
751  }
752 
753  KRATOS_ERROR << "Non-existent DOF in node #" << Id() << " for variable : " << rDofVariable.Name() << std::endl;
754  }
755 
756 
758  template<class TVariableType>
759  inline typename DofType::Pointer pAddDof(TVariableType const& rDofVariable)
760  {
761  KRATOS_TRY
762 
763  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
764  if((*it_dof)->GetVariable() == rDofVariable){
765  return (*it_dof).get();
766  }
767  }
768 
769  mDofs.push_back(Kratos::make_unique<DofType>(&mNodalData, rDofVariable));
770 
771  DofType* p_new_dof = mDofs.back().get();
772 
773  SortDofs();
774 
775  return p_new_dof;
776 
777  KRATOS_CATCH(*this);
778  }
779 
781  inline typename DofType::Pointer pAddDof(DofType const& SourceDof)
782  {
783  KRATOS_TRY
784 
785  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
786  if((*it_dof)->GetVariable() == SourceDof.GetVariable()){
787  if((*it_dof)->GetReaction() != SourceDof.GetReaction())
788  {
789  **it_dof = SourceDof;
790  (*it_dof)->SetNodalData(&mNodalData);
791  }
792  return (*it_dof).get();
793  }
794  }
795 
796  mDofs.push_back(Kratos::make_unique<DofType>(SourceDof));
797  mDofs.back()->SetNodalData(&mNodalData);
798 
799  DofType* p_new_dof = mDofs.back().get();
800 
801  SortDofs();
802 
803  return p_new_dof;
804 
805  KRATOS_CATCH(*this);
806  }
807 
809  template<class TVariableType, class TReactionType>
810  inline typename DofType::Pointer pAddDof(TVariableType const& rDofVariable, TReactionType const& rDofReaction)
811  {
812  KRATOS_TRY
813 
814  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
815  if((*it_dof)->GetVariable() == rDofVariable){
816  (*it_dof)->SetReaction(rDofReaction);
817  return (*it_dof).get();
818  }
819  }
820 
821  mDofs.push_back(Kratos::make_unique<DofType>(&mNodalData, rDofVariable, rDofReaction));
822 
823  DofType* p_new_dof = mDofs.back().get();
824 
825  SortDofs();
826 
827  return p_new_dof;
828 
829  KRATOS_CATCH(*this);
830 
831  }
832 
834  template<class TVariableType>
835  inline DofType& AddDof(TVariableType const& rDofVariable)
836  {
837  KRATOS_TRY
838 
839  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
840  if((*it_dof)->GetVariable() == rDofVariable){
841  return **it_dof;
842  }
843  }
844 
845  mDofs.push_back(Kratos::make_unique<DofType>(&mNodalData, rDofVariable));
846 
847  DofType* p_new_dof = mDofs.back().get();
848 
849  SortDofs();
850 
851  return *p_new_dof;
852 
853  KRATOS_CATCH(*this);
854 
855  }
856 
858  template<class TVariableType, class TReactionType>
859  inline DofType& AddDof(TVariableType const& rDofVariable, TReactionType const& rDofReaction)
860  {
861  KRATOS_TRY
862 
863  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
864  if((*it_dof)->GetVariable() == rDofVariable){
865  (*it_dof)->SetReaction(rDofReaction);
866  return **it_dof;
867  }
868  }
869 
870  mDofs.push_back(Kratos::make_unique<DofType>(&mNodalData, rDofVariable, rDofReaction));
871 
872  DofType* p_new_dof = mDofs.back().get();
873 
874  SortDofs();
875 
876  return *p_new_dof;
877 
878  KRATOS_CATCH(*this);
879 
880  }
881 
885 
887  inline bool HasDofFor(const VariableData& rDofVariable) const
888  {
889  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
890  if((*it_dof)->GetVariable() == rDofVariable){
891  return true;
892  }
893  }
894  return false;
895  }
896 
897  inline bool IsFixed(const VariableData& rDofVariable) const
898  {
899  for(auto it_dof = mDofs.begin() ; it_dof != mDofs.end() ; it_dof++){
900  if((*it_dof)->GetVariable() == rDofVariable){
901  return (*it_dof)->IsFixed();
902  }
903  }
904  return false;
905  }
906 
911  inline bool IsActive() const
912  {
913  return IsDefined(ACTIVE) ? Is(ACTIVE) : true;
914  }
915 
919 
921  std::string Info() const override
922  {
923  std::stringstream buffer;
924  buffer << "Node #" << Id();
925  return buffer.str();
926  }
927 
929  void PrintInfo(std::ostream& rOStream) const override
930  {
931  rOStream << Info();
932  }
933 
935  void PrintData(std::ostream& rOStream) const override
936  {
937  BaseType::PrintData(rOStream);
938  if(!mDofs.empty())
939  rOStream << std::endl << " Dofs :" << std::endl;
940  for(typename DofsContainerType::const_iterator i = mDofs.begin() ; i != mDofs.end() ; i++)
941  rOStream << " " << (*i)->Info() << std::endl;
942  }
943 
947 
949 protected:
952 
956 
960 
964 
968 
972 
976 
978 private:
981 
985 
986  NodalData mNodalData;
987 
989  DofsContainerType mDofs;
990 
992  DataValueContainer mData;
993 
994 
996  PointType mInitialPosition;
997 
998  LockObject mNodeLock;
999 
1003  //*********************************************
1004  //this block is needed for refcounting
1005  mutable std::atomic<int> mReferenceCounter{0};
1006 
1007  friend void intrusive_ptr_add_ref(const NodeType* x)
1008  {
1009  x->mReferenceCounter.fetch_add(1, std::memory_order_relaxed);
1010  }
1011 
1012  friend void intrusive_ptr_release(const NodeType* x)
1013  {
1014  if (x->mReferenceCounter.fetch_sub(1, std::memory_order_release) == 1) {
1015  std::atomic_thread_fence(std::memory_order_acquire);
1016  delete x;
1017  }
1018  }
1019  //*********************************************
1020 
1021 
1022  void SortDofs(){
1023  std::sort(mDofs.begin(), mDofs.end(), [](Kratos::unique_ptr<DofType> const& First, Kratos::unique_ptr<DofType> const& Second)->bool{
1024  return First->GetVariable().Key() < Second->GetVariable().Key();
1025  });
1026  }
1030 
1034 
1035  friend class Serializer;
1036 
1037  void save(Serializer& rSerializer) const override
1038  {
1039  KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, Point );
1040  KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, Flags );
1041  rSerializer.save("NodalData", &mNodalData); // Storing it as pointer to be shared by Dof pointer
1042  rSerializer.save("Data", mData);
1043  rSerializer.save("Initial Position", mInitialPosition);
1044  rSerializer.save("Data", mDofs);
1045 
1046  }
1047 
1048  void load(Serializer& rSerializer) override
1049  {
1050  KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, Point );
1051  KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, Flags );
1052  NodalData* p_nodal_data = &mNodalData;
1053  rSerializer.load("NodalData", p_nodal_data);
1054  rSerializer.load("Data", mData);
1055  rSerializer.load("Initial Position", mInitialPosition);
1056  rSerializer.load("Data", mDofs);
1057  }
1058 
1062 
1066 
1070 
1072 
1073 }; // Class Node
1074 
1076 
1077 // template class KRATOS_API(KRATOS_CORE) KratosComponents<Node >;
1078 // template class KRATOS_API(KRATOS_CORE) KratosComponents<Node::Pointer >;
1079 
1082 
1083 
1087 
1088 
1090 inline std::istream& operator >> (std::istream& rIStream,
1091  Node& rThis);
1092 
1094 inline std::ostream& operator << (std::ostream& rOStream,
1095  const Node& rThis)
1096 {
1097  rThis.PrintInfo(rOStream);
1098  rOStream << " : ";
1099  rThis.PrintData(rOStream);
1100 
1101  return rOStream;
1102 }
1104 
1105 // namespace Globals
1106 // {
1107 // extern Node DefaultNode3;
1108 // }
1109 
1110 } // namespace Kratos.
Container for storing data values associated with variables.
Definition: data_value_container.h:63
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
void SetValue(const Variable< TDataType > &rThisVariable, TDataType const &rValue)
Sets the value for a given variable.
Definition: data_value_container.h:320
TDataType & GetValue(const Variable< TDataType > &rThisVariable)
Gets the value associated with a given variable.
Definition: data_value_container.h:268
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
const VariableData & GetVariable() const
Definition: dof.h:303
void FixDof()
Definition: dof.h:338
void SetNodalData(NodalData *pNewNodalData)
Definition: dof.h:355
void FreeDof()
Definition: dof.h:345
const VariableData & GetReaction() const
Definition: dof.h:309
Definition: flags.h:58
std::size_t IndexType
Definition: flags.h:74
bool IsDefined(Flags const &rOther) const
Definition: flags.h:279
bool Is(Flags const &rOther) const
Definition: flags.h:274
int64_t BlockType
Definition: flags.h:70
Flags()
Default constructor.
Definition: flags.h:119
Flags & operator=(Flags const &rOther)
Assignment operator.
Definition: flags.h:151
This class defines and stores a lock and gives an interface to it.
Definition: lock_object.h:42
void lock() const
Definition: lock_object.h:77
void unlock() const
Definition: lock_object.h:92
Stores all data and dofs which are stored in each elements.
Definition: nodal_data.h:37
void SetId(IndexType NewId)
Sets the Id of the Node.
Definition: nodal_data.h:95
IndexType Id() const
Returns the Id of the Node. Same as GetId to ensure backward compatibility.
Definition: nodal_data.h:83
VariablesListDataValueContainer & GetSolutionStepData()
Definition: nodal_data.h:106
This class defines the node.
Definition: node.h:65
const VariablesList::Pointer pGetVariablesList() const
Definition: node.h:613
TVariableType::Type const & GetValue(const TVariableType &rThisVariable, IndexType SolutionStepIndex) const
Definition: node.h:484
TVariableType::Type & GetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:406
PointType & GetInitialPosition()
Definition: node.h:563
void Fix(const TVariableType &rDofVariable)
Definition: node.h:508
void Free(const TVariableType &rDofVariable)
Definition: node.h:527
DataValueContainer & Data()
Definition: node.h:391
void SetBufferSize(IndexType NewBufferSize)
Definition: node.h:550
const TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable) const
Definition: node.h:440
DataValueContainer & GetData()
Definition: node.h:396
const TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable, IndexType SolutionStepIndex) const
Definition: node.h:450
const DofType & GetDof(TVariableType const &rDofVariable, int pos) const
Get dof with a given position. If not found it is search.
Definition: node.h:649
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: node.h:929
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
std::string Info() const override
Turn back information as a string.
Definition: node.h:921
IndexType Id() const
Definition: node.h:262
void SetLock()
Definition: node.h:282
IndexType GetId() const
Definition: node.h:267
DofType & AddDof(TVariableType const &rDofVariable, TReactionType const &rDofReaction)
Definition: node.h:859
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: node.h:935
void SetInitialPosition(const PointType &NewInitialPosition)
Definition: node.h:594
TVariableType::Type const & GetValue(const TVariableType &rThisVariable) const
Definition: node.h:471
void SetValue(const TVariableType &rThisVariable, typename TVariableType::Type const &rValue)
Definition: node.h:493
bool HasDofFor(const VariableData &rDofVariable) const
Definition: node.h:887
IndexType GetBufferSize() const
Definition: node.h:545
void ClearSolutionStepsData()
Definition: node.h:370
double X0() const
Definition: node.h:581
friend void intrusive_ptr_release(const NodeType *x)
Definition: node.h:1012
void SetInitialPosition(double X, double Y, double Z)
Definition: node.h:601
bool SolutionStepsDataHas(const VariableData &rThisVariable) const
Definition: node.h:427
Node(IndexType NewId, double const &NewX)
1d constructor.
Definition: node.h:131
Node(IndexType NewId, PointType const &rThisPoint)
Point constructor.
Definition: node.h:170
void SetSolutionStepVariablesList(VariablesList::Pointer pVariablesList)
Definition: node.h:375
TVariableType::Type & GetValue(const TVariableType &rThisVariable, IndexType SolutionStepIndex)
Definition: node.h:476
friend void intrusive_ptr_add_ref(const NodeType *x)
Definition: node.h:1007
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: node.h:466
const TDataType & operator[](const Variable< TDataType > &rThisVariable) const
Definition: node.h:336
bool operator==(const Node &rOther)
Definition: node.h:316
TDataType & operator[](const Variable< TDataType > &rThisVariable)
Definition: node.h:331
Node(Node const &rOtherNode)=delete
double Z0() const
Definition: node.h:589
const DofsContainerType & GetDofs() const
Definition: node.h:699
unsigned int GetDofPosition(TVariableType const &rDofVariable) const
Get DoF position with a given position.
Definition: node.h:629
double & Z0()
Definition: node.h:576
TVariableType::Type const & GetSolutionStepValue(const TVariableType &rThisVariable, IndexType SolutionStepIndex) const
Definition: node.h:421
void UnSetLock()
Definition: node.h:287
TVariableType::Type & operator()(const TVariableType &rThisVariable)
Definition: node.h:326
TVariableType::Type & FastGetCurrentSolutionStepValue(const TVariableType &rThisVariable, IndexType ThisPosition)
Definition: node.h:460
double & operator[](IndexType ThisIndex)
Definition: node.h:341
~Node() override
Destructor.
Definition: node.h:249
TVariableType::Type const & GetSolutionStepValue(const TVariableType &rThisVariable) const
Definition: node.h:411
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(Node)
Pointer definition of Node.
bool IsFixed(const VariableData &rDofVariable) const
Definition: node.h:897
Node(IndexType NewId, double const &NewX, double const &NewY, double const &NewZ, VariablesList::Pointer pVariablesList, BlockType const *ThisData, SizeType NewQueueSize=1)
3d with variables list and data constructor.
Definition: node.h:218
Node(IndexType NewId, std::vector< double > const &rOtherCoordinates)
Definition: node.h:205
double & X0()
Definition: node.h:568
Node(IndexType NewId, double const &NewX, double const &NewY)
2d constructor.
Definition: node.h:144
Node()
Default constructor.
Definition: node.h:105
void OverwriteSolutionStepData(IndexType SourceSolutionStepIndex, IndexType DestinationSourceSolutionStepIndex)
Definition: node.h:365
DofType::Pointer pAddDof(TVariableType const &rDofVariable, TReactionType const &rDofReaction)
Definition: node.h:810
void SetId(IndexType NewId)
Definition: node.h:272
DofsContainerType & GetDofs()
Definition: node.h:694
unsigned int use_count() const noexcept
Definition: node.h:256
const VariablesListDataValueContainer & SolutionStepData() const
Definition: node.h:385
Node(IndexType NewId, double const &NewX, double const &NewY, double const &NewZ)
3d constructor.
Definition: node.h:157
Node & operator=(const Node &rOther)
Assignment operator.
Definition: node.h:297
TVariableType::Type & GetSolutionStepValue(const TVariableType &rThisVariable, IndexType SolutionStepIndex)
Definition: node.h:416
double Y0() const
Definition: node.h:585
Node(IndexType NewId, vector_expression< TVectorType > const &rOtherCoordinates)
Definition: node.h:189
double & Y0()
Definition: node.h:572
DofType::Pointer pGetDof(TVariableType const &rDofVariable) const
Get DoF counted pointer for a given variable.
Definition: node.h:711
VariablesList::Pointer pGetVariablesList()
Definition: node.h:608
Node(IndexType NewId)
Definition: node.h:117
double operator[](IndexType ThisIndex) const
Definition: node.h:346
void CreateSolutionStepData()
Definition: node.h:355
const DataValueContainer & GetData() const
Definition: node.h:401
TVariableType::Type & operator()(const TVariableType &rThisVariable, IndexType SolutionStepIndex)
Definition: node.h:321
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
Node::Pointer Clone()
Definition: node.h:229
DofType::Pointer pAddDof(TVariableType const &rDofVariable)
Definition: node.h:759
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable, IndexType SolutionStepIndex, IndexType ThisPosition)
Definition: node.h:455
VariablesListDataValueContainer & SolutionStepData()
Definition: node.h:380
bool Has(const Variable< TDataType > &rThisVariable) const
Definition: node.h:498
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable, IndexType SolutionStepIndex)
Definition: node.h:445
LockObject & GetLock()
Definition: node.h:277
const DofType & GetDof(TVariableType const &rDofVariable) const
Get DoF for a given variable.
Definition: node.h:681
DofType::Pointer pGetDof(TVariableType const &rDofVariable, int Position) const
Get DoF counted pointer with a given position. If not found it is search.
Definition: node.h:731
void CloneSolutionStepData()
Definition: node.h:360
DofType & AddDof(TVariableType const &rDofVariable)
Definition: node.h:835
bool IsActive() const
Checks if the GeometricalObject is active.
Definition: node.h:911
DofType::Pointer pAddDof(DofType const &SourceDof)
Definition: node.h:781
const PointType & GetInitialPosition() const
Definition: node.h:559
static int IsInParallel()
Wrapper for omp_in_parallel().
Definition: openmp_utils.h:122
Point class.
Definition: point.h:59
bool operator==(const Point &rOther) const
Definition: point.h:139
Point & operator=(const Point &rOther)
Assignment operator.
Definition: point.h:133
Point()
Default constructor.
Definition: point.h:86
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: point.h:242
double Y() const
Definition: point.h:187
std::size_t SizeType
Definition: point.h:77
double Z() const
Definition: point.h:193
double X() const
Definition: point.h:181
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
This class is the base of variables and variable's components which contains their common data.
Definition: variable_data.h:49
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
A shared variable list gives the position of each variable in the containers sharing it.
Definition: variables_list_data_value_container.h:61
void Clear()
Definition: variables_list_data_value_container.h:410
void AssignData(BlockType *Source, SizeType QueueIndex)
Definition: variables_list_data_value_container.h:629
TDataType & FastGetCurrentValue(const Variable< TDataType > &rThisVariable, SizeType ThisPosition)
Definition: variables_list_data_value_container.h:341
void PushFront()
Definition: variables_list_data_value_container.h:660
SizeType QueueSize() const
Definition: variables_list_data_value_container.h:387
void SetVariablesList(VariablesList::Pointer pVariablesList)
Definition: variables_list_data_value_container.h:444
TDataType & GetValue(const Variable< TDataType > &rThisVariable)
Definition: variables_list_data_value_container.h:282
bool Has(const VariableData &rThisVariable) const
This method returns if a certain variable is stored in the data value container.
Definition: variables_list_data_value_container.h:704
void Resize(SizeType NewSize)
Definition: variables_list_data_value_container.h:490
VariablesList::Pointer pGetVariablesList()
Definition: variables_list_data_value_container.h:424
VariablesList::BlockType BlockType
The block type definition.
Definition: variables_list_data_value_container.h:70
TDataType & FastGetValue(const Variable< TDataType > &rThisVariable)
Definition: variables_list_data_value_container.h:314
void CloneFront()
Definition: variables_list_data_value_container.h:641
Short class definition.
Definition: array_1d.h:61
BOOST_UBLAS_INLINE const_reference operator[](size_type i) const
Definition: array_1d.h:173
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
namespace KRATOS_DEPRECATED_MESSAGE("Please use std::filesystem directly") filesystem
Definition: kratos_filesystem.h:33
AMatrix::MatrixExpression< TExpressionType, AMatrix::row_major_access > vector_expression
Definition: amatrix_interface.h:490
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
tuple const
Definition: ode_solve.py:403
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17