8 #if !defined(KRATOS_BINBASED_DEM_FLUID_COUPLED_MAPPING)
9 #define KRATOS_BINBASED_DEM_FLUID_COUPLED_MAPPING
88 template <std::
size_t TDim,
typename TBaseTypeOfSwimmingParticle>
132 : mMustCalculateMaxNodalArea(true),
133 mFluidDeltaTime(0.0),
134 mFluidLastCouplingFromDEMTime(0.0),
135 mMaxNodalAreaInv(0.0),
136 mGentleCouplingInitiationInterval(mFluidDeltaTime),
137 mNumberOfDEMSamplesSoFarInTheCurrentFluidStep(0),
138 mpSpSearch(pSpSearch)
142 "gentle_coupling_initiation": {
144 "backward_coupling": {},
145 "forward_coupling" : {},
147 "viscosity_modification_type" : 0,
148 "n_particles_per_depth_distance" : 1,
149 "body_force_per_unit_mass_variable_name" : "BODY_FORCE"
153 mMinFluidFraction = rParameters["backward_coupling"][
"min_fluid_fraction"].
GetDouble();
154 mCouplingType = rParameters[
"coupling_type"].
GetInt();
155 mTimeAveragingType = rParameters[
"forward_coupling"][
"time_averaging_type"].
GetInt();
156 mViscosityModificationType = rParameters[
"viscosity_modification_type"].
GetInt();
157 mGentleCouplingInitiationInterval = rParameters[
"gentle_coupling_initiation"][
"initiation_interval"].
GetDouble();
158 mParticlesPerDepthDistance = rParameters[
"n_particles_per_depth_distance"].
GetInt();
160 if constexpr (TDim == 3){
161 mParticlesPerDepthDistance = 1;
165 mVariables = VariablesContainer();
179 template<
class TDataType>
181 std::string variable_list_identifier =
"DEM";
182 std::string coupling_variable_description =
"fluid-interpolated DEM phase variable";
183 AddCouplingVariable<TDataType>(r_variable, variable_list_identifier, coupling_variable_description);
186 template<
class TDataType>
188 std::string variable_list_identifier =
"Fluid";
189 std::string coupling_variable_description =
"DEM-interpolated fluid phase variable";
190 AddCouplingVariable<TDataType>(r_variable, variable_list_identifier, coupling_variable_description);
193 template<
class TDataType>
195 std::string variable_list_identifier =
"DEMToImpose";
196 std::string coupling_variable_description =
"DEM-phase variables with imposed fluid-interpolated values";
197 AddCouplingVariable<TDataType>(r_variable, variable_list_identifier, coupling_variable_description);
200 template<
class TDataType>
202 mAlphas[r_variable] = time_constant;
203 mIsFirstTimeFiltering[r_variable] =
true;
204 std::string variable_list_identifier =
"FluidTimeFiltered";
205 std::string coupling_variable_description =
"Fluid variables to be time-filtered";
206 AddCouplingVariable<TDataType>(r_variable, variable_list_identifier, coupling_variable_description);
209 template<
class TDataType>
212 if (std::is_same<TDataType, double>::value){
213 mVariables.Add(r_variable, variable_list_identifier,
"Scalar");
217 mVariables.Add(r_variable, variable_list_identifier,
"Vector");
221 KRATOS_ERROR <<
"Variable " << r_variable.
Name() <<
"'s type (" <<
typeid(r_variable).name()
222 <<
") is currently not available as a" << coupling_variable_description <<
"."
223 <<
"Please implement." << std::endl;
231 void UpdateOldVelocity(
ModelPart& r_dem_model_part);
232 void UpdateOldAdditionalForce(
ModelPart& r_dem_model_part);
234 void VariingRadiusHomogenizeFromDEMMesh(
ModelPart& r_dem_model_part,
ModelPart& r_fluid_model_part,
const double& search_radius,
const double& shape_factor,
bool must_search =
true,
bool use_drew_model =
false);
235 void HomogenizeFromDEMMesh(
ModelPart& r_dem_model_part,
ModelPart& r_fluid_model_part,
const double& search_radius,
const double& shape_factor,
bool must_search =
true,
bool use_drew_model =
false);
251 virtual std::string
Info()
const
267 return (mElementsPartition);
272 return (mNodesPartition);
278 return (pElements.ptr_begin() + this->GetElementPartition()[
k]);
284 return (pElements.ptr_begin() + this->GetElementPartition()[
k + 1]);
290 return (pNodes.ptr_begin() + this->GetNodePartition()[
k]);
296 return (pNodes.ptr_begin() + this->GetNodePartition()[
k + 1]);
312 class VariablesContainer
315 std::map<std::set<std::string>,
VariablesList> mCouplingVariablesMap;
317 VariablesList& GetVariablesList(std::string first_criterion, std::string second_criterion=
""){
318 std::set<std::string> identifier_set;
319 identifier_set.insert(
"");
320 identifier_set.insert(first_criterion);
321 identifier_set.insert(second_criterion);
322 if (mCouplingVariablesMap.find(identifier_set) == mCouplingVariablesMap.end()){
324 mCouplingVariablesMap[identifier_set] = new_list;
326 return mCouplingVariablesMap[identifier_set];
329 bool Is(
VariableData const& rVariable, std::string first_criterion, std::string second_criterion=
""){
330 return GetVariablesList(first_criterion, second_criterion).
Has(rVariable);
333 void Add(
VariableData const& rVariable, std::string list_identifier, std::string type_id=
""){
334 GetVariablesList(list_identifier, type_id).Add(rVariable);
335 GetVariablesList(type_id).Add(rVariable);
336 GetVariablesList(list_identifier).Add(rVariable);
337 GetVariablesList(
"",
"").Add(rVariable);
341 bool mMustCalculateMaxNodalArea;
342 double mFluidDeltaTime;
343 double mFluidLastCouplingFromDEMTime;
344 double mMinFluidFraction;
345 double mMaxNodalAreaInv;
346 double mGentleCouplingInitiationInterval;
348 int mTimeAveragingType;
349 int mViscosityModificationType;
350 int mParticlesPerDepthDistance;
351 int mNumberOfDEMSamplesSoFarInTheCurrentFluidStep;
354 VariablesContainer mVariables;
355 std::map<VariableData, double> mAlphas;
356 std::map<VariableData, bool> mIsFirstTimeFiltering;
357 PointPointSearch::Pointer mpPointPointSearch;
358 SpatialSearch::Pointer mpSpSearch;
365 std::vector<double> mSearchRadii;
366 std::vector<SwimmingParticle<TBaseTypeOfSwimmingParticle>* > mSwimmingSphereElementPointers;
367 VectorResultNodesContainerType mVectorsOfNeighNodes;
368 VectorDistanceType mVectorsOfDistances;
369 VectorDistanceType mVectorsOfRadii;
379 void ComputeHomogenizedFluidFraction(
ModelPart& r_fluid_model_part,
ModelPart& r_dem_model_part);
382 void SearchParticleNodalNeighbours(
ModelPart& r_fluid_model_part,
ModelPart& r_dem_model_part,
const double& search_radius);
383 void SearchParticleNodalNeighboursFixedRadius(
ModelPart& r_fluid_model_part,
ModelPart& r_dem_model_part,
const double& search_radius);
384 void RecalculateDistances(
ModelPart& r_dem_model_part);
385 void UpdateGentleCouplingInitiationCoefficients(
ModelPart& r_dem_model_part);
387 double CalculateNormOfSymmetricGradient(
const Geometry<Node >& geom,
const int index);
389 void Project(Element::Pointer p_elem,
const Vector&
N, Node::Pointer p_node,
const VariableData *r_destination_variable,
double alpha);
390 void DistributeDimensionalContributionToFluidFraction(Element::Pointer p_elem,
const Vector&
N, ParticleType& particle);
391 void Distribute(Element::Pointer p_elem,
const Vector&
N, Node::Pointer p_node,
const VariableData *r_destination_variable);
392 void ComputeHomogenizedNodalVariable(
const ParticleType& particle,
const ResultNodesContainerType& neighbours,
const DistanceType& weights,
const VariableData *r_destination_variable,
bool use_drew_model);
393 void CalculateFluidFraction(
ModelPart& r_fluid_model_part);
394 void CalculateFluidMassFraction(
ModelPart& r_fluid_model_part);
397 void CalculateVelocityProjectedRate(Node::Pointer p_node);
399 void InterpolateShearRate(Element::Pointer p_elem,
const Vector&
N, Node::Pointer p_node,
const Variable<double>& r_destination_variable);
400 void InterpolateShearRate(Element::Pointer p_elem,
const Vector&
N, Node::Pointer p_node,
const Variable<double>& r_destination_variable,
double alpha);
405 void CalculateNodalFluidFractionWithConstantWeighing(Element::Pointer p_elem,
const Vector&
N, ParticleType& particle);
406 void CalculateNodalFluidFractionWithLinearWeighing(Element::Pointer p_elem,
const Vector&
N, ParticleType& particle);
407 void CalculateNodalFluidFractionByLumpedL2Projection(Element::Pointer p_elem,
const Vector&
N, Node::Pointer p_node);
409 void TransferByAveraging(
const ParticleType& particle,
const ResultNodesContainerType& neighbours,
const DistanceType& weights,
const Variable<
array_1d<double, 3> >& r_destination_variable,
const Variable<
array_1d<double, 3> >& r_origin_variable,
bool use_drew_model);
410 void CalculateNodalFluidFractionByAveraging(ParticleType& particle,
const ResultNodesContainerType& neighbours,
const DistanceType& weights);
411 void CalculateNodalSolidFractionByAveraging(
const Node::Pointer p_node,
const ResultNodesContainerType& neighbours,
const DistanceType& weights,
const double averaging_volume_inv);
414 void ResetDEMVariables(
ModelPart& r_dem_model_part);
415 void ResetFluidVariables(
ModelPart& r_fluid_model_part);
418 void CalculateFluidNodesMaxNodalArea(
ModelPart& r_fluid_model_part);
420 inline unsigned int GetNearestNode(
const Vector&
N);
421 void FillVectorOfSwimmingSpheres(
ModelPart& r_dem_model_part);
458 template<std::
size_t TDim,
typename TBaseTypeOfSwimmingParticle>
463 rOStream << std::endl;
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Definition: binbased_DEM_fluid_coupled_mapping.h:90
std::size_t ListIndexType
Definition: binbased_DEM_fluid_coupled_mapping.h:106
NodesArrayType::iterator GetNodePartitionBegin(ModelPart &r_model_part, unsigned int k)
Definition: binbased_DEM_fluid_coupled_mapping.h:287
void AddDEMCouplingVariable(Variable< TDataType > const &r_variable)
Definition: binbased_DEM_fluid_coupled_mapping.h:180
void AddCouplingVariable(Variable< TDataType > const &r_variable, std::string variable_list_identifier, std::string coupling_variable_description)
Definition: binbased_DEM_fluid_coupled_mapping.h:210
DenseVector< unsigned int > mNodesPartition
Definition: binbased_DEM_fluid_coupled_mapping.h:303
DenseVector< unsigned int > mElementsPartition
Definition: binbased_DEM_fluid_coupled_mapping.h:302
ModelPart::NodesContainerType::iterator NodeIteratorType
Definition: binbased_DEM_fluid_coupled_mapping.h:104
std::vector< ResultNodesContainerType > VectorResultNodesContainerType
Definition: binbased_DEM_fluid_coupled_mapping.h:102
ModelPart::NodesContainerType NodesArrayType
Definition: binbased_DEM_fluid_coupled_mapping.h:100
void AddFluidVariableToBeTimeFiltered(Variable< TDataType > const &r_variable, const double time_constant)
Definition: binbased_DEM_fluid_coupled_mapping.h:201
DenseVector< unsigned int > & GetNodePartition()
Definition: binbased_DEM_fluid_coupled_mapping.h:270
DenseVector< unsigned int > & GetElementPartition()
Definition: binbased_DEM_fluid_coupled_mapping.h:265
KRATOS_CLASS_POINTER_DEFINITION(BinBasedDEMFluidCoupledMapping_TDim_TBaseTypeOfSwimmingParticle)
virtual ~BinBasedDEMFluidCoupledMapping()
Destructor.
Definition: binbased_DEM_fluid_coupled_mapping.h:169
NodesArrayType::iterator GetNodePartitionEnd(ModelPart &r_model_part, unsigned int k)
Definition: binbased_DEM_fluid_coupled_mapping.h:293
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: binbased_DEM_fluid_coupled_mapping.h:260
void AddFluidCouplingVariable(Variable< TDataType > const &r_variable)
Definition: binbased_DEM_fluid_coupled_mapping.h:187
virtual std::string Info() const
Turn back information as a stemplate<class T, std::size_t dim> tring.
Definition: binbased_DEM_fluid_coupled_mapping.h:251
ModelPart::ElementsContainerType ElementsArrayType
Definition: binbased_DEM_fluid_coupled_mapping.h:94
void AddDEMVariablesToImpose(Variable< TDataType > const &r_variable)
Definition: binbased_DEM_fluid_coupled_mapping.h:194
ElementsArrayType::ContainerType ResultElementsContainerType
Definition: binbased_DEM_fluid_coupled_mapping.h:95
SpatialSearch::DistanceType DistanceType
Definition: binbased_DEM_fluid_coupled_mapping.h:107
NodesArrayType::ContainerType ResultNodesContainerType
Definition: binbased_DEM_fluid_coupled_mapping.h:101
ElementsArrayType::iterator GetElementPartitionBegin(ModelPart &r_model_part, unsigned int k)
Definition: binbased_DEM_fluid_coupled_mapping.h:275
SpatialSearch::VectorDistanceType VectorDistanceType
Definition: binbased_DEM_fluid_coupled_mapping.h:108
ElementsArrayType::iterator GetElementPartitionEnd(ModelPart &r_model_part, unsigned int k)
Definition: binbased_DEM_fluid_coupled_mapping.h:281
BinBasedDEMFluidCoupledMapping(Parameters &rParameters, SpatialSearch::Pointer pSpSearch=NULL)
Default constructor.
Definition: binbased_DEM_fluid_coupled_mapping.h:131
BinBasedDEMFluidCoupledMapping< TDim, TBaseTypeOfSwimmingParticle > BinBasedDEMFluidCoupledMapping_TDim_TBaseTypeOfSwimmingParticle
Pointer definition of BinBasedDEMFluidCoupledMapping.
Definition: binbased_DEM_fluid_coupled_mapping.h:111
ModelPart::ElementsContainerType::iterator ElementIteratorType
Definition: binbased_DEM_fluid_coupled_mapping.h:97
std::vector< Node::Pointer > NodalPointersContainerType
Definition: binbased_DEM_fluid_coupled_mapping.h:103
SwimmingParticle< TBaseTypeOfSwimmingParticle > ParticleType
Definition: binbased_DEM_fluid_coupled_mapping.h:98
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: binbased_DEM_fluid_coupled_mapping.h:257
std::vector< ResultElementsContainerType > VectorResultElementsContainerType
Definition: binbased_DEM_fluid_coupled_mapping.h:96
This class is designed to allow the fast location of MANY points on the top of a 3D mesh.
Definition: binbased_fast_point_locator.h:68
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Definition: fluid_field_utility.h:13
Geometry base class.
Definition: geometry.h:71
Definition: amatrix_interface.h:41
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
NodesContainerType & Nodes()
Definition: mesh.h:346
ElementsContainerType & Elements()
Definition: mesh.h:568
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
Communicator & GetCommunicator()
Definition: model_part.h:1821
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
std::vector< DistanceType > VectorDistanceType
Definition: spatial_search.h:97
std::vector< double > DistanceType
Definition: spatial_search.h:96
Definition: swimming_particle.h:28
This class is the base of variables and variable's components which contains their common data.
Definition: variable_data.h:49
const std::string & Name() const
Definition: variable_data.h:201
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
Holds a list of variables and their position in VariablesListDataValueContainer.
Definition: variables_list.h:50
bool Has(const VariableData &rThisVariable) const
Definition: variables_list.h:372
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
ModelPart::NodesContainerType::iterator NodeIteratorType
Definition: fix_free_velocity_on_nodes_process.h:25
void ModifyViscosityLikeEinstein(double &viscosity, const double solid_fraction)
This class allows the interpolation between non-matching simplicial meshes in 2D and 3D with linear s...
Definition: binbased_DEM_fluid_coupled_mapping.cpp:9
void ModifyViscosityLikeLiu(double &viscosity, const double solid_fraction)
Definition: binbased_DEM_fluid_coupled_mapping.cpp:15
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
float viscosity
Definition: edgebased_var.py:8
parameters
Definition: fluid_chimera_analysis.py:35
alpha
Definition: generate_convection_diffusion_explicit_element.py:113
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
def Interpolate(variable, entity, sf_values, historical_value)
Definition: point_output_process.py:231
int k
Definition: quadrature.py:595
N
Definition: sensitivityMatrix.py:29
float factor
for node in (self.combined_model_part).Nodes: pold = node.GetSolutionStepValue(PRESSURE,...
Definition: ulf_PGLASS.py:254
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247