15 #if !defined(KRATOS_NONLOCAL_DAMAGE_3D_UTILITIES )
16 #define KRATOS_NONLOCAL_DAMAGE_3D_UTILITIES
37 struct Utility3DVariables
39 double X_max, X_min, Y_max, Y_min, Z_max, Z_min;
40 int NRows, NColumns, NSections;
41 double RowSize, ColumnSize, SectionSize;
43 std::vector< std::vector< std::vector< std::vector<GaussPoint*> > > > GaussPointCellMatrix;
64 KRATOS_INFO(
"Nonlocal Damage 3D utility") <<
"Starting non-local search of neighbours ..." << std::endl;
67 Utility3DVariables AuxVariables;
74 KRATOS_INFO(
"Nonlocal Damage 3D utility") <<
"... search of neighbours completed." << std::endl;
86 Utility3DVariables& rAuxVariables,
91 this->ComputeCellMatrixDimensions(rAuxVariables,rModelPart);
93 rAuxVariables.GaussPointCellMatrix.resize(rAuxVariables.NRows);
94 for(
int i = 0;
i < rAuxVariables.NRows;
i++)
95 rAuxVariables.GaussPointCellMatrix[
i].resize(rAuxVariables.NColumns);
96 for(
int i = 0;
i < rAuxVariables.NRows;
i++)
98 for(
int j = 0;
j < rAuxVariables.NColumns;
j++)
99 rAuxVariables.GaussPointCellMatrix[
i][
j].resize(rAuxVariables.NSections);
103 unsigned int NGPoints = 0;
110 unsigned int NumBodySubModelParts = rParameters[
"body_domain_sub_model_part_list"].
size();
113 for(
unsigned int i = 0;
i < NumBodySubModelParts;
i++)
117 int NElems =
static_cast<int>(BodySubModelPart.
Elements().size());
118 ModelPart::ElementsContainerType::iterator el_begin = BodySubModelPart.
ElementsBegin();
121 #pragma omp parallel for private(MyIntegrationMethod,AuxGlobalCoordinates,AuxLocalCoordinates)
122 for(
int j = 0;
j < NElems;
j++)
124 ModelPart::ElementsContainerType::iterator itElem = el_begin +
j;
127 MyIntegrationMethod = itElem->GetIntegrationMethod();
129 unsigned int NumGPoints = IntegrationPoints.size();
130 Vector detJContainer(NumGPoints);
132 std::vector<ConstitutiveLaw::Pointer> ConstitutiveLawVector(NumGPoints);
133 itElem->CalculateOnIntegrationPoints(CONSTITUTIVE_LAW,ConstitutiveLawVector,CurrentProcessInfo);
139 for (
unsigned int GPoint = 0; GPoint < NumGPoints; GPoint++ )
142 AuxLocalCoordinates[0] = IntegrationPoints[GPoint][0];
143 AuxLocalCoordinates[1] = IntegrationPoints[GPoint][1];
144 AuxLocalCoordinates[2] = IntegrationPoints[GPoint][2];
148 double Weight = detJContainer[GPoint]*IntegrationPoints[GPoint].Weight();
151 Row =
int((rAuxVariables.Y_max-AuxGlobalCoordinates[1])/rAuxVariables.RowSize);
152 Column =
int((AuxGlobalCoordinates[0]-rAuxVariables.X_min)/rAuxVariables.ColumnSize);
153 Section =
int((AuxGlobalCoordinates[2]-rAuxVariables.Z_min)/rAuxVariables.SectionSize);
159 rAuxVariables.GaussPointCellMatrix[Row][Column][Section].push_back(
mGaussPointList[NGPoints]);
170 Utility3DVariables& rAuxVariables,
175 double CharacteristicLength = (*pParameters)[
"characteristic_length"].GetDouble();
178 #pragma omp parallel for
179 for(
int i = 0;
i < NGPoints;
i++)
183 double X_left = rMyGaussPoint.
Coordinates[0] - CharacteristicLength;
184 double X_right = rMyGaussPoint.
Coordinates[0] + CharacteristicLength;
185 double Y_top = rMyGaussPoint.
Coordinates[1] + CharacteristicLength;
186 double Y_bot = rMyGaussPoint.
Coordinates[1] - CharacteristicLength;
187 double Z_back = rMyGaussPoint.
Coordinates[2] - CharacteristicLength;
188 double Z_front = rMyGaussPoint.
Coordinates[2] + CharacteristicLength;
190 int Column_left =
int((X_left-rAuxVariables.X_min)/rAuxVariables.ColumnSize);
191 int Column_right =
int((X_right-rAuxVariables.X_min)/rAuxVariables.ColumnSize);
192 int Row_top =
int((rAuxVariables.Y_max-Y_top)/rAuxVariables.RowSize);
193 int Row_bot =
int((rAuxVariables.Y_max-Y_bot)/rAuxVariables.RowSize);
194 int Section_back =
int((Z_back-rAuxVariables.Z_min)/rAuxVariables.SectionSize);
195 int Section_front =
int((Z_front-rAuxVariables.Z_min)/rAuxVariables.SectionSize);
197 if(Column_left < 0) Column_left = 0;
198 if(Column_right >= rAuxVariables.NColumns) Column_right = rAuxVariables.NColumns-1;
199 if(Row_top < 0) Row_top = 0;
200 if(Row_bot >= rAuxVariables.NRows) Row_bot = rAuxVariables.NRows-1;
201 if(Section_back < 0) Section_back = 0;
202 if(Section_front >= rAuxVariables.NSections) Section_front = rAuxVariables.NSections-1;
205 for(
int s = Section_back; s <= Section_front; s++)
207 for(
int k = Row_top;
k <= Row_bot;
k++)
209 for(
int l = Column_left;
l <= Column_right;
l++)
211 for(
unsigned int m = 0;
m < rAuxVariables.GaussPointCellMatrix[
k][
l][s].size();
m++)
213 if ( (&rMyGaussPoint) != rAuxVariables.GaussPointCellMatrix[
k][
l][s][
m] )
215 GaussPoint& rMyNeighbourPoint = *(rAuxVariables.GaussPointCellMatrix[
k][
l][s][
m]);
221 if(Distance <= CharacteristicLength)
252 void ComputeCellMatrixDimensions(
253 Utility3DVariables& rAuxVariables,
258 std::vector<double> X_max_partition(NumThreads);
259 std::vector<double> X_min_partition(NumThreads);
260 std::vector<double> Y_max_partition(NumThreads);
261 std::vector<double> Y_min_partition(NumThreads);
262 std::vector<double> Z_max_partition(NumThreads);
263 std::vector<double> Z_min_partition(NumThreads);
265 const int NNodes =
static_cast<int>(rModelPart.
Nodes().size());
266 ModelPart::NodesContainerType::iterator node_begin = rModelPart.
NodesBegin();
272 X_max_partition[
k] = node_begin->X();
273 X_min_partition[
k] = X_max_partition[
k];
274 Y_max_partition[
k] = node_begin->Y();
275 Y_min_partition[
k] = Y_max_partition[
k];
276 Z_max_partition[
k] = node_begin->Z();
277 Z_min_partition[
k] = Z_max_partition[
k];
279 double X_me, Y_me, Z_me;
282 for(
int i = 0;
i < NNodes;
i++)
284 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
290 if( X_me > X_max_partition[
k] ) X_max_partition[
k] = X_me;
291 else if( X_me < X_min_partition[
k] ) X_min_partition[
k] = X_me;
293 if( Y_me > Y_max_partition[
k] ) Y_max_partition[
k] = Y_me;
294 else if( Y_me < Y_min_partition[
k] ) Y_min_partition[
k] = Y_me;
296 if( Z_me > Z_max_partition[
k] ) Z_max_partition[
k] = Z_me;
297 else if( Z_me < Z_min_partition[
k] ) Z_min_partition[
k] = Z_me;
301 rAuxVariables.X_max = X_max_partition[0];
302 rAuxVariables.X_min = X_min_partition[0];
303 rAuxVariables.Y_max = Y_max_partition[0];
304 rAuxVariables.Y_min = Y_min_partition[0];
305 rAuxVariables.Z_max = Z_max_partition[0];
306 rAuxVariables.Z_min = Z_min_partition[0];
308 for(
unsigned int i=1;
i < NumThreads;
i++)
310 if(X_max_partition[
i] > rAuxVariables.X_max) rAuxVariables.X_max = X_max_partition[
i];
311 if(X_min_partition[
i] < rAuxVariables.X_min) rAuxVariables.X_min = X_min_partition[
i];
312 if(Y_max_partition[
i] > rAuxVariables.Y_max) rAuxVariables.Y_max = Y_max_partition[
i];
313 if(Y_min_partition[
i] < rAuxVariables.Y_min) rAuxVariables.Y_min = Y_min_partition[
i];
314 if(Z_max_partition[
i] > rAuxVariables.Z_max) rAuxVariables.Z_max = Z_max_partition[
i];
315 if(Z_min_partition[
i] < rAuxVariables.Z_min) rAuxVariables.Z_min = Z_min_partition[
i];
319 double AverageElementLength = 0.0;
321 int NElems =
static_cast<int>(rModelPart.
Elements().size());
322 ModelPart::ElementsContainerType::iterator el_begin = rModelPart.
ElementsBegin();
324 #pragma omp parallel for reduction(+:AverageElementLength)
325 for(
int i = 0;
i < NElems;
i++)
327 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
329 AverageElementLength += itElem->GetGeometry().Length();
332 AverageElementLength = AverageElementLength/NElems;
335 rAuxVariables.NRows =
int((rAuxVariables.Y_max-rAuxVariables.Y_min)/AverageElementLength);
336 rAuxVariables.NColumns =
int((rAuxVariables.X_max-rAuxVariables.X_min)/AverageElementLength);
337 rAuxVariables.NSections =
int((rAuxVariables.Z_max-rAuxVariables.Z_min)/AverageElementLength);
338 if(rAuxVariables.NRows <= 0) rAuxVariables.NRows = 1;
339 if(rAuxVariables.NColumns <= 0) rAuxVariables.NColumns = 1;
340 if(rAuxVariables.NSections <= 0) rAuxVariables.NSections = 1;
341 rAuxVariables.RowSize = (rAuxVariables.Y_max-rAuxVariables.Y_min)/rAuxVariables.NRows;
342 rAuxVariables.ColumnSize = (rAuxVariables.X_max-rAuxVariables.X_min)/rAuxVariables.NColumns;
343 rAuxVariables.SectionSize = (rAuxVariables.Z_max-rAuxVariables.Z_min)/rAuxVariables.NSections;
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_3D_utilities.hpp:26
NonlocalDamageUtilities::GaussPoint GaussPoint
Definition: nonlocal_damage_3D_utilities.hpp:30
KRATOS_CLASS_POINTER_DEFINITION(NonlocalDamage3DUtilities)
void ComputeNeighbourDistance(double &rDistance, const GaussPoint &ReceiverPoint, const GaussPoint &SourcePoint) override
Definition: nonlocal_damage_3D_utilities.hpp:238
void SearchGaussPointsNeighbours(Parameters *pParameters, ModelPart &rModelPart) override
Definition: nonlocal_damage_3D_utilities.hpp:62
void InitializeNonlocalSearch(Utility3DVariables &rAuxVariables, Parameters *pParameters, ModelPart &rModelPart)
Member Variables.
Definition: nonlocal_damage_3D_utilities.hpp:85
std::vector< GaussPoint * > mGaussPointList
Member Variables.
Definition: nonlocal_damage_utilities.hpp:125
void SearchNeighbours(Utility3DVariables &rAuxVariables, Parameters *pParameters, ModelPart &rModelPart)
Definition: nonlocal_damage_3D_utilities.hpp:169
NonlocalDamage3DUtilities()
Default Constructor.
Definition: nonlocal_damage_3D_utilities.hpp:53
~NonlocalDamage3DUtilities() override
Destructor.
Definition: nonlocal_damage_3D_utilities.hpp:58
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
int m
Definition: run_marine_rain_substepping.py:8
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