10 #if !defined(KRATOS_RESIDUAL_BASED_BOSSAK_SCHEME )
11 #define KRATOS_RESIDUAL_BASED_BOSSAK_SCHEME
16 #include "boost/smart_ptr.hpp"
33 template<
class TSparseSpace,
class TDenseSpace >
70 std::vector< Matrix >
M;
71 std::vector< Matrix >
D;
78 std::vector< Vector >
v;
79 std::vector< Vector >
a;
80 std::vector< Vector >
ap;
118 :
Scheme<TSparseSpace,TDenseSpace>()
133 int NumThreads = OpenMPUtils::GetNumThreads();
196 if (i_dof->IsFree() )
198 i_dof->GetSolutionStepValue() += Dx[i_dof->EquationId()];
208 noalias(DeltaDisplacement) = (
i)->FastGetSolutionStepValue(DISPLACEMENT) - (
i)->FastGetSolutionStepValue(DISPLACEMENT, 1);
217 UpdateVelocity (CurrentVelocity, DeltaDisplacement, PreviousVelocity, PreviousAcceleration);
219 UpdateAcceleration (CurrentAcceleration, DeltaDisplacement, PreviousVelocity, PreviousAcceleration);
258 if ((
i->pGetDof(DISPLACEMENT_X))->IsFixed() ==
false)
260 CurrentDisplacement[0] = PreviousDisplacement[0];
264 CurrentDisplacement[0] = PreviousDisplacement[0] + ImposedDisplacement[0];
268 if (
i->pGetDof(DISPLACEMENT_Y)->IsFixed() ==
false)
270 CurrentDisplacement[1] = PreviousDisplacement[1];
274 CurrentDisplacement[1] = PreviousDisplacement[1] + ImposedDisplacement[1];
279 if (
i->HasDofFor(DISPLACEMENT_Z))
281 if (
i->pGetDof(DISPLACEMENT_Z)->IsFixed() ==
false)
283 CurrentDisplacement[2] = PreviousDisplacement[2];
287 CurrentDisplacement[2] = PreviousDisplacement[2] + ImposedDisplacement[2];
296 if (
i->HasDofFor(PRESSURE))
298 double& PreviousPressure = (
i)->FastGetSolutionStepValue(PRESSURE, 1);
299 double& CurrentPressure = (
i)->FastGetSolutionStepValue(PRESSURE);
301 if ((
i->pGetDof(PRESSURE))->IsFixed() ==
false)
302 CurrentPressure = PreviousPressure;
312 noalias(DeltaDisplacement) = CurrentDisplacement - PreviousDisplacement;
318 UpdateVelocity (CurrentVelocity, DeltaDisplacement, PreviousVelocity, PreviousAcceleration);
320 UpdateAcceleration (CurrentAcceleration, DeltaDisplacement, PreviousVelocity, PreviousAcceleration);
336 int NumThreads = OpenMPUtils::GetNumThreads();
343 ElementsArrayType::iterator ElemBegin = rModelPart.
Elements().begin() + ElementPartition[
k];
344 ElementsArrayType::iterator ElemEnd = rModelPart.
Elements().begin() + ElementPartition[
k + 1];
346 for (ElementsArrayType::iterator itElem = ElemBegin; itElem != ElemEnd; itElem++)
348 itElem->Initialize();
371 KRATOS_THROW_ERROR( std::logic_error,
"Before initilizing Conditions, initialize Elements FIRST",
"" )
373 int NumThreads = OpenMPUtils::GetNumThreads();
380 ConditionsArrayType::iterator CondBegin = rModelPart.
Conditions().begin() + ConditionPartition[
k];
381 ConditionsArrayType::iterator CondEnd = rModelPart.
Conditions().begin() + ConditionPartition[
k + 1];
383 for (ConditionsArrayType::iterator itCond = CondBegin; itCond != CondEnd; itCond++)
385 itCond->Initialize();
417 double DeltaTime = CurrentProcessInfo[DELTA_TIME];
423 std::cout<<
" WARNING: detected delta_time = 0 in the Solution Scheme "<<std::endl;
424 std::cout<<
" DELTA_TIME set to 1 considering a Quasistatic step with one step only "<<std::endl;
425 std::cout<<
" PLEASE : check if the time step is created correctly for the current model part "<<std::endl;
427 CurrentProcessInfo[DELTA_TIME] = 1;
428 DeltaTime = CurrentProcessInfo[DELTA_TIME];
461 int NumThreads = OpenMPUtils::GetNumThreads();
469 ElementsArrayType::iterator ElementsBegin = rElements.begin() + ElementPartition[
k];
470 ElementsArrayType::iterator ElementsEnd = rElements.begin() + ElementPartition[
k + 1];
472 for (ElementsArrayType::iterator itElem = ElementsBegin; itElem != ElementsEnd; itElem++)
474 itElem->FinalizeSolutionStep(CurrentProcessInfo);
487 ConditionsArrayType::iterator ConditionsBegin = rConditions.begin() + ConditionPartition[
k];
488 ConditionsArrayType::iterator ConditionsEnd = rConditions.begin() + ConditionPartition[
k + 1];
490 for (ConditionsArrayType::iterator itCond = ConditionsBegin; itCond != ConditionsEnd; itCond++)
492 itCond->FinalizeSolutionStep(CurrentProcessInfo);
510 for (ElementsArrayType::iterator it = pElements.begin(); it != pElements.end(); ++it)
516 for (ConditionsArrayType::iterator it = pConditions.begin(); it != pConditions.end(); ++it)
548 Element::Pointer rCurrentElement,
560 (rCurrentElement) -> CalculateLocalSystem(LHS_Contribution,RHS_Contribution,CurrentProcessInfo);
565 (rCurrentElement) -> CalculateMassMatrix(
mMatrix.
M[thread],CurrentProcessInfo);
567 (rCurrentElement) -> CalculateDampingMatrix(
mMatrix.
D[thread],CurrentProcessInfo);
571 (rCurrentElement) -> EquationIdVector(
EquationId,CurrentProcessInfo);
591 Element::Pointer rCurrentElement,
605 (rCurrentElement) -> CalculateRightHandSide(RHS_Contribution,CurrentProcessInfo);
610 (rCurrentElement) -> CalculateMassMatrix(
mMatrix.
M[thread], CurrentProcessInfo);
612 (rCurrentElement) -> CalculateDampingMatrix(
mMatrix.
D[thread],CurrentProcessInfo);
615 (rCurrentElement) -> EquationIdVector(
EquationId,CurrentProcessInfo);
631 Condition::Pointer rCurrentCondition,
647 (rCurrentCondition) -> CalculateLocalSystem(LHS_Contribution,RHS_Contribution,CurrentProcessInfo);
653 (rCurrentCondition) -> CalculateMassMatrix(
mMatrix.
M[thread], CurrentProcessInfo);
655 (rCurrentCondition) -> CalculateDampingMatrix(
mMatrix.
D[thread],CurrentProcessInfo);
659 (rCurrentCondition) -> EquationIdVector(
EquationId,CurrentProcessInfo);
679 Condition::Pointer rCurrentCondition,
692 (rCurrentCondition) -> CalculateRightHandSide(RHS_Contribution, CurrentProcessInfo);
697 (rCurrentCondition) -> CalculateMassMatrix(
mMatrix.
M[thread], CurrentProcessInfo);
699 (rCurrentCondition) -> CalculateDampingMatrix(
mMatrix.
D[thread], CurrentProcessInfo);
703 (rCurrentCondition) -> EquationIdVector(
EquationId, CurrentProcessInfo);
722 Element::Pointer rCurrentElement,
726 rCurrentElement->GetDofList(ElementalDofList, CurrentProcessInfo);
734 Condition::Pointer rCurrentCondition,
738 rCurrentCondition->GetDofList(ConditionDofList, CurrentProcessInfo);
756 if(err!=0)
return err;
760 if(DISPLACEMENT.Key() == 0)
761 KRATOS_THROW_ERROR( std::invalid_argument,
"DISPLACEMENT has Key zero! (check if the application is correctly registered",
"" )
762 if(VELOCITY.Key() == 0)
763 KRATOS_THROW_ERROR( std::invalid_argument,
"VELOCITY has Key zero! (check if the application is correctly registered",
"" )
764 if(ACCELERATION.Key() == 0)
765 KRATOS_THROW_ERROR( std::invalid_argument,
"ACCELERATION has Key zero! (check if the application is correctly registered",
"" )
768 for(ModelPart::NodesContainerType::iterator it=r_model_part.
NodesBegin();
771 if (it->SolutionStepsDataHas(DISPLACEMENT) ==
false)
772 KRATOS_THROW_ERROR( std::logic_error,
"DISPLACEMENT variable is not allocated for node ", it->Id() )
773 if (it->SolutionStepsDataHas(VELOCITY) ==
false)
774 KRATOS_THROW_ERROR( std::logic_error,
"DISPLACEMENT variable is not allocated for node ", it->Id() )
775 if (it->SolutionStepsDataHas(ACCELERATION) ==
false)
776 KRATOS_THROW_ERROR( std::logic_error,
"DISPLACEMENT variable is not allocated for node ", it->Id() )
780 for(ModelPart::NodesContainerType::iterator it=r_model_part.
NodesBegin();
783 if(it->HasDofFor(DISPLACEMENT_X) ==
false)
784 KRATOS_THROW_ERROR( std::invalid_argument,
"missing DISPLACEMENT_X dof on node ",it->Id() )
785 if(it->HasDofFor(DISPLACEMENT_Y) ==
false)
786 KRATOS_THROW_ERROR( std::invalid_argument,
"missing DISPLACEMENT_Y dof on node ",it->Id() )
787 if(it->HasDofFor(DISPLACEMENT_Z) ==
false)
788 KRATOS_THROW_ERROR( std::invalid_argument,
"missing DISPLACEMENT_Z dof on node ",it->Id() )
794 KRATOS_THROW_ERROR( std::logic_error,
"Value not admissible for AlphaBossak. Admissible values should be between 0.0 and -0.3. Current value is ",
mAlpha.
m )
799 KRATOS_THROW_ERROR( std::logic_error,
"insufficient buffer size. Buffer size should be greater than 2. Current size is", r_model_part.
GetBufferSize() )
888 Element::Pointer rCurrentElement,
899 rCurrentElement->GetSecondDerivativesVector(
mVector.
a[thread], 0);
903 rCurrentElement->GetSecondDerivativesVector(
mVector.
ap[thread], 1);
915 rCurrentElement->GetFirstDerivativesVector(
mVector.
v[thread], 0);
930 Condition::Pointer rCurrentCondition,
941 rCurrentCondition->GetSecondDerivativesVector(
mVector.
a[thread], 0);
945 rCurrentCondition->GetSecondDerivativesVector(
mVector.
ap[thread], 1);
956 rCurrentCondition->GetFirstDerivativesVector(
mVector.
v[thread], 0);
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
IndexType GetBufferSize() const
This method gets the suffer size of the model part database.
Definition: model_part.h:1876
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
static void DivideInPartitions(const int NumTerms, const int NumThreads, PartitionVector &Partitions)
Divide an array of length NumTerms between NumThreads threads.
Definition: openmp_utils.h:158
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
std::vector< int > PartitionVector
Vector type for the output of DivideInPartitions method.
Definition: openmp_utils.h:53
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Definition: residual_based_bossak_scheme.hpp:35
ResidualBasedBossakScheme(ResidualBasedBossakScheme &rOther)
Definition: residual_based_bossak_scheme.hpp:146
void InitializeNonLinearIteration(Condition::Pointer rCurrentCondition, ProcessInfo &CurrentProcessInfo) override
Definition: residual_based_bossak_scheme.hpp:526
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: residual_based_bossak_scheme.hpp:111
BaseType::TSystemVectorType TSystemVectorType
Definition: residual_based_bossak_scheme.hpp:103
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residual_based_bossak_scheme.hpp:107
virtual ~ResidualBasedBossakScheme()
Definition: residual_based_bossak_scheme.hpp:157
void Condition_Calculate_RHS_Contribution(Condition::Pointer rCurrentCondition, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, ProcessInfo &CurrentProcessInfo) override
Definition: residual_based_bossak_scheme.hpp:678
void GetConditionDofList(Condition::Pointer rCurrentCondition, Element::DofsVectorType &ConditionDofList, ProcessInfo &CurrentProcessInfo) override
Get the list of Degrees of freedom to be assembled in the system for a Given Condition.
Definition: residual_based_bossak_scheme.hpp:733
BaseType::Pointer BaseTypePointer
Definition: residual_based_bossak_scheme.hpp:113
void Calculate_RHS_Contribution(Element::Pointer rCurrentElement, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, ProcessInfo &CurrentProcessInfo) override
Definition: residual_based_bossak_scheme.hpp:590
void InitializeSolutionStep(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Prepare state variables for a new step.
Definition: residual_based_bossak_scheme.hpp:403
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: residual_based_bossak_scheme.hpp:93
void CalculateSystemContributions(Element::Pointer rCurrentElement, LocalSystemMatrixType &LHS_Contribution, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, ProcessInfo &CurrentProcessInfo) override
Compute local contributions.
Definition: residual_based_bossak_scheme.hpp:547
ModelPart::ElementsContainerType ElementsArrayType
Definition: residual_based_bossak_scheme.hpp:109
KRATOS_CLASS_POINTER_DEFINITION(ResidualBasedBossakScheme)
void AddDynamicsToRHS(Condition::Pointer rCurrentCondition, LocalSystemVectorType &RHS_Contribution, LocalSystemMatrixType &D, LocalSystemMatrixType &M, ProcessInfo &CurrentProcessInfo)
Definition: residual_based_bossak_scheme.hpp:929
GeneralAlphaMethod mAlpha
Definition: residual_based_bossak_scheme.hpp:812
void UpdateVelocity(array_1d< double, 3 > &CurrentVelocity, const array_1d< double, 3 > &DeltaDisplacement, const array_1d< double, 3 > &PreviousVelocity, const array_1d< double, 3 > &PreviousAcceleration)
Definition: residual_based_bossak_scheme.hpp:826
BaseType::TDataType TDataType
Definition: residual_based_bossak_scheme.hpp:95
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residual_based_bossak_scheme.hpp:105
NewmarkMethod mNewmark
Definition: residual_based_bossak_scheme.hpp:813
void AddDynamicsToRHS(Element::Pointer rCurrentElement, LocalSystemVectorType &RHS_Contribution, LocalSystemMatrixType &D, LocalSystemMatrixType &M, ProcessInfo &CurrentProcessInfo)
Definition: residual_based_bossak_scheme.hpp:887
BaseTypePointer Clone() override
Clone method.
Definition: residual_based_bossak_scheme.hpp:164
void UpdateAcceleration(array_1d< double, 3 > &CurrentAcceleration, const array_1d< double, 3 > &DeltaDisplacement, const array_1d< double, 3 > &PreviousVelocity, const array_1d< double, 3 > &PreviousAcceleration)
Definition: residual_based_bossak_scheme.hpp:842
void InitializeNonLinIteration(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
unction to be called when it is needed to initialize an iteration. It is designed to be called at the...
Definition: residual_based_bossak_scheme.hpp:501
Element::DofsVectorType DofsVectorType
Definition: residual_based_bossak_scheme.hpp:99
void InitializeElements(ModelPart &rModelPart) override
Initialize all Element s in the provided ModelPart.
Definition: residual_based_bossak_scheme.hpp:332
GeneralVectors mVector
Definition: residual_based_bossak_scheme.hpp:816
GeneralMatrices mMatrix
Definition: residual_based_bossak_scheme.hpp:815
void InitializeNonLinearIteration(Element::Pointer rCurrentElement, ProcessInfo &CurrentProcessInfo) override
Definition: residual_based_bossak_scheme.hpp:536
BaseType::TSystemMatrixType TSystemMatrixType
Definition: residual_based_bossak_scheme.hpp:101
int Check(ModelPart &r_model_part) override
Check whether the scheme was configured correctly for the provided ModelPart.
Definition: residual_based_bossak_scheme.hpp:751
void Predict(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Predict the solution for the current step.
Definition: residual_based_bossak_scheme.hpp:232
void AddDynamicsToLHS(LocalSystemMatrixType &LHS_Contribution, LocalSystemMatrixType &D, LocalSystemMatrixType &M, ProcessInfo &CurrentProcessInfo)
Definition: residual_based_bossak_scheme.hpp:859
ResidualBasedBossakScheme(double rAlpham=0, double rDynamic=1)
Definition: residual_based_bossak_scheme.hpp:117
void FinalizeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Finish the current time step.
Definition: residual_based_bossak_scheme.hpp:450
void Condition_CalculateSystemContributions(Condition::Pointer rCurrentCondition, LocalSystemMatrixType &LHS_Contribution, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, ProcessInfo &CurrentProcessInfo) override
Definition: residual_based_bossak_scheme.hpp:630
void InitializeConditions(ModelPart &rModelPart) override
Initialize all Condition s in the provided ModelPart.
Definition: residual_based_bossak_scheme.hpp:366
void GetElementalDofList(Element::Pointer rCurrentElement, Element::DofsVectorType &ElementalDofList, ProcessInfo &CurrentProcessInfo) override
Get the list of Degrees of freedom to be assembled in the system for a given Element.
Definition: residual_based_bossak_scheme.hpp:721
BaseType::DofsArrayType DofsArrayType
Definition: residual_based_bossak_scheme.hpp:97
void Update(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Update the solution within the newton iteration.
Definition: residual_based_bossak_scheme.hpp:183
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
typename TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: scheme.h:71
bool mConditionsAreInitialized
Flag taking in account if the elements were initialized correctly or not.
Definition: scheme.h:757
ModelPart::ElementsContainerType ElementsArrayType
Elements containers definition.
Definition: scheme.h:89
virtual void EquationId(const Element &rElement, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo)
This method gets the eqaution id corresponding to the current element.
Definition: scheme.h:636
typename TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: scheme.h:74
typename TDenseSpace::VectorType LocalSystemVectorType
Local system vector type definition.
Definition: scheme.h:80
virtual void InitializeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function called once at the beginning of each solution step.
Definition: scheme.h:272
typename TSparseSpace::DataType TDataType
Data type definition.
Definition: scheme.h:68
typename TDenseSpace::MatrixType LocalSystemMatrixType
Local system matrix type definition.
Definition: scheme.h:77
virtual int Check(const ModelPart &rModelPart) const
This function is designed to be called once to perform all the checks needed on the input provided....
Definition: scheme.h:508
bool mElementsAreInitialized
Flag to be used in controlling if the Scheme has been initialized or not.
Definition: scheme.h:756
ModelPart::ConditionsContainerType ConditionsArrayType
Conditions containers definition.
Definition: scheme.h:92
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int k
Definition: quadrature.py:595
A
Definition: sensitivityMatrix.py:70
integer i
Definition: TensorModule.f:17
Definition: residual_based_bossak_scheme.hpp:39
double m
Definition: residual_based_bossak_scheme.hpp:42
double f
Definition: residual_based_bossak_scheme.hpp:41
Definition: residual_based_bossak_scheme.hpp:68
std::vector< Matrix > D
Definition: residual_based_bossak_scheme.hpp:71
std::vector< Matrix > M
Definition: residual_based_bossak_scheme.hpp:70
Definition: residual_based_bossak_scheme.hpp:76
std::vector< Vector > v
Definition: residual_based_bossak_scheme.hpp:78
std::vector< Vector > ap
Definition: residual_based_bossak_scheme.hpp:80
std::vector< Vector > a
Definition: residual_based_bossak_scheme.hpp:79
Definition: residual_based_bossak_scheme.hpp:47
double c6
Definition: residual_based_bossak_scheme.hpp:59
double beta
Definition: residual_based_bossak_scheme.hpp:49
double static_dynamic
Definition: residual_based_bossak_scheme.hpp:62
double c4
Definition: residual_based_bossak_scheme.hpp:57
double c5
Definition: residual_based_bossak_scheme.hpp:58
double c1
Definition: residual_based_bossak_scheme.hpp:54
double c3
Definition: residual_based_bossak_scheme.hpp:56
double c2
Definition: residual_based_bossak_scheme.hpp:55
double gamma
Definition: residual_based_bossak_scheme.hpp:50
double c0
Definition: residual_based_bossak_scheme.hpp:53