diff --git a/kratos/includes/dof.h b/kratos/includes/dof.h index 3df855005f74..1a96fbf88810 100644 --- a/kratos/includes/dof.h +++ b/kratos/includes/dof.h @@ -25,6 +25,8 @@ #include "includes/define.h" #include "containers/data_value_container.h" #include "containers/nodal_data.h" +#include "containers/flags.h" +#include "includes/kratos_flags.h" namespace Kratos { @@ -83,7 +85,7 @@ This class enables the system to work with different set of dofs and also represents the Dirichlet condition assigned to each dof. */ template -class Dof{ +class Dof : public Flags { public: ///@name Type Definitions ///@{ @@ -118,7 +120,7 @@ class Dof{ template Dof(NodalData* pThisNodalData, const TVariableType& rThisVariable) - : mIsFixed(false), + : Flags(), mVariableType(DofTrait::Id), mReactionType(DofTrait >::Id), mEquationId(IndexType()), @@ -156,7 +158,7 @@ class Dof{ Dof(NodalData* pThisNodalData, const TVariableType& rThisVariable, const TReactionType& rThisReaction) - : mIsFixed(false), + : Flags(), mVariableType(DofTrait::Id), mReactionType(DofTrait::Id), mEquationId(IndexType()), @@ -175,7 +177,7 @@ class Dof{ //This default constructor is needed for serializer Dof() - : mIsFixed(false), + : Flags(), mVariableType(DofTrait >::Id), mReactionType(DofTrait >::Id), mIndex(), @@ -185,15 +187,7 @@ class Dof{ } /// Copy constructor. - Dof(Dof const& rOther) - : mIsFixed(rOther.mIsFixed), - mVariableType(rOther.mVariableType), - mReactionType(rOther.mReactionType), - mIndex(rOther.mIndex), - mEquationId(rOther.mEquationId), - mpNodalData(rOther.mpNodalData) - { - } + Dof(Dof const& rOther) = default; /// Destructor. @@ -205,17 +199,7 @@ class Dof{ ///@{ /// Assignment operator. - Dof& operator=(Dof const& rOther) - { - mIsFixed = rOther.mIsFixed; - mEquationId = rOther.mEquationId; - mpNodalData = rOther.mpNodalData; - mIndex = rOther.mIndex; - mVariableType = rOther.mVariableType; - mReactionType = rOther.mReactionType; - - return *this; - } + Dof& operator=(Dof const& rOther) = default; template typename TVariableType::Type& operator()(const TVariableType& rThisVariable, IndexType SolutionStepIndex = 0) @@ -337,14 +321,14 @@ class Dof{ */ void FixDof() { - mIsFixed=true; + this->Set(FIXED); } /** Frees the degree of freedom */ void FreeDof() { - mIsFixed=false; + this->Set(FIXED, false); } SolutionStepsDataContainerType* GetSolutionStepsData() @@ -375,7 +359,7 @@ class Dof{ bool IsFixed() const { - return mIsFixed; + return this->Is(FIXED); } @@ -390,7 +374,7 @@ class Dof{ /// Turn back information as a string. - std::string Info() const + std::string Info() const override { std::stringstream buffer; @@ -403,13 +387,13 @@ class Dof{ } /// Print information about this object. - void PrintInfo(std::ostream& rOStream) const + void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } /// Print object's data. - void PrintData(std::ostream& rOStream) const + void PrintData(std::ostream& rOStream) const override { rOStream << " Variable : " << GetVariable().Name() << std::endl; rOStream << " Reaction : " << GetReaction().Name() << std::endl; @@ -436,9 +420,6 @@ class Dof{ ///@name Member Variables ///@{ - /** True is is fixed */ - int mIsFixed : 1; - int mVariableType : 4; int mReactionType : 4; @@ -486,9 +467,9 @@ class Dof{ friend class Serializer; - void save(Serializer& rSerializer) const + void save(Serializer& rSerializer) const override { - rSerializer.save("IsFixed", static_cast(mIsFixed)); + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, Flags); rSerializer.save("EquationId", static_cast(mEquationId)); rSerializer.save("NodalData", mpNodalData); rSerializer.save("VariableType", static_cast(mVariableType)); @@ -497,12 +478,9 @@ class Dof{ } - void load(Serializer& rSerializer) + void load(Serializer& rSerializer) override { - std::string name; - bool is_fixed; - rSerializer.load("IsFixed", is_fixed); - mIsFixed=is_fixed; + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, Flags); EquationIdType equation_id; rSerializer.load("EquationId", equation_id); mEquationId = equation_id; diff --git a/kratos/includes/kratos_flags.h b/kratos/includes/kratos_flags.h index bb62ac8dd564..1863bdd26dba 100644 --- a/kratos/includes/kratos_flags.h +++ b/kratos/includes/kratos_flags.h @@ -71,7 +71,7 @@ KRATOS_CREATE_FLAG(BLOCKED, 36); KRATOS_CREATE_FLAG(MARKER, 35); KRATOS_CREATE_FLAG(PERIODIC, 34); KRATOS_CREATE_FLAG(WALL, 33); -// KRATOS_CREATE_FLAG(,32); +KRATOS_CREATE_FLAG(FIXED, 32); // KRATOS_CREATE_FLAG(,31); // KRATOS_CREATE_FLAG(,30);