14 #if !defined(KRATOS_MPM_EXPLICIT_SCHEME)
15 #define KRATOS_MPM_EXPLICIT_SCHEME
39 template <
class TSparseSpace,
43 :
public Scheme<TSparseSpace, TDenseSpace> {
98 :
Scheme<TSparseSpace, TDenseSpace>(),
150 const SizeType dim = r_current_process_info[DOMAIN_SIZE];
151 const double delta_time = r_current_process_info[DELTA_TIME];
154 const auto it_node_begin = r_model_part.
NodesBegin();
157 const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X);
159 #pragma omp parallel for schedule(guided,512)
160 for (
int i = 0; i < static_cast<int>(r_model_part.
Nodes().size()); ++
i) {
161 auto it_node = it_node_begin +
i;
162 if ((it_node)->Is(ACTIVE))
182 std::array<bool, 3> fix_displacements = {
false,
false,
false };
183 fix_displacements[0] = (itCurrentNode->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed());
184 fix_displacements[1] = (itCurrentNode->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed());
186 fix_displacements[2] = (itCurrentNode->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed());
188 array_1d<double, 3>& r_nodal_momenta = itCurrentNode->FastGetSolutionStepValue(NODAL_MOMENTUM);
189 array_1d<double, 3>& r_current_residual = itCurrentNode->FastGetSolutionStepValue(FORCE_RESIDUAL);
191 const double gamma = (r_current_process_info.
GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE))
198 if (fix_displacements[
j])
200 r_nodal_momenta[
j] = 0.0;
201 r_current_residual[
j] = 0.0;
230 #pragma omp parallel for
238 double& nodal_mass = (
i)->FastGetSolutionStepValue(NODAL_MASS);
246 double& nodal_old_pressure = (
i)->FastGetSolutionStepValue(PRESSURE, 1);
247 double& nodal_pressure = (
i)->FastGetSolutionStepValue(PRESSURE);
248 if (
i->SolutionStepsDataHas(NODAL_MPRESSURE)) {
249 double& nodal_mpressure = (
i)->FastGetSolutionStepValue(NODAL_MPRESSURE);
250 nodal_mpressure = 0.0;
255 nodal_momentum.
clear();
256 nodal_inertia.
clear();
259 nodal_displacement.
clear();
260 nodal_velocity.
clear();
261 nodal_acceleration.
clear();
262 nodal_old_pressure = 0.0;
263 nodal_pressure = 0.0;
271 if (rCurrentProcessInfo.GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 0 ||
272 rCurrentProcessInfo.GetValue(IS_EXPLICIT_CENTRAL_DIFFERENCE))
279 #pragma omp parallel for
280 for (
int i = 0; i < static_cast<int>(r_model_part.
Elements().size()); ++
i) {
281 auto it_elem = it_elem_begin +
i;
282 std::vector<bool>
dummy;
283 it_elem->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS,
dummy, rCurrentProcessInfo);
292 bool calculateVelocityFromMomenta =
false)
297 const SizeType DomainSize = rCurrentProcessInfo[DOMAIN_SIZE];
299 #pragma omp parallel for
306 double& nodal_mass = (
i)->FastGetSolutionStepValue(NODAL_MASS);
310 std::array<bool, 3> fix_displacements = {
false,
false,
false };
311 fix_displacements[0] = (
i->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed());
312 fix_displacements[1] = (
i->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed());
314 fix_displacements[2] = (
i->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed());
318 if (fix_displacements[
j])
320 nodal_velocity[
j] = 0.0;
324 nodal_velocity[
j] = nodal_momentum[
j] / nodal_mass;
350 #pragma omp parallel for
351 for (
int i = 0; i < static_cast<int>(rElements.size()); ++
i)
353 auto it_elem = it_elem_begin +
i;
354 std::vector<bool>
dummy;
355 it_elem->CalculateOnIntegrationPoints(EXPLICIT_MAP_GRID_TO_MP,
dummy, rCurrentProcessInfo);
359 if (rCurrentProcessInfo.
GetValue(EXPLICIT_STRESS_UPDATE_OPTION) > 0)
363 #pragma omp parallel for
364 for (
int i = 0; i < static_cast<int>(rElements.size()); ++
i)
366 auto it_elem = it_elem_begin +
i;
367 std::vector<bool>
dummy;
368 it_elem->CalculateOnIntegrationPoints(CALCULATE_EXPLICIT_MP_STRESS,
dummy, rCurrentProcessInfo);
374 #pragma omp parallel for
375 for (
int i = 0; i < static_cast<int>(rModelPart.
Conditions().size()); ++
i) {
376 auto it_cond = it_cond_begin +
i;
377 it_cond->FinalizeSolutionStep(rCurrentProcessInfo);
387 if (rCurrentProcessInfo.
GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 1)
390 const SizeType DomainSize = rCurrentProcessInfo[DOMAIN_SIZE];
391 #pragma omp parallel for
392 for (
int iter = 0; iter < static_cast<int>(rModelPart.
Nodes().size()); ++iter)
399 r_current_velocity.
clear();
400 const double nodal_mass =
i->FastGetSolutionStepValue(NODAL_MASS);
405 r_current_velocity[
j] = r_nodal_momenta[
j] / nodal_mass;
411 else if (rCurrentProcessInfo.
GetValue(EXPLICIT_STRESS_UPDATE_OPTION) == 2)
418 #pragma omp parallel for
419 for (
int iter = 0; iter < static_cast<int>(rModelPart.
Nodes().size()); ++iter)
423 nodal_velocity.
clear();
428 #pragma omp parallel for
429 for (
int i = 0; i < static_cast<int>(rModelPart.
Elements().size()); ++
i) {
430 auto it_elem = it_elem_begin +
i;
431 std::vector<bool>
dummy;
432 it_elem->CalculateOnIntegrationPoints(CALCULATE_MUSL_VELOCITY_FIELD,
dummy, rCurrentProcessInfo);
447 const Element& rCurrentElement,
451 rCurrentElement.
GetDofList(ElementalDofList, CurrentProcessInfo);
465 rCurrentCondition.
GetDofList(rConditionDofList, rCurrentProcessInfo);
483 if (err != 0)
return err;
489 KRATOS_ERROR_IF(it->SolutionStepsDataHas(DISPLACEMENT) ==
false) <<
"DISPLACEMENT variable is not allocated for node " << it->Id() << std::endl;
490 KRATOS_ERROR_IF(it->SolutionStepsDataHas(VELOCITY) ==
false) <<
"VELOCITY variable is not allocated for node " << it->Id() << std::endl;
491 KRATOS_ERROR_IF(it->SolutionStepsDataHas(ACCELERATION) ==
false) <<
"ACCELERATION variable is not allocated for node " << it->Id() << std::endl;
498 KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_X) ==
false) <<
"Missing DISPLACEMENT_X dof on node " << it->Id() << std::endl;
499 KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_Y) ==
false) <<
"Missing DISPLACEMENT_Y dof on node " << it->Id() << std::endl;
500 KRATOS_ERROR_IF(it->HasDofFor(DISPLACEMENT_Z) ==
false) <<
"Missing DISPLACEMENT_Z dof on node " << it->Id() << std::endl;
518 rCurrentElement.
AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, FORCE_RESIDUAL, rCurrentProcessInfo);
538 rCurrentCondition.
AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, FORCE_RESIDUAL, rCurrentProcessInfo);
Base class for all Conditions.
Definition: condition.h:59
virtual void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const
Definition: condition.h:273
virtual void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:440
virtual void AddExplicitContribution(const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:609
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 CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:437
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
virtual void AddExplicitContribution(const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:622
virtual void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const
Definition: element.h:271
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
A MPM explicit scheme.
Definition: mpm_explicit_scheme.hpp:43
ModelPart::ElementsContainerType ElementsArrayType
Definition: mpm_explicit_scheme.hpp:67
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: mpm_explicit_scheme.hpp:69
void CalculateRHSContribution(Condition &rCurrentCondition, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &rCurrentProcessInfo) override
Functions that calculates the RHS of a "condition" object.
Definition: mpm_explicit_scheme.hpp:529
void Initialize(ModelPart &rModelPart) override
This is the place to initialize the Scheme. This is intended to be called just once when the strategy...
Definition: mpm_explicit_scheme.hpp:118
BaseType::TDataType TDataType
Definition: mpm_explicit_scheme.hpp:53
BaseType::Pointer BaseTypePointer
Definition: mpm_explicit_scheme.hpp:71
std::size_t IndexType
Definition of the index type.
Definition: mpm_explicit_scheme.hpp:83
ModelPart::NodesContainerType NodesArrayType
The arrays of elements and nodes.
Definition: mpm_explicit_scheme.hpp:74
void UpdateTranslationalDegreesOfFreedom(const ProcessInfo &r_current_process_info, NodeIterator itCurrentNode, const IndexType DisplacementPosition, const double delta_time, const SizeType DomainSize=3)
Definition: mpm_explicit_scheme.hpp:174
ModelPart & mr_grid_model_part
Definition: mpm_explicit_scheme.hpp:544
void InitializeSolutionStep(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Definition: mpm_explicit_scheme.hpp:220
BaseTypePointer Clone() override
Definition: mpm_explicit_scheme.hpp:109
static constexpr double numerical_limit
The definition of the numerical limit.
Definition: mpm_explicit_scheme.hpp:86
void FinalizeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Definition: mpm_explicit_scheme.hpp:336
virtual ~MPMExplicitScheme()
Destructor.
Definition: mpm_explicit_scheme.hpp:104
void GetDofList(const Element &rCurrentElement, Element::DofsVectorType &ElementalDofList, const ProcessInfo &CurrentProcessInfo) override
Definition: mpm_explicit_scheme.hpp:446
int Check(const ModelPart &rModelPart) const override
Definition: mpm_explicit_scheme.hpp:478
ModelPart::NodeIterator NodeIterator
Definition for the node iterator.
Definition: mpm_explicit_scheme.hpp:77
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: mpm_explicit_scheme.hpp:63
void CalculateRHSContribution(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: mpm_explicit_scheme.hpp:509
BaseType::TSystemVectorType TSystemVectorType
Definition: mpm_explicit_scheme.hpp:61
void Update(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Definition: mpm_explicit_scheme.hpp:138
void CalculateUpdatedGridVelocityField(const ProcessInfo &rCurrentProcessInfo, ModelPart &rModelPart)
Definition: mpm_explicit_scheme.hpp:385
Element::DofsVectorType DofsVectorType
Definition: mpm_explicit_scheme.hpp:57
BaseType::DofsArrayType DofsArrayType
Definition: mpm_explicit_scheme.hpp:55
KRATOS_CLASS_POINTER_DEFINITION(MPMExplicitScheme)
void calculateGridVelocityAndApplyDirichletBC(const ProcessInfo rCurrentProcessInfo, bool calculateVelocityFromMomenta=false)
Apply Dirichlet BCs to nodal velocity field.
Definition: mpm_explicit_scheme.hpp:290
MPMExplicitScheme(ModelPart &grid_model_part)
Default constructor.
Definition: mpm_explicit_scheme.hpp:95
BaseType::TSystemMatrixType TSystemMatrixType
Definition: mpm_explicit_scheme.hpp:59
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: mpm_explicit_scheme.hpp:65
std::size_t SizeType
Definition of the size type.
Definition: mpm_explicit_scheme.hpp:80
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: mpm_explicit_scheme.hpp:51
void GetDofList(const Condition &rCurrentCondition, Element::DofsVectorType &rConditionDofList, const ProcessInfo &rCurrentProcessInfo) override
Definition: mpm_explicit_scheme.hpp:460
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
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
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
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
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
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
void SetSchemeIsInitialized(bool SchemeIsInitializedFlag=true)
This method sets if the elements have been initialized or not (true by default)
Definition: scheme.h:188
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
BOOST_UBLAS_INLINE void clear()
Definition: array_1d.h:325
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
delta_time
Definition: generate_frictional_mortar_condition.py:130
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
float gamma
Definition: generate_two_fluid_navier_stokes.py:131
int j
Definition: quadrature.py:648
dummy
Definition: script.py:194
A
Definition: sensitivityMatrix.py:70
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17