13 #if !defined(KRATOS_INTERNAL_VARIABLES_INTERPOLATION_PROCESS )
14 #define KRATOS_INTERNAL_VARIABLES_INTERPOLATION_PROCESS
112 CLOSEST_POINT_TRANSFER = 0,
113 LEAST_SQUARE_TRANSFER = 1,
114 SHAPE_FUNCTION_TRANSFER = 2
159 void Execute()
override;
164 const Parameters GetDefaultParameters()
const override;
181 std::string
Info()
const override
183 return "InternalVariablesInterpolationProcess";
237 template<std::
size_t TDim>
238 struct auxiliar_search
241 : point_locator(rModelPart)
244 point_locator.UpdateSearchDatabase();
247 BinBasedFastPointLocator<TDim> point_locator;
249 Element::Pointer p_element;
263 const std::size_t mDimension;
266 std::size_t mAllocationSize;
267 std::size_t mBucketSize;
270 double mSearchFactor;
274 std::vector<std::string> mInternalVariableList;
275 InterpolationTypes mThisInterpolationType;
290 PointVector CreateGaussPointList(ModelPart& ThisModelPart);
296 void InterpolateGaussPointsClosestPointTransfer();
302 void InterpolateGaussPointsLeastSquareTransfer();
308 void InterpolateGaussPointsShapeFunctionTransfer();
314 std::size_t ComputeTotalNumberOfVariables();
324 template<
class TVarType>
325 static inline void SaveValuesOnGaussPoint(
326 const Variable<TVarType>& rThisVar,
328 ElementsArrayType::iterator itElemOrigin,
330 const ProcessInfo& rCurrentProcessInfo
333 std::vector<TVarType>
values;
334 itElemOrigin->CalculateOnIntegrationPoints(rThisVar,
values, rCurrentProcessInfo);
335 pPointOrigin->SetValue(rThisVar,
values[GaussPointId]);
345 template<
class TVarType>
346 static inline void GetAndSetDirectVariableOnConstitutiveLaw(
347 const Variable<TVarType>& rThisVar,
348 ConstitutiveLaw::Pointer pOriginConstitutiveLaw,
349 ConstitutiveLaw::Pointer pDestinationConstitutiveLaw,
350 const ProcessInfo& rCurrentProcessInfo
353 TVarType origin_value;
354 origin_value = pOriginConstitutiveLaw->GetValue(rThisVar, origin_value);
356 pDestinationConstitutiveLaw->SetValue(rThisVar, origin_value, rCurrentProcessInfo);
367 template<
class TVarType>
368 static inline void GetAndSetDirectVariableOnElements(
369 const Variable<TVarType>& rThisVar,
371 ElementsArrayType::iterator itElemDestination,
373 const ProcessInfo& rCurrentProcessInfo
376 std::vector<TVarType>
values;
377 itElemDestination->CalculateOnIntegrationPoints(rThisVar,
values, rCurrentProcessInfo);
379 values[GaussPointId] = pPointOrigin->GetValue(rThisVar, aux_value);
380 itElemDestination->SetValuesOnIntegrationPoints(rThisVar,
values, rCurrentProcessInfo);
393 template<
class TVarType>
394 static inline void GetAndSetWeightedVariableOnConstitutiveLaw(
395 const Variable<TVarType>& rThisVar,
396 const std::size_t NumberOfPointsFound,
398 const std::vector<double>& PointDistances,
399 const double CharacteristicLenght,
400 ConstitutiveLaw::Pointer pDestinationConstitutiveLaw,
401 const ProcessInfo& rCurrentProcessInfo
404 TVarType weighting_function_numerator = rThisVar.Zero();
405 double weighting_function_denominator = 0.0;
406 TVarType origin_value;
408 for (std::size_t i_point_found = 0; i_point_found < NumberOfPointsFound; ++i_point_found) {
411 const double distance = PointDistances[i_point_found];
413 origin_value = (p_gp_origin->GetConstitutiveLaw())->
GetValue(rThisVar, origin_value);
415 const double ponderated_weight = p_gp_origin->GetWeight() * std::exp( -4.0 * distance * distance /std::pow(CharacteristicLenght, 2));
417 weighting_function_numerator += ponderated_weight * origin_value;
418 weighting_function_denominator += ponderated_weight;
421 const TVarType destination_value = weighting_function_numerator/weighting_function_denominator;
423 pDestinationConstitutiveLaw->SetValue(rThisVar, destination_value, rCurrentProcessInfo);
437 template<
class TVarType>
438 static inline void GetAndSetWeightedVariableOnElements(
439 const Variable<TVarType>& rThisVar,
440 const std::size_t NumberOfPointsFound,
442 const std::vector<double>& PointDistances,
443 const double CharacteristicLenght,
444 ElementsArrayType::iterator itElemDestination,
446 const ProcessInfo& rCurrentProcessInfo
449 TVarType weighting_function_numerator = rThisVar.Zero();
450 double weighting_function_denominator = 0.0;
451 TVarType origin_value;
453 for (std::size_t i_point_found = 0; i_point_found < NumberOfPointsFound; ++i_point_found) {
456 const double distance = PointDistances[i_point_found];
458 origin_value = p_gp_origin->GetValue(rThisVar, origin_value);
460 const double ponderated_weight = p_gp_origin->GetWeight() * std::exp( -4.0 * distance * distance /std::pow(CharacteristicLenght, 2));
462 weighting_function_numerator += ponderated_weight * origin_value;
463 weighting_function_denominator += ponderated_weight;
466 const TVarType destination_value = weighting_function_numerator/weighting_function_denominator;
468 std::vector<TVarType>
values;
469 itElemDestination->CalculateOnIntegrationPoints(rThisVar,
values, rCurrentProcessInfo);
470 values[GaussPointId] = destination_value;
471 itElemDestination->SetValuesOnIntegrationPoints(rThisVar,
values, rCurrentProcessInfo);
482 template<
class TVarType>
483 static inline void InterpolateAddVariableOnConstitutiveLaw(
485 const Variable<TVarType>& rThisVar,
487 ConstitutiveLaw::Pointer& pConstitutiveLaw,
501 template<
class TVarType>
502 static inline void InterpolateAddVariableOnElement(
504 const Variable<TVarType>& rThisVar,
509 const ProcessInfo& rCurrentProcessInfo
518 template<
class TVarType>
519 static inline void PonderateVariable(
521 const Variable<TVarType>& rThisVar,
522 const double TotalWeight
532 template<
class TVarType>
533 static inline void InterpolateToNode(
534 const Variable<TVarType>& rThisVar,
537 Element::Pointer pElement
541 TVarType aux_value = rThisVar.Zero();
544 const std::size_t number_nodes = pElement->GetGeometry().size();
545 for (std::size_t i_node = 0; i_node < number_nodes; ++i_node)
546 aux_value +=
N[i_node] * pElement->GetGeometry()[i_node].GetValue(rThisVar);
548 rNode.
SetValue(rThisVar, aux_value);
559 template<
class TVarType>
560 static inline void SetInterpolatedValueOnConstitutiveLaw(
562 const Variable<TVarType>& rThisVar,
564 ConstitutiveLaw::Pointer pDestinationConstitutiveLaw,
565 const ProcessInfo& rCurrentProcessInfo
569 TVarType destination_value = rThisVar.Zero();
572 const std::size_t number_nodes = rThisGeometry.size();
573 for (std::size_t i_node = 0; i_node < number_nodes; ++i_node)
574 destination_value +=
N[i_node] * rThisGeometry[i_node].
GetValue(rThisVar);
576 pDestinationConstitutiveLaw->
SetValue(rThisVar, destination_value, rCurrentProcessInfo);
588 template<
class TVarType>
589 static inline void SetInterpolatedValueOnElement(
591 const Variable<TVarType>& rThisVar,
595 const ProcessInfo& rCurrentProcessInfo
599 TVarType destination_value = rThisVar.Zero();
602 const std::size_t number_nodes = rThisGeometry.size();
603 for (std::size_t i_node = 0; i_node < number_nodes; ++i_node)
604 destination_value +=
N[i_node] * rThisGeometry[i_node].
GetValue(rThisVar);
606 std::vector<TVarType>
values;
607 rElement.CalculateOnIntegrationPoints(rThisVar,
values, rCurrentProcessInfo);
608 values[GaussPointId] = destination_value;
609 rElement.SetValuesOnIntegrationPoints(rThisVar,
values, rCurrentProcessInfo);
616 template<std::
size_t TDim>
617 void InterpolateToNodes()
620 NodesArrayType& r_nodes_array = mrDestinationMainModelPart.Nodes();
623 block_for_each(r_nodes_array, auxiliar_search<TDim>(mrOriginMainModelPart),
624 [
this](Node& rNode, auxiliar_search<TDim>& aux) {
626 const bool old_entity = rNode.IsDefined(OLD_ENTITY) ? rNode.Is(OLD_ENTITY) :
false;
628 const bool found = aux.point_locator.FindPointOnMeshSimplified(rNode.Coordinates(), aux.N, aux.p_element, mAllocationSize);
631 KRATOS_WARNING(
"InternalVariablesInterpolationProcess") <<
"WARNING: Node "<< rNode.Id() <<
" not found (interpolation not posible)" <<
"\t X:"<< rNode.X() <<
"\t Y:"<< rNode.Y() <<
"\t Z:"<< rNode.Z() << std::endl;
633 for (
auto& variable_name : mInternalVariableList) {
636 InterpolateToNode(r_variable, aux.N, rNode, aux.p_element);
639 InterpolateToNode(r_variable, aux.N, rNode, aux.p_element);
642 InterpolateToNode(r_variable, aux.N, rNode, aux.p_element);
645 InterpolateToNode(r_variable, aux.N, rNode, aux.p_element);
647 KRATOS_WARNING(
"InternalVariablesInterpolationProcess") <<
"WARNING:: " << variable_name <<
" is not registered as any type of compatible variable: DOUBLE or ARRAY_1D or VECTOR or Matrix" << std::endl;
660 InterpolationTypes ConvertInter(
const std::string& Str);
683 void InternalVariablesInterpolationProcess::InterpolateAddVariableOnConstitutiveLaw<double>(
685 const Variable<double>& rThisVar,
687 ConstitutiveLaw::Pointer& pConstitutiveLaw,
691 void InternalVariablesInterpolationProcess::InterpolateAddVariableOnConstitutiveLaw<array_1d<double, 3>>(
693 const Variable<array_1d<double, 3>>& rThisVar,
695 ConstitutiveLaw::Pointer& pConstitutiveLaw,
699 void InternalVariablesInterpolationProcess::InterpolateAddVariableOnConstitutiveLaw<Vector>(
701 const Variable<Vector>& rThisVar,
703 ConstitutiveLaw::Pointer& pConstitutiveLaw,
707 void InternalVariablesInterpolationProcess::InterpolateAddVariableOnConstitutiveLaw<Matrix>(
709 const Variable<Matrix>& rThisVar,
711 ConstitutiveLaw::Pointer& pConstitutiveLaw,
716 void InternalVariablesInterpolationProcess::InterpolateAddVariableOnElement(
718 const Variable<double>& rThisVar,
723 const ProcessInfo& rCurrentProcessInfo
727 void InternalVariablesInterpolationProcess::InterpolateAddVariableOnElement(
729 const Variable<array_1d<double, 3>>& rThisVar,
734 const ProcessInfo& rCurrentProcessInfo
738 void InternalVariablesInterpolationProcess::InterpolateAddVariableOnElement(
740 const Variable<Vector>& rThisVar,
745 const ProcessInfo& rCurrentProcessInfo
749 void InternalVariablesInterpolationProcess::InterpolateAddVariableOnElement(
751 const Variable<Matrix>& rThisVar,
756 const ProcessInfo& rCurrentProcessInfo
760 void InternalVariablesInterpolationProcess::PonderateVariable(
762 const Variable<double>& rThisVar,
763 const double TotalWeight
767 void InternalVariablesInterpolationProcess::PonderateVariable(
769 const Variable<array_1d<double, 3>>& rThisVar,
770 const double TotalWeight
774 void InternalVariablesInterpolationProcess::PonderateVariable(
776 const Variable<Vector>& rThisVar,
777 const double TotalWeight
781 void InternalVariablesInterpolationProcess::PonderateVariable(
783 const Variable<Matrix>& rThisVar,
784 const double TotalWeight
794 template<
class TPo
intType,
class TPo
interType>
801 template<
class TPo
intType,
class TPo
interType>
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Short class definition.
Definition: bucket.h:57
Geometry base class.
Definition: geometry.h:71
This utilitiy has as objective to interpolate the values inside elements (and conditions?...
Definition: internal_variables_interpolation_process.h:79
InterpolationTypes
This enum it used to list the different types of interpolations available.
Definition: internal_variables_interpolation_process.h:111
Variable< double > DoubleVarType
Definitions for the variables.
Definition: internal_variables_interpolation_process.h:89
std::string Info() const override
Turn back information as a string.
Definition: internal_variables_interpolation_process.h:181
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: internal_variables_interpolation_process.h:97
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: internal_variables_interpolation_process.h:189
ModelPart::NodesContainerType NodesArrayType
Definition: internal_variables_interpolation_process.h:95
ModelPart::ElementsContainerType ElementsArrayType
Definition: internal_variables_interpolation_process.h:96
Tree< KDTreePartition< BucketType > > KDTree
Definition: internal_variables_interpolation_process.h:86
Bucket< 3ul, PointType, PointVector, PointTypePointer, PointIterator, DistanceIterator > BucketType
KDtree definitions.
Definition: internal_variables_interpolation_process.h:85
Variable< array_1d< double, 3 > > ArrayVarType
Definition: internal_variables_interpolation_process.h:90
Variable< Matrix > MatrixVarType
Definition: internal_variables_interpolation_process.h:92
Geometry< NodeType > GeometryType
Definition: internal_variables_interpolation_process.h:99
Variable< Vector > VectorVarType
Definition: internal_variables_interpolation_process.h:91
KRATOS_CLASS_POINTER_DEFINITION(InternalVariablesInterpolationProcess)
Pointer definition of InternalVariablesInterpolationProcess.
Node NodeType
Definition: internal_variables_interpolation_process.h:98
~InternalVariablesInterpolationProcess() override=default
void operator()()
Definition: internal_variables_interpolation_process.h:142
static bool Has(const std::string &rName)
Check if the given name exists in the set of components.
Definition: kratos_components.h:161
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
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
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 defines the node.
Definition: node.h:65
void SetValue(const TVariableType &rThisVariable, typename TVariableType::Type const &rValue)
Definition: node.h:493
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void SetValue(const std::string &rEntry, const Parameters &rOtherValue)
This method sets an existing parameter with a given parameter.
Definition: kratos_parameters.cpp:443
The base class for all processes in Kratos.
Definition: process.h:49
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_WARNING(label)
Definition: logger.h:265
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
Node NodeType
The definition of the node.
Definition: tetrahedral_mesh_orientation_check.h:34
Geometry< Node > GeometryType
The definition of the geometry.
Definition: mortar_classes.h:37
ModelPart::NodesContainerType NodesArrayType
Definition: gid_gauss_point_container.h:42
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
DistanceVector::iterator DistanceIterator
Definition: internal_variables_interpolation_process.h:56
std::vector< PointTypePointer > PointVector
Definition: internal_variables_interpolation_process.h:53
PointType::Pointer PointTypePointer
Definition: internal_variables_interpolation_process.h:52
PointVector::iterator PointIterator
Definition: internal_variables_interpolation_process.h:54
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
std::vector< double > DistanceVector
Definition: internal_variables_interpolation_process.h:55
Point PointType
Geometric definitions.
Definition: mortar_classes.h:36
list values
Definition: bombardelli_test.py:42
N
Definition: sensitivityMatrix.py:29