-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12539 from KratosMultiphysics/dem/improvement_part1
[DEMApplication] Added new features and fixed a bug related to the periodic boundary [improvement part 1]
- Loading branch information
Showing
12 changed files
with
351 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
applications/DEMApplication/custom_utilities/fast_filling_creator.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
///////////////////////////////////////////////// | ||
// Main author: Chengshun Shang (CIMNE) | ||
// Email: [email protected] | ||
// Date: Sep 2023 | ||
///////////////////////////////////////////////// | ||
|
||
#include <string> | ||
#include <iostream> | ||
#include <random> | ||
#include <functional> | ||
|
||
#include "fast_filling_creator.h" | ||
#include "create_and_destroy.h" | ||
#include "custom_elements/spheric_continuum_particle.h" | ||
#include "custom_elements/cluster3D.h" | ||
#include "custom_constitutive/DEM_discontinuum_constitutive_law.h" | ||
#include "custom_constitutive/DEM_continuum_constitutive_law.h" | ||
#include "dem_fem_utilities.h" | ||
#include "GeometryFunctions.h" | ||
|
||
|
||
namespace Kratos { | ||
|
||
/// Constructor | ||
|
||
Fast_Filling_Creator::Fast_Filling_Creator(const int seed): | ||
Fast_Filling_Creator(Parameters(R"({})"), seed){} | ||
|
||
Fast_Filling_Creator::Fast_Filling_Creator(const Parameters& r_fast_filling_creator_settings, const int seed): | ||
mFastFillingCreatorSettings(Parameters(r_fast_filling_creator_settings)) | ||
{ | ||
std::mt19937 gen(seed); | ||
mGenerator = gen; | ||
|
||
mTotalNumberOfParticlesInjected = 0; | ||
mTotalMassInjected = 0.0; | ||
} | ||
|
||
double Fast_Filling_Creator::GetRandomParticleRadius(ParticleCreatorDestructor& creator) { | ||
|
||
KRATOS_TRY | ||
|
||
if (mFastFillingCreatorSettings["PROBABILITY_DISTRIBUTION"].GetString() == "piecewise_linear" || mFastFillingCreatorSettings["PROBABILITY_DISTRIBUTION"].GetString() == "discrete"){ | ||
|
||
const Parameters& rv_settings = mFastFillingCreatorSettings["random_variable_settings"]; | ||
int seed = rv_settings["seed"].GetInt(); | ||
if (!rv_settings["do_use_seed"].GetBool()){ | ||
seed = std::random_device{}(); | ||
} | ||
if (mFastFillingCreatorSettings["PROBABILITY_DISTRIBUTION"].GetString() == "piecewise_linear"){ | ||
|
||
mInletsRandomVariables[mFastFillingCreatorSettings["NAME"].GetString()] = std::unique_ptr<PiecewiseLinearRandomVariable>(new PiecewiseLinearRandomVariable(rv_settings, seed)); | ||
} | ||
|
||
else if (mFastFillingCreatorSettings["PROBABILITY_DISTRIBUTION"].GetString() == "discrete"){ | ||
mInletsRandomVariables[mFastFillingCreatorSettings["NAME"].GetString()] = std::unique_ptr<DiscreteRandomVariable>(new DiscreteRandomVariable(rv_settings, seed)); | ||
} | ||
|
||
else { | ||
KRATOS_ERROR << "Unknown Fast Filling Creator random variable: " << mFastFillingCreatorSettings["PROBABILITY_DISTRIBUTION"].GetString() << "."; | ||
} | ||
} | ||
|
||
double radius = creator.SelectRadius(mFastFillingCreatorSettings, mInletsRandomVariables); | ||
|
||
return radius; | ||
|
||
KRATOS_CATCH("") | ||
} | ||
|
||
bool Fast_Filling_Creator::CheckHasIndentationOrNot(const double x_1, const double y_1, const double z_1, const double r_1, | ||
const double x_2, const double y_2, const double z_2, const double r_2){ | ||
|
||
KRATOS_TRY | ||
|
||
double distance = std::sqrt(std::pow(x_1 - x_2, 2) + std::pow(y_1 - y_2, 2) + std::pow(z_1 - z_2, 2)); | ||
|
||
return distance <= (r_1 + r_2); | ||
|
||
KRATOS_CATCH("") | ||
} | ||
|
||
} // namespace Kratos |
80 changes: 80 additions & 0 deletions
80
applications/DEMApplication/custom_utilities/fast_filling_creator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
///////////////////////////////////////////////// | ||
// Main author: Chengshun Shang (CIMNE) | ||
// Email: [email protected] | ||
// Date: Sep 2023 | ||
///////////////////////////////////////////////// | ||
|
||
#if !defined(FAST_FILLING_PARTICLES_H) | ||
#define FAST_FILLING_PARTICLES_H | ||
|
||
// System includes | ||
#include <string> | ||
#include <iostream> | ||
#include <random> | ||
|
||
// Project includes | ||
#include "includes/define.h" | ||
#include "includes/variables.h" | ||
#include "includes/node.h" | ||
#include "includes/element.h" | ||
#include "geometries/geometry.h" | ||
#include "includes/properties.h" | ||
#include "includes/process_info.h" | ||
#include "includes/indexed_object.h" | ||
#include "containers/global_pointers_vector.h" | ||
#include "includes/constitutive_law.h" | ||
#include "includes/condition.h" | ||
#include "custom_elements/discrete_element.h" | ||
#include "custom_utilities/AuxiliaryFunctions.h" | ||
#include "custom_utilities/random_variable.h" | ||
#include "custom_utilities/piecewise_linear_random_variable.h" | ||
#include "custom_utilities/discrete_random_variable.h" | ||
#include "custom_utilities/properties_proxies.h" | ||
#include "custom_elements/spheric_particle.h" | ||
|
||
namespace Kratos { | ||
|
||
class ParticleCreatorDestructor; | ||
|
||
class KRATOS_API(DEM_APPLICATION) Fast_Filling_Creator | ||
{ | ||
public: | ||
|
||
typedef GlobalPointersVector<Element >::iterator ParticleWeakIteratorType; | ||
typedef GlobalPointersVector<Element> ParticleWeakVectorType; | ||
typedef ModelPart::ElementsContainerType ElementsArrayType; | ||
|
||
KRATOS_CLASS_POINTER_DEFINITION(Fast_Filling_Creator); | ||
|
||
/// Constructor: | ||
Fast_Filling_Creator(const int seed=42); | ||
Fast_Filling_Creator(const Parameters& r_fast_filling_creator_settings, const int seed=42); | ||
|
||
/// Destructor. | ||
virtual ~Fast_Filling_Creator(){} | ||
|
||
Fast_Filling_Creator(const Fast_Filling_Creator&) = delete; | ||
Fast_Filling_Creator& operator=(const Fast_Filling_Creator&) = delete; | ||
|
||
virtual double GetRandomParticleRadius(ParticleCreatorDestructor& creator); | ||
virtual bool CheckHasIndentationOrNot(const double x_1, const double y_1, const double z_1, const double r_1, | ||
const double x_2, const double y_2, const double z_2, const double r_2); | ||
|
||
protected: | ||
|
||
private: | ||
|
||
int mTotalNumberOfParticlesInjected; | ||
double mTotalMassInjected; | ||
//int mSeed; | ||
std::vector<double> mMassInjected; | ||
std::mt19937 mGenerator; | ||
|
||
std::map<std::string, std::unique_ptr<RandomVariable>> mInletsRandomVariables; | ||
std::map<std::string, Parameters> mInletsRandomSettings; | ||
Parameters mFastFillingCreatorSettings; | ||
}; | ||
}// namespace Kratos. | ||
|
||
#endif // FAST_FILLING_PARTICLES_H defined | ||
|
Oops, something went wrong.