9 #ifndef KRATOS_V_P_STRATEGY_H
10 #define KRATOS_V_P_STRATEGY_H
22 #include "custom_utilities/solver_settings.h"
55 template <
class TSparseSpace,
76 std::cout <<
"VPStrategy INITIALIZE STRATEGY" << std::endl;
81 typename TLinearSolver::Pointer pVelocityLinearSolver,
82 typename TLinearSolver::Pointer pPressureLinearSolver,
83 bool ReformDofSet =
true,
84 unsigned int DomainSize = 2) :
BaseType(rModelPart)
130 unsigned int numNodes = itElem->GetGeometry().size();
131 std::vector<array_1d<double, 3>> nodesCoordinates;
132 nodesCoordinates.resize(numNodes);
134 (itElem)->Set(BLOCKED,
false);
135 (itElem)->Set(ISOLATED,
false);
137 unsigned int freeSurfaceNodes = 0;
138 unsigned int freeSurfaceRigidNodes = 0;
139 unsigned int rigidNodes = 0;
140 unsigned int isolatedNodes = 0;
141 for (
unsigned int i = 0;
i < numNodes;
i++)
143 if (itElem->GetGeometry()[
i].Is(FREE_SURFACE))
146 if (itElem->GetGeometry()[
i].Is(RIGID))
148 freeSurfaceRigidNodes++;
151 else if (itElem->GetGeometry()[
i].Is(RIGID))
155 nodesCoordinates[
i] = itElem->GetGeometry()[
i].Coordinates();
157 if (neighb_elems.
size() == 1)
168 a1 = (nodesCoordinates[1][1] - nodesCoordinates[0][1]) * (nodesCoordinates[2][2] - nodesCoordinates[0][2]) - (nodesCoordinates[2][1] - nodesCoordinates[0][1]) * (nodesCoordinates[1][2] - nodesCoordinates[0][2]);
169 b1 = (nodesCoordinates[1][2] - nodesCoordinates[0][2]) * (nodesCoordinates[2][0] - nodesCoordinates[0][0]) - (nodesCoordinates[2][2] - nodesCoordinates[0][2]) * (nodesCoordinates[1][0] - nodesCoordinates[0][0]);
170 c1 = (nodesCoordinates[1][0] - nodesCoordinates[0][0]) * (nodesCoordinates[2][1] - nodesCoordinates[0][1]) - (nodesCoordinates[2][0] - nodesCoordinates[0][0]) * (nodesCoordinates[1][1] - nodesCoordinates[0][1]);
174 a2 = (nodesCoordinates[1][1] - nodesCoordinates[0][1]) * (nodesCoordinates[3][2] - nodesCoordinates[0][2]) - (nodesCoordinates[3][1] - nodesCoordinates[0][1]) * (nodesCoordinates[1][2] - nodesCoordinates[0][2]);
175 b2 = (nodesCoordinates[1][2] - nodesCoordinates[0][2]) * (nodesCoordinates[3][0] - nodesCoordinates[0][0]) - (nodesCoordinates[3][2] - nodesCoordinates[0][2]) * (nodesCoordinates[1][0] - nodesCoordinates[0][0]);
176 c2 = (nodesCoordinates[1][0] - nodesCoordinates[0][0]) * (nodesCoordinates[3][1] - nodesCoordinates[0][1]) - (nodesCoordinates[3][0] - nodesCoordinates[0][0]) * (nodesCoordinates[1][1] - nodesCoordinates[0][1]);
180 a3 = (nodesCoordinates[1][1] - nodesCoordinates[2][1]) * (nodesCoordinates[3][2] - nodesCoordinates[2][2]) - (nodesCoordinates[3][1] - nodesCoordinates[2][1]) * (nodesCoordinates[1][2] - nodesCoordinates[2][2]);
181 b3 = (nodesCoordinates[1][2] - nodesCoordinates[2][2]) * (nodesCoordinates[3][0] - nodesCoordinates[2][0]) - (nodesCoordinates[3][2] - nodesCoordinates[2][2]) * (nodesCoordinates[1][0] - nodesCoordinates[2][0]);
182 c3 = (nodesCoordinates[1][0] - nodesCoordinates[2][0]) * (nodesCoordinates[3][1] - nodesCoordinates[2][1]) - (nodesCoordinates[3][0] - nodesCoordinates[2][0]) * (nodesCoordinates[1][1] - nodesCoordinates[2][1]);
186 a4 = (nodesCoordinates[0][1] - nodesCoordinates[2][1]) * (nodesCoordinates[3][2] - nodesCoordinates[2][2]) - (nodesCoordinates[3][1] - nodesCoordinates[2][1]) * (nodesCoordinates[0][2] - nodesCoordinates[2][2]);
187 b4 = (nodesCoordinates[0][2] - nodesCoordinates[2][2]) * (nodesCoordinates[3][0] - nodesCoordinates[2][0]) - (nodesCoordinates[3][2] - nodesCoordinates[2][2]) * (nodesCoordinates[0][0] - nodesCoordinates[2][0]);
188 c4 = (nodesCoordinates[0][0] - nodesCoordinates[2][0]) * (nodesCoordinates[3][1] - nodesCoordinates[2][1]) - (nodesCoordinates[3][0] - nodesCoordinates[2][0]) * (nodesCoordinates[0][1] - nodesCoordinates[2][1]);
190 double cosAngle12 = (a1 * a2 + b1 * b2 + c1 * c2) / (sqrt(pow(a1, 2) + pow(b1, 2) + pow(c1, 2)) * sqrt(pow(a2, 2) + pow(b2, 2) + pow(c2, 2)));
191 double cosAngle13 = (a1 * a3 + b1 * b3 + c1 * c3) / (sqrt(pow(a1, 2) + pow(b1, 2) + pow(c1, 2)) * sqrt(pow(a3, 2) + pow(b3, 2) + pow(c3, 2)));
192 double cosAngle14 = (a1 * a4 + b1 * b4 + c1 * c4) / (sqrt(pow(a1, 2) + pow(b1, 2) + pow(c1, 2)) * sqrt(pow(a4, 2) + pow(b4, 2) + pow(c4, 2)));
193 double cosAngle23 = (a3 * a2 + b3 * b2 + c3 * c2) / (sqrt(pow(a3, 2) + pow(b3, 2) + pow(c3, 2)) * sqrt(pow(a2, 2) + pow(b2, 2) + pow(c2, 2)));
194 double cosAngle24 = (a4 * a2 + b4 * b2 + c4 * c2) / (sqrt(pow(a4, 2) + pow(b4, 2) + pow(c4, 2)) * sqrt(pow(a2, 2) + pow(b2, 2) + pow(c2, 2)));
195 double cosAngle34 = (a4 * a3 + b4 * b3 + c4 * c3) / (sqrt(pow(a4, 2) + pow(b4, 2) + pow(c4, 2)) * sqrt(pow(a3, 2) + pow(b3, 2) + pow(c3, 2)));
197 if ((fabs(cosAngle12) > 0.99 || fabs(cosAngle13) > 0.99 || fabs(cosAngle14) > 0.99 || fabs(cosAngle23) > 0.99 || fabs(cosAngle24) > 0.99 || fabs(cosAngle34) > 0.99) && (freeSurfaceNodes == numNodes) && isolatedNodes > 1)
199 (itElem)->Set(BLOCKED,
true);
202 else if ((fabs(cosAngle12) > 0.995 || fabs(cosAngle13) > 0.995 || fabs(cosAngle14) > 0.995 || fabs(cosAngle23) > 0.995 || fabs(cosAngle24) > 0.995 || fabs(cosAngle34) > 0.995) && (freeSurfaceNodes == numNodes) && isolatedNodes == 1)
204 (itElem)->Set(BLOCKED,
true);
207 else if ((fabs(cosAngle12) > 0.999 || fabs(cosAngle13) > 0.999 || fabs(cosAngle14) > 0.999 || fabs(cosAngle23) > 0.999 || fabs(cosAngle24) > 0.999 || fabs(cosAngle34) > 0.999) && (freeSurfaceNodes == numNodes))
209 (itElem)->Set(BLOCKED,
true);
214 if (freeSurfaceNodes == numNodes && rigidNodes == 0 && isolatedNodes >= (numNodes - 1))
216 (itElem)->Set(ISOLATED,
true);
217 (itElem)->Set(BLOCKED,
false);
228 const double timeInterval = rCurrentProcessInfo[DELTA_TIME];
229 unsigned int timeStep = rCurrentProcessInfo[STEP];
236 (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0) = 0;
237 (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 1) = 0;
241 double &CurrentPressure = (
i)->FastGetSolutionStepValue(PRESSURE, 0);
242 double &PreviousPressure = (
i)->FastGetSolutionStepValue(PRESSURE, 1);
243 double &CurrentPressureVelocity = (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0);
244 CurrentPressureVelocity = (CurrentPressure - PreviousPressure) / timeInterval;
253 const double timeInterval = rCurrentProcessInfo[DELTA_TIME];
254 unsigned int timeStep = rCurrentProcessInfo[STEP];
261 (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0) = 0;
262 (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 1) = 0;
266 double &CurrentPressureVelocity = (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0);
267 double &PreviousPressureVelocity = (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 1);
268 double &CurrentPressureAcceleration = (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0);
269 CurrentPressureAcceleration = (CurrentPressureVelocity - PreviousPressureVelocity) / timeInterval;
290 if ((
i)->IsNot(ISOLATED) && ((
i)->IsNot(RIGID) || (
i)->Is(SOLID)))
292 UpdateAccelerations(CurrentAcceleration, CurrentVelocity, PreviousAcceleration, PreviousVelocity);
294 else if ((
i)->Is(RIGID))
297 (
i)->FastGetSolutionStepValue(ACCELERATION, 0) = Zeros;
298 (
i)->FastGetSolutionStepValue(ACCELERATION, 1) = Zeros;
302 (
i)->FastGetSolutionStepValue(PRESSURE, 0) = 0.0;
303 (
i)->FastGetSolutionStepValue(PRESSURE, 1) = 0.0;
304 (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0) = 0.0;
305 (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 1) = 0.0;
306 (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0) = 0.0;
307 (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 1) = 0.0;
308 if ((
i)->SolutionStepsDataHas(VOLUME_ACCELERATION))
311 (
i)->FastGetSolutionStepValue(ACCELERATION, 0) = VolumeAcceleration;
312 (
i)->FastGetSolutionStepValue(VELOCITY, 0) += VolumeAcceleration * rCurrentProcessInfo[DELTA_TIME];
316 const double timeInterval = rCurrentProcessInfo[DELTA_TIME];
317 unsigned int timeStep = rCurrentProcessInfo[STEP];
320 (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0) = 0;
321 (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 1) = 0;
322 (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0) = 0;
323 (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 1) = 0;
327 double &CurrentPressure = (
i)->FastGetSolutionStepValue(PRESSURE, 0);
328 double &PreviousPressure = (
i)->FastGetSolutionStepValue(PRESSURE, 1);
329 double &CurrentPressureVelocity = (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0);
330 double &CurrentPressureAcceleration = (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0);
332 CurrentPressureAcceleration = CurrentPressureVelocity / timeInterval;
334 CurrentPressureVelocity = (CurrentPressure - PreviousPressure) / timeInterval;
336 CurrentPressureAcceleration += -CurrentPressureVelocity / timeInterval;
357 if ((
i)->IsNot(ISOLATED) && ((
i)->IsNot(RIGID) || (
i)->Is(SOLID)))
359 UpdateAccelerations(CurrentAcceleration, CurrentVelocity, PreviousAcceleration, PreviousVelocity);
361 else if ((
i)->Is(RIGID))
364 (
i)->FastGetSolutionStepValue(ACCELERATION, 0) = Zeros;
365 (
i)->FastGetSolutionStepValue(ACCELERATION, 1) = Zeros;
369 (
i)->FastGetSolutionStepValue(PRESSURE, 0) = 0.0;
370 (
i)->FastGetSolutionStepValue(PRESSURE, 1) = 0.0;
371 (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 0) = 0.0;
372 (
i)->FastGetSolutionStepValue(PRESSURE_VELOCITY, 1) = 0.0;
373 (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 0) = 0.0;
374 (
i)->FastGetSolutionStepValue(PRESSURE_ACCELERATION, 1) = 0.0;
375 if ((
i)->SolutionStepsDataHas(VOLUME_ACCELERATION))
378 (
i)->FastGetSolutionStepValue(ACCELERATION, 0) = VolumeAcceleration;
379 (
i)->FastGetSolutionStepValue(VELOCITY, 0) += VolumeAcceleration * rCurrentProcessInfo[DELTA_TIME];
392 double Dt = rCurrentProcessInfo[DELTA_TIME];
393 noalias(CurrentAcceleration) = 2.0 * (CurrentVelocity - PreviousVelocity) /
Dt - PreviousAcceleration;
400 const double TimeStep = rCurrentProcessInfo[DELTA_TIME];
405 if ((
i)->IsNot(PFEMFlags::EULERIAN_INLET))
415 CurrentDisplacement[0] = 0.5 * TimeStep * (CurrentVelocity[0] + PreviousVelocity[0]) + PreviousDisplacement[0];
418 CurrentDisplacement[1] = 0.5 * TimeStep * (CurrentVelocity[1] + PreviousVelocity[1]) + PreviousDisplacement[1];
421 CurrentDisplacement[2] = 0.5 * TimeStep * (CurrentVelocity[2] + PreviousVelocity[2]) + PreviousDisplacement[2];
450 std::string
Info()
const override
452 std::stringstream buffer;
453 buffer <<
"VPStrategy";
460 rOStream <<
"VPStrategy";
513 const double currentTime = rCurrentProcessInfo[TIME];
516 long double sumErrorL2Velocity = 0;
517 long double sumErrorL2VelocityX = 0;
518 long double sumErrorL2VelocityY = 0;
519 long double sumErrorL2Pressure = 0;
520 long double sumErrorL2TauXX = 0;
521 long double sumErrorL2TauYY = 0;
522 long double sumErrorL2TauXY = 0;
533 long double nodalArea = 0;
537 nodalArea = geometry.
Area() / 3.0;
541 nodalArea = geometry.
Volume() * 0.25;
544 long double bariPosX = 0;
545 long double bariPosY = 0;
547 long double eleErrorL2Velocity = 0;
548 long double eleErrorL2VelocityX = 0;
549 long double eleErrorL2VelocityY = 0;
550 long double eleErrorL2Pressure = 0;
557 const unsigned int NumNodes = geometry.
size();
559 double elementalPressure =
N[0] * geometry(0)->FastGetSolutionStepValue(PRESSURE);
560 double elementalVelocityX =
N[0] * geometry(0)->FastGetSolutionStepValue(VELOCITY_X);
561 double elementalVelocityY =
N[0] * geometry(0)->FastGetSolutionStepValue(VELOCITY_Y);
564 for (
unsigned int i = 1;
i < NumNodes;
i++)
566 elementalPressure +=
N[
i] * geometry(
i)->FastGetSolutionStepValue(PRESSURE);
567 elementalVelocityX +=
N[
i] * geometry(
i)->FastGetSolutionStepValue(VELOCITY_X);
568 elementalVelocityY +=
N[
i] * geometry(
i)->FastGetSolutionStepValue(VELOCITY_Y);
571 for (
unsigned int i = 0;
i < geometry.
size();
i++)
574 const long double nodalPosX = geometry(
i)->X();
575 const long double nodalPosY = geometry(
i)->Y();
577 bariPosX += nodalPosX / 3.0;
578 bariPosY += nodalPosY / 3.0;
581 const long double posX = bariPosX;
582 const long double posY = bariPosY;
583 long double expectedVelocityX = pow(posX, 2) * (1.0 - posX) * (1.0 - posX) * (2.0 * posY - 6.0 * pow(posY, 2) + 4.0 * pow(posY, 3));
584 long double expectedVelocityY = -pow(posY, 2) * (1.0 - posY) * (1.0 - posY) * (2.0 * posX - 6.0 * pow(posX, 2) + 4.0 * pow(posX, 3));
585 long double expectedPressure = -tensilStressSign * posX * (1.0 - posX);
587 eleErrorL2VelocityX = elementalVelocityX - expectedVelocityX;
588 eleErrorL2VelocityY = elementalVelocityY - expectedVelocityY;
589 eleErrorL2Pressure = elementalPressure - expectedPressure;
591 sumErrorL2VelocityX += pow(eleErrorL2VelocityX, 2) * geometry.
Area();
592 sumErrorL2VelocityY += pow(eleErrorL2VelocityY, 2) * geometry.
Area();
593 sumErrorL2Pressure += pow(eleErrorL2Pressure, 2) * geometry.
Area();
595 const long double tauXX = 0;
596 const long double tauYY = 0;
597 const long double tauXY = 0;
599 long double expectedTauXX = 2.0 * (-4.0 * (1.0 - bariPosX) * bariPosX * (-1.0 + 2.0 * bariPosX) * bariPosY * (1.0 - 3.0 * bariPosY + 2.0 * pow(bariPosY, 2)));
600 long double expectedTauYY = 2.0 * (4.0 * bariPosX * (1.0 - 3.0 * bariPosX + 2.0 * pow(bariPosX, 2)) * (1.0 - bariPosY) * bariPosY * (-1.0 + 2.0 * bariPosY));
601 long double expectedTauXY = (2.0 * (1.0 - 6.0 * bariPosY + 6.0 * pow(bariPosY, 2)) * (1.0 - bariPosX) * (1.0 - bariPosX) * pow(bariPosX, 2) - 2.0 * (1.0 - 6.0 * bariPosX + 6.0 * pow(bariPosX, 2)) * (1.0 - bariPosY) * (1 - bariPosY) * pow(bariPosY, 2));
603 long double nodalErrorTauXX = tauXX - expectedTauXX;
604 long double nodalErrorTauYY = tauYY - expectedTauYY;
605 long double nodalErrorTauXY = tauXY - expectedTauXY;
607 sumErrorL2TauXX += pow(nodalErrorTauXX, 2) * geometry.
Area();
608 sumErrorL2TauYY += pow(nodalErrorTauYY, 2) * geometry.
Area();
609 sumErrorL2TauXY += pow(nodalErrorTauXY, 2) * geometry.
Area();
613 long double errorL2Velocity = sqrt(sumErrorL2Velocity);
614 long double errorL2VelocityX = sqrt(sumErrorL2VelocityX);
615 long double errorL2VelocityY = sqrt(sumErrorL2VelocityY);
616 long double errorL2Pressure = sqrt(sumErrorL2Pressure);
617 long double errorL2TauXX = sqrt(sumErrorL2TauXX);
618 long double errorL2TauYY = sqrt(sumErrorL2TauYY);
619 long double errorL2TauXY = sqrt(sumErrorL2TauXY);
621 std::ofstream myfileVelocity;
622 myfileVelocity.open(
"errorL2VelocityFile.txt", std::ios::app);
623 myfileVelocity << currentTime <<
"\t" << errorL2Velocity <<
"\n";
624 myfileVelocity.close();
626 std::ofstream myfileVelocityX;
627 myfileVelocityX.open(
"errorL2VelocityXFile.txt", std::ios::app);
628 myfileVelocityX << currentTime <<
"\t" << errorL2VelocityX <<
"\n";
629 myfileVelocityX.close();
631 std::ofstream myfileVelocityY;
632 myfileVelocityY.open(
"errorL2VelocityYFile.txt", std::ios::app);
633 myfileVelocityY << currentTime <<
"\t" << errorL2VelocityY <<
"\n";
634 myfileVelocityY.close();
636 std::ofstream myfilePressure;
637 myfilePressure.open(
"errorL2PressureFile.txt", std::ios::app);
638 myfilePressure << currentTime <<
"\t" << errorL2Pressure <<
"\n";
639 myfilePressure.close();
641 std::ofstream myfileTauXX;
642 myfileTauXX.open(
"errorL2TauXXFile.txt", std::ios::app);
643 myfileTauXX << currentTime <<
"\t" << errorL2TauXX <<
"\n";
646 std::ofstream myfileTauYY;
647 myfileTauYY.open(
"errorL2TauYYFile.txt", std::ios::app);
648 myfileTauYY << currentTime <<
"\t" << errorL2TauYY <<
"\n";
651 std::ofstream myfileTauXY;
652 myfileTauXY.open(
"errorL2TauXYFile.txt", std::ios::app);
653 myfileTauXY << currentTime <<
"\t" << errorL2TauXY <<
"\n";
661 const double currentTime = rCurrentProcessInfo[TIME];
664 double sumErrorL2VelocityTheta = 0;
665 double sumErrorL2TauTheta = 0;
669 double kappa = r_in / R_out;
682 long double nodalArea = 0;
686 nodalArea = geometry.
Area() / 3.0;
690 nodalArea = geometry.
Volume() * 0.25;
693 long double bariPosX = 0;
694 long double bariPosY = 0;
696 long double eleErrorL2Velocity = 0;
697 long double eleErrorL2VelocityX = 0;
698 long double eleErrorL2VelocityY = 0;
699 long double eleErrorL2Pressure = 0;
706 const unsigned int NumNodes = geometry.
size();
708 double elementalPressure =
N[0] * geometry(0)->FastGetSolutionStepValue(PRESSURE);
709 double elementalVelocityX =
N[0] * geometry(0)->FastGetSolutionStepValue(VELOCITY_X);
710 double elementalVelocityY =
N[0] * geometry(0)->FastGetSolutionStepValue(VELOCITY_Y);
713 for (
unsigned int i = 1;
i < NumNodes;
i++)
715 elementalPressure +=
N[
i] * geometry(
i)->FastGetSolutionStepValue(PRESSURE);
716 elementalVelocityX +=
N[
i] * geometry(
i)->FastGetSolutionStepValue(VELOCITY_X);
717 elementalVelocityY +=
N[
i] * geometry(
i)->FastGetSolutionStepValue(VELOCITY_Y);
720 for (
unsigned int i = 0;
i < geometry.
size();
i++)
724 const long double nodalPosX = geometry(
i)->X();
725 const long double nodalPosY = geometry(
i)->Y();
727 bariPosX += nodalPosX / 3.0;
728 bariPosY += nodalPosY / 3.0;
731 const long double posX = bariPosX;
732 const long double posY = bariPosY;
733 const double rPos = sqrt(pow(posX, 2) + pow(posY, 2));
734 const double cosalfa = posX / rPos;
735 const double sinalfa = posY / rPos;
736 const double sin2alfa = 2.0 * cosalfa * sinalfa;
737 const double cos2alfa = 1.0 - 2.0 * pow(sinalfa, 2);
739 double expectedVelocityTheta = pow(
kappa, 2) * omega * R_out / (1.0 - pow(
kappa, 2)) * (R_out / rPos - rPos / R_out);
740 double computedVelocityTheta = sqrt(pow(elementalVelocityX, 2) + pow(elementalVelocityY, 2));
741 double nodalErrorVelocityTheta = computedVelocityTheta - expectedVelocityTheta;
743 const long double tauXX = 0;
744 const long double tauYY = 0;
745 const long double tauXY = 0;
747 double expectedTauTheta = (2.0 *
viscosity * pow(
kappa, 2) * omega * pow(R_out, 2)) / (1.0 - pow(
kappa, 2)) / pow(rPos, 2);
748 double computedTauTheta = (tauXX - tauYY) * sin2alfa / 2.0 - tauXY * cos2alfa;
749 double nodalErrorTauTheta = computedTauTheta - expectedTauTheta;
751 sumErrorL2VelocityTheta += pow(nodalErrorVelocityTheta, 2) * geometry.
Area();
752 sumErrorL2TauTheta += pow(nodalErrorTauTheta, 2) * geometry.
Area();
756 double errorL2VelocityTheta = sqrt(sumErrorL2VelocityTheta);
757 double errorL2TauTheta = sqrt(sumErrorL2TauTheta);
759 std::ofstream myfileVelocity;
760 myfileVelocity.open(
"errorL2Poiseuille.txt", std::ios::app);
761 myfileVelocity << currentTime <<
"\t" << errorL2VelocityTheta <<
"\t" << errorL2TauTheta <<
"\n";
762 myfileVelocity.close();
772 #pragma omp parallel for reduction(+ \
774 for (
int i_node = 0; i_node <
n_nodes; ++i_node)
776 const auto it_node = rModelPart.
NodesBegin() + i_node;
777 const auto &r_vel = it_node->FastGetSolutionStepValue(VELOCITY);
778 for (
unsigned int d = 0;
d < 3; ++
d)
780 NormV += r_vel[
d] * r_vel[
d];
786 const double zero_tol = 1.0e-12;
787 if (NormV < zero_tol)
800 #pragma omp parallel for reduction(+ \
802 for (
int i_node = 0; i_node <
n_nodes; ++i_node)
804 const auto it_node = rModelPart.
NodesBegin() + i_node;
805 const double Pr = it_node->FastGetSolutionStepValue(PRESSURE);
811 const double zero_tol = 1.0e-12;
812 if (NormP < zero_tol)
virtual const DataCommunicator & GetDataCommunicator() const
Definition: communicator.cpp:340
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
const Matrix & ShapeFunctionsValues() const
Definition: geometry.h:3393
virtual double Volume() const
This method calculate and return volume of this geometry.
Definition: geometry.h:1358
virtual double Area() const
This method calculate and return area or surface area of this geometry depending to it's dimension.
Definition: geometry.h:1345
size_type size() const
Definition: global_pointers_vector.h:307
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
Communicator & GetCommunicator()
Definition: model_part.h:1821
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
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
MeshType::ElementIterator ElementIterator
Definition: model_part.h:174
SizeType NumberOfNodes(IndexType ThisIndex=0) const
Definition: model_part.h:341
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
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
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Solving strategy base class This is the base class from which we will derive all the strategies (impl...
Definition: solving_strategy.h:64
virtual void SetEchoLevel(const int Level)
This sets the level of echo for the solving strategy.
Definition: solving_strategy.h:255
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
virtual void MoveMesh()
This function is designed to move the mesh.
Definition: solving_strategy.h:330
Helper class to define solution strategies for TwoStepVPStrategy.
Definition: solver_settings.h:57
Definition: v_p_strategy.h:59
VPStrategy(ModelPart &rModelPart, SolverSettingsType &rSolverConfig)
Definition: v_p_strategy.h:73
virtual void SetEchoLevel(int Level) override
This sets the level of echo for the solving strategy.
Definition: v_p_strategy.h:436
std::string Info() const override
Turn back information as a string.
Definition: v_p_strategy.h:450
KRATOS_CLASS_POINTER_DEFINITION(VPStrategy)
virtual bool FixTimeStepContinuity(const double DvErrorNorm, bool &fixedTimeStep)
Definition: v_p_strategy.h:838
VPStrategy(VPStrategy const &rOther)
Copy constructor.
Definition: v_p_strategy.h:908
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: v_p_strategy.h:464
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: v_p_strategy.h:458
void CalculateAccelerations()
Definition: v_p_strategy.h:341
virtual void CalculateTemporalVariables()
Definition: v_p_strategy.h:274
void CalculatePressureVelocity()
Definition: v_p_strategy.h:224
void CalculatePressureAcceleration()
Definition: v_p_strategy.h:249
virtual bool CheckVelocityConvergence(const double NormDv, double &errorNormDv)
Definition: v_p_strategy.h:818
virtual bool CheckContinuityConvergence(const double DvErrorNorm, bool &fixedTimeStep)
Definition: v_p_strategy.h:843
VPStrategy & operator=(VPStrategy const &rOther)
Assignment operator.
Definition: v_p_strategy.h:905
virtual bool CheckPressureConvergence(const double NormDp, double &errorNormDp, double &NormP)
Definition: v_p_strategy.h:823
void UpdateAccelerations(array_1d< double, 3 > &CurrentAcceleration, const array_1d< double, 3 > &CurrentVelocity, array_1d< double, 3 > &PreviousAcceleration, const array_1d< double, 3 > &PreviousVelocity)
Definition: v_p_strategy.h:385
double ComputeVelocityNorm()
Definition: v_p_strategy.h:765
virtual void Clear() override
Clears the internal storage.
Definition: v_p_strategy.h:430
virtual bool CheckMomentumConvergence(const double DvErrorNorm, bool &fixedTimeStep)
Definition: v_p_strategy.h:833
virtual bool FixTimeStepMomentum(const double DvErrorNorm, bool &fixedTimeStep)
Definition: v_p_strategy.h:828
virtual void CalculateDisplacementsAndPorosity()
Definition: v_p_strategy.h:396
virtual void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: v_p_strategy.h:103
virtual void InitializeStrategy(SolverSettingsType &rSolverConfig)
Definition: v_p_strategy.h:886
VPStrategy(ModelPart &rModelPart, typename TLinearSolver::Pointer pVelocityLinearSolver, typename TLinearSolver::Pointer pPressureLinearSolver, bool ReformDofSet=true, unsigned int DomainSize=2)
Definition: v_p_strategy.h:80
TwoStepVPSolverSettings< TSparseSpace, TDenseSpace, TLinearSolver > SolverSettingsType
Definition: v_p_strategy.h:67
void ComputeErrorL2NormCasePoiseuille()
Definition: v_p_strategy.h:657
void UpdateTopology(ModelPart &rModelPart, unsigned int echoLevel)
Definition: v_p_strategy.h:107
void ComputeErrorL2Norm(double tensilStressSign)
Definition: v_p_strategy.h:509
virtual void UpdateStressStrain()
Definition: v_p_strategy.h:428
virtual bool SolveContinuityIteration(unsigned int it, unsigned int maxIt, double &NormP)
Definition: v_p_strategy.h:504
virtual bool SolveSolutionStep() override
Solves the current step. This function returns true if a solution has been found, false otherwise.
Definition: v_p_strategy.h:98
double ComputePressureNorm()
Definition: v_p_strategy.h:793
virtual ~VPStrategy()
Destructor.
Definition: v_p_strategy.h:91
virtual bool SolveMomentumIteration(unsigned int it, unsigned int maxIt, bool &fixedTimeStep, double &velocityNorm)
Calculate the coefficients for time iteration.
Definition: v_p_strategy.h:499
SolvingStrategy< TSparseSpace, TDenseSpace > BaseType
Definition: v_p_strategy.h:65
void SetBlockedAndIsolatedFlags()
Definition: v_p_strategy.h:116
virtual void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: v_p_strategy.h:105
virtual int Check() override
Function to perform expensive checks.
Definition: v_p_strategy.h:93
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
float viscosity
Definition: edgebased_var.py:8
Dt
Definition: face_heat.py:78
int n_nodes
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:15
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
kappa
Definition: ode_solve.py:416
int d
Definition: ode_solve.py:397
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17