16 #if !defined(KRATOS_NORMAL_CALCULATION_UTILS )
17 #define KRATOS_NORMAL_CALCULATION_UTILS
103 template<
class TContainerType>
118 template<
class TContainerType,
bool TIsHistorical = true>
121 const bool EnforceGenericGeometryAlgorithm =
false,
122 const bool ConsiderUnitNormal =
false,
134 template<
class TContainerType,
bool TIsHistorical = true>
137 const bool EnforceGenericGeometryAlgorithm =
false,
151 const std::size_t Dimension,
165 const std::size_t Dimension,
175 void CalculateNormalShapeDerivativesOnSimplex(
177 const std::size_t Dimension
190 const std::size_t Dimension,
204 const std::size_t Dimension,
248 template<
class TValueType>
251 const std::size_t Dimension,
253 const TValueType Zero,
263 noalias(it->FastGetSolutionStepValue(rNormalVariable)) = ZeroNormal;
269 if ( Dimension == 2 ) {
271 if ( itCond->GetValue(rVariable) != Zero )
272 CalculateNormal2D(*itCond,An,rNormalVariable);
274 }
else if ( Dimension == 3 ) {
279 if ( itCond->GetValue(rVariable) != Zero )
280 CalculateNormal3D(*itCond,An,v1,v2,rNormalVariable);
288 const auto& r_normal = itCond->GetValue(rNormalVariable);
290 noalias(itNode->FastGetSolutionStepValue(rNormalVariable)) += r_normal * Coef;
307 template<
class TValueType>
310 const std::size_t Dimension,
314 CalculateOnSimplex(rModelPart,Dimension,rVariable,TValueType(),NORMAL);
326 template<
class TValueType>
329 const std::size_t Dimension,
331 const TValueType Zero,
342 noalias(it->FastGetSolutionStepValue(NORMAL)) = ZeroNormal;
343 it->FastGetSolutionStepValue(NODAL_PAUX) = 0.0;
349 if ( Dimension == 2 ) {
351 if ( itCond->GetValue(rVariable) != Zero )
352 CalculateNormal2D(*itCond,An,rNormalVariable);
354 }
else if ( Dimension == 3 ) {
359 if ( itCond->GetValue(rVariable) != Zero )
360 CalculateNormal3D(*itCond,An,v1,v2,rNormalVariable);
366 std::vector< array_1d<double,3> > N_Mat;
368 double nodal_area = 0.0;
372 if(ng_cond.
size() != 0) {
375 const auto& rNormal = ic->
GetValue(rNormalVariable);
377 double norm_normal =
norm_2( rNormal );
379 if(norm_normal != 0.0) {
380 nodal_area += Coef * norm_normal;
382 if(N_Mat.size() == 0.0) {
383 N_Mat.push_back( rNormal * Coef );
386 for(
unsigned int ii=0; ii<N_Mat.size();++ii) {
388 double norm_temp =
norm_2( temp_normal );
390 double cos_alpha=temp_normal[0]*rNormal[0] + temp_normal[1]*rNormal[1] +temp_normal[2]*rNormal[2];
391 cos_alpha /= (norm_temp*norm_normal);
393 if( cos_alpha > std::cos(0.017453293*rAlpha)) {
394 N_Mat[ii] += rNormal * Coef;
400 N_Mat.push_back( rNormal*Coef );
409 for(
unsigned int ii=0; ii<N_Mat.size(); ++ii) {
410 sum_Normal += N_Mat[ii];
413 noalias( it->FastGetSolutionStepValue(rNormalVariable) ) = sum_Normal;
414 it->FastGetSolutionStepValue(NODAL_PAUX) = nodal_area;
416 if(N_Mat.size() == 2) {
418 it->FastGetSolutionStepValue(IS_SLIP)=20.0;
419 }
else if(N_Mat.size() == 3) {
420 it->FastGetSolutionStepValue(IS_SLIP)=30.0;
421 }
else if(N_Mat.size() == 1) {
422 it->FastGetSolutionStepValue(IS_SLIP)=10.0;
442 template<
class TValueType >
447 const TValueType Zero,
const double rAlpha,
457 noalias(it->GetValue(rNormalVariable)) = ZeroNormal;
458 it->GetValue(NODAL_PAUX) = 0.0;
464 if ( Dimension == 2 ) {
466 if ( itCond->GetValue(rVariable) != Zero )
467 CalculateNormal2D(*itCond,An,rNormalVariable);
469 }
else if ( Dimension == 3 ) {
474 if ( itCond->GetValue(rVariable) != Zero )
475 CalculateNormal3D(*itCond,An,v1,v2,rNormalVariable);
481 std::vector< array_1d<double,3> > N_Mat;
483 double nodal_area = 0.0;
487 if(ng_cond.
size() != 0){
490 const auto& rNormal = ic->
GetValue(rNormalVariable);
492 double norm_normal =
norm_2( rNormal );
494 if(norm_normal != 0.0) {
495 nodal_area += Coef * norm_normal;
497 if(N_Mat.size() == 0.0) {
498 N_Mat.push_back( rNormal * Coef );
501 for(
unsigned int ii=0; ii<N_Mat.size();++ii) {
503 double norm_temp =
norm_2( temp_normal );
505 double cos_alpha=temp_normal[0]*rNormal[0] + temp_normal[1]*rNormal[1] +temp_normal[2]*rNormal[2];
506 cos_alpha /= (norm_temp*norm_normal);
508 if( cos_alpha > cos(0.017453293*rAlpha) ){
509 N_Mat[ii] += rNormal * Coef;
513 N_Mat.push_back( rNormal*Coef );
523 for(
unsigned int ii=0; ii<N_Mat.size(); ++ii){
524 sum_Normal += N_Mat[ii];
527 noalias( it->FastGetSolutionStepValue(rNormalVariable) ) = sum_Normal;
528 it->FastGetSolutionStepValue(NODAL_PAUX) = nodal_area;
530 if(N_Mat.size() == 2){
532 it->FastGetSolutionStepValue(IS_SLIP)=20.0;
533 }
else if(N_Mat.size() == 3) {
534 it->FastGetSolutionStepValue(IS_SLIP)=30.0;
535 }
else if(N_Mat.size() == 1) {
536 it->FastGetSolutionStepValue(IS_SLIP)=10.0;
571 template<
class TContainerType,
bool TIsHistorical>
572 void InitializeNormals(
574 const NormalVariableType& rNormalVariable
584 template<
class TContainerType,
bool TIsHistorical>
585 void ComputeUnitNormalsFromAreaNormals(
587 const NormalVariableType& rNormalVariable
596 static void CalculateNormal2D(
599 const NormalVariableType& rNormalVariable
606 static void CalculateNormalShapeDerivative2D(
617 static void CalculateNormal3D(
622 const NormalVariableType& rNormalVariable
629 static void CalculateNormalShapeDerivative3D(
639 template<
class TContainerType>
650 template<
class TContainerType,
bool TIsHistorical>
651 void CalculateNormalsUsingGenericAlgorithm(
653 const bool ConsiderUnitNormal,
654 const NormalVariableType& rNormalVariable
665 template<
bool TIsHistorical>
668 const NormalVariableType& rNormalVariable
679 template<
bool TIsHistorical>
682 const NormalVariableType& rNormalVariable,
694 bool CheckUseSimplex(
696 const bool EnforceGenericGeometryAlgorithm
707 template<
bool TIsHistorical>
708 void AuxiliaryCalculateOnSimplex(
710 const std::size_t Dimension,
711 const NormalVariableType& rNormalVariable
virtual bool AssembleCurrentData(Variable< int > const &ThisVariable)
Definition: communicator.cpp:502
Base class for all Conditions.
Definition: condition.h:59
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
PointsArrayType::iterator iterator
PointsArrayType typedefs.
Definition: geometry.h:213
iterator begin()
Definition: geometry.h:465
iterator end()
Definition: geometry.h:473
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
iterator begin()
Definition: global_pointers_vector.h:221
size_type size() const
Definition: global_pointers_vector.h:307
iterator end()
Definition: global_pointers_vector.h:229
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
Communicator & GetCommunicator()
Definition: model_part.h:1821
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
MeshType::ConditionIterator ConditionIterator
Definition: model_part.h:189
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
This class defines the node.
Definition: node.h:65
void CalculateNormals(ModelPart &rModelPart, const bool EnforceGenericGeometryAlgorithm=false, const bool ConsiderUnitNormal=false, const NormalVariableType &rNormalVariable=NORMAL)
It computes the mean of the normal in the entities and in all the nodes.
Geometry< NodeType > GeometryType
Definition of geometries.
Definition: normal_calculation_utils.h:75
ModelPart::ConditionType ConditionType
Condition type definition.
Definition: normal_calculation_utils.h:78
void CalculateOnSimplex(ModelPart &rModelPart, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the area normal (vector oriented as the normal with a dimension proportional to the area).
void CalculateOnSimplexLowMemory(ModelPart &rModelPart, int Dimension, const Variable< TValueType > &rVariable, const TValueType Zero, const double rAlpha, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the area normal (vector oriented as the normal with a dimension proportional to the area) ...
Definition: normal_calculation_utils.h:443
std::size_t SizeType
The size type definition.
Definition: normal_calculation_utils.h:69
void CalculateUnitNormals(ModelPart &rModelPart, const bool EnforceGenericGeometryAlgorithm=false, const NormalVariableType &rNormalVariable=NORMAL)
It computes the mean of the normal in the entities and in all the nodes (unit normal version)
void CalculateOnSimplexNonHistorical(ModelPart &rModelPart, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the area normal in the non-historical database (vector oriented as the normal with a dimen...
Node NodeType
Definition: normal_calculation_utils.h:72
std::size_t IndexType
The index type definition.
Definition: normal_calculation_utils.h:66
void CalculateOnSimplex(ModelPart &rModelPart, const std::size_t Dimension, const Variable< TValueType > &rVariable, const TValueType Zero, const double rAlpha, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the area normal (vector oriented as the normal with a dimension proportional to the area) ...
Definition: normal_calculation_utils.h:327
void CalculateNormalsInContainer(ModelPart &rModelPart, const NormalVariableType &rNormalVariable=NORMAL)
It computes the normal in the conditions.
void CalculateOnSimplexNonHistorical(ModelPart &rModelPart, const std::size_t Dimension, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the area normal in the non-historical database (vector oriented as the normal with a dimen...
void CalculateOnSimplex(ConditionsArrayType &rConditions, const std::size_t Dimension, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the "area normal" (vector oriented as the normal with a dimension proportional to the area...
void CalculateOnSimplex(ModelPart &rModelPart, const std::size_t Dimension, const Variable< TValueType > &rVariable, const TValueType Zero, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the area normal (vector oriented as the normal with a dimension proportional to the area) ...
Definition: normal_calculation_utils.h:249
ModelPart::ConditionsContainerType ConditionsArrayType
Conditions array definition.
Definition: normal_calculation_utils.h:81
void CalculateOnSimplex(ModelPart &rModelPart, const std::size_t Dimension, const Variable< TValueType > &rVariable)
Calculates the area normal (vector oriented as the normal with a dimension proportional to the area) ...
Definition: normal_calculation_utils.h:308
void CalculateOnSimplex(ModelPart &rModelPart, const std::size_t Dimension, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the area normal (vector oriented as the normal with a dimension proportional to the area).
void CalculateOnSimplexNonHistorical(ConditionsArrayType &rConditions, const std::size_t Dimension, const NormalVariableType &rNormalVariable=NORMAL)
Calculates the "area normal" in the non-historical database (vector oriented as the normal with a dim...
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
TContainerType & GetContainer(ModelPart::MeshType &rMesh)
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
Tool to evaluate the normals on nodes based on the normals of a set of surface conditions.