7 #ifndef KRATOS_STRUCTURES_DEM_COUPLING_UTILITIES_H
8 #define KRATOS_STRUCTURES_DEM_COUPLING_UTILITIES_H
68 for (
unsigned int i = 0;
i < source_conditions.size();
i++) {
69 ModelPart::ConditionsContainerType::iterator it = r_source_model_part.
ConditionsBegin() +
i;
71 Condition::Pointer cond;
73 cond = Condition::Pointer(
new RigidEdge2D(
id, p_geometry, props));
75 cond = Condition::Pointer(
new RigidFace3D(
id, p_geometry, props));
78 cond->Set(DEMFlags::STICKY,
true);
88 std::vector<const Variable<double>* > list_of_variables_double_to_check = {&STATIC_FRICTION, &DYNAMIC_FRICTION, &FRICTION_DECAY, &WALL_COHESION, &SEVERITY_OF_WEAR, &IMPACT_WEAR_SEVERITY, &BRINELL_HARDNESS, &YOUNG_MODULUS, &POISSON_RATIO};
89 std::vector<const Variable<bool>* > list_of_variables_bool_to_check = {&COMPUTE_WEAR};
90 for (
int i=0;
i<(
int)list_of_variables_double_to_check.size();
i++) {
91 if(!props->Has(*list_of_variables_double_to_check[
i]))
return list_of_variables_double_to_check[
i]->Name();
93 for (
int i=0;
i<(
int)list_of_variables_bool_to_check.size();
i++) {
94 if(!props->Has(*list_of_variables_bool_to_check[
i]))
return list_of_variables_bool_to_check[
i]->Name();
100 #pragma omp parallel for
101 for (
int i=0;
i<(
int)r_model_part.
Nodes().size();
i++) {
105 noalias(averaged_force) = portion_of_the_force_which_is_new * node_dem_load + (1.0 - portion_of_the_force_which_is_new) * node_it->FastGetSolutionStepValue(DEM_SURFACE_LOAD, 1);
106 noalias(node_dem_load) = averaged_force;
112 const std::string sand_prod_filename =
"sand_production_graph.txt";
113 static std::ofstream ofs_sand_prod_file;
114 static bool first_time_entered =
true;
115 if (first_time_entered) {
116 ofs_sand_prod_file.open(sand_prod_filename,
std::ofstream::out | std::ofstream::trunc);
117 first_time_entered =
false;
121 double current_total_mass_in_grams = 0.0;
123 for (
unsigned int k = 0;
k < pElements.size();
k++) {
125 ModelPart::ElementsContainerType::iterator it = pElements.
ptr_begin() +
k;
126 Element* raw_p_element = &(*it);
128 if (p_sphere->
Is(ISOLATED))
continue;
129 const double particle_density = p_sphere->
GetDensity();
131 current_total_mass_in_grams += particle_volume * particle_density * 1.0e3;
133 static const double initial_total_mass_in_grams = current_total_mass_in_grams;
134 const double cumulative_sand_mass_in_grams = initial_total_mass_in_grams - current_total_mass_in_grams;
139 const double Pascals_to_psi_factor = 0.000145;
140 const double face_pressure_in_psi = fabs(r_process_info[TARGET_STRESS_Z]) * Pascals_to_psi_factor;
142 static std::ofstream sand_prod_file(
"sand_production_graph.txt",
std::ios_base::out | std::ios_base::app);
143 sand_prod_file <<
time <<
" " << face_pressure_in_psi <<
" " << cumulative_sand_mass_in_grams <<
'\n';
144 sand_prod_file.flush();
146 return cumulative_sand_mass_in_grams;
153 for (
unsigned int k = 0;
k < pElements.size();
k++) {
155 ModelPart::ElementsContainerType::iterator it = pElements.
ptr_begin() +
k;
156 Element* raw_p_element = &(*it);
158 if (p_sphere->
Is(ISOLATED))
continue;
159 bool go_to_next_particle =
false;
164 go_to_next_particle =
true;
168 if (go_to_next_particle)
continue;
169 else p_sphere->
Set(ISOLATED,
true);
175 const std::string sand_prod_filename =
"sand_production_graph_with_chunks_non_recursive.txt";
176 static std::ofstream ofs_sand_prod_file;
177 const std::string granulometry_distr_filename =
"granulometry_distribution.txt";
178 static std::ofstream ofs_granulometry_distr_file;
179 static bool first_time_entered =
true;
180 if (first_time_entered) {
181 ofs_sand_prod_file.open(sand_prod_filename,
std::ofstream::out | std::ofstream::trunc);
182 ofs_granulometry_distr_file.open(granulometry_distr_filename,
std::ofstream::out | std::ofstream::trunc);
183 first_time_entered =
false;
188 std::vector<double> chunks_masses;
190 for (
unsigned int k = 0;
k < pElements.size();
k++) {
191 ModelPart::ElementsContainerType::iterator it = pElements.
ptr_begin() +
k;
192 it->Set(VISITED,
false);
195 std::vector<SphericContinuumParticle*> stack_of_particles_to_check;
197 for (
unsigned int k = 0;
k < pElements.size();
k++) {
198 ModelPart::ElementsContainerType::iterator it = pElements.ptr_begin() +
k;
199 Element* raw_p_element = &(*it);
201 double this_chunk_mass = 0.0;
202 stack_of_particles_to_check.push_back(p_sphere);
203 while (stack_of_particles_to_check.size()) {
205 stack_of_particles_to_check.pop_back();
206 if (current_particle->
Is(VISITED))
continue;
207 const double particle_density = current_particle->
GetDensity();
209 this_chunk_mass += particle_volume * particle_density * 1.0e3;
211 current_particle->
Set(VISITED,
true);
215 if (p_neighbour_sphere == NULL)
continue;
217 if (p_neighbour_sphere->
Is(VISITED))
continue;
224 stack_of_particles_to_check.push_back(p_neigh_cont_sphere);
227 if (this_chunk_mass) chunks_masses.push_back(this_chunk_mass);
230 const double max_mass_of_a_single_chunck = *std::max_element(chunks_masses.begin(), chunks_masses.end());
231 const double current_total_mass_in_grams = max_mass_of_a_single_chunck;
232 static const double initial_total_mass_in_grams = current_total_mass_in_grams;
233 const double cumulative_sand_mass_in_grams = initial_total_mass_in_grams - current_total_mass_in_grams;
236 const double Pascals_to_psi_factor = 0.000145;
237 const double face_pressure_in_psi = fabs(r_process_info[TARGET_STRESS_Z]) * Pascals_to_psi_factor;
239 ofs_sand_prod_file <<
time <<
" " << face_pressure_in_psi <<
" " << cumulative_sand_mass_in_grams <<
'\n';
240 ofs_sand_prod_file.flush();
242 unsigned int number_of_time_steps_between_granulometry_prints = 1e9;
243 static unsigned int printing_counter = 0;
244 if (printing_counter == number_of_time_steps_between_granulometry_prints) {
245 ofs_granulometry_distr_file <<
time;
246 for (
unsigned int k = 0;
k < chunks_masses.size();
k++) {
247 ofs_granulometry_distr_file <<
" " << chunks_masses[
k];
249 ofs_granulometry_distr_file <<
'\n';
250 printing_counter = 0;
253 ofs_granulometry_distr_file.flush();
255 return cumulative_sand_mass_in_grams;
260 const std::string
filename =
"sand_production_graph_with_chunks.txt";
261 std::ifstream ifile(
filename.c_str());
262 static bool first_time_entered =
true;
263 if ((
bool) ifile && first_time_entered) {
265 first_time_entered =
false;
270 std::vector<double> chunks_masses;
272 for (
unsigned int k = 0;
k < pElements.size();
k++) {
273 ModelPart::ElementsContainerType::iterator it = pElements.
ptr_begin() +
k;
274 it->Set(VISITED,
false);
277 for (
unsigned int k = 0;
k < pElements.size();
k++) {
278 ModelPart::ElementsContainerType::iterator it = pElements.ptr_begin() +
k;
279 Element* raw_p_element = &(*it);
281 double this_chunk_mass = 0.0;
282 if( it->IsNot(VISITED) ) {
284 chunks_masses.push_back(this_chunk_mass);
288 const double max_mass_of_a_single_chunck = *std::max_element(chunks_masses.begin(), chunks_masses.end());
289 const double current_total_mass_in_grams = max_mass_of_a_single_chunck;
290 static const double initial_total_mass_in_grams = current_total_mass_in_grams;
291 const double cumulative_sand_mass_in_grams = initial_total_mass_in_grams - current_total_mass_in_grams;
293 ModelPart::ConditionsContainerType::iterator condition_begin = outer_walls_model_part.
ConditionsBegin();
294 const double Pascals_to_psi_factor = 0.000145;
295 const double face_pressure_in_psi = condition_begin->GetValue(POSITIVE_FACE_PRESSURE) * Pascals_to_psi_factor;
298 sand_prod_file <<
time <<
" " << face_pressure_in_psi <<
" " << cumulative_sand_mass_in_grams <<
'\n';
299 sand_prod_file.flush();
303 p_sphere->
Set(VISITED,
true);
304 const double particle_radius = p_sphere->
GetRadius();
305 const double particle_density = p_sphere->
GetDensity();
306 this_chunk_mass += (4.0/3.0) *
Globals::Pi * particle_density * particle_radius * particle_radius * particle_radius * 1000.0;
309 if (p_neighbour_sphere==NULL)
continue;
311 if (p_neighbour_sphere->
IsNot(VISITED)) {
320 const std::string
filename =
"sand_production_graph.txt";
321 std::ifstream ifile(
filename.c_str());
322 static bool first_time_entered =
true;
323 if ((
bool) ifile && first_time_entered) {
325 first_time_entered =
false;
329 double current_total_mass_in_grams = 0.0;
331 for (
unsigned int k = 0;
k < pElements.size();
k++) {
333 ModelPart::ElementsContainerType::iterator it = pElements.
ptr_begin() +
k;
334 Element* raw_p_element = &(*it);
336 if (p_sphere->
Is(ISOLATED))
continue;
337 const double particle_radius = p_sphere->
GetRadius();
338 const double particle_density = p_sphere->
GetDensity();
339 current_total_mass_in_grams += (4.0/3.0) *
Globals::Pi * particle_density * particle_radius * particle_radius * particle_radius * 1000.0;
341 static const double initial_total_mass_in_grams = current_total_mass_in_grams;
342 const double cumulative_sand_mass_in_grams = initial_total_mass_in_grams - current_total_mass_in_grams;
344 ModelPart::ConditionsContainerType::iterator condition_begin_1 = outer_walls_model_part_1.
ConditionsBegin();
345 ModelPart::ConditionsContainerType::iterator condition_begin_2 = outer_walls_model_part_2.
ConditionsBegin();
347 const double Pascals_to_psi_factor = 0.000145;
348 const double face_pressure_in_psi = (condition_begin_1->GetValue(POSITIVE_FACE_PRESSURE) +
349 condition_begin_2->GetValue(POSITIVE_FACE_PRESSURE) +
350 3.45e6) * Pascals_to_psi_factor * 0.33333333333333;
353 sand_prod_file <<
time <<
" " << face_pressure_in_psi <<
" " << cumulative_sand_mass_in_grams <<
'\n';
354 sand_prod_file.flush();
362 virtual std::string
Info()
const
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Definition: dem_structures_coupling_utilities.h:38
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: dem_structures_coupling_utilities.h:375
void ComputeSandProductionWithDepthFirstSearch(ModelPart &dem_model_part, ModelPart &outer_walls_model_part, const double time)
Definition: dem_structures_coupling_utilities.h:258
void ComputeTriaxialSandProduction(ModelPart &dem_model_part, ModelPart &outer_walls_model_part_1, ModelPart &outer_walls_model_part_2, const double time)
Definition: dem_structures_coupling_utilities.h:318
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: dem_structures_coupling_utilities.h:369
void DepthFirstSearchVisit(SphericContinuumParticle *p_sphere, double &this_chunk_mass)
Definition: dem_structures_coupling_utilities.h:302
virtual std::string Info() const
Turn back information as a stemplate<class T, std::size_t dim> tring.
Definition: dem_structures_coupling_utilities.h:362
ModelPart::NodesContainerType::ContainerType::iterator NodesIteratorType
Definition: dem_structures_coupling_utilities.h:40
virtual ~DemStructuresCouplingUtilities()
Destructor.
Definition: dem_structures_coupling_utilities.h:48
void SmoothLoadTrasferredToFem(ModelPart &r_model_part, const double portion_of_the_force_which_is_new)
Definition: dem_structures_coupling_utilities.h:99
DemStructuresCouplingUtilities()
Default constructor.
Definition: dem_structures_coupling_utilities.h:45
void TransferStructuresSkinToDem(ModelPart &r_source_model_part, ModelPart &r_destination_model_part, Properties::Pointer props)
Definition: dem_structures_coupling_utilities.h:53
double ComputeSandProductionWithDepthFirstSearchNonRecursiveImplementation(ModelPart &dem_model_part, ModelPart &outer_walls_model_part, const double time)
Definition: dem_structures_coupling_utilities.h:173
std::string CheckProvidedProperties(Properties::Pointer props)
Definition: dem_structures_coupling_utilities.h:87
KRATOS_CLASS_POINTER_DEFINITION(DemStructuresCouplingUtilities)
double ComputeSandProduction(ModelPart &dem_model_part, ModelPart &outer_walls_model_part, const double time)
Definition: dem_structures_coupling_utilities.h:110
void MarkBrokenSpheres(ModelPart &dem_model_part)
Definition: dem_structures_coupling_utilities.h:149
Base class for all Elements.
Definition: element.h:60
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
Geometry base class.
Definition: geometry.h:71
IndexType Id() const
Definition: indexed_object.h:107
ElementIterator ElementsEnd()
Definition: mesh.h:558
ElementsContainerType & Elements()
Definition: mesh.h:568
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
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
Communicator & GetCommunicator()
Definition: model_part.h:1821
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
void AddCondition(ConditionType::Pointer pNewCondition, IndexType ThisIndex=0)
Definition: model_part.cpp:1436
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
void AddNodes(std::vector< IndexType > const &NodeIds, IndexType ThisIndex=0)
Definition: model_part.cpp:235
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
ptr_iterator ptr_begin()
Returns an iterator pointing to the beginning of the underlying data container.
Definition: pointer_vector_set.h:386
iterator find(const key_type &Key)
Find an element with the specified key.
Definition: pointer_vector_set.h:678
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Definition: RigidEdge.h:24
Definition: RigidFace.h:21
Definition: spheric_continuum_particle.h:26
unsigned int mContinuumInitialNeighborsSize
Definition: spheric_continuum_particle.h:133
std::vector< int > mIniNeighbourFailureId
Definition: spheric_continuum_particle.h:130
Definition: spheric_particle.h:31
virtual double CalculateVolume()
Definition: spheric_particle.cpp:2196
virtual double GetDensity()
Definition: spheric_particle.cpp:2214
virtual double GetRadius()
Definition: spheric_particle.cpp:2195
std::vector< SphericParticle * > mNeighbourElements
Definition: spheric_particle.h:248
constexpr double Pi
Definition: global_variables.h:25
bool remove(const std::string &rPath)
Definition: kratos_filesystem.cpp:57
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
string filename
Definition: cube_mesher.py:766
time
Definition: face_heat.py:85
out
Definition: isotropic_damage_automatic_differentiation.py:200
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int k
Definition: quadrature.py:595
integer i
Definition: TensorModule.f:17