11 #if !defined(KRATOS_RECOVER_VOLUME_LOSSES_PROCESS_H_INCLUDED )
12 #define KRATOS_RECOVER_VOLUME_LOSSES_PROCESS_H_INCLUDED
94 mTotalVolume = this->ComputeVolume(mrModelPart);
104 mTotalVolume = this->RecoverVolume(mrModelPart);
114 mTotalVolume = this->RecoverVolume(mrModelPart);
149 std::string
Info()
const override
151 return "RecoverVolumeLossesProcess";
157 rOStream <<
"RecoverVolumeLossesProcess";
218 double RecoverVolume(
ModelPart& rModelPart)
223 double Tolerance = 1
e-6;
224 unsigned int NumberOfIterations = 5;
227 double CurrentVolume = this->ComputeVolume(rModelPart);
229 double Error = fabs(mTotalVolume-CurrentVolume);
231 this->SetFreeSurfaceElements(rModelPart);
232 double FreeSurfaceVolume = this->ComputeFreeSurfaceVolume(rModelPart);
233 double FreeSurfaceArea = this->ComputeFreeSurfaceArea(rModelPart);
235 double VolumeIncrement = mTotalVolume-CurrentVolume;
237 double Offset = VolumeIncrement/FreeSurfaceArea;
239 FreeSurfaceVolume += VolumeIncrement;
241 double CurrentFreeSurfaceVolume = 0;
243 while( ++iteration < NumberOfIterations && Error > Tolerance )
246 this->MoveFreeSurface(rModelPart,Offset);
248 CurrentFreeSurfaceVolume = this->ComputeFreeSurfaceVolume(rModelPart);
250 VolumeIncrement = (FreeSurfaceVolume - CurrentFreeSurfaceVolume);
252 Offset = (VolumeIncrement / FreeSurfaceArea );
254 Error = fabs(VolumeIncrement);
260 this->ResetFreeSurfaceElements(rModelPart);
262 CurrentVolume = this->ComputeVolume(rModelPart);
266 return CurrentVolume;
275 void MoveFreeSurface(ModelPart& rModelPart,
const double& rOffset)
279 ModelPart::NodesContainerType::iterator it_begin = rModelPart.NodesBegin();
280 int NumberOfNodes = rModelPart.NumberOfNodes();
282 #pragma omp parallel for
283 for (
int i=0;
i<NumberOfNodes; ++
i)
285 ModelPart::NodesContainerType::iterator i_node = it_begin +
i;
286 if(i_node->Is(FREE_SURFACE) && (i_node->IsNot(RIGID) && i_node->IsNot(SOLID)) ){
287 const array_1d<double,3>& rNormal = i_node->FastGetSolutionStepValue(NORMAL);
288 i_node->Coordinates() += rOffset * rNormal;
289 i_node->FastGetSolutionStepValue(DISPLACEMENT) += rOffset * rNormal;
290 i_node->FastGetSolutionStepValue(DISPLACEMENT,1) += rOffset * rNormal;
301 void SetFreeSurfaceElements(ModelPart& rModelPart)
305 for(ModelPart::ElementsContainerType::iterator i_elem = rModelPart.ElementsBegin() ; i_elem != rModelPart.ElementsEnd() ; ++i_elem)
307 for(
unsigned int i=0;
i<i_elem->GetGeometry().size(); ++
i)
309 if(i_elem->GetGeometry()[
i].Is(FREE_SURFACE)){
310 i_elem->Set(FREE_SURFACE,
true);
323 void ResetFreeSurfaceElements(ModelPart& rModelPart)
327 for(ModelPart::ElementsContainerType::iterator i_elem = rModelPart.ElementsBegin() ; i_elem != rModelPart.ElementsEnd() ; ++i_elem)
329 i_elem->Set(FREE_SURFACE,
false);
338 double ComputeVolume(ModelPart& rModelPart)
342 const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
343 double ModelPartVolume = 0;
347 ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
348 int NumberOfElements = rModelPart.NumberOfElements();
350 #pragma omp parallel for reduction(+:ModelPartVolume)
351 for (
int i=0;
i<NumberOfElements; ++
i)
353 ModelPart::ElementsContainerType::iterator i_elem = it_begin +
i;
354 if( i_elem->GetGeometry().Dimension() == 2 && i_elem->Is(FLUID) )
355 ModelPartVolume += i_elem->GetGeometry().Area();
360 ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
361 int NumberOfElements = rModelPart.NumberOfElements();
363 #pragma omp parallel for reduction(+:ModelPartVolume)
364 for (
int i=0;
i<NumberOfElements; ++
i)
366 ModelPart::ElementsContainerType::iterator i_elem = it_begin +
i;
367 if( i_elem->GetGeometry().Dimension() == 3 && i_elem->Is(FLUID) )
368 ModelPartVolume += i_elem->GetGeometry().Volume();
372 return ModelPartVolume;
381 double ComputeFreeSurfaceVolume(ModelPart& rModelPart)
385 const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
386 double ModelPartVolume = 0;
390 ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
391 int NumberOfElements = rModelPart.NumberOfElements();
393 #pragma omp parallel for reduction(+:ModelPartVolume)
394 for (
int i=0;
i<NumberOfElements; ++
i)
396 ModelPart::ElementsContainerType::iterator i_elem = it_begin +
i;
397 if( i_elem->GetGeometry().Dimension() == 2 && i_elem->Is(FREE_SURFACE) && i_elem->Is(FLUID) )
398 ModelPartVolume += i_elem->GetGeometry().Area();
403 ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
404 int NumberOfElements = rModelPart.NumberOfElements();
406 #pragma omp parallel for reduction(+:ModelPartVolume)
407 for (
int i=0;
i<NumberOfElements; ++
i)
409 ModelPart::ElementsContainerType::iterator i_elem = it_begin +
i;
410 if( i_elem->GetGeometry().Dimension() == 3 && i_elem->Is(FREE_SURFACE) && i_elem->Is(FLUID) )
411 ModelPartVolume += i_elem->GetGeometry().Volume();
415 return ModelPartVolume;
425 double ComputeFreeSurfaceArea(ModelPart& rModelPart)
429 const unsigned int dimension = rModelPart.GetProcessInfo()[SPACE_DIMENSION];
430 double FreeSurfaceArea = 0;
434 ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
435 int NumberOfElements = rModelPart.NumberOfElements();
437 #pragma omp parallel for reduction(+:FreeSurfaceArea)
438 for (
int i=0;
i<NumberOfElements; ++
i)
440 ModelPart::ElementsContainerType::iterator i_elem = it_begin +
i;
442 if( rGeometry.Dimension() == 2 && i_elem->Is(FREE_SURFACE) && i_elem->Is(FLUID) ){
443 for(
unsigned int j=0;
j<rGeometry.size()-1; ++
j)
445 if(rGeometry[
j].
Is(FREE_SURFACE)){
446 for(
unsigned int k=
j+1;
k<rGeometry.size(); ++
k)
448 if(rGeometry[
k].
Is(FREE_SURFACE)){
449 FreeSurfaceArea +=
norm_2( rGeometry[
k].Coordinates() - rGeometry[
j].Coordinates() );
460 DenseMatrix<unsigned int> lpofa;
461 DenseVector<unsigned int> lnofa;
463 ModelPart::ElementsContainerType::iterator it_begin = rModelPart.ElementsBegin();
464 int NumberOfElements = rModelPart.NumberOfElements();
466 #pragma omp parallel for private(lpofa,lnofa) reduction(+:FreeSurfaceArea)
467 for (
int i=0;
i<NumberOfElements; ++
i)
469 ModelPart::ElementsContainerType::iterator i_elem = it_begin +
i;
473 if( rGeometry.Dimension() == 3 && i_elem->Is(FREE_SURFACE) && i_elem->Is(FLUID) ){
476 rGeometry.NumberNodesInFaces(lnofa);
478 for(
unsigned int iface=0; iface<rGeometry.FacesNumber(); ++iface)
480 unsigned int free_surface = 0;
481 for(
unsigned int j=1;
j<=lnofa[iface]; ++
j)
482 if(rGeometry[
j].
Is(FREE_SURFACE))
485 if(free_surface==lnofa[iface])
486 FreeSurfaceArea+=Compute3DArea(rGeometry[lpofa(1,iface)].Coordinates(),
487 rGeometry[lpofa(2,iface)].Coordinates(),
488 rGeometry[lpofa(3,iface)].Coordinates());
494 return FreeSurfaceArea;
503 double Compute3DArea(array_1d<double,3> PointA, array_1d<double,3> PointB, array_1d<double,3> PointC){
507 double s = (
a+
b+
c) / 2.0;
508 double Area=std::sqrt(s*(s-
a)*(s-
b)*(s-
c));
562 rOStream << std::endl;
Base class for all Conditions.
Definition: condition.h:59
bool Is(Flags const &rOther) const
Definition: flags.h:274
Geometry base class.
Definition: geometry.h:71
virtual void NodesInFaces(DenseMatrix< unsigned int > &rNodesInFaces) const
Definition: geometry.h:2195
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
This class defines the node.
Definition: node.h:65
The base class for all processes in Kratos.
Definition: process.h:49
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Move free surface to restore volume losses.
Definition: recover_volume_losses_process.hpp:35
void ExecuteBeforeSolutionLoop() override
Definition: recover_volume_losses_process.hpp:92
ModelPart::NodeType NodeType
Definition: recover_volume_losses_process.hpp:43
void ExecuteAfterOutputStep() override
this function will be executed at every time step AFTER writing the output
Definition: recover_volume_losses_process.hpp:126
ConditionType::GeometryType GeometryType
Definition: recover_volume_losses_process.hpp:46
ModelPart::PropertiesType PropertiesType
Definition: recover_volume_losses_process.hpp:45
void Execute() override
Execute method is used to execute the AssignPropertiesToNodesProcess algorithms.
Definition: recover_volume_losses_process.hpp:80
RecoverVolumeLossesProcess(ModelPart &rModelPart, int EchoLevel)
Default constructor.
Definition: recover_volume_losses_process.hpp:53
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: recover_volume_losses_process.hpp:70
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: recover_volume_losses_process.hpp:110
ModelPart::ConditionType ConditionType
Definition: recover_volume_losses_process.hpp:44
void ExecuteFinalize() override
Definition: recover_volume_losses_process.hpp:133
void ExecuteInitializeSolutionStep() override
this function will be executed at every time step BEFORE performing the solve phase
Definition: recover_volume_losses_process.hpp:99
void ExecuteInitialize() override
Definition: recover_volume_losses_process.hpp:86
std::string Info() const override
Turn back information as a string.
Definition: recover_volume_losses_process.hpp:149
KRATOS_CLASS_POINTER_DEFINITION(RecoverVolumeLossesProcess)
Pointer definition of Process.
void PrintData(std::ostream &rOStream) const override
Print object's data.s.
Definition: recover_volume_losses_process.hpp:161
void ExecuteBeforeOutputStep() override
this function will be executed at every time step BEFORE writing the output
Definition: recover_volume_losses_process.hpp:120
virtual ~RecoverVolumeLossesProcess()
Destructor.
Definition: recover_volume_losses_process.hpp:62
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: recover_volume_losses_process.hpp:155
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
iteration
Definition: DEM_benchmarks.py:172
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31