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.
explicit_forward_euler_scheme.hpp
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: Albert Puigferrat Perez
11 // Ignasi de Pouplana
12 //
13 
14 #if !defined(KRATOS_EXPLICIT_FORWARD_EULER_SCHEME )
15 #define KRATOS_EXPLICIT_FORWARD_EULER_SCHEME
16 
17 // Project includes
18 #include "includes/define.h"
19 #include "includes/model_part.h"
20 // #include "solving_strategies/schemes/scheme.h"
23 
24 // Application includes
26 
27 namespace Kratos
28 {
29 
30 template<class TSparseSpace, class TDenseSpace>
31 
32 class ExplicitForwardEulerScheme : public GeneralizedNewmarkGN11Scheme<TSparseSpace,TDenseSpace>
33 {
34 
35 public:
36 
38 
45 
46 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
47 
49  ExplicitForwardEulerScheme(double theta) : GeneralizedNewmarkGN11Scheme<TSparseSpace,TDenseSpace>(theta)
50  {
51  }
52 
53  //------------------------------------------------------------------------------------
54 
57 
58 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
59 
60  void Predict(
61  ModelPart& r_model_part,
62  DofsArrayType& rDofSet,
65  TSystemVectorType& b) override
66  {
67  // this->UpdateVariablesDerivatives(r_model_part);
68  }
69 
70 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
71 
72  void Update(
73  ModelPart& r_model_part,
74  DofsArrayType& rDofSet,
77  TSystemVectorType& b) override
78  {
80 
81  int NumThreads = ParallelUtilities::GetNumThreads();
82  OpenMPUtils::PartitionVector DofSetPartition;
83  OpenMPUtils::DivideInPartitions(rDofSet.size(), NumThreads, DofSetPartition);
84 
85  #pragma omp parallel
86  {
87  int k = OpenMPUtils::ThisThread();
88 
89  typename DofsArrayType::iterator DofsBegin = rDofSet.begin() + DofSetPartition[k];
90  typename DofsArrayType::iterator DofsEnd = rDofSet.begin() + DofSetPartition[k+1];
91 
92  //Update Phi (DOFs)
93  for (typename DofsArrayType::iterator itDof = DofsBegin; itDof != DofsEnd; ++itDof)
94  {
95  if (itDof->IsFree())
96  itDof->GetSolutionStepValue() = TSparseSpace::GetValue(Dx, itDof->EquationId());
97  }
98  }
99 
100  //this->UpdateVariablesDerivatives(r_model_part);
101 
102  KRATOS_CATCH( "" )
103  }
104 
105 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
106 
107 protected:
108 
110 
111 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
112 
113  // inline void UpdateVariablesDerivatives(ModelPart& r_model_part)
114  // {
115  // KRATOS_TRY
116 
117  // ConvectionDiffusionSettings::Pointer my_settings = r_model_part.GetProcessInfo().GetValue(CONVECTION_DIFFUSION_SETTINGS);
118  // const Variable<double>& rUnknownVar = my_settings->GetUnknownVariable();
119 
120  // const int NNodes = static_cast<int>(r_model_part.Nodes().size());
121  // ModelPart::NodesContainerType::iterator node_begin = r_model_part.NodesBegin();
122 
123  // #pragma omp parallel for
124  // for(int i = 0; i < NNodes; i++)
125  // {
126  // ModelPart::NodesContainerType::iterator itNode = node_begin + i;
127 
128  // double& CurrentPhi = itNode->FastGetSolutionStepValue(TEMPERATURE);
129  // const double& PreviousPhi = itNode->FastGetSolutionStepValue(TEMPERATURE, 1);
130  // const double& CurrentPhiTheta = itNode->FastGetSolutionStepValue(rUnknownVar);
131 
132  // CurrentPhi = 1.0 / mTheta * CurrentPhiTheta + (1.0 - 1.0 / mTheta) * PreviousPhi;
133  // }
134 
135  // KRATOS_CATCH( "" )
136  // }
137 
138 }; // Class ExplicitForwardEulerScheme
139 } // namespace Kratos
140 
141 #endif // KRATOS_EXPLICIT_FORWARD_EULER_SCHEME defined
Definition: explicit_forward_euler_scheme.hpp:33
~ExplicitForwardEulerScheme() override
Destructor.
Definition: explicit_forward_euler_scheme.hpp:56
ExplicitForwardEulerScheme(double theta)
Constructor.
Definition: explicit_forward_euler_scheme.hpp:49
void Predict(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Performing the prediction of the solution.
Definition: explicit_forward_euler_scheme.hpp:60
GeneralizedNewmarkGN11Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: explicit_forward_euler_scheme.hpp:39
KRATOS_CLASS_POINTER_DEFINITION(ExplicitForwardEulerScheme)
BaseType::TSystemMatrixType TSystemMatrixType
Definition: explicit_forward_euler_scheme.hpp:41
void Update(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Performing the update of the solution.
Definition: explicit_forward_euler_scheme.hpp:72
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: explicit_forward_euler_scheme.hpp:43
BaseType::TSystemVectorType TSystemVectorType
Definition: explicit_forward_euler_scheme.hpp:42
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: explicit_forward_euler_scheme.hpp:44
BaseType::DofsArrayType DofsArrayType
Definition: explicit_forward_euler_scheme.hpp:40
Definition: generalized_newmark_GN11_scheme.hpp:32
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: generalized_newmark_GN11_scheme.hpp:42
BaseType::TSystemVectorType TSystemVectorType
Definition: generalized_newmark_GN11_scheme.hpp:41
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: generalized_newmark_GN11_scheme.hpp:43
BaseType::TSystemMatrixType TSystemMatrixType
Definition: generalized_newmark_GN11_scheme.hpp:40
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
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
typename TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: scheme.h:71
typename TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: scheme.h:74
#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
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int k
Definition: quadrature.py:595
A
Definition: sensitivityMatrix.py:70