Refactoring
This commit is contained in:
parent
b764d7db2c
commit
513529f0a4
|
|
@ -1235,7 +1235,24 @@ void DRMSimulationModel::updateNodalMasses()
|
|||
pMesh->nodes[v].mass_6d[DoF::Nx] = pMesh->nodes[v].mass.rotationalJ;
|
||||
pMesh->nodes[v].mass_6d[DoF::Ny] = pMesh->nodes[v].mass.rotationalI3;
|
||||
pMesh->nodes[v].mass_6d[DoF::Nr] = pMesh->nodes[v].mass.rotationalI2;
|
||||
|
||||
if (mSettings.useViscousDamping) {
|
||||
//fill 6d damping vector
|
||||
const double translationalDampingFactor
|
||||
= 2 * std::sqrt(translationalSumSk * pMesh->nodes[v].mass.translational);
|
||||
pMesh->nodes[v].damping_6d[DoF::Ux] = translationalDampingFactor;
|
||||
pMesh->nodes[v].damping_6d[DoF::Uy] = translationalDampingFactor;
|
||||
pMesh->nodes[v].damping_6d[DoF::Uz] = translationalDampingFactor;
|
||||
pMesh->nodes[v].damping_6d[DoF::Nx] = 2
|
||||
* std::sqrt(rotationalSumSk_J
|
||||
* pMesh->nodes[v].mass_6d[DoF::Nx]);
|
||||
pMesh->nodes[v].damping_6d[DoF::Ny] = 2
|
||||
* std::sqrt(rotationalSumSk_I3
|
||||
* pMesh->nodes[v].mass_6d[DoF::Ny]);
|
||||
pMesh->nodes[v].damping_6d[DoF::Nr] = 2
|
||||
* std::sqrt(rotationalSumSk_I2
|
||||
* pMesh->nodes[v].mass_6d[DoF::Nr]);
|
||||
pMesh->nodes[v].damping_6d = pMesh->nodes[v].damping_6d * 1e-2;
|
||||
}
|
||||
assert(std::pow(mSettings.Dtini, 2.0) * translationalSumSk
|
||||
/ pMesh->nodes[v].mass.translational
|
||||
< 2);
|
||||
|
|
@ -1277,21 +1294,23 @@ void DRMSimulationModel::updateNodalVelocities()
|
|||
for (VertexType &v : pMesh->vert) {
|
||||
const VertexIndex vi = pMesh->getIndex(v);
|
||||
Node &node = pMesh->nodes[v];
|
||||
#ifdef POLYSCOPE_DEFINED
|
||||
if (std::isnan(node.velocity.norm())) {
|
||||
std::cout << "Velocity " << vi << ":" << node.velocity.toString() << std::endl;
|
||||
}
|
||||
#endif
|
||||
if (mSettings.useViscousDamping) {
|
||||
const Vector6d massOverDt = node.mass_6d / Dt;
|
||||
const Vector6d denominator = massOverDt + Vector6d(viscuousDampingConstant / 2);
|
||||
const Vector6d firstTermNominator = massOverDt - Vector6d(viscuousDampingConstant / 2);
|
||||
const Vector6d visciousDampingFactor(viscuousDampingConstant / 2);
|
||||
// const Vector6d &visciousDampingFactor = node.damping_6d;
|
||||
const Vector6d denominator = massOverDt + visciousDampingFactor / 2;
|
||||
const Vector6d firstTermNominator = massOverDt - visciousDampingFactor / 2;
|
||||
const Vector6d firstTerm = node.velocity * firstTermNominator / denominator;
|
||||
const Vector6d secondTerm = node.force.residual / denominator;
|
||||
node.velocity = firstTerm + secondTerm;
|
||||
} else {
|
||||
node.velocity = node.velocity + node.acceleration * Dt;
|
||||
}
|
||||
#ifdef POLYSCOPE_DEFINED
|
||||
if (std::isnan(node.velocity.norm())) {
|
||||
std::cout << "Velocity " << vi << ":" << node.velocity.toString() << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
updateKineticEnergy();
|
||||
}
|
||||
|
|
@ -2266,19 +2285,19 @@ SimulationResults DRMSimulationModel::executeSimulation(const std::shared_ptr<Si
|
|||
// SimulationResultsReporter::createPlot("Number of Steps",
|
||||
// "Residual Forces mov aver deriv",
|
||||
// movingAveragesDerivatives_norm);
|
||||
SimulationResultsReporter::createPlot("Number of Steps",
|
||||
"Residual Forces mov aver",
|
||||
history.residualForcesMovingAverage);
|
||||
// SimulationResultsReporter::createPlot("Number of Steps",
|
||||
// "Residual Forces mov aver",
|
||||
// history.residualForcesMovingAverage);
|
||||
// SimulationResultsReporter::createPlot("Number of Steps",
|
||||
// "Log of Residual Forces",
|
||||
// history.logResidualForces,
|
||||
// {},
|
||||
// history.redMarks);
|
||||
// SimulationResultsReporter::createPlot("Number of Steps",
|
||||
// "Log of Kinetic energy",
|
||||
// history.kineticEnergy,
|
||||
// {},
|
||||
// history.redMarks);
|
||||
SimulationResultsReporter::createPlot("Number of Steps",
|
||||
"Log of Kinetic energy",
|
||||
history.kineticEnergy,
|
||||
{},
|
||||
history.redMarks);
|
||||
// SimulationResultsReporter reporter;
|
||||
// reporter.reportHistory(history, "IntermediateResults", pJob->pMesh->getLabel());
|
||||
// SimulationResultsReporter::createPlot("Number of Iterations",
|
||||
|
|
@ -2330,10 +2349,18 @@ currentSimulationStep > maxDRMIterations*/
|
|||
= mSettings.useAverage
|
||||
&& (pMesh->totalResidualForcesNorm / pMesh->VN()) / totalExternalForcesNorm
|
||||
< mSettings.averageResidualForcesCriterionThreshold;
|
||||
if (fullfillsResidualForcesNormTerminationCriterion
|
||||
|| fullfillsResidualForcesNormTerminationCriterion) {
|
||||
if (mSettings.beVerbose /*&& !mSettings.isDebugMode*/) {
|
||||
std::cout << "Simulation converged." << std::endl;
|
||||
printCurrentState();
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Residual forces norm convergence
|
||||
if (((pMesh->previousTotalKineticEnergy > pMesh->currentTotalKineticEnergy
|
||||
|| fullfillsAverageResidualForcesNormTerminationCriterion
|
||||
|| fullfillsResidualForcesNormTerminationCriterion)
|
||||
if ((mSettings.useKineticDamping)
|
||||
&& (pMesh->previousTotalKineticEnergy > pMesh->currentTotalKineticEnergy
|
||||
|
||||
// && mCurrentSimulationStep > movingAverageSampleSize
|
||||
&& (pJob->nodalForcedDisplacements.empty()
|
||||
|| mCurrentSimulationStep > mSettings.gradualForcedDisplacementSteps))
|
||||
|
|
@ -2405,6 +2432,7 @@ mesh->currentTotalPotentialEnergykN*/
|
|||
// }
|
||||
}
|
||||
|
||||
if (!mSettings.useViscousDamping) {
|
||||
const bool shouldCapDisplacements = mSettings.displacementCap.has_value();
|
||||
for (VertexType &v : pMesh->vert) {
|
||||
Node &node = pMesh->nodes[v];
|
||||
|
|
@ -2424,6 +2452,7 @@ mesh->currentTotalPotentialEnergykN*/
|
|||
pJob->nodalForcedDisplacements);
|
||||
}
|
||||
updateElementalLengths();
|
||||
}
|
||||
|
||||
// const double triggerPercentage = 0.01;
|
||||
// const double xi_min = 0.55;
|
||||
|
|
@ -2436,7 +2465,9 @@ mesh->currentTotalPotentialEnergykN*/
|
|||
// + xi_init - triggerPercentage * xi_min)
|
||||
// / (1 - triggerPercentage);
|
||||
// }
|
||||
if (mSettings.useKineticDamping) {
|
||||
resetVelocities();
|
||||
}
|
||||
Dt *= mSettings.xi;
|
||||
// if (mSettings.isDebugMode) {
|
||||
// std::cout << Dt << std::endl;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public:
|
|||
double averageResidualForcesCriterionThreshold{1e-5};
|
||||
Settings() {}
|
||||
bool useViscousDamping{false};
|
||||
bool useKineticDamping{true};
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
@ -62,7 +63,7 @@ private:
|
|||
std::vector<double> plotYValues;
|
||||
size_t numOfDampings{0};
|
||||
int externalLoadStep{1};
|
||||
const double viscuousDampingConstant{0.01};
|
||||
const double viscuousDampingConstant{100};
|
||||
std::vector<bool> isVertexConstrained;
|
||||
std::vector<bool> isRigidSupport;
|
||||
double minTotalResidualForcesNorm{std::numeric_limits<double>::max()};
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ struct Node {
|
|||
|
||||
Mass mass;
|
||||
Vector6d mass_6d;
|
||||
Vector6d damping_6d;
|
||||
VertexIndex vi;
|
||||
CoordType initialLocation;
|
||||
CoordType initialNormal;
|
||||
|
|
|
|||
Loading…
Reference in New Issue