19 #ifndef CABLE_NET_MPC_PROCESS_H
20 #define CABLE_NET_MPC_PROCESS_H
75 ModelPart &master_model_part = mrModelPart.GetSubModelPart(mParameters[
"master_sub_model_part_name"].GetString());
76 ModelPart &slave_model_part = mrModelPart.GetSubModelPart(mParameters[
"slave_sub_model_part_name"].GetString());
77 double neighbor_search_radius = mParameters[
"neighbor_search_radius"].GetDouble();
78 const int bucket_size = mParameters[
"bucket_size"].GetInt();
82 NodeVector master_node_list(r_nodes_master.size());
85 KDTree::Pointer search_tree =
91 const int max_number_of_neighbors = 2;
92 for(
NodeType& node_i : r_nodes_slave)
94 neighbor_search_radius = mParameters[
"neighbor_search_radius"].GetDouble();
96 NodeVector neighbor_nodes( max_number_of_neighbors );
97 DoubleVector resulting_squared_distances( max_number_of_neighbors );
106 while (number_of_neighbors<1)
109 neighbor_nodes.clear();
110 resulting_squared_distances.clear();
112 number_of_neighbors = search_tree->SearchInRadius( node_i,
113 neighbor_search_radius,
114 neighbor_nodes.begin(),
115 resulting_squared_distances.begin(),
116 max_number_of_neighbors );
118 (nr_searches>1000.0)?(
KRATOS_ERROR <<
"found no neighbor for slave node "
119 << node_i.Id() <<
" " << node_i.Coordinates() << std::endl):neighbor_search_radius*=2.0;
122 if(mParameters[
"debug_info"].GetBool()) std::cout <<
"nr.ne.: " << number_of_neighbors << std::endl;
123 DoubleVector list_of_weights( number_of_neighbors, 0.0 );
149 ModelPart &master_model_part = mrModelPart.GetSubModelPart(mParameters[
"master_sub_model_part_name"].GetString());
150 ModelPart &slave_model_part = mrModelPart.GetSubModelPart(mParameters[
"slave_sub_model_part_name"].GetString());
155 for(
SizeType dof_iterator=0;dof_iterator<mParameters[
"variable_names"].size();++dof_iterator)
159 for(
SizeType master_iterator =0;master_iterator<rNumberOfNeighbors;++master_iterator)
163 ApplyMultipointConstraintsProcess::AddMasterSlaveRelationWithNodesAndVariableComponents(
164 r_nodes_master[rNeighborNodes[master_iterator]->Id()],current_dof,
165 r_nodes_slave[rCurrentSlaveNode.
Id()],current_dof,rNodalNeighborWeights[master_iterator],0);
167 if(mParameters[
"debug_info"].GetBool()){
168 std::cout << rNeighborNodes[master_iterator]->Id() <<
"-----" << rCurrentSlaveNode.
Id() <<
"-----" << rNodalNeighborWeights[master_iterator] << std::endl;
183 ModelPart &master_model_part = mrModelPart.GetSubModelPart(mParameters[
"master_sub_model_part_name"].GetString());
186 MasterNodeList.resize(r_nodes.size());
187 auto i_begin = master_model_part.
NodesBegin();
192 MasterNodeList[
i] = pnode;
202 const double numerical_limit = std::numeric_limits<double>::epsilon();
203 double total_nodal_distance = 0.00;
205 if((rNumberOfNeighbors==1)&&(std::abs(rResultingSquaredDistances[0])<numerical_limit))
206 {rNodalNeighborWeights[0] = 1.00;}
209 for (
SizeType i=0;
i<rNumberOfNeighbors;++
i) total_nodal_distance+=std::sqrt(rResultingSquaredDistances[
i]);
212 double current_weight = std::sqrt(rResultingSquaredDistances[rNumberOfNeighbors-(
i+1)])/total_nodal_distance;
213 (current_weight>numerical_limit) ? (rNodalNeighborWeights[
i]=current_weight) : (rNodalNeighborWeights[
i]=0.00);
224 {
if (mParameters[
"reform_every_step"].GetBool())
240 auto master_element_begin = rMasterModelPart.
ElementsBegin();
245 for (
SizeType slave_element_counter(0);slave_element_counter<r_slave_elements.size();slave_element_counter++)
247 auto slave_current_element = slave_element_begin+slave_element_counter;
248 const GeometryType& r_element_geometry = slave_current_element->GetGeometry();
249 const NodeType& r_node_a = r_element_geometry[0];
250 const NodeType& r_node_b = r_element_geometry[1];
254 slave_current_element->CalculateRightHandSide(right_hand_side,r_current_process_info);
255 const double internal_truss_force = std::sqrt(std::pow(right_hand_side[3],2)+
256 std::pow(right_hand_side[4],2)+std::pow(right_hand_side[5],2));
258 const double friction_coeff = 10.0;
259 const double friction_stiff = friction_coeff*internal_truss_force;
261 for (
SizeType master_element_counter(0);master_element_counter<r_master_elements.size();master_element_counter++)
278 double total_length(0.0);
282 for(
SizeType neighbor_itr = 0 ; neighbor_itr<number_of_neighbors ; neighbor_itr++)
287 temp_vector[neighbor_itr] = current_length;
288 total_length += current_length;
291 for(
SizeType i=0;
i<number_of_neighbors;++
i) temp_vector[
i] /= total_length;
292 for(
SizeType i=0;
i<number_of_neighbors;++
i) list_of_weights[
i] = temp_vector[number_of_neighbors-(
i+1)];
305 const double dx = rNodeJ.
X0() - rNodeI.
X0();
306 const double dy = rNodeJ.
Y0() - rNodeI.
Y0();
307 const double dz = rNodeJ.
Z0() - rNodeI.
Z0();
308 const double l = std::sqrt((du + dx) * (du + dx) + (dv + dy) * (dv + dy) +
309 (dw + dz) * (dw + dz));
327 bool mIsInitialized =
false;
Short class definition.
Definition: bucket.h:57
Definition: old_cable_net_mpc_process.h:40
void CalculateNodalWeights(const DoubleVector &rResultingSquaredDistances, DoubleVector &rNodalNeighborWeights, const SizeType &rNumberOfNeighbors)
This function re-calculates the weights used in mpc.
Definition: old_cable_net_mpc_process.h:200
double CalculateCurrentLength(ModelPart::NodeType &rNodeI, ModelPart::NodeType &rNodeJ)
Definition: old_cable_net_mpc_process.h:295
std::vector< NodeTypePointer > NodeVector
Definition: old_cable_net_mpc_process.h:45
Element::VectorType VectorType
Definition: old_cable_net_mpc_process.h:52
Node NodeType
Definition: old_cable_net_mpc_process.h:43
void ComputeWeightForAllNeighbors(ModelPart::NodeType &design_node, NodeVector &neighbor_nodes, SizeType number_of_neighbors, DoubleVector &list_of_weights)
Definition: old_cable_net_mpc_process.h:271
Node ::Pointer NodeTypePointer
Definition: old_cable_net_mpc_process.h:44
Element::GeometryType GeometryType
Definition: old_cable_net_mpc_process.h:51
void CoupleSlaveToNeighborMasterNodes(const NodeType &rCurrentSlaveNode, const NodeVector &rNeighborNodes, const DoubleVector &rNodalNeighborWeights, const SizeType &rNumberOfNeighbors)
This function couples nodes by calling the parent class functions.
Definition: old_cable_net_mpc_process.h:145
KRATOS_CLASS_POINTER_DEFINITION(CableNetMpcProcess)
Pointer definition of ApplyMultipointConstraintsProcess.
std::vector< NodeTypePointer >::iterator NodeIterator
Definition: old_cable_net_mpc_process.h:47
ModelPart::ElementsContainerType ElementsArrayType
Definition: old_cable_net_mpc_process.h:53
std::size_t SizeType
Definition: old_cable_net_mpc_process.h:50
bool GetmIsInitialized() const
Definition: old_cable_net_mpc_process.h:319
void ExecuteInitializeSolutionStep() override
Definition: old_cable_net_mpc_process.h:221
Bucket< 3, NodeType, NodeVector, NodeTypePointer, NodeIterator, DoubleVectorIterator > BucketType
Definition: old_cable_net_mpc_process.h:56
void CreateListOfNodesOfMasterSubModelPart(NodeVector &MasterNodeList)
This function creates a NodeVector of the master nodes to be used for the Kd tree.
Definition: old_cable_net_mpc_process.h:181
ModelPart::NodesContainerType NodesArrayType
Definition: old_cable_net_mpc_process.h:46
void SetmIsInitialized(const bool &check)
Definition: old_cable_net_mpc_process.h:318
std::vector< double > DoubleVector
Definition: old_cable_net_mpc_process.h:48
CableNetMpcProcess(ModelPart &model_part, Parameters rParameters)
Constructor.
Definition: old_cable_net_mpc_process.h:64
Tree< KDTreePartition< BucketType > > KDTree
Definition: old_cable_net_mpc_process.h:57
void CreateSpringElements(ModelPart &rMasterModelPart, ModelPart &rSlaveModelPart)
Definition: old_cable_net_mpc_process.h:232
DoubleVector::iterator DoubleVectorIterator
Definition: old_cable_net_mpc_process.h:49
void CoupleModelParts()
This function finds neighbor nodes for each slave node and couples the nodes this is the main functio...
Definition: old_cable_net_mpc_process.h:73
Geometry base class.
Definition: geometry.h:71
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
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
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
IndexType Id() const
Definition: node.h:262
double & Z0()
Definition: node.h:576
double & X0()
Definition: node.h:568
double & Y0()
Definition: node.h:572
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
#define KRATOS_WATCH(variable)
Definition: define.h:806
#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
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
model_part
Definition: face_heat.py:14
integer i
Definition: TensorModule.f:17
integer l
Definition: TensorModule.f:17