11 #if !defined(KRATOS_ENERGY_UTILITIES_H_INCLUDED)
12 #define KRATOS_ENERGY_UTILITIES_H_INCLUDED
85 double KinematicEnergy = 0.0;
94 int number_of_threads = omp_get_max_threads();
96 int number_of_threads = 1;
99 if( mParallel ==
false ){ number_of_threads = 1; }
101 vector<unsigned int> node_partition;
102 OpenMPUtils::CreatePartition(number_of_threads, pNodes.size(), node_partition);
104 std::vector<double> KinematicEnergyPartition(number_of_threads);
105 for(
int i=0;
i<number_of_threads;
i++){
106 KinematicEnergyPartition[
i] = 0.0;
109 #pragma omp parallel private (KinematicEnergy, vel, mass, vel_arg)
112 ModelPart::NodesContainerType::iterator NodeBegin = pNodes.begin() + node_partition[
k];
113 ModelPart::NodesContainerType::iterator NodeEnd = pNodes.begin() + node_partition[
k + 1];
116 for (ModelPart::NodesContainerType::const_iterator in = NodeBegin; in != NodeEnd; in++){
118 mass = in->FastGetSolutionStepValue(NODAL_MASS);
119 vel = in->FastGetSolutionStepValue(VELOCITY);
121 KinematicEnergyPartition[
k] += 0.5*vel_arg*vel_arg*mass;
125 for(
int i=0;
i<number_of_threads;
i++){
126 KinematicEnergy += KinematicEnergyPartition[
i];
130 return KinematicEnergy;
142 double PotentialEnergy = 0.0;
148 Vector VolumeAcceleration(3);
154 int number_of_threads = omp_get_max_threads();
156 int number_of_threads = 1;
159 if( mParallel ==
false ){ number_of_threads = 1; }
161 vector<unsigned int> node_partition;
162 OpenMPUtils::CreatePartition(number_of_threads, pNodes.size(), node_partition);
164 std::vector<double> PotentialEnergyPartition(number_of_threads);
165 for(
int i=0;
i<number_of_threads;
i++){
166 PotentialEnergyPartition[
i] = 0.0;
169 #pragma omp parallel private (gh, VolumeAcceleration, mass, coord)
172 ModelPart::NodesContainerType::iterator NodeBegin = pNodes.begin() + node_partition[
k];
173 ModelPart::NodesContainerType::iterator NodeEnd = pNodes.begin() + node_partition[
k + 1];
176 for (ModelPart::NodesContainerType::const_iterator in = NodeBegin; in != NodeEnd; in++)
179 mass = in->FastGetSolutionStepValue(NODAL_MASS);
180 coord = in->Coordinates();
183 VolumeAcceleration = in->FastGetSolutionStepValue(VOLUME_ACCELERATION);
185 for (
unsigned int i=0;
i<3;
i++){
186 gh += coord(
i)*-VolumeAcceleration(
i);
189 PotentialEnergyPartition[
k] += mass*gh;
194 for(
int i=0;
i<number_of_threads;
i++){
195 PotentialEnergy += PotentialEnergyPartition[
i];
199 return PotentialEnergy;
212 double StrainEnergy = 0.0;
218 int number_of_threads = omp_get_max_threads();
220 int number_of_threads = 1;
223 if( mParallel ==
false ){ number_of_threads = 1; }
225 vector<unsigned int> element_partition;
226 OpenMPUtils::CreatePartition(number_of_threads, pElements.size(), element_partition);
227 std::vector<double> StrainEnergyPartition(number_of_threads);
228 for(
int i=0;
i<number_of_threads;
i++){
229 StrainEnergyPartition[
i] = 0.0;
235 ModelPart::ElementsContainerType::iterator ElemBegin = pElements.begin() + element_partition[
k];
236 ModelPart::ElementsContainerType::iterator ElemEnd = pElements.begin() + element_partition[
k + 1];
238 for(ModelPart::ElementsContainerType::const_iterator ie = ElemBegin; ie != ElemEnd; ie++)
243 std::vector<double> rOutput;
244 ie->CalculateOnIntegrationPoints(STRAIN_ENERGY,rOutput,rCurrentProcessInfo );
246 for (
unsigned int PointNumber = 0; PointNumber < integration_points.size(); PointNumber++ )
249 StrainEnergyPartition[
k] += rOutput[PointNumber];
257 for(
int i=0;
i<number_of_threads;
i++){
258 StrainEnergy += StrainEnergyPartition[
i];
263 std::cout<<
" [ NO_STRAIN_ENERGY] "<<std::endl;
289 int number_of_threads = omp_get_max_threads();
291 int number_of_threads = 1;
294 vector<unsigned int> node_partition;
295 OpenMPUtils::CreatePartition(number_of_threads, pNodes.size(), node_partition);
297 vector<unsigned int> element_partition;
298 OpenMPUtils::CreatePartition(number_of_threads, pElements.size(), element_partition);
306 for(
int k=0;
k<number_of_threads;
k++)
308 ModelPart::NodesContainerType::iterator i_begin=pNodes.ptr_begin()+node_partition[
k];
309 ModelPart::NodesContainerType::iterator i_end=pNodes.ptr_begin()+node_partition[
k+1];
313 double& nodal_mass =
i->FastGetSolutionStepValue(NODAL_MASS);
322 unsigned int index = 0;
327 ModelPart::ElementsContainerType::iterator ElemBegin = pElements.begin() + element_partition[
k];
328 ModelPart::ElementsContainerType::iterator ElemEnd = pElements.begin() + element_partition[
k + 1];
330 for (ModelPart::ElementsContainerType::iterator itElem = ElemBegin; itElem != ElemEnd; itElem++)
336 (itElem)->CalculateMassMatrix(MassMatrix, rCurrentProcessInfo);
341 for (
unsigned int i = 0;
i <geometry.
size();
i++)
345 geometry(
i)->SetLock();
346 double& mass = geometry(
i)->FastGetSolutionStepValue(NODAL_MASS);
347 mass += MassMatrix(index,index);
348 geometry(
i)->UnSetLock();
Short class definition.
Definition: energy_utilities.h:44
ModelPart::ElementsContainerType ElementsContainerType
Definition: energy_utilities.h:50
double GetTotalKinematicEnergy(ModelPart &rModelPart)
Definition: energy_utilities.h:81
double GetGravitationalEnergy(ModelPart &rModelPart)
Definition: energy_utilities.h:138
void CalculateNodalMass(ModelPart::NodesContainerType &pNodes, ModelPart::ElementsContainerType &pElements, ProcessInfo &rCurrentProcessInfo)
Definition: energy_utilities.h:284
virtual void SetEchoLevel(int Level)
Definition: energy_utilities.h:365
virtual ~EnergyUtilities()
Destructor.
Definition: energy_utilities.h:64
EnergyUtilities()
Default constructor.
Definition: energy_utilities.h:58
int GetEchoLevel()
Definition: energy_utilities.h:370
double GetExternallyAppliedEnergy(ModelPart &rModelPart)
Definition: energy_utilities.h:274
double GetTotalStrainEnergy(ModelPart &rModelPart)
Definition: energy_utilities.h:207
EnergyUtilities(bool Parallel)
Definition: energy_utilities.h:60
ModelPart::MeshType::GeometryType GeometryType
Definition: energy_utilities.h:51
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: geometry.h:161
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
static double Norm3(const TVectorType &a)
Calculates the norm of vector "a" which is assumed to be of size 3.
Definition: math_utils.h:691
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
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
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
#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
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
vel
Definition: pure_conduction.py:76
int k
Definition: quadrature.py:595
integer i
Definition: TensorModule.f:17