15 #if !defined(KRATOS_NONLOCAL_DAMAGE_2D_UTILITIES )
16 #define KRATOS_NONLOCAL_DAMAGE_2D_UTILITIES
37 struct Utility2DVariables
39 double X_max, X_min, Y_max, Y_min;
43 std::vector< std::vector< std::vector<GaussPoint*> > > GaussPointCellMatrix;
64 KRATOS_INFO(
"Nonlocal Damage 2D utility") <<
"Starting non-local search of neighbours ..." << std::endl;
67 Utility2DVariables AuxVariables;
74 KRATOS_INFO(
"Nonlocal Damage 2D utility") <<
"... search of neighbours completed." << std::endl;
86 Utility2DVariables& rAuxVariables,
91 this->ComputeCellMatrixDimensions(rAuxVariables,rModelPart);
93 rAuxVariables.GaussPointCellMatrix.resize(rAuxVariables.NRows);
94 for(
int i = 0;
i < rAuxVariables.NRows;
i++) rAuxVariables.GaussPointCellMatrix[
i].resize(rAuxVariables.NColumns);
97 unsigned int NGPoints = 0;
104 unsigned int NumBodySubModelParts = rParameters[
"body_domain_sub_model_part_list"].
size();
107 for(
unsigned int i = 0;
i < NumBodySubModelParts;
i++)
111 int NElems =
static_cast<int>(BodySubModelPart.
Elements().size());
112 ModelPart::ElementsContainerType::iterator el_begin = BodySubModelPart.
ElementsBegin();
115 #pragma omp parallel for private(MyIntegrationMethod,AuxGlobalCoordinates,AuxLocalCoordinates)
116 for(
int j = 0;
j < NElems;
j++)
118 ModelPart::ElementsContainerType::iterator itElem = el_begin +
j;
121 MyIntegrationMethod = itElem->GetIntegrationMethod();
123 unsigned int NumGPoints = IntegrationPoints.size();
124 Vector detJContainer(NumGPoints);
126 std::vector<ConstitutiveLaw::Pointer> ConstitutiveLawVector(NumGPoints);
127 itElem->CalculateOnIntegrationPoints(CONSTITUTIVE_LAW,ConstitutiveLawVector,CurrentProcessInfo);
132 for (
unsigned int GPoint = 0; GPoint < NumGPoints; GPoint++ )
135 AuxLocalCoordinates[0] = IntegrationPoints[GPoint][0];
136 AuxLocalCoordinates[1] = IntegrationPoints[GPoint][1];
137 AuxLocalCoordinates[2] = IntegrationPoints[GPoint][2];
141 double Weight = detJContainer[GPoint]*IntegrationPoints[GPoint].Weight();
144 Row =
int((rAuxVariables.Y_max-AuxGlobalCoordinates[1])/rAuxVariables.RowSize);
145 Column =
int((AuxGlobalCoordinates[0]-rAuxVariables.X_min)/rAuxVariables.ColumnSize);
151 rAuxVariables.GaussPointCellMatrix[Row][Column].push_back(
mGaussPointList[NGPoints]);
162 Utility2DVariables& rAuxVariables,
167 double CharacteristicLength = (*pParameters)[
"characteristic_length"].GetDouble();
170 #pragma omp parallel for
171 for(
int i = 0;
i < NGPoints;
i++)
175 double X_left = rMyGaussPoint.
Coordinates[0] - CharacteristicLength;
176 double X_right = rMyGaussPoint.
Coordinates[0] + CharacteristicLength;
177 double Y_top = rMyGaussPoint.
Coordinates[1] + CharacteristicLength;
178 double Y_bot = rMyGaussPoint.
Coordinates[1] - CharacteristicLength;
180 int Column_left =
int((X_left-rAuxVariables.X_min)/rAuxVariables.ColumnSize);
181 int Column_right =
int((X_right-rAuxVariables.X_min)/rAuxVariables.ColumnSize);
182 int Row_top =
int((rAuxVariables.Y_max-Y_top)/rAuxVariables.RowSize);
183 int Row_bot =
int((rAuxVariables.Y_max-Y_bot)/rAuxVariables.RowSize);
185 if(Column_left < 0) Column_left = 0;
186 if(Column_right >= rAuxVariables.NColumns) Column_right = rAuxVariables.NColumns-1;
187 if(Row_top < 0) Row_top = 0;
188 if(Row_bot >= rAuxVariables.NRows) Row_bot = rAuxVariables.NRows-1;
191 for(
int j = Row_top;
j <= Row_bot;
j++)
193 for(
int k = Column_left;
k <= Column_right;
k++)
195 for(
unsigned int l = 0;
l < rAuxVariables.GaussPointCellMatrix[
j][
k].size();
l++)
197 if ( (&rMyGaussPoint) != rAuxVariables.GaussPointCellMatrix[
j][
k][
l] )
199 GaussPoint& rMyNeighbourPoint = *(rAuxVariables.GaussPointCellMatrix[
j][
k][
l]);
204 if(Distance <= CharacteristicLength)
233 void ComputeCellMatrixDimensions(
234 Utility2DVariables& rAuxVariables,
239 std::vector<double> X_max_partition(NumThreads);
240 std::vector<double> X_min_partition(NumThreads);
241 std::vector<double> Y_max_partition(NumThreads);
242 std::vector<double> Y_min_partition(NumThreads);
244 const int NNodes =
static_cast<int>(rModelPart.
Nodes().size());
245 ModelPart::NodesContainerType::iterator node_begin = rModelPart.
NodesBegin();
251 X_max_partition[
k] = node_begin->X();
252 X_min_partition[
k] = X_max_partition[
k];
253 Y_max_partition[
k] = node_begin->Y();
254 Y_min_partition[
k] = Y_max_partition[
k];
259 for(
int i = 0;
i < NNodes;
i++)
261 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
266 if( X_me > X_max_partition[
k] ) X_max_partition[
k] = X_me;
267 else if( X_me < X_min_partition[
k] ) X_min_partition[
k] = X_me;
269 if( Y_me > Y_max_partition[
k] ) Y_max_partition[
k] = Y_me;
270 else if( Y_me < Y_min_partition[
k] ) Y_min_partition[
k] = Y_me;
274 rAuxVariables.X_max = X_max_partition[0];
275 rAuxVariables.X_min = X_min_partition[0];
276 rAuxVariables.Y_max = Y_max_partition[0];
277 rAuxVariables.Y_min = Y_min_partition[0];
279 for(
unsigned int i=1;
i < NumThreads;
i++)
281 if(X_max_partition[
i] > rAuxVariables.X_max) rAuxVariables.X_max = X_max_partition[
i];
282 if(X_min_partition[
i] < rAuxVariables.X_min) rAuxVariables.X_min = X_min_partition[
i];
283 if(Y_max_partition[
i] > rAuxVariables.Y_max) rAuxVariables.Y_max = Y_max_partition[
i];
284 if(Y_min_partition[
i] < rAuxVariables.Y_min) rAuxVariables.Y_min = Y_min_partition[
i];
288 double AverageElementLength = 0.0;
290 int NElems =
static_cast<int>(rModelPart.
Elements().size());
291 ModelPart::ElementsContainerType::iterator el_begin = rModelPart.
ElementsBegin();
293 #pragma omp parallel for reduction(+:AverageElementLength)
294 for(
int i = 0;
i < NElems;
i++)
296 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
298 AverageElementLength += itElem->GetGeometry().Length();
301 AverageElementLength = AverageElementLength/NElems;
304 rAuxVariables.NRows =
int((rAuxVariables.Y_max-rAuxVariables.Y_min)/(AverageElementLength));
305 rAuxVariables.NColumns =
int((rAuxVariables.X_max-rAuxVariables.X_min)/(AverageElementLength));
306 if(rAuxVariables.NRows <= 0) rAuxVariables.NRows = 1;
307 if(rAuxVariables.NColumns <= 0) rAuxVariables.NColumns = 1;
308 rAuxVariables.RowSize = (rAuxVariables.Y_max-rAuxVariables.Y_min)/rAuxVariables.NRows;
309 rAuxVariables.ColumnSize = (rAuxVariables.X_max-rAuxVariables.X_min)/rAuxVariables.NColumns;
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
virtual CoordinatesArrayType & GlobalCoordinates(CoordinatesArrayType &rResult, CoordinatesArrayType const &LocalCoordinates) const
Definition: geometry.h:2377
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: geometry.h:161
Vector & DeterminantOfJacobian(Vector &rResult) const
Definition: geometry.h:3154
const IntegrationPointsArrayType & IntegrationPoints() const
Definition: geometry.h:2284
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
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
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Definition: nonlocal_damage_2D_utilities.hpp:26
void SearchGaussPointsNeighbours(Parameters *pParameters, ModelPart &rModelPart) override
Definition: nonlocal_damage_2D_utilities.hpp:62
void InitializeNonlocalSearch(Utility2DVariables &rAuxVariables, Parameters *pParameters, ModelPart &rModelPart)
Member Variables.
Definition: nonlocal_damage_2D_utilities.hpp:85
KRATOS_CLASS_POINTER_DEFINITION(NonlocalDamage2DUtilities)
~NonlocalDamage2DUtilities() override
Destructor.
Definition: nonlocal_damage_2D_utilities.hpp:58
std::vector< GaussPoint * > mGaussPointList
Member Variables.
Definition: nonlocal_damage_utilities.hpp:125
void SearchNeighbours(Utility2DVariables &rAuxVariables, Parameters *pParameters, ModelPart &rModelPart)
Definition: nonlocal_damage_2D_utilities.hpp:161
void ComputeNeighbourDistance(double &rDistance, const GaussPoint &ReceiverPoint, const GaussPoint &SourcePoint) override
Definition: nonlocal_damage_2D_utilities.hpp:220
NonlocalDamageUtilities::GaussPoint GaussPoint
Definition: nonlocal_damage_2D_utilities.hpp:30
NonlocalDamage2DUtilities()
Default Constructor.
Definition: nonlocal_damage_2D_utilities.hpp:53
Definition: nonlocal_damage_utilities.hpp:36
std::vector< GaussPoint * > mGaussPointList
Member Variables.
Definition: nonlocal_damage_utilities.hpp:125
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
SizeType size() const
This method returns the total size of the current array parameter.
Definition: kratos_parameters.cpp:993
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
#define KRATOS_INFO(label)
Definition: logger.h:250
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
integer l
Definition: TensorModule.f:17
def RowSize(_A)
Definition: custom_math.py:54
Definition: nonlocal_damage_utilities.hpp:41
std::vector< GaussPoint * > NeighbourPoints
Definition: nonlocal_damage_utilities.hpp:59
array_1d< double, 3 > Coordinates
Definition: nonlocal_damage_utilities.hpp:57