KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
nodal_residualbased_elimination_builder_and_solver.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi, Alessandro Franci
11 //
12 //
13 
14 #if !defined(KRATOS_NODAL_RESIDUAL_BASED_ELIMINATION_BUILDER_AND_SOLVER)
15 #define KRATOS_NODAL_RESIDUAL_BASED_ELIMINATION_BUILDER_AND_SOLVER
16 
17 /* System includes */
18 #include <set>
19 #ifdef _OPENMP
20 #include <omp.h>
21 #endif
22 
23 /* External includes */
24 // #define USE_GOOGLE_HASH
25 #ifdef USE_GOOGLE_HASH
26 #include "sparsehash/dense_hash_set" //included in external libraries
27 #else
28 #include <unordered_set>
29 #endif
30 
31 /* Project includes */
32 #include "utilities/timer.h"
33 #include "includes/define.h"
34 #include "includes/key_hash.h"
36 #include "includes/model_part.h"
37 
39 
40 namespace Kratos
41 {
42 
45 
49 
53 
57 
61 
74  template <class TSparseSpace,
75  class TDenseSpace, //= DenseSpace<double>,
76  class TLinearSolver //= LinearSolver<TSparseSpace,TDenseSpace>
77  >
79  : public BuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver>
80  {
81  public:
85 
87 
89 
90  typedef typename BaseType::TDataType TDataType;
91 
93 
95 
97 
99 
101 
104 
105  typedef Node NodeType;
106 
110 
112 
115 
119 
123  typename TLinearSolver::Pointer pNewLinearSystemSolver)
124  : BuilderAndSolver<TSparseSpace, TDenseSpace, TLinearSolver>(pNewLinearSystemSolver)
125  {
126  // KRATOS_INFO("NodalResidualBasedEliminationBuilderAndSolver") << "Using the standard builder and solver " << std::endl;
127  }
128 
132  {
133  }
134 
138 
142 
145  double &density,
146  double &deviatoricCoeff,
147  double &volumetricCoeff,
148  double timeInterval,
149  double nodalVolume)
150  {
151 
152  deviatoricCoeff = itNode->FastGetSolutionStepValue(DEVIATORIC_COEFFICIENT);
153  density = itNode->FastGetSolutionStepValue(DENSITY);
154 
155  volumetricCoeff = timeInterval * itNode->FastGetSolutionStepValue(BULK_MODULUS);
156 
157  if (volumetricCoeff > 0)
158  {
159  volumetricCoeff = timeInterval * itNode->FastGetSolutionStepValue(BULK_MODULUS);
160  double bulkReduction = density * nodalVolume / (timeInterval * volumetricCoeff);
161  volumetricCoeff *= bulkReduction;
162  }
163  }
164 
166  typename TSchemeType::Pointer pScheme,
167  ModelPart &rModelPart,
170  {
171  KRATOS_TRY
172 
173  KRATOS_ERROR_IF(!pScheme) << "No scheme provided!" << std::endl;
174 
175  // contributions to the system
176  LocalSystemMatrixType LHS_Contribution = LocalSystemMatrixType(0, 0);
177  LocalSystemVectorType RHS_Contribution = LocalSystemVectorType(0);
178 
179  // vector containing the localization in the system of the different terms
181  const ProcessInfo &CurrentProcessInfo = rModelPart.GetProcessInfo();
182 
183  const unsigned int dimension = rModelPart.ElementsBegin()->GetGeometry().WorkingSpaceDimension();
184  const double timeInterval = CurrentProcessInfo[DELTA_TIME];
185  const double FourThirds = 4.0 / 3.0;
186  const double nTwoThirds = -2.0 / 3.0;
187 
188  double theta = 0.5;
189  array_1d<double, 3> Acc(3, 0.0);
190  // array_1d<double,6> Sigma(6,0.0);
191  double pressure = 0;
192  double dNdXi = 0;
193  double dNdYi = 0;
194  double dNdZi = 0;
195  double dNdXj = 0;
196  double dNdYj = 0;
197  double dNdZj = 0;
198  unsigned int firstRow = 0;
199  unsigned int firstCol = 0;
200 
201  double density = 0;
202  double deviatoricCoeff = 0;
203  double volumetricCoeff = 0;
204 
205  /* #pragma omp parallel */
206  // {
207  ModelPart::NodeIterator NodesBegin;
208  ModelPart::NodeIterator NodesEnd;
209  OpenMPUtils::PartitionedIterators(rModelPart.Nodes(), NodesBegin, NodesEnd);
210 
211  for (ModelPart::NodeIterator itNode = NodesBegin; itNode != NodesEnd; ++itNode)
212  {
213 
214  NodeWeakPtrVectorType &neighb_nodes = itNode->GetValue(NEIGHBOUR_NODES);
215  Vector nodalSFDneighboursId = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS_ORDER);
216  // const unsigned int neighSize = neighb_nodes.size()+1;
217  const unsigned int neighSize = nodalSFDneighboursId.size();
218  const double nodalVolume = itNode->FastGetSolutionStepValue(NODAL_VOLUME);
219 
220  if (neighSize > 1 && nodalVolume > 0)
221  {
222 
223  const unsigned int localSize = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS).size();
224 
225  if (LHS_Contribution.size1() != localSize)
226  LHS_Contribution.resize(localSize, localSize, false); // false says not to preserve existing storage!!
227 
228  if (RHS_Contribution.size() != localSize)
229  RHS_Contribution.resize(localSize, false); // false says not to preserve existing storage!!
230 
231  if (EquationId.size() != localSize)
232  EquationId.resize(localSize, false);
233 
234  noalias(LHS_Contribution) = ZeroMatrix(localSize, localSize);
235  noalias(RHS_Contribution) = ZeroVector(localSize);
236 
237  this->SetMaterialPropertiesToFluid(itNode, density, deviatoricCoeff, volumetricCoeff, timeInterval, nodalVolume);
238 
239  firstRow = 0;
240  firstCol = 0;
241 
242  if (dimension == 2)
243  {
245  LHS_Contribution(0, 0) += nodalVolume * density * 2.0 / timeInterval;
246  LHS_Contribution(1, 1) += nodalVolume * density * 2.0 / timeInterval;
247 
249  //-------- DYNAMIC FORCES TERM -------//
250  Acc = 2.0 * (itNode->FastGetSolutionStepValue(VELOCITY, 0) - itNode->FastGetSolutionStepValue(VELOCITY, 1)) / timeInterval -
251  itNode->FastGetSolutionStepValue(ACCELERATION, 0);
252 
253  RHS_Contribution[0] += -nodalVolume * density * Acc[0];
254  RHS_Contribution[1] += -nodalVolume * density * Acc[1];
255 
256  //-------- EXTERNAL FORCES TERM -------//
257 
258  array_1d<double, 3> &VolumeAcceleration = itNode->FastGetSolutionStepValue(VOLUME_ACCELERATION);
259 
260  // double posX= itNode->X();
261  // double posY= itNode->Y();
262  // double coeffX =(12.0-24.0*posY)*pow(posX,4);
263  // coeffX += (-24.0+48.0*posY)*pow(posX,3);
264  // coeffX += (-48.0*posY+72.0*pow(posY,2)-48.0*pow(posY,3)+12.0)*pow(posX,2);
265  // coeffX += (-2.0+24.0*posY-72.0*pow(posY,2)+48.0*pow(posY,3))*posX;
266  // coeffX += 1.0-4.0*posY+12.0*pow(posY,2)-8.0*pow(posY,3);
267  // double coeffY =(8.0-48.0*posY+48.0*pow(posY,2))*pow(posX,3);
268  // coeffY += (-12.0+72.0*posY-72.0*pow(posY,2))*pow(posX,2);
269  // coeffY += (4.0-24.0*posY+48.0*pow(posY,2)-48.0*pow(posY,3)+24.0*pow(posY,4))*posX;
270  // coeffY += -12.0*pow(posY,2)+24.0*pow(posY,3)-12.0*pow(posY,4);
271  // RHS_Contribution[0]+=nodalVolume*density*VolumeAcceleration[0]*coeffX;
272  // RHS_Contribution[1]+=nodalVolume*density*VolumeAcceleration[1]*coeffY;
273 
274  RHS_Contribution[0] += nodalVolume * density * VolumeAcceleration[0];
275  RHS_Contribution[1] += nodalVolume * density * VolumeAcceleration[1];
276 
277  //-------- INTERNAL FORCES TERM -------//
278  array_1d<double, 3> Sigma(3, 0.0);
279  Sigma = itNode->FastGetSolutionStepValue(NODAL_CAUCHY_STRESS);
280 
281  pressure = itNode->FastGetSolutionStepValue(PRESSURE, 0) * theta + itNode->FastGetSolutionStepValue(PRESSURE, 1) * (1 - theta);
282  Sigma[0] = itNode->FastGetSolutionStepValue(NODAL_DEVIATORIC_CAUCHY_STRESS)[0] + pressure;
283  Sigma[1] = itNode->FastGetSolutionStepValue(NODAL_DEVIATORIC_CAUCHY_STRESS)[1] + pressure;
284 
285  const unsigned int xDofPos = itNode->GetDofPosition(VELOCITY_X);
286  EquationId[0] = itNode->GetDof(VELOCITY_X, xDofPos).EquationId();
287  EquationId[1] = itNode->GetDof(VELOCITY_Y, xDofPos + 1).EquationId();
288 
289  for (unsigned int i = 0; i < neighSize; i++)
290  {
291  dNdXi = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstCol];
292  dNdYi = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstCol + 1];
293 
294  RHS_Contribution[firstCol] += -nodalVolume * (dNdXi * Sigma[0] + dNdYi * Sigma[2]);
295  RHS_Contribution[firstCol + 1] += -nodalVolume * (dNdYi * Sigma[1] + dNdXi * Sigma[2]);
296 
297  for (unsigned int j = 0; j < neighSize; j++)
298  {
299  dNdXj = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstRow];
300  dNdYj = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstRow + 1];
301 
302  LHS_Contribution(firstRow, firstCol) += nodalVolume * ((FourThirds * deviatoricCoeff + volumetricCoeff) * dNdXj * dNdXi + dNdYj * dNdYi * deviatoricCoeff) * theta;
303  LHS_Contribution(firstRow, firstCol + 1) += nodalVolume * ((nTwoThirds * deviatoricCoeff + volumetricCoeff) * dNdXj * dNdYi + dNdYj * dNdXi * deviatoricCoeff) * theta;
304 
305  LHS_Contribution(firstRow + 1, firstCol) += nodalVolume * ((nTwoThirds * deviatoricCoeff + volumetricCoeff) * dNdYj * dNdXi + dNdXj * dNdYi * deviatoricCoeff) * theta;
306  LHS_Contribution(firstRow + 1, firstCol + 1) += nodalVolume * ((FourThirds * deviatoricCoeff + volumetricCoeff) * dNdYj * dNdYi + dNdXj * dNdXi * deviatoricCoeff) * theta;
307 
308  firstRow += 2;
309  }
310 
311  firstRow = 0;
312  firstCol += 2;
313 
314  if (i < neighb_nodes.size())
315  {
316  EquationId[firstCol] = neighb_nodes[i].GetDof(VELOCITY_X, xDofPos).EquationId();
317  EquationId[firstCol + 1] = neighb_nodes[i].GetDof(VELOCITY_Y, xDofPos + 1).EquationId();
318  }
319  }
320  }
321  else if (dimension == 3)
322  {
324  LHS_Contribution(0, 0) += nodalVolume * density * 2.0 / timeInterval;
325  LHS_Contribution(1, 1) += nodalVolume * density * 2.0 / timeInterval;
326  LHS_Contribution(2, 2) += nodalVolume * density * 2.0 / timeInterval;
327 
329  //-------- DYNAMIC FORCES TERM -------//
330  Acc = 2.0 * (itNode->FastGetSolutionStepValue(VELOCITY, 0) - itNode->FastGetSolutionStepValue(VELOCITY, 1)) / timeInterval -
331  itNode->FastGetSolutionStepValue(ACCELERATION, 0);
332 
333  RHS_Contribution[0] += -nodalVolume * density * Acc[0];
334  RHS_Contribution[1] += -nodalVolume * density * Acc[1];
335  RHS_Contribution[2] += -nodalVolume * density * Acc[2];
336 
337  //-------- EXTERNAL FORCES TERM -------//
338 
339  array_1d<double, 3> &VolumeAcceleration = itNode->FastGetSolutionStepValue(VOLUME_ACCELERATION);
340 
341  RHS_Contribution[0] += nodalVolume * density * VolumeAcceleration[0];
342  RHS_Contribution[1] += nodalVolume * density * VolumeAcceleration[1];
343  RHS_Contribution[2] += nodalVolume * density * VolumeAcceleration[2];
344 
345  //-------- INTERNAL FORCES TERM -------//
346 
347  array_1d<double, 6> Sigma(6, 0.0);
348  Sigma = itNode->FastGetSolutionStepValue(NODAL_CAUCHY_STRESS);
349 
350  pressure = itNode->FastGetSolutionStepValue(PRESSURE, 0) * theta + itNode->FastGetSolutionStepValue(PRESSURE, 1) * (1 - theta);
351  Sigma[0] = itNode->FastGetSolutionStepValue(NODAL_DEVIATORIC_CAUCHY_STRESS)[0] + pressure;
352  Sigma[1] = itNode->FastGetSolutionStepValue(NODAL_DEVIATORIC_CAUCHY_STRESS)[1] + pressure;
353  Sigma[2] = itNode->FastGetSolutionStepValue(NODAL_DEVIATORIC_CAUCHY_STRESS)[2] + pressure;
354 
355  const unsigned int xDofPos = itNode->GetDofPosition(VELOCITY_X);
356  EquationId[0] = itNode->GetDof(VELOCITY_X, xDofPos).EquationId();
357  EquationId[1] = itNode->GetDof(VELOCITY_Y, xDofPos + 1).EquationId();
358  EquationId[2] = itNode->GetDof(VELOCITY_Z, xDofPos + 2).EquationId();
359 
360  for (unsigned int i = 0; i < neighSize; i++)
361  {
362  dNdXi = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstCol];
363  dNdYi = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstCol + 1];
364  dNdZi = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstCol + 2];
365 
366  RHS_Contribution[firstCol] += -nodalVolume * (dNdXi * Sigma[0] + dNdYi * Sigma[3] + dNdZi * Sigma[4]);
367  RHS_Contribution[firstCol + 1] += -nodalVolume * (dNdYi * Sigma[1] + dNdXi * Sigma[3] + dNdZi * Sigma[5]);
368  RHS_Contribution[firstCol + 2] += -nodalVolume * (dNdZi * Sigma[2] + dNdXi * Sigma[4] + dNdYi * Sigma[5]);
369 
370  for (unsigned int j = 0; j < neighSize; j++)
371  {
372 
373  dNdXj = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstRow];
374  dNdYj = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstRow + 1];
375  dNdZj = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS)[firstRow + 2];
376 
377  LHS_Contribution(firstRow, firstCol) += nodalVolume * ((FourThirds * deviatoricCoeff + volumetricCoeff) * dNdXj * dNdXi + (dNdYj * dNdYi + dNdZj * dNdZi) * deviatoricCoeff) * theta;
378  LHS_Contribution(firstRow, firstCol + 1) += nodalVolume * ((nTwoThirds * deviatoricCoeff + volumetricCoeff) * dNdXj * dNdYi + dNdYj * dNdXi * deviatoricCoeff) * theta;
379  LHS_Contribution(firstRow, firstCol + 2) += nodalVolume * ((nTwoThirds * deviatoricCoeff + volumetricCoeff) * dNdXj * dNdZi + dNdZj * dNdXi * deviatoricCoeff) * theta;
380 
381  LHS_Contribution(firstRow + 1, firstCol) += nodalVolume * ((nTwoThirds * deviatoricCoeff + volumetricCoeff) * dNdYj * dNdXi + dNdXj * dNdYi * deviatoricCoeff) * theta;
382  LHS_Contribution(firstRow + 1, firstCol + 1) += nodalVolume * ((FourThirds * deviatoricCoeff + volumetricCoeff) * dNdYj * dNdYi + (dNdXj * dNdXi + dNdZj * dNdZi) * deviatoricCoeff) * theta;
383  LHS_Contribution(firstRow + 1, firstCol + 2) += nodalVolume * ((nTwoThirds * deviatoricCoeff + volumetricCoeff) * dNdYj * dNdZi + dNdZj * dNdYi * deviatoricCoeff) * theta;
384 
385  LHS_Contribution(firstRow + 2, firstCol) += nodalVolume * ((nTwoThirds * deviatoricCoeff + volumetricCoeff) * dNdZj * dNdXi + dNdXj * dNdZi * deviatoricCoeff) * theta;
386  LHS_Contribution(firstRow + 2, firstCol + 1) += nodalVolume * ((nTwoThirds * deviatoricCoeff + volumetricCoeff) * dNdZj * dNdYi + dNdYj * dNdZi * deviatoricCoeff) * theta;
387  LHS_Contribution(firstRow + 2, firstCol + 2) += nodalVolume * ((FourThirds * deviatoricCoeff + volumetricCoeff) * dNdZj * dNdZi + (dNdXj * dNdXi + dNdYj * dNdYi) * deviatoricCoeff) * theta;
388 
389  firstRow += 3;
390  }
391 
392  firstRow = 0;
393  firstCol += 3;
394 
395  if (i < neighb_nodes.size())
396  {
397  EquationId[firstCol] = neighb_nodes[i].GetDof(VELOCITY_X, xDofPos).EquationId();
398  EquationId[firstCol + 1] = neighb_nodes[i].GetDof(VELOCITY_Y, xDofPos + 1).EquationId();
399  EquationId[firstCol + 2] = neighb_nodes[i].GetDof(VELOCITY_Z, xDofPos + 2).EquationId();
400  }
401  }
402  }
403 
404 #ifdef _OPENMP
405  Assemble(A, b, LHS_Contribution, RHS_Contribution, EquationId, mlock_array);
406 #else
407  Assemble(A, b, LHS_Contribution, RHS_Contribution, EquationId);
408 #endif
409  }
410  }
411 
412  // }
413 
414  KRATOS_CATCH("")
415  }
416 
425  TSystemVectorType &Dx,
426  TSystemVectorType &b) override
427  {
428  KRATOS_TRY
429 
430  double norm_b;
431  if (TSparseSpace::Size(b) != 0)
432  norm_b = TSparseSpace::TwoNorm(b);
433  else
434  norm_b = 0.00;
435 
436  if (norm_b != 0.00)
437  {
438  // do solve
439  BaseType::mpLinearSystemSolver->Solve(A, Dx, b);
440  }
441  else
442  TSparseSpace::SetToZero(Dx);
443 
444  // Prints informations about the current time
445  KRATOS_INFO_IF("NodalResidualBasedEliminationBuilderAndSolver", this->GetEchoLevel() > 1) << *(BaseType::mpLinearSystemSolver) << std::endl;
446 
447  KRATOS_CATCH("")
448  }
449 
459  TSystemVectorType &Dx,
461  ModelPart &rModelPart)
462  {
463  KRATOS_TRY
464 
465  double norm_b;
466  if (TSparseSpace::Size(b) != 0)
467  norm_b = TSparseSpace::TwoNorm(b);
468  else
469  norm_b = 0.00;
470 
471  if (norm_b != 0.00)
472  {
473  // provide physical data as needed
474  if (BaseType::mpLinearSystemSolver->AdditionalPhysicalDataIsNeeded())
475  BaseType::mpLinearSystemSolver->ProvideAdditionalData(A, Dx, b, BaseType::mDofSet, rModelPart);
476 
477  // do solve
478  BaseType::mpLinearSystemSolver->Solve(A, Dx, b);
479  }
480  else
481  {
482  TSparseSpace::SetToZero(Dx);
483  KRATOS_WARNING_IF("NodalResidualBasedEliminationBuilderAndSolver", rModelPart.GetCommunicator().MyPID() == 0) << "ATTENTION! setting the RHS to zero!" << std::endl;
484  }
485 
486  // Prints informations about the current time
487  KRATOS_INFO_IF("NodalResidualBasedEliminationBuilderAndSolver", this->GetEchoLevel() > 1 && rModelPart.GetCommunicator().MyPID() == 0) << *(BaseType::mpLinearSystemSolver) << std::endl;
488 
489  KRATOS_CATCH("")
490  }
491 
503  typename TSchemeType::Pointer pScheme,
504  ModelPart &rModelPart,
506  TSystemVectorType &Dx,
507  TSystemVectorType &b) override
508  {
509  KRATOS_TRY
510 
511  Timer::Start("Build");
512  BuildFluidNodally(pScheme, rModelPart, A, b);
513  Timer::Stop("Build");
514 
515  // ApplyPointLoads(pScheme,rModelPart,b);
516 
517  // Does nothing...dirichlet conditions are naturally dealt with in defining the residual
518  ApplyDirichletConditions(pScheme, rModelPart, A, Dx, b);
519 
520  KRATOS_INFO_IF("ResidualBasedBlockBuilderAndSolver", (this->GetEchoLevel() == 3)) << "Before the solution of the system"
521  << "\nSystem Matrix = " << A << "\nUnknowns vector = " << Dx << "\nRHS vector = " << b << std::endl;
522 
523  SystemSolveWithPhysics(A, Dx, b, rModelPart);
524 
525  KRATOS_INFO_IF("ResidualBasedBlockBuilderAndSolver", (this->GetEchoLevel() == 3)) << "After the solution of the system"
526  << "\nSystem Matrix = " << A << "\nUnknowns vector = " << Dx << "\nRHS vector = " << b << std::endl;
527 
528  KRATOS_CATCH("")
529  }
530 
540  typename TSchemeType::Pointer pScheme,
541  ModelPart &rModelPart) override
542  {
543  KRATOS_TRY;
544 
545  KRATOS_INFO_IF("NodalResidualBasedEliminationBuilderAndSolver", this->GetEchoLevel() > 1 && rModelPart.GetCommunicator().MyPID() == 0) << "Setting up the dofs" << std::endl;
546 
547  // Gets the array of elements from the modeler
548  ElementsArrayType &pElements = rModelPart.Elements();
549  const int nelements = static_cast<int>(pElements.size());
550 
551  Element::DofsVectorType ElementalDofList;
552 
553  const ProcessInfo &CurrentProcessInfo = rModelPart.GetProcessInfo();
554 
555  unsigned int nthreads = ParallelUtilities::GetNumThreads();
556 
557 #ifdef USE_GOOGLE_HASH
558  typedef google::dense_hash_set<NodeType::DofType::Pointer, DofPointerHasher> set_type;
559 #else
560  typedef std::unordered_set<NodeType::DofType::Pointer, DofPointerHasher> set_type;
561 #endif
562  //
563 
564  std::vector<set_type> dofs_aux_list(nthreads);
565  // std::vector<allocator_type> allocators(nthreads);
566 
567  for (int i = 0; i < static_cast<int>(nthreads); i++)
568  {
569 #ifdef USE_GOOGLE_HASH
570  dofs_aux_list[i].set_empty_key(NodeType::DofType::Pointer());
571 #else
572  dofs_aux_list[i].reserve(nelements);
573 #endif
574  }
575 
576  for (int i = 0; i < static_cast<int>(nelements); ++i)
577  {
578  auto it_elem = pElements.begin() + i;
579  const IndexType this_thread_id = OpenMPUtils::ThisThread();
580 
581  // Gets list of Dof involved on every element
582  pScheme->GetDofList(*it_elem, ElementalDofList, CurrentProcessInfo);
583 
584  dofs_aux_list[this_thread_id].insert(ElementalDofList.begin(), ElementalDofList.end());
585  }
586 
587  ConditionsArrayType &pConditions = rModelPart.Conditions();
588  const int nconditions = static_cast<int>(pConditions.size());
589 #pragma omp parallel for firstprivate(nconditions, ElementalDofList)
590  for (int i = 0; i < nconditions; ++i)
591  {
592  auto it_cond = pConditions.begin() + i;
593  const IndexType this_thread_id = OpenMPUtils::ThisThread();
594 
595  // Gets list of Dof involved on every element
596  pScheme->GetDofList(*it_cond, ElementalDofList, CurrentProcessInfo);
597  dofs_aux_list[this_thread_id].insert(ElementalDofList.begin(), ElementalDofList.end());
598  }
599 
600  // here we do a reduction in a tree so to have everything on thread 0
601  unsigned int old_max = nthreads;
602  unsigned int new_max = ceil(0.5 * static_cast<double>(old_max));
603  while (new_max >= 1 && new_max != old_max)
604  {
605 
606 #pragma omp parallel for
607  for (int i = 0; i < static_cast<int>(new_max); i++)
608  {
609  if (i + new_max < old_max)
610  {
611  dofs_aux_list[i].insert(dofs_aux_list[i + new_max].begin(), dofs_aux_list[i + new_max].end());
612  dofs_aux_list[i + new_max].clear();
613  }
614  }
615 
616  old_max = new_max;
617  new_max = ceil(0.5 * static_cast<double>(old_max));
618  }
619 
620  DofsArrayType Doftemp;
622 
623  Doftemp.reserve(dofs_aux_list[0].size());
624  for (auto it = dofs_aux_list[0].begin(); it != dofs_aux_list[0].end(); it++)
625  {
626  Doftemp.push_back((*it));
627  }
628  Doftemp.Sort();
629 
630  BaseType::mDofSet = Doftemp;
631 
632  // Throws an execption if there are no Degrees of freedom involved in the analysis
633  KRATOS_ERROR_IF(BaseType::mDofSet.size() == 0) << "No degrees of freedom!" << std::endl;
634 
636 
637  KRATOS_INFO_IF("NodalResidualBasedEliminationBuilderAndSolver", this->GetEchoLevel() > 2 && rModelPart.GetCommunicator().MyPID() == 0) << "Finished setting up the dofs" << std::endl;
638 
639 #ifdef _OPENMP
640  if (mlock_array.size() != 0)
641  {
642  for (int i = 0; i < static_cast<int>(mlock_array.size()); i++)
643  omp_destroy_lock(&mlock_array[i]);
644  }
645 
646  mlock_array.resize(BaseType::mDofSet.size());
647 
648  for (int i = 0; i < static_cast<int>(mlock_array.size()); i++)
649  omp_init_lock(&mlock_array[i]);
650 #endif
651 
652  // If reactions are to be calculated, we check if all the dofs have reactions defined
653  // This is tobe done only in debug mode
654 #ifdef KRATOS_DEBUG
656  {
657  for (auto dof_iterator = BaseType::mDofSet.begin(); dof_iterator != BaseType::mDofSet.end(); ++dof_iterator)
658  {
659  KRATOS_ERROR_IF_NOT(dof_iterator->HasReaction()) << "Reaction variable not set for the following : " << std::endl
660  << "Node : " << dof_iterator->Id() << std::endl
661  << "Dof : " << (*dof_iterator) << std::endl
662  << "Not possible to calculate reactions." << std::endl;
663  }
664  }
665 #endif
666 
667  KRATOS_CATCH("");
668  }
669 
675  ModelPart &rModelPart) override
676  {
677  // Set equation id for degrees of freedom
678  // the free degrees of freedom are positioned at the beginning of the system,
679  // while the fixed one are at the end (in opposite order).
680  //
681  // that means that if the EquationId is greater than "mEquationSystemSize"
682  // the pointed degree of freedom is restrained
683  //
684  int free_id = 0;
685  int fix_id = BaseType::mDofSet.size();
686 
687  for (typename DofsArrayType::iterator dof_iterator = BaseType::mDofSet.begin(); dof_iterator != BaseType::mDofSet.end(); ++dof_iterator)
688  if (dof_iterator->IsFixed())
689  dof_iterator->SetEquationId(--fix_id);
690  else
691  dof_iterator->SetEquationId(free_id++);
692 
694  }
695 
696  //**************************************************************************
697  //**************************************************************************
698 
700  typename TSchemeType::Pointer pScheme,
704  ModelPart &rModelPart) override
705  {
706  KRATOS_TRY
707 
708  // boost::timer m_contruct_matrix;
709 
710  if (pA == NULL) // if the pointer is not initialized initialize it to an empty matrix
711  {
713  pA.swap(pNewA);
714  }
715  if (pDx == NULL) // if the pointer is not initialized initialize it to an empty matrix
716  {
718  pDx.swap(pNewDx);
719  }
720  if (pb == NULL) // if the pointer is not initialized initialize it to an empty matrix
721  {
723  pb.swap(pNewb);
724  }
725  if (BaseType::mpReactionsVector == NULL) // if the pointer is not initialized initialize it to an empty matrix
726  {
728  BaseType::mpReactionsVector.swap(pNewReactionsVector);
729  }
730 
731  TSystemMatrixType &A = *pA;
732  TSystemVectorType &Dx = *pDx;
733  TSystemVectorType &b = *pb;
734 
735  // resizing the system vectors and matrix
736  if (A.size1() == 0 || BaseType::GetReshapeMatrixFlag() == true) // if the matrix is not initialized
737  {
739  ConstructMatrixStructure(pScheme, A, rModelPart);
740  }
741  else
742  {
743  if (A.size1() != BaseType::mEquationSystemSize || A.size2() != BaseType::mEquationSystemSize)
744  {
745  KRATOS_WATCH("it should not come here!!!!!!!! ... this is SLOW");
746  KRATOS_ERROR << "The equation system size has changed during the simulation. This is not permited." << std::endl;
748  ConstructMatrixStructure(pScheme, A, rModelPart);
749  }
750  }
751  if (Dx.size() != BaseType::mEquationSystemSize)
752  Dx.resize(BaseType::mEquationSystemSize, false);
753  if (b.size() != BaseType::mEquationSystemSize)
754  b.resize(BaseType::mEquationSystemSize, false);
755 
756  // if needed resize the vector for the calculation of reactions
758  {
759  unsigned int ReactionsVectorSize = BaseType::mDofSet.size();
760  if (BaseType::mpReactionsVector->size() != ReactionsVectorSize)
761  BaseType::mpReactionsVector->resize(ReactionsVectorSize, false);
762  }
763  // std::cout << "MOMENTUM EQ: contruct_matrix : " << m_contruct_matrix.elapsed() << std::endl;
764 
765  KRATOS_CATCH("")
766  }
767 
768  //**************************************************************************
769  //**************************************************************************
770 
783  typename TSchemeType::Pointer pScheme,
784  ModelPart &rModelPart,
786  TSystemVectorType &Dx,
787  TSystemVectorType &b) override
788  {
789  }
790 
794  void Clear() override
795  {
796  this->mDofSet = DofsArrayType();
797 
798  if (this->mpReactionsVector != NULL)
799  TSparseSpace::Clear((this->mpReactionsVector));
800  // this->mReactionsVector = TSystemVectorType();
801 
802  this->mpLinearSystemSolver->Clear();
803 
804  KRATOS_INFO_IF("NodalResidualBasedEliminationBuilderAndSolver", this->GetEchoLevel() > 1) << "Clear Function called" << std::endl;
805  }
806 
814  int Check(ModelPart &rModelPart) override
815  {
816  KRATOS_TRY
817 
818  return 0;
819  KRATOS_CATCH("");
820  }
821 
825 
829 
833 
835 
836  protected:
839 
843 
847 
851 
852  void Assemble(
855  const LocalSystemMatrixType &LHS_Contribution,
856  const LocalSystemVectorType &RHS_Contribution,
857  const Element::EquationIdVectorType &EquationId
858 #ifdef _OPENMP
859  ,
860  std::vector<omp_lock_t> &lock_array
861 #endif
862  )
863  {
864  unsigned int local_size = LHS_Contribution.size1();
865 
866  for (unsigned int i_local = 0; i_local < local_size; i_local++)
867  {
868  unsigned int i_global = EquationId[i_local];
869 
870  if (i_global < BaseType::mEquationSystemSize)
871  {
872 #ifdef _OPENMP
873  omp_set_lock(&lock_array[i_global]);
874 #endif
875  b[i_global] += RHS_Contribution(i_local);
876  for (unsigned int j_local = 0; j_local < local_size; j_local++)
877  {
878  unsigned int j_global = EquationId[j_local];
879  if (j_global < BaseType::mEquationSystemSize)
880  {
881  A(i_global, j_global) += LHS_Contribution(i_local, j_local);
882  }
883  }
884 #ifdef _OPENMP
885  omp_unset_lock(&lock_array[i_global]);
886 #endif
887  }
888  // note that assembly on fixed rows is not performed here
889  }
890  }
891 
892  //**************************************************************************
894  typename TSchemeType::Pointer pScheme,
896  ModelPart &rModelPart)
897  {
898 
899  // filling with zero the matrix (creating the structure)
900  Timer::Start("MatrixStructure");
901 
902  ProcessInfo &CurrentProcessInfo = rModelPart.GetProcessInfo();
903 
904  // Getting the array of the conditions
905  const int nconditions = static_cast<int>(rModelPart.Conditions().size());
906  ModelPart::ConditionsContainerType::iterator cond_begin = rModelPart.ConditionsBegin();
907 
908  const std::size_t equation_size = BaseType::mEquationSystemSize;
909 
910 #ifdef USE_GOOGLE_HASH
911  std::vector<google::dense_hash_set<std::size_t>> indices(equation_size);
912  const std::size_t empty_key = 2 * equation_size + 10;
913 #else
914  std::vector<std::unordered_set<std::size_t>> indices(equation_size);
915 #endif
916 
917 #pragma omp parallel for firstprivate(equation_size)
918  for (int iii = 0; iii < static_cast<int>(equation_size); iii++)
919  {
920 #ifdef USE_GOOGLE_HASH
921  indices[iii].set_empty_key(empty_key);
922 #else
923  indices[iii].reserve(40);
924 #endif
925  }
926 
928 
929  ModelPart::NodeIterator NodesBegin;
930  ModelPart::NodeIterator NodesEnd;
931  OpenMPUtils::PartitionedIterators(rModelPart.Nodes(), NodesBegin, NodesEnd);
932  for (ModelPart::NodeIterator itNode = NodesBegin; itNode != NodesEnd; ++itNode)
933  {
934 
935  const unsigned int localSize = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS).size();
936  const unsigned int dimension = rModelPart.ElementsBegin()->GetGeometry().WorkingSpaceDimension();
937 
938  Vector nodalSFDneighboursId = itNode->FastGetSolutionStepValue(NODAL_SFD_NEIGHBOURS_ORDER);
939 
940  if (EquationId.size() != localSize)
941  EquationId.resize(localSize, false);
942 
943  unsigned int firstCol = 0;
944 
945  const unsigned int xDofPos = itNode->GetDofPosition(VELOCITY_X);
946  EquationId[0] = itNode->GetDof(VELOCITY_X, xDofPos).EquationId();
947  EquationId[1] = itNode->GetDof(VELOCITY_Y, xDofPos + 1).EquationId();
948  if (dimension == 3)
949  EquationId[2] = itNode->GetDof(VELOCITY_Z, xDofPos + 2).EquationId();
950 
951  NodeWeakPtrVectorType &neighb_nodes = itNode->GetValue(NEIGHBOUR_NODES);
952  for (unsigned int i = 0; i < neighb_nodes.size(); i++)
953  {
954  firstCol += dimension;
955  EquationId[firstCol] = neighb_nodes[i].GetDof(VELOCITY_X, xDofPos).EquationId();
956  EquationId[firstCol + 1] = neighb_nodes[i].GetDof(VELOCITY_Y, xDofPos + 1).EquationId();
957  if (dimension == 3)
958  {
959  EquationId[firstCol + 2] = neighb_nodes[i].GetDof(VELOCITY_Z, xDofPos + 2).EquationId();
960  }
961  }
962 
963  for (std::size_t i = 0; i < EquationId.size(); i++)
964  {
965  if (EquationId[i] < BaseType::mEquationSystemSize)
966  {
967 #ifdef _OPENMP
968  omp_set_lock(&mlock_array[EquationId[i]]);
969 #endif
970 
971  auto &row_indices = indices[EquationId[i]];
972  for (auto it = EquationId.begin(); it != EquationId.end(); it++)
973  {
974 
976 
977  row_indices.insert(*it);
978  }
979 
980 #ifdef _OPENMP
981  omp_unset_lock(&mlock_array[EquationId[i]]);
982 #endif
983  }
984  }
985  }
986 
988 
989 #pragma omp parallel for firstprivate(nconditions, ids)
990  for (int iii = 0; iii < nconditions; iii++)
991  {
992  typename ConditionsArrayType::iterator i_condition = cond_begin + iii;
993  pScheme->EquationId(*i_condition, ids, CurrentProcessInfo);
994  for (std::size_t i = 0; i < ids.size(); i++)
995  {
996  if (ids[i] < BaseType::mEquationSystemSize)
997  {
998 #ifdef _OPENMP
999  omp_set_lock(&mlock_array[ids[i]]);
1000 #endif
1001  auto &row_indices = indices[ids[i]];
1002  for (auto it = ids.begin(); it != ids.end(); it++)
1003  {
1005  row_indices.insert(*it);
1006  }
1007 #ifdef _OPENMP
1008  omp_unset_lock(&mlock_array[ids[i]]);
1009 #endif
1010  }
1011  }
1012  }
1013 
1014  // count the row sizes
1015  unsigned int nnz = 0;
1016  for (unsigned int i = 0; i < indices.size(); i++)
1017  nnz += indices[i].size();
1018 
1019  A = boost::numeric::ublas::compressed_matrix<double>(indices.size(), indices.size(), nnz);
1020 
1021  double *Avalues = A.value_data().begin();
1022  std::size_t *Arow_indices = A.index1_data().begin();
1023  std::size_t *Acol_indices = A.index2_data().begin();
1024 
1025  // filling the index1 vector - DO NOT MAKE PARALLEL THE FOLLOWING LOOP!
1026  Arow_indices[0] = 0;
1027  for (int i = 0; i < static_cast<int>(A.size1()); i++)
1028  Arow_indices[i + 1] = Arow_indices[i] + indices[i].size();
1029 
1030 #pragma omp parallel for
1031  for (int i = 0; i < static_cast<int>(A.size1()); i++)
1032  {
1033  const unsigned int row_begin = Arow_indices[i];
1034  const unsigned int row_end = Arow_indices[i + 1];
1035  unsigned int k = row_begin;
1036  for (auto it = indices[i].begin(); it != indices[i].end(); it++)
1037  {
1038  Acol_indices[k] = *it;
1039  Avalues[k] = 0.0;
1040  k++;
1041  }
1042 
1043  std::sort(&Acol_indices[row_begin], &Acol_indices[row_end]);
1044  }
1045 
1046  A.set_filled(indices.size() + 1, nnz);
1047 
1048  Timer::Stop("MatrixStructure");
1049  }
1050 
1053  LocalSystemMatrixType &LHS_Contribution,
1054  Element::EquationIdVectorType &EquationId)
1055  {
1056  unsigned int local_size = LHS_Contribution.size1();
1057 
1058  for (unsigned int i_local = 0; i_local < local_size; i_local++)
1059  {
1060  unsigned int i_global = EquationId[i_local];
1061  if (i_global < BaseType::mEquationSystemSize)
1062  {
1063  for (unsigned int j_local = 0; j_local < local_size; j_local++)
1064  {
1065  unsigned int j_global = EquationId[j_local];
1066  if (j_global < BaseType::mEquationSystemSize)
1067  A(i_global, j_global) += LHS_Contribution(i_local, j_local);
1068  }
1069  }
1070  }
1071  }
1072 
1076 
1080 
1084 
1086 
1087  private:
1090 
1094 #ifdef _OPENMP
1095  std::vector<omp_lock_t> mlock_array;
1096 #endif
1100 
1104 
1105  inline void AddUnique(std::vector<std::size_t> &v, const std::size_t &candidate)
1106  {
1107  std::vector<std::size_t>::iterator i = v.begin();
1108  std::vector<std::size_t>::iterator endit = v.end();
1109  while (i != endit && (*i) != candidate)
1110  {
1111  i++;
1112  }
1113  if (i == endit)
1114  {
1115  v.push_back(candidate);
1116  }
1117  }
1118 
1119  void AssembleRHS(
1121  const LocalSystemVectorType &RHS_Contribution,
1122  const Element::EquationIdVectorType &EquationId)
1123  {
1124  unsigned int local_size = RHS_Contribution.size();
1125 
1126  if (BaseType::mCalculateReactionsFlag == false)
1127  {
1128  for (unsigned int i_local = 0; i_local < local_size; i_local++)
1129  {
1130  const unsigned int i_global = EquationId[i_local];
1131 
1132  if (i_global < BaseType::mEquationSystemSize) // free dof
1133  {
1134  // ASSEMBLING THE SYSTEM VECTOR
1135  double &b_value = b[i_global];
1136  const double &rhs_value = RHS_Contribution[i_local];
1137 
1138 #pragma omp atomic
1139  b_value += rhs_value;
1140  }
1141  }
1142  }
1143  else
1144  {
1145  TSystemVectorType &ReactionsVector = *BaseType::mpReactionsVector;
1146  for (unsigned int i_local = 0; i_local < local_size; i_local++)
1147  {
1148  const unsigned int i_global = EquationId[i_local];
1149 
1150  if (i_global < BaseType::mEquationSystemSize) // free dof
1151  {
1152  // ASSEMBLING THE SYSTEM VECTOR
1153  double &b_value = b[i_global];
1154  const double &rhs_value = RHS_Contribution[i_local];
1155 
1156 #pragma omp atomic
1157  b_value += rhs_value;
1158  }
1159  else // fixed dof
1160  {
1161  double &b_value = ReactionsVector[i_global - BaseType::mEquationSystemSize];
1162  const double &rhs_value = RHS_Contribution[i_local];
1163 
1164 #pragma omp atomic
1165  b_value += rhs_value;
1166  }
1167  }
1168  }
1169  }
1170 
1171  //**************************************************************************
1172 
1173  void AssembleLHS_CompleteOnFreeRows(
1175  LocalSystemMatrixType &LHS_Contribution,
1176  Element::EquationIdVectorType &EquationId)
1177  {
1178  unsigned int local_size = LHS_Contribution.size1();
1179  for (unsigned int i_local = 0; i_local < local_size; i_local++)
1180  {
1181  unsigned int i_global = EquationId[i_local];
1182  if (i_global < BaseType::mEquationSystemSize)
1183  {
1184  for (unsigned int j_local = 0; j_local < local_size; j_local++)
1185  {
1186  int j_global = EquationId[j_local];
1187  A(i_global, j_global) += LHS_Contribution(i_local, j_local);
1188  }
1189  }
1190  }
1191  }
1192 
1196 
1200 
1204 
1208 
1210 
1211  }; /* Class NodalResidualBasedEliminationBuilderAndSolver */
1212 
1214 
1217 
1219 
1220 } /* namespace Kratos.*/
1221 
1222 #endif /* KRATOS_NODAL_RESIDUAL_BASED_ELIMINATION_BUILDER_AND_SOLVER defined */
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
std::size_t IndexType
Definition of the index type.
Definition: builder_and_solver.h:76
bool mDofSetIsInitialized
If the matrix is reshaped each step.
Definition: builder_and_solver.h:743
TSparseSpace::VectorType TSystemVectorType
Definition of the vector size.
Definition: builder_and_solver.h:85
ModelPart::NodesContainerType NodesArrayType
The containers of the entities.
Definition: builder_and_solver.h:109
bool GetCalculateReactionsFlag() const
This method returns the flag mCalculateReactionsFlag.
Definition: builder_and_solver.h:184
TSparseSpace::MatrixType TSystemMatrixType
Definition of the sparse matrix.
Definition: builder_and_solver.h:82
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: builder_and_solver.h:111
TSystemVectorPointerType mpReactionsVector
Definition: builder_and_solver.h:751
bool GetReshapeMatrixFlag() const
This method returns the flag mReshapeMatrixFlag.
Definition: builder_and_solver.h:220
TDenseSpace::MatrixType LocalSystemMatrixType
The local matrix definition.
Definition: builder_and_solver.h:94
TSparseSpace::VectorPointerType TSystemVectorPointerType
Definition of the pointer to the vector.
Definition: builder_and_solver.h:91
TSparseSpace::DataType TDataType
Definition of the data type.
Definition: builder_and_solver.h:79
TLinearSolver::Pointer mpLinearSystemSolver
Definition: builder_and_solver.h:737
DofsArrayType mDofSet
Pointer to the linear solver.
Definition: builder_and_solver.h:739
TDenseSpace::VectorType LocalSystemVectorType
The local vector definition.
Definition: builder_and_solver.h:97
TSparseSpace::MatrixPointerType TSystemMatrixPointerType
Definition of the pointer to the sparse matrix.
Definition: builder_and_solver.h:88
bool mCalculateReactionsFlag
Flag taking care if the dof set was initialized ot not.
Definition: builder_and_solver.h:745
int GetEchoLevel() const
It returns the echo level.
Definition: builder_and_solver.h:674
unsigned int mEquationSystemSize
Flag taking in account if it is needed or not to calculate the reactions.
Definition: builder_and_solver.h:747
ModelPart::ElementsContainerType ElementsArrayType
Definition: builder_and_solver.h:110
virtual int MyPID() const
Definition: communicator.cpp:91
Dof * Pointer
Pointer definition of Dof.
Definition: dof.h:93
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
size_type size() const
Definition: global_pointers_vector.h:307
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
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
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
Communicator & GetCommunicator()
Definition: model_part.h:1821
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Current class provides an implementation for standard builder and solving operations.
Definition: nodal_residualbased_elimination_builder_and_solver.h:80
Node NodeType
Definition: nodal_residualbased_elimination_builder_and_solver.h:105
BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: nodal_residualbased_elimination_builder_and_solver.h:103
void SetUpSystem(ModelPart &rModelPart) override
Organises the dofset in order to speed up the building phase.
Definition: nodal_residualbased_elimination_builder_and_solver.h:674
KRATOS_CLASS_POINTER_DEFINITION(NodalResidualBasedEliminationBuilderAndSolver)
BaseType::ElementsContainerType ElementsContainerType
Definition: nodal_residualbased_elimination_builder_and_solver.h:111
void SystemSolveWithPhysics(TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b, ModelPart &rModelPart)
This is a call to the linear system solver (taking into account some physical particularities of the ...
Definition: nodal_residualbased_elimination_builder_and_solver.h:457
BaseType::TSystemMatrixType TSystemMatrixType
Definition: nodal_residualbased_elimination_builder_and_solver.h:94
void BuildFluidNodally(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &b)
Definition: nodal_residualbased_elimination_builder_and_solver.h:165
GlobalPointersVector< Node > NodeWeakPtrVectorType
Definition: nodal_residualbased_elimination_builder_and_solver.h:114
BaseType::DofsArrayType DofsArrayType
Definition: nodal_residualbased_elimination_builder_and_solver.h:92
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: nodal_residualbased_elimination_builder_and_solver.h:98
BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition: nodal_residualbased_elimination_builder_and_solver.h:102
void SetUpDofSet(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart) override
Builds the list of the DofSets involved in the problem by "asking" to each element and condition its ...
Definition: nodal_residualbased_elimination_builder_and_solver.h:539
void ResizeAndInitializeVectors(typename TSchemeType::Pointer pScheme, TSystemMatrixPointerType &pA, TSystemVectorPointerType &pDx, TSystemVectorPointerType &pb, ModelPart &rModelPart) override
This method initializes and resizes the system of equations.
Definition: nodal_residualbased_elimination_builder_and_solver.h:699
void Assemble(TSystemMatrixType &A, TSystemVectorType &b, const LocalSystemMatrixType &LHS_Contribution, const LocalSystemVectorType &RHS_Contribution, const Element::EquationIdVectorType &EquationId)
Definition: nodal_residualbased_elimination_builder_and_solver.h:852
BaseType::ConditionsArrayType ConditionsArrayType
Definition: nodal_residualbased_elimination_builder_and_solver.h:109
BaseType::TSystemVectorType TSystemVectorType
Definition: nodal_residualbased_elimination_builder_and_solver.h:96
BaseType::NodesArrayType NodesArrayType
Definition: nodal_residualbased_elimination_builder_and_solver.h:107
void Clear() override
This function is intended to be called at the end of the solution step to clean up memory storage not...
Definition: nodal_residualbased_elimination_builder_and_solver.h:794
void SystemSolve(TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
This is a call to the linear system solver.
Definition: nodal_residualbased_elimination_builder_and_solver.h:423
int Check(ModelPart &rModelPart) override
This function is designed to be called once to perform all the checks needed on the input provided....
Definition: nodal_residualbased_elimination_builder_and_solver.h:814
NodalResidualBasedEliminationBuilderAndSolver(typename TLinearSolver::Pointer pNewLinearSystemSolver)
Definition: nodal_residualbased_elimination_builder_and_solver.h:122
void ApplyDirichletConditions(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Applies the dirichlet conditions. This operation may be very heavy or completely unexpensive dependin...
Definition: nodal_residualbased_elimination_builder_and_solver.h:782
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: nodal_residualbased_elimination_builder_and_solver.h:100
void BuildAndSolve(typename TSchemeType::Pointer pScheme, ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function to perform the building and solving phase at the same time.
Definition: nodal_residualbased_elimination_builder_and_solver.h:502
void SetMaterialPropertiesToFluid(ModelPart::NodeIterator itNode, double &density, double &deviatoricCoeff, double &volumetricCoeff, double timeInterval, double nodalVolume)
Definition: nodal_residualbased_elimination_builder_and_solver.h:143
BaseType::TDataType TDataType
Definition: nodal_residualbased_elimination_builder_and_solver.h:90
void AssembleLHS(TSystemMatrixType &A, LocalSystemMatrixType &LHS_Contribution, Element::EquationIdVectorType &EquationId)
Definition: nodal_residualbased_elimination_builder_and_solver.h:1051
BuilderAndSolver< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: nodal_residualbased_elimination_builder_and_solver.h:86
BaseType::ElementsArrayType ElementsArrayType
Definition: nodal_residualbased_elimination_builder_and_solver.h:108
BaseType::TSchemeType TSchemeType
Definition: nodal_residualbased_elimination_builder_and_solver.h:88
Vector VectorType
Definition: nodal_residualbased_elimination_builder_and_solver.h:113
virtual void ConstructMatrixStructure(typename TSchemeType::Pointer pScheme, TSystemMatrixType &A, ModelPart &rModelPart)
Definition: nodal_residualbased_elimination_builder_and_solver.h:893
~NodalResidualBasedEliminationBuilderAndSolver() override
Definition: nodal_residualbased_elimination_builder_and_solver.h:131
This class defines the node.
Definition: node.h:65
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
static void PartitionedIterators(TVector &rVector, typename TVector::iterator &rBegin, typename TVector::iterator &rEnd)
Generate a partition for an std::vector-like array, providing iterators to the begin and end position...
Definition: openmp_utils.h:179
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
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
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
void Sort()
Sort the elements in the set.
Definition: pointer_vector_set.h:753
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
void reserve(int reservedsize)
Reserves memory for a specified number of elements.
Definition: pointer_vector_set.h:733
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
static void Start(std::string const &rIntervalName)
This method starts the timer meassures.
Definition: timer.cpp:109
static void Stop(std::string const &rIntervalName)
This method stops the timer meassures.
Definition: timer.cpp:125
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
#define KRATOS_WARNING_IF(label, conditional)
Definition: logger.h:266
double TwoNorm(SparseSpaceType &dummy, SparseSpaceType::VectorType &x)
Definition: add_strategies_to_python.cpp:164
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
float density
Definition: face_heat.py:56
v
Definition: generate_convection_diffusion_explicit_element.py:114
int local_size
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:17
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
A
Definition: sensitivityMatrix.py:70
integer i
Definition: TensorModule.f:17
float pressure
Definition: test_pureconvectionsolver_benchmarking.py:101