14 #if !defined(KRATOS_GENERALIZED_NEWMARK_GN11_SCHEME )
15 #define KRATOS_GENERALIZED_NEWMARK_GN11_SCHEME
29 template<
class TSparseSpace,
class TDenseSpace>
69 ConvectionDiffusionSettings::Pointer my_settings = r_model_part.
GetProcessInfo().
GetValue(CONVECTION_DIFFUSION_SETTINGS);
74 if(DELTA_TIME.Key() == 0)
75 KRATOS_THROW_ERROR( std::invalid_argument,
"DELTA_TIME Key is 0. Check if all applications were correctly registered.",
"")
76 if(rUnknownVar.
Key() == 0)
77 KRATOS_THROW_ERROR( std::invalid_argument,
"UnknownVar Key is 0. Check if all applications were correctly registered.",
"" )
79 if(TEMPERATURE.Key() == 0)
80 KRATOS_THROW_ERROR( std::invalid_argument,
"TEMPERATURE Key is 0. Check if all applications were correctly registered.",
"" )
83 for(ModelPart::NodesContainerType::iterator it=r_model_part.
NodesBegin(); it!=r_model_part.
NodesEnd(); it++)
85 if(it->SolutionStepsDataHas(rUnknownVar) ==
false)
86 KRATOS_THROW_ERROR( std::logic_error,
"UnknownVar variable is not allocated for node ", it->Id() )
87 if(it->SolutionStepsDataHas(TEMPERATURE) ==
false)
88 KRATOS_THROW_ERROR( std::logic_error,
"TEMPERATURE variable is not allocated for node ", it->Id() )
90 if(it->HasDofFor(rUnknownVar) ==
false)
100 KRATOS_THROW_ERROR( std::invalid_argument,
"Some of the scheme variables: theta has an invalid value ",
"" )
136 int NElems =
static_cast<int>(r_model_part.
Elements().size());
137 ModelPart::ElementsContainerType::iterator el_begin = r_model_part.
ElementsBegin();
139 #pragma omp parallel for
140 for(
int i = 0;
i < NElems;
i++)
142 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
146 int NCons =
static_cast<int>(r_model_part.
Conditions().size());
147 ModelPart::ConditionsContainerType::iterator con_begin = r_model_part.
ConditionsBegin();
149 #pragma omp parallel for
150 for(
int i = 0;
i < NCons;
i++)
152 ModelPart::ConditionsContainerType::iterator itCond = con_begin +
i;
171 const int NNodes =
static_cast<int>(r_model_part.
Nodes().size());
172 ModelPart::NodesContainerType::iterator node_begin = r_model_part.
NodesBegin();
175 #pragma omp parallel for
176 for(
int i = 0;
i < NNodes;
i++)
178 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
180 itNode->FastGetSolutionStepValue(NODAL_AREA) = 0.0;
182 array_1d<double,3>& rNodalPhiGradient = itNode->FastGetSolutionStepValue(NODAL_PHI_GRADIENT);
190 #pragma omp parallel for
191 for(
int i = 0;
i < NNodes;
i++)
193 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
195 const double& NodalArea = itNode->FastGetSolutionStepValue(NODAL_AREA);
196 if (NodalArea>1.0e-20)
198 const double InvNodalArea = 1.0/NodalArea;
199 array_1d<double,3>& rNodalPhiGradient = itNode->FastGetSolutionStepValue(NODAL_PHI_GRADIENT);
200 for(
unsigned int i = 0;
i<3;
i++)
202 rNodalPhiGradient[
i] *= InvNodalArea;
259 const int NNodes =
static_cast<int>(r_model_part.
Nodes().size());
260 ModelPart::NodesContainerType::iterator node_begin = r_model_part.
NodesBegin();
263 #pragma omp parallel for
264 for(
int i = 0;
i < NNodes;
i++)
266 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
268 itNode->FastGetSolutionStepValue(NODAL_AREA) = 0.0;
270 array_1d<double,3>& rNodalPhiGradient = itNode->FastGetSolutionStepValue(NODAL_PHI_GRADIENT);
279 int NElems =
static_cast<int>(r_model_part.
Elements().size());
280 ModelPart::ElementsContainerType::iterator el_begin = r_model_part.
ElementsBegin();
282 #pragma omp parallel for
283 for(
int i = 0;
i < NElems;
i++)
285 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
286 itElem -> InitializeNonLinearIteration(CurrentProcessInfo);
289 int NCons =
static_cast<int>(r_model_part.
Conditions().size());
290 ModelPart::ConditionsContainerType::iterator con_begin = r_model_part.
ConditionsBegin();
292 #pragma omp parallel for
293 for(
int i = 0;
i < NCons;
i++)
295 ModelPart::ConditionsContainerType::iterator itCond = con_begin +
i;
296 itCond -> InitializeNonLinearIteration(CurrentProcessInfo);
302 #pragma omp parallel for
303 for(
int i = 0;
i < NNodes;
i++)
305 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
307 const double& NodalArea = itNode->FastGetSolutionStepValue(NODAL_AREA);
308 if (NodalArea>1.0e-20)
310 const double InvNodalArea = 1.0/NodalArea;
311 array_1d<double,3>& rNodalPhiGradient = itNode->FastGetSolutionStepValue(NODAL_PHI_GRADIENT);
312 for(
unsigned int i = 0;
i<3;
i++)
314 rNodalPhiGradient[
i] *= InvNodalArea;
335 int NElems =
static_cast<int>(r_model_part.
Elements().size());
336 ModelPart::ElementsContainerType::iterator el_begin = r_model_part.
ElementsBegin();
338 #pragma omp parallel for
339 for(
int i = 0;
i < NElems;
i++)
341 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
342 itElem -> FinalizeNonLinearIteration(CurrentProcessInfo);
345 int NCons =
static_cast<int>(r_model_part.
Conditions().size());
346 ModelPart::ConditionsContainerType::iterator con_begin = r_model_part.
ConditionsBegin();
348 #pragma omp parallel for
349 for(
int i = 0;
i < NCons;
i++)
351 ModelPart::ConditionsContainerType::iterator itCond = con_begin +
i;
352 itCond -> FinalizeNonLinearIteration(CurrentProcessInfo);
562 ConvectionDiffusionSettings::Pointer my_settings = r_model_part.
GetProcessInfo().
GetValue(CONVECTION_DIFFUSION_SETTINGS);
565 const int NNodes =
static_cast<int>(r_model_part.
Nodes().size());
566 ModelPart::NodesContainerType::iterator node_begin = r_model_part.
NodesBegin();
568 #pragma omp parallel for
569 for(
int i = 0;
i < NNodes;
i++)
571 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
573 double& CurrentPhi = itNode->FastGetSolutionStepValue(TEMPERATURE);
574 const double& PreviousPhi = itNode->FastGetSolutionStepValue(TEMPERATURE, 1);
575 const double& CurrentPhiTheta = itNode->FastGetSolutionStepValue(rUnknownVar);
577 CurrentPhi = 1.0 /
mTheta * CurrentPhiTheta + (1.0 - 1.0 /
mTheta) * PreviousPhi;
Base class for all Conditions.
Definition: condition.h:59
virtual void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:426
virtual void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const
Definition: condition.h:260
virtual void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:440
virtual void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:408
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
Base class for all Elements.
Definition: element.h:60
virtual void CalculateFirstDerivativesLHS(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:479
virtual void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:423
virtual void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:437
virtual void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const
Definition: element.h:258
virtual void CalculateFirstDerivativesContributions(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:461
virtual void CalculateFirstDerivativesRHS(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:493
virtual void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:405
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
Definition: generalized_newmark_GN11_scheme.hpp:32
void CalculateRHSContribution(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: generalized_newmark_GN11_scheme.hpp:420
BaseType::DofsArrayType DofsArrayType
Definition: generalized_newmark_GN11_scheme.hpp:39
void Update(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Performing the update of the solution.
Definition: generalized_newmark_GN11_scheme.hpp:511
GeneralizedNewmarkGN11Scheme(double theta)
Constructor.
Definition: generalized_newmark_GN11_scheme.hpp:48
void Initialize(ModelPart &r_model_part) override
This is the place to initialize the Scheme.
Definition: generalized_newmark_GN11_scheme.hpp:109
void CalculateRHSContribution(Condition &rCurrentCondition, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
Functions totally analogous to the precedent but applied to the "condition" objects.
Definition: generalized_newmark_GN11_scheme.hpp:448
void CalculateSystemContributions(Element &rCurrentElement, LocalSystemMatrixType &LHS_Contribution, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
This function is designed to be called in the builder and solver to introduce the selected time integ...
Definition: generalized_newmark_GN11_scheme.hpp:363
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: generalized_newmark_GN11_scheme.hpp:42
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: generalized_newmark_GN11_scheme.hpp:38
double mTheta
Member Variables.
Definition: generalized_newmark_GN11_scheme.hpp:550
void Predict(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Performing the prediction of the solution.
Definition: generalized_newmark_GN11_scheme.hpp:236
std::vector< Matrix > mMMatrix
Definition: generalized_newmark_GN11_scheme.hpp:553
BaseType::TSystemVectorType TSystemVectorType
Definition: generalized_newmark_GN11_scheme.hpp:41
void CalculateSystemContributions(Condition &rCurrentCondition, LocalSystemMatrixType &LHS_Contribution, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
Functions totally analogous to the precedent but applied to the "condition" objects.
Definition: generalized_newmark_GN11_scheme.hpp:400
void CalculateLHSContribution(Condition &rCurrentCondition, LocalSystemMatrixType &LHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
Functions totally analogous to the precedent but applied to the "condition" objects.
Definition: generalized_newmark_GN11_scheme.hpp:494
std::vector< Vector > mMVector
Definition: generalized_newmark_GN11_scheme.hpp:554
void FinalizeSolutionStep(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function called once at the end of a solution step, after convergence is reached if an iterative proc...
Definition: generalized_newmark_GN11_scheme.hpp:161
double mDeltaTime
Definition: generalized_newmark_GN11_scheme.hpp:551
int Check(ModelPart &r_model_part) override
Definition: generalized_newmark_GN11_scheme.hpp:65
void InitializeSolutionStep(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function called once at the beginning of each solution step.
Definition: generalized_newmark_GN11_scheme.hpp:123
~GeneralizedNewmarkGN11Scheme() override
Destructor.
Definition: generalized_newmark_GN11_scheme.hpp:61
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: generalized_newmark_GN11_scheme.hpp:248
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: generalized_newmark_GN11_scheme.hpp:43
void CalculateLHSContribution(Element &rCurrentElement, LocalSystemMatrixType &LHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
This function is designed to calculate just the LHS contribution.
Definition: generalized_newmark_GN11_scheme.hpp:467
void UpdateVariablesDerivatives(ModelPart &r_model_part)
Definition: generalized_newmark_GN11_scheme.hpp:558
BaseType::TSystemMatrixType TSystemMatrixType
Definition: generalized_newmark_GN11_scheme.hpp:40
KRATOS_CLASS_POINTER_DEFINITION(GeneralizedNewmarkGN11Scheme)
void FinalizeNonLinIteration(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function to be called when it is needed to finalize an iteration. It is designed to be called at the ...
Definition: generalized_newmark_GN11_scheme.hpp:325
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
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
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
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
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
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
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
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
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 FinalizeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function called once at the end of a solution step, after convergence is reached if an iterative proc...
Definition: scheme.h:294
typename TDenseSpace::MatrixType LocalSystemMatrixType
Local system matrix type definition.
Definition: scheme.h:77
bool mSchemeIsInitialized
Definition: scheme.h:755
KeyType Key() const
Definition: variable_data.h:187
#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
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
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