Refactoring
This commit is contained in:
parent
164f156aa7
commit
76fb1b8609
|
|
@ -217,14 +217,22 @@ void DRMSimulationModel::runUnitTests()
|
||||||
|
|
||||||
// polyscope::show();
|
// polyscope::show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DRMSimulationModel::reset(const std::shared_ptr<SimulationJob> &pJob)
|
void DRMSimulationModel::reset(const std::shared_ptr<SimulationJob> &pJob)
|
||||||
{
|
{
|
||||||
//#ifdef USE_ENSMALLEN
|
mCurrentSimulationStep = 0;
|
||||||
// this->pJob = pJob;
|
history.clear();
|
||||||
//#endif
|
history.label = pJob->pMesh->getLabel() + "_" + pJob->getLabel();
|
||||||
pMesh.reset();
|
plotYValues.clear();
|
||||||
pMesh = std::make_unique<SimulationMesh>(*pJob->pMesh);
|
plotHandle.reset();
|
||||||
vcg::tri::UpdateBounding<SimulationMesh>::Box(*pMesh);
|
checkedForMaximumMoment = false;
|
||||||
|
externalMomentsNorm = 0;
|
||||||
|
Dt = mSettings.Dtini;
|
||||||
|
numOfDampings = 0;
|
||||||
|
shouldTemporarilyDampForces = false;
|
||||||
|
externalLoadStep = 1;
|
||||||
|
isVertexConstrained.clear();
|
||||||
|
minTotalResidualForcesNorm = std::numeric_limits<double>::max();
|
||||||
|
|
||||||
constrainedVertices.clear();
|
constrainedVertices.clear();
|
||||||
constrainedVertices = pJob->constrainedVertices;
|
constrainedVertices = pJob->constrainedVertices;
|
||||||
|
|
@ -239,26 +247,6 @@ void DRMSimulationModel::reset(const std::shared_ptr<SimulationJob> &pJob)
|
||||||
for (auto fixedVertex : constrainedVertices) {
|
for (auto fixedVertex : constrainedVertices) {
|
||||||
isVertexConstrained[fixedVertex.first] = true;
|
isVertexConstrained[fixedVertex.first] = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void DRMSimulationModel::reset(const std::shared_ptr<SimulationJob> &pJob, const Settings &settings)
|
|
||||||
{
|
|
||||||
mSettings = settings;
|
|
||||||
mCurrentSimulationStep = 0;
|
|
||||||
history.clear();
|
|
||||||
history.label = pJob->pMesh->getLabel() + "_" + pJob->getLabel();
|
|
||||||
plotYValues.clear();
|
|
||||||
plotHandle.reset();
|
|
||||||
checkedForMaximumMoment = false;
|
|
||||||
externalMomentsNorm = 0;
|
|
||||||
Dt = settings.Dtini;
|
|
||||||
numOfDampings = 0;
|
|
||||||
shouldTemporarilyDampForces = false;
|
|
||||||
externalLoadStep = 1;
|
|
||||||
isVertexConstrained.clear();
|
|
||||||
minTotalResidualForcesNorm = std::numeric_limits<double>::max();
|
|
||||||
|
|
||||||
reset(pJob);
|
|
||||||
|
|
||||||
#ifdef POLYSCOPE_DEFINED
|
#ifdef POLYSCOPE_DEFINED
|
||||||
if (mSettings.shouldDraw || mSettings.debugModeStep.has_value()) {
|
if (mSettings.shouldDraw || mSettings.debugModeStep.has_value()) {
|
||||||
|
|
@ -269,7 +257,7 @@ void DRMSimulationModel::reset(const std::shared_ptr<SimulationJob> &pJob, const
|
||||||
polyscope::registerCurveNetwork("Initial_" + meshPolyscopeLabel + "_" + pMesh->getLabel(),
|
polyscope::registerCurveNetwork("Initial_" + meshPolyscopeLabel + "_" + pMesh->getLabel(),
|
||||||
pMesh->getEigenVertices(),
|
pMesh->getEigenVertices(),
|
||||||
pMesh->getEigenEdges())
|
pMesh->getEigenEdges())
|
||||||
->setRadius(0.002);
|
->setRadius(pMesh->elements[0].dimensions.getDrawingRadius());
|
||||||
// registerWorldAxes();
|
// registerWorldAxes();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1426,6 +1414,7 @@ void DRMSimulationModel::updateResidualForces()
|
||||||
|
|
||||||
void DRMSimulationModel::computeRigidSupports()
|
void DRMSimulationModel::computeRigidSupports()
|
||||||
{
|
{
|
||||||
|
assert(pMesh != nullptr);
|
||||||
isRigidSupport.clear();
|
isRigidSupport.clear();
|
||||||
isRigidSupport.resize(pMesh->VN(), false);
|
isRigidSupport.resize(pMesh->VN(), false);
|
||||||
for (const VertexType &v : pMesh->vert) {
|
for (const VertexType &v : pMesh->vert) {
|
||||||
|
|
@ -2611,6 +2600,8 @@ void DRMSimulationModel::applyKineticDamping(const std::shared_ptr<SimulationJob
|
||||||
|
|
||||||
SimulationResults DRMSimulationModel::executeSimulation(const std::shared_ptr<SimulationJob> &pJob)
|
SimulationResults DRMSimulationModel::executeSimulation(const std::shared_ptr<SimulationJob> &pJob)
|
||||||
{
|
{
|
||||||
|
assert(pMesh != nullptr && pMesh->VN() == pJob->pMesh->VN() && pMesh->EN() == pJob->pMesh->EN());
|
||||||
|
reset(pJob);
|
||||||
auto beginTime = std::chrono::high_resolution_clock::now();
|
auto beginTime = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
updateNodalMasses();
|
updateNodalMasses();
|
||||||
|
|
@ -2975,11 +2966,11 @@ currentSimulationStep > maxDRMIterations*/
|
||||||
|
|
||||||
if (mSettings.useTranslationalKineticEnergyForKineticDamping) {
|
if (mSettings.useTranslationalKineticEnergyForKineticDamping) {
|
||||||
applyKineticDamping(pJob);
|
applyKineticDamping(pJob);
|
||||||
Dt *= mSettings.xi;
|
|
||||||
if (mSettings.shouldCreatePlots) {
|
if (mSettings.shouldCreatePlots) {
|
||||||
history.redMarks.push_back(mCurrentSimulationStep);
|
history.redMarks.push_back(mCurrentSimulationStep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Dt *= mSettings.xi;
|
||||||
// if (mSettings.isDebugMode) {
|
// if (mSettings.isDebugMode) {
|
||||||
// std::cout << Dt << std::endl;
|
// std::cout << Dt << std::endl;
|
||||||
// }
|
// }
|
||||||
|
|
@ -3011,9 +3002,11 @@ currentSimulationStep > maxDRMIterations*/
|
||||||
|
|
||||||
void DRMSimulationModel::setStructure(const std::shared_ptr<SimulationMesh> &pMesh)
|
void DRMSimulationModel::setStructure(const std::shared_ptr<SimulationMesh> &pMesh)
|
||||||
{
|
{
|
||||||
std::cout << "This function is currently not implemented" << std::endl;
|
this->pMesh.reset();
|
||||||
assert(false);
|
this->pMesh = std::make_unique<SimulationMesh>(*pMesh);
|
||||||
std::terminate();
|
vcg::tri::UpdateBounding<SimulationMesh>::Box(*pMesh);
|
||||||
|
// assert(false);
|
||||||
|
// std::terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationResults DRMSimulationModel::executeSimulation(const std::shared_ptr<SimulationJob> &pJob,
|
SimulationResults DRMSimulationModel::executeSimulation(const std::shared_ptr<SimulationJob> &pJob,
|
||||||
|
|
@ -3021,7 +3014,8 @@ SimulationResults DRMSimulationModel::executeSimulation(const std::shared_ptr<Si
|
||||||
const SimulationResults &solutionGuess)
|
const SimulationResults &solutionGuess)
|
||||||
{
|
{
|
||||||
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
|
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
|
||||||
reset(pJob, settings);
|
mSettings = settings;
|
||||||
|
setStructure(pJob->pMesh);
|
||||||
assert(pJob->pMesh != nullptr);
|
assert(pJob->pMesh != nullptr);
|
||||||
|
|
||||||
if (!solutionGuess.displacements.empty()) {
|
if (!solutionGuess.displacements.empty()) {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public:
|
||||||
// int desiredGradualExternalLoadsSteps{1};
|
// int desiredGradualExternalLoadsSteps{1};
|
||||||
double gamma{0.8};
|
double gamma{0.8};
|
||||||
double totalResidualForcesNormThreshold{1e-20};
|
double totalResidualForcesNormThreshold{1e-20};
|
||||||
double totalExternalForcesNormPercentageTermination{1e-5};
|
double totalExternalForcesNormPercentageTermination{1e-3};
|
||||||
std::optional<int> maxDRMIterations;
|
std::optional<int> maxDRMIterations;
|
||||||
std::optional<int> debugModeStep;
|
std::optional<int> debugModeStep;
|
||||||
std::optional<double> totalTranslationalKineticEnergyThreshold;
|
std::optional<double> totalTranslationalKineticEnergyThreshold;
|
||||||
|
|
@ -108,7 +108,6 @@ private:
|
||||||
//#ifdef USE_ENSMALLEN
|
//#ifdef USE_ENSMALLEN
|
||||||
// std::shared_ptr<SimulationJob> pJob;
|
// std::shared_ptr<SimulationJob> pJob;
|
||||||
//#endif
|
//#endif
|
||||||
void reset(const std::shared_ptr<SimulationJob> &pJob, const Settings &settings);
|
|
||||||
void updateNodalInternalForces(
|
void updateNodalInternalForces(
|
||||||
const std::unordered_map<VertexIndex, std::unordered_set<DoFType>> &fixedVertices);
|
const std::unordered_map<VertexIndex, std::unordered_set<DoFType>> &fixedVertices);
|
||||||
void updateNodalExternalForces(
|
void updateNodalExternalForces(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue