Added max iterations on all drm simulations.using global optimizer for dome magnitude.Added bool variable for success in force magnitude search.
This commit is contained in:
parent
a9c5ca3fc6
commit
0863db658d
|
|
@ -692,9 +692,8 @@ void ReducedModelOptimizer::getResults(const dlib::function_evaluation &optimiza
|
||||||
const Settings &settings,
|
const Settings &settings,
|
||||||
ReducedPatternOptimization::Results &results)
|
ReducedPatternOptimization::Results &results)
|
||||||
{
|
{
|
||||||
results.baseTriangle = global.baseTriangle;
|
|
||||||
//Number of crashes
|
//Number of crashes
|
||||||
results.numberOfSimulationCrashes = global.numOfSimulationCrashes;
|
// results.numberOfSimulationCrashes = global.numOfSimulationCrashes;
|
||||||
//Value of optimal objective Y
|
//Value of optimal objective Y
|
||||||
results.objectiveValue.total = optimizationResult_dlib.y;
|
results.objectiveValue.total = optimizationResult_dlib.y;
|
||||||
//Optimal X values
|
//Optimal X values
|
||||||
|
|
@ -932,7 +931,7 @@ void ReducedModelOptimizer::constructDomeSimulationScenario(
|
||||||
= Eigen::Vector3d(-interfaceVector[0],
|
= Eigen::Vector3d(-interfaceVector[0],
|
||||||
-interfaceVector[1],
|
-interfaceVector[1],
|
||||||
0)
|
0)
|
||||||
* 0.001
|
* 0.01
|
||||||
* std::abs(
|
* std::abs(
|
||||||
forceMagnitude); //NOTE:Should the forced displacement change relatively to the magnitude?
|
forceMagnitude); //NOTE:Should the forced displacement change relatively to the magnitude?
|
||||||
// * std::abs(forceMagnitude / maxForceMagnitude_dome);
|
// * std::abs(forceMagnitude / maxForceMagnitude_dome);
|
||||||
|
|
@ -1000,21 +999,31 @@ double fullPatternMaxSimulationForceRotationalObjective(const double &forceMagni
|
||||||
|
|
||||||
DRMSimulationModel simulator;
|
DRMSimulationModel simulator;
|
||||||
DRMSimulationModel::Settings settings;
|
DRMSimulationModel::Settings settings;
|
||||||
settings.totalExternalForcesNormPercentageTermination = 1e-2;
|
// settings.totalResidualForcesNormThreshold = 1e-3;
|
||||||
|
// settings.totalTranslationalKineticEnergyThreshold = 1e-6;
|
||||||
// settings.shouldUseTranslationalKineticEnergyThreshold = true;
|
// settings.shouldUseTranslationalKineticEnergyThreshold = true;
|
||||||
// settings.totalTranslationalKineticEnergyThreshold = 1e-7;
|
settings.shouldDraw = true;
|
||||||
|
// settings.isDebugMode = true;
|
||||||
|
// settings.drawingStep = 500;
|
||||||
|
// settings.beVerbose = true;
|
||||||
|
// settings.debugModeStep = 200000;
|
||||||
|
// settings.shouldCreatePlots = true;
|
||||||
|
settings.maxDRMIterations = 100000;
|
||||||
SimulationResults results = simulator.executeSimulation(std::make_shared<SimulationJob>(job),
|
SimulationResults results = simulator.executeSimulation(std::make_shared<SimulationJob>(job),
|
||||||
settings);
|
settings);
|
||||||
const double &desiredRotationAngle = global.desiredMaxRotationAngle;
|
const double &desiredRotationAngle = global.desiredMaxRotationAngle;
|
||||||
|
if (!results.converged) {
|
||||||
|
return std::numeric_limits<double>::max();
|
||||||
|
}
|
||||||
const double error = std::abs(
|
const double error = std::abs(
|
||||||
// results.displacements[global.fullPatternInterfaceViPairs[1].first].getTranslation().norm()
|
// results.displacements[global.fullPatternInterfaceViPairs[1].first].getTranslation().norm()
|
||||||
results.rotationalDisplacementQuaternion[global.interfaceViForComputingScenarioError]
|
results.rotationalDisplacementQuaternion[global.interfaceViForComputingScenarioError]
|
||||||
.angularDistance(Eigen::Quaterniond::Identity())
|
.angularDistance(Eigen::Quaterniond::Identity())
|
||||||
- desiredRotationAngle);
|
- desiredRotationAngle);
|
||||||
|
|
||||||
//#ifdef POLYSCOPE_DEFINED
|
#ifdef POLYSCOPE_DEFINED
|
||||||
// std::cout << "Force:" << forceMagnitude << " Error is:" << vcg::math::ToDeg(error) << std::endl;
|
std::cout << "Force:" << forceMagnitude << " Error is:" << vcg::math::ToDeg(error) << std::endl;
|
||||||
//#endif
|
#endif
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1029,36 +1038,47 @@ double fullPatternMaxSimulationForceTranslationalObjective(const double &forceMa
|
||||||
|
|
||||||
DRMSimulationModel simulator;
|
DRMSimulationModel simulator;
|
||||||
DRMSimulationModel::Settings settings;
|
DRMSimulationModel::Settings settings;
|
||||||
settings.totalExternalForcesNormPercentageTermination = 1e-2;
|
settings.totalResidualForcesNormThreshold = 1e-3;
|
||||||
settings.shouldUseTranslationalKineticEnergyThreshold = true;
|
// settings.totalTranslationalKineticEnergyThreshold = 1e-10;
|
||||||
settings.totalTranslationalKineticEnergyThreshold = 1e-14;
|
// settings.shouldUseTranslationalKineticEnergyThreshold = true;
|
||||||
settings.shouldUseTranslationalKineticEnergyThreshold = true;
|
// settings.shouldDraw = true;
|
||||||
|
// settings.isDebugMode = true;
|
||||||
|
// settings.drawingStep = 200000;
|
||||||
|
// settings.beVerbose = true;
|
||||||
|
// settings.debugModeStep = 200000;
|
||||||
|
settings.maxDRMIterations = 50000;
|
||||||
#ifdef POLYSCOPE_DEFINED
|
#ifdef POLYSCOPE_DEFINED
|
||||||
// settings.shouldDraw = true;
|
// settings.shouldDraw = true;
|
||||||
// settings.isDebugMode = true;
|
// settings.isDebugMode = true;
|
||||||
// settings.drawingStep = 100000;
|
// settings.drawingStep = 100000;
|
||||||
|
// settings.debugModeStep = 10000;
|
||||||
// settings.shouldCreatePlots = true;
|
// settings.shouldCreatePlots = true;
|
||||||
#endif
|
#endif
|
||||||
SimulationResults results = simulator.executeSimulation(std::make_shared<SimulationJob>(job),
|
SimulationResults results = simulator.executeSimulation(std::make_shared<SimulationJob>(job));
|
||||||
settings);
|
|
||||||
const double &desiredDisplacementValue = global.desiredMaxDisplacementValue;
|
const double &desiredDisplacementValue = global.desiredMaxDisplacementValue;
|
||||||
|
if (!results.converged) {
|
||||||
|
return std::numeric_limits<double>::max();
|
||||||
|
}
|
||||||
const double error = std::abs(
|
const double error = std::abs(
|
||||||
// results.displacements[global.fullPatternInterfaceViPairs[1].first].getTranslation().norm()
|
// results.displacements[global.fullPatternInterfaceViPairs[1].first].getTranslation().norm()
|
||||||
results.displacements[global.interfaceViForComputingScenarioError].getTranslation().norm()
|
results.displacements[global.interfaceViForComputingScenarioError].getTranslation().norm()
|
||||||
- desiredDisplacementValue);
|
- desiredDisplacementValue);
|
||||||
|
|
||||||
|
#ifdef POLYSCOPE_DEFINED
|
||||||
|
std::cout << "Force:" << forceMagnitude << " Error is:" << error << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ReducedModelOptimizer::getFullPatternMaxSimulationForce(const BaseSimulationScenario &scenario)
|
double ReducedModelOptimizer::getFullPatternMaxSimulationForce(
|
||||||
|
const BaseSimulationScenario &scenario, bool &wasSuccessful)
|
||||||
{
|
{
|
||||||
double forceMagnitude = 1;
|
double forceMagnitude = 1;
|
||||||
global.desiredMaxDisplacementValue = 0.1
|
const double forceMagnitudeEpsilon = 1e-2;
|
||||||
* vcg::Distance(global.baseTriangle.cP(0),
|
double minimumError;
|
||||||
(global.baseTriangle.cP(1)
|
double translationalOptimizationEpsilon;
|
||||||
+ global.baseTriangle.cP(2))
|
dlib::function_evaluation result;
|
||||||
/ 2);
|
|
||||||
const double optimizationEpsilon = 1e-1;
|
|
||||||
switch (scenario) {
|
switch (scenario) {
|
||||||
case Axial:
|
case Axial:
|
||||||
global.desiredMaxDisplacementValue = 0.03
|
global.desiredMaxDisplacementValue = 0.03
|
||||||
|
|
@ -1068,11 +1088,14 @@ double ReducedModelOptimizer::getFullPatternMaxSimulationForce(const BaseSimulat
|
||||||
/ 2);
|
/ 2);
|
||||||
global.constructScenarioFunction = &ReducedModelOptimizer::constructAxialSimulationScenario;
|
global.constructScenarioFunction = &ReducedModelOptimizer::constructAxialSimulationScenario;
|
||||||
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[1].first;
|
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[1].first;
|
||||||
dlib::find_min_single_variable(&fullPatternMaxSimulationForceTranslationalObjective,
|
minimumError
|
||||||
|
= dlib::find_min_single_variable(&fullPatternMaxSimulationForceTranslationalObjective,
|
||||||
forceMagnitude,
|
forceMagnitude,
|
||||||
1e-8,
|
1e-2,
|
||||||
1e8,
|
1e2,
|
||||||
optimizationEpsilon);
|
forceMagnitudeEpsilon);
|
||||||
|
translationalOptimizationEpsilon = 1e-2 * global.desiredMaxDisplacementValue;
|
||||||
|
wasSuccessful = minimumError < translationalOptimizationEpsilon;
|
||||||
break;
|
break;
|
||||||
case Shear:
|
case Shear:
|
||||||
global.desiredMaxDisplacementValue = 0.04
|
global.desiredMaxDisplacementValue = 0.04
|
||||||
|
|
@ -1082,11 +1105,14 @@ double ReducedModelOptimizer::getFullPatternMaxSimulationForce(const BaseSimulat
|
||||||
/ 2);
|
/ 2);
|
||||||
global.constructScenarioFunction = &ReducedModelOptimizer::constructShearSimulationScenario;
|
global.constructScenarioFunction = &ReducedModelOptimizer::constructShearSimulationScenario;
|
||||||
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[1].first;
|
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[1].first;
|
||||||
dlib::find_min_single_variable(&fullPatternMaxSimulationForceTranslationalObjective,
|
minimumError
|
||||||
|
= dlib::find_min_single_variable(&fullPatternMaxSimulationForceTranslationalObjective,
|
||||||
forceMagnitude,
|
forceMagnitude,
|
||||||
1e-8,
|
1e-2,
|
||||||
1e8,
|
1e2,
|
||||||
optimizationEpsilon);
|
forceMagnitudeEpsilon);
|
||||||
|
translationalOptimizationEpsilon = 1e-2 * global.desiredMaxDisplacementValue;
|
||||||
|
wasSuccessful = minimumError < translationalOptimizationEpsilon;
|
||||||
break;
|
break;
|
||||||
case Bending:
|
case Bending:
|
||||||
global.desiredMaxDisplacementValue = 0.1
|
global.desiredMaxDisplacementValue = 0.1
|
||||||
|
|
@ -1096,28 +1122,33 @@ double ReducedModelOptimizer::getFullPatternMaxSimulationForce(const BaseSimulat
|
||||||
/ 2);
|
/ 2);
|
||||||
global.constructScenarioFunction = &ReducedModelOptimizer::constructBendingSimulationScenario;
|
global.constructScenarioFunction = &ReducedModelOptimizer::constructBendingSimulationScenario;
|
||||||
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[0].first;
|
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[0].first;
|
||||||
dlib::find_min_single_variable(&fullPatternMaxSimulationForceTranslationalObjective,
|
minimumError
|
||||||
|
= dlib::find_min_single_variable(&fullPatternMaxSimulationForceTranslationalObjective,
|
||||||
forceMagnitude,
|
forceMagnitude,
|
||||||
1e-8,
|
1e-2,
|
||||||
1e8,
|
1e2,
|
||||||
optimizationEpsilon);
|
forceMagnitudeEpsilon);
|
||||||
|
translationalOptimizationEpsilon = 1e-2 * global.desiredMaxDisplacementValue;
|
||||||
|
wasSuccessful = minimumError < translationalOptimizationEpsilon;
|
||||||
break;
|
break;
|
||||||
case Dome:
|
case Dome:
|
||||||
global.desiredMaxRotationAngle = vcg::math::ToRad(35.0);
|
global.desiredMaxRotationAngle = vcg::math::ToRad(25.0);
|
||||||
global.constructScenarioFunction = &ReducedModelOptimizer::constructDomeSimulationScenario;
|
global.constructScenarioFunction = &ReducedModelOptimizer::constructDomeSimulationScenario;
|
||||||
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[1].first;
|
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[1].first;
|
||||||
dlib::find_min_single_variable(
|
// minimumError
|
||||||
&fullPatternMaxSimulationForceRotationalObjective,
|
// = dlib::find_min_single_variable(&fullPatternMaxSimulationForceRotationalObjective,
|
||||||
forceMagnitude,
|
// forceMagnitude,
|
||||||
1e-8,
|
// 1e-2,
|
||||||
1e8,
|
// 1e2,
|
||||||
vcg::math::ToRad(1.0)
|
// forceMagnitudeEpsilon);
|
||||||
// global.desiredMaxRotationAngle * 0.5,
|
// wasSuccessful = minimumError < vcg::math::ToRad(3.0);
|
||||||
// optimizationEpsilon,
|
result = dlib::find_min_global(&fullPatternMaxSimulationForceRotationalObjective,
|
||||||
);
|
1e-2,
|
||||||
|
1,
|
||||||
|
dlib::max_function_calls(50));
|
||||||
|
wasSuccessful = result.y < vcg::math::ToRad(3.0);
|
||||||
break;
|
break;
|
||||||
case Saddle:
|
case Saddle:
|
||||||
// global.desiredMaxDisplacementValue *= 2;
|
|
||||||
global.desiredMaxDisplacementValue = 0.1
|
global.desiredMaxDisplacementValue = 0.1
|
||||||
* vcg::Distance(global.baseTriangle.cP(0),
|
* vcg::Distance(global.baseTriangle.cP(0),
|
||||||
(global.baseTriangle.cP(1)
|
(global.baseTriangle.cP(1)
|
||||||
|
|
@ -1125,14 +1156,30 @@ double ReducedModelOptimizer::getFullPatternMaxSimulationForce(const BaseSimulat
|
||||||
/ 2);
|
/ 2);
|
||||||
global.constructScenarioFunction = &ReducedModelOptimizer::constructSaddleSimulationScenario;
|
global.constructScenarioFunction = &ReducedModelOptimizer::constructSaddleSimulationScenario;
|
||||||
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[0].first;
|
global.interfaceViForComputingScenarioError = global.fullPatternInterfaceViPairs[0].first;
|
||||||
dlib::find_min_single_variable(&fullPatternMaxSimulationForceTranslationalObjective,
|
minimumError
|
||||||
|
= dlib::find_min_single_variable(&fullPatternMaxSimulationForceTranslationalObjective,
|
||||||
forceMagnitude,
|
forceMagnitude,
|
||||||
1e-8,
|
1e-2,
|
||||||
1e8,
|
1e2,
|
||||||
1e-2);
|
forceMagnitudeEpsilon);
|
||||||
|
translationalOptimizationEpsilon = 1e-2 * global.desiredMaxDisplacementValue;
|
||||||
|
wasSuccessful = minimumError < translationalOptimizationEpsilon;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POLYSCOPE_DEFINED
|
||||||
|
std::cout << "Max " << ReducedPatternOptimization::baseSimulationScenarioNames[scenario]
|
||||||
|
<< " magnitude:" << forceMagnitude << std::endl;
|
||||||
|
if (!wasSuccessful)
|
||||||
|
std::cout << "Was not successfull" << std::endl;
|
||||||
|
#endif
|
||||||
|
if (!wasSuccessful) {
|
||||||
|
const std::string debugMessage
|
||||||
|
= ReducedPatternOptimization::baseSimulationScenarioNames[scenario]
|
||||||
|
+ " max scenario magnitude was not succefully determined.";
|
||||||
|
optimizationNotes.append(debugMessage);
|
||||||
|
}
|
||||||
|
|
||||||
return forceMagnitude;
|
return forceMagnitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1148,11 +1195,9 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
job.pMesh = pMesh;
|
job.pMesh = pMesh;
|
||||||
|
|
||||||
//// Axial
|
//// Axial
|
||||||
#ifdef POLYSCOPE_DEFINED
|
bool wasSuccessful;
|
||||||
std::cout << "Computing Axial scenarios.." << std::endl;
|
const double maxForceMagnitude_axial
|
||||||
#endif
|
= getFullPatternMaxSimulationForce(BaseSimulationScenario::Axial, wasSuccessful);
|
||||||
const double maxForceMagnitude_axial = getFullPatternMaxSimulationForce(
|
|
||||||
BaseSimulationScenario::Axial);
|
|
||||||
const double minForceMagnitude_axial = -maxForceMagnitude_axial;
|
const double minForceMagnitude_axial = -maxForceMagnitude_axial;
|
||||||
const int numberOfSimulationScenarios_axial
|
const int numberOfSimulationScenarios_axial
|
||||||
= simulationScenariosResolution[BaseSimulationScenario::Axial];
|
= simulationScenariosResolution[BaseSimulationScenario::Axial];
|
||||||
|
|
@ -1167,9 +1212,6 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
for (int axialSimulationScenarioIndex = 0;
|
for (int axialSimulationScenarioIndex = 0;
|
||||||
axialSimulationScenarioIndex < numberOfSimulationScenarios_axial;
|
axialSimulationScenarioIndex < numberOfSimulationScenarios_axial;
|
||||||
axialSimulationScenarioIndex++) {
|
axialSimulationScenarioIndex++) {
|
||||||
#ifdef POLYSCOPE_DEFINED
|
|
||||||
std::cout << "Computing Axial scenario:" << axialSimulationScenarioIndex << std::endl;
|
|
||||||
#endif
|
|
||||||
job.nodalExternalForces.clear();
|
job.nodalExternalForces.clear();
|
||||||
job.constrainedVertices.clear();
|
job.constrainedVertices.clear();
|
||||||
job.nodalForcedDisplacements.clear();
|
job.nodalForcedDisplacements.clear();
|
||||||
|
|
@ -1185,8 +1227,8 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Shear
|
//// Shear
|
||||||
const double maxForceMagnitude_shear = getFullPatternMaxSimulationForce(
|
const double maxForceMagnitude_shear
|
||||||
BaseSimulationScenario::Shear);
|
= getFullPatternMaxSimulationForce(BaseSimulationScenario::Shear, wasSuccessful);
|
||||||
const double minForceMagnitude_shear = -maxForceMagnitude_shear;
|
const double minForceMagnitude_shear = -maxForceMagnitude_shear;
|
||||||
const int numberOfSimulationScenarios_shear
|
const int numberOfSimulationScenarios_shear
|
||||||
= simulationScenariosResolution[BaseSimulationScenario::Shear];
|
= simulationScenariosResolution[BaseSimulationScenario::Shear];
|
||||||
|
|
@ -1201,9 +1243,6 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
for (int shearSimulationScenarioIndex = 0;
|
for (int shearSimulationScenarioIndex = 0;
|
||||||
shearSimulationScenarioIndex < numberOfSimulationScenarios_shear;
|
shearSimulationScenarioIndex < numberOfSimulationScenarios_shear;
|
||||||
shearSimulationScenarioIndex++) {
|
shearSimulationScenarioIndex++) {
|
||||||
#ifdef POLYSCOPE_DEFINED
|
|
||||||
std::cout << "Computing shear scenario:" << shearSimulationScenarioIndex << std::endl;
|
|
||||||
#endif
|
|
||||||
job.constrainedVertices.clear();
|
job.constrainedVertices.clear();
|
||||||
job.nodalExternalForces.clear();
|
job.nodalExternalForces.clear();
|
||||||
job.label = baseSimulationScenarioNames[BaseSimulationScenario::Shear] + "_"
|
job.label = baseSimulationScenarioNames[BaseSimulationScenario::Shear] + "_"
|
||||||
|
|
@ -1216,8 +1255,8 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Bending
|
//// Bending
|
||||||
const double maxForceMagnitude_bending = getFullPatternMaxSimulationForce(
|
const double maxForceMagnitude_bending
|
||||||
BaseSimulationScenario::Bending);
|
= getFullPatternMaxSimulationForce(BaseSimulationScenario::Bending, wasSuccessful);
|
||||||
const double minForceMagnitude_bending = 0;
|
const double minForceMagnitude_bending = 0;
|
||||||
const int numberOfSimulationScenarios_bending
|
const int numberOfSimulationScenarios_bending
|
||||||
= simulationScenariosResolution[BaseSimulationScenario::Bending];
|
= simulationScenariosResolution[BaseSimulationScenario::Bending];
|
||||||
|
|
@ -1230,9 +1269,6 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
for (int bendingSimulationScenarioIndex = 0;
|
for (int bendingSimulationScenarioIndex = 0;
|
||||||
bendingSimulationScenarioIndex < numberOfSimulationScenarios_bending;
|
bendingSimulationScenarioIndex < numberOfSimulationScenarios_bending;
|
||||||
bendingSimulationScenarioIndex++) {
|
bendingSimulationScenarioIndex++) {
|
||||||
#ifdef POLYSCOPE_DEFINED
|
|
||||||
std::cout << "Computing bending scenario:" << bendingSimulationScenarioIndex << std::endl;
|
|
||||||
#endif
|
|
||||||
job.nodalExternalForces.clear();
|
job.nodalExternalForces.clear();
|
||||||
job.constrainedVertices.clear();
|
job.constrainedVertices.clear();
|
||||||
job.label = baseSimulationScenarioNames[BaseSimulationScenario::Bending] + "_"
|
job.label = baseSimulationScenarioNames[BaseSimulationScenario::Bending] + "_"
|
||||||
|
|
@ -1248,8 +1284,8 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Dome
|
//// Dome
|
||||||
const double maxForceMagnitude_dome = getFullPatternMaxSimulationForce(
|
const double maxForceMagnitude_dome
|
||||||
BaseSimulationScenario::Dome);
|
= getFullPatternMaxSimulationForce(BaseSimulationScenario::Dome, wasSuccessful);
|
||||||
const double minForceMagnitude_dome = 0;
|
const double minForceMagnitude_dome = 0;
|
||||||
const int numberOfSimulationScenarios_dome
|
const int numberOfSimulationScenarios_dome
|
||||||
= simulationScenariosResolution[BaseSimulationScenario::Dome];
|
= simulationScenariosResolution[BaseSimulationScenario::Dome];
|
||||||
|
|
@ -1262,9 +1298,6 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
for (int domeSimulationScenarioIndex = 0;
|
for (int domeSimulationScenarioIndex = 0;
|
||||||
domeSimulationScenarioIndex < numberOfSimulationScenarios_dome;
|
domeSimulationScenarioIndex < numberOfSimulationScenarios_dome;
|
||||||
domeSimulationScenarioIndex++) {
|
domeSimulationScenarioIndex++) {
|
||||||
#ifdef POLYSCOPE_DEFINED
|
|
||||||
std::cout << "Computing dome scenario:" << domeSimulationScenarioIndex << std::endl;
|
|
||||||
#endif
|
|
||||||
job.constrainedVertices.clear();
|
job.constrainedVertices.clear();
|
||||||
job.nodalExternalForces.clear();
|
job.nodalExternalForces.clear();
|
||||||
job.nodalForcedDisplacements.clear();
|
job.nodalForcedDisplacements.clear();
|
||||||
|
|
@ -1278,8 +1311,8 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Saddle
|
//// Saddle
|
||||||
const double maxForceMagnitude_saddle = getFullPatternMaxSimulationForce(
|
const double maxForceMagnitude_saddle
|
||||||
BaseSimulationScenario::Saddle);
|
= getFullPatternMaxSimulationForce(BaseSimulationScenario::Saddle, wasSuccessful);
|
||||||
const double minForceMagnitude_saddle = 0;
|
const double minForceMagnitude_saddle = 0;
|
||||||
const int numberOfSimulationScenarios_saddle
|
const int numberOfSimulationScenarios_saddle
|
||||||
= simulationScenariosResolution[BaseSimulationScenario::Saddle];
|
= simulationScenariosResolution[BaseSimulationScenario::Saddle];
|
||||||
|
|
@ -1292,9 +1325,6 @@ ReducedModelOptimizer::createFullPatternSimulationScenarios(
|
||||||
for (int saddleSimulationScenarioIndex = 0;
|
for (int saddleSimulationScenarioIndex = 0;
|
||||||
saddleSimulationScenarioIndex < numberOfSimulationScenarios_saddle;
|
saddleSimulationScenarioIndex < numberOfSimulationScenarios_saddle;
|
||||||
saddleSimulationScenarioIndex++) {
|
saddleSimulationScenarioIndex++) {
|
||||||
#ifdef POLYSCOPE_DEFINED
|
|
||||||
std::cout << "Computing saddle scenario:" << saddleSimulationScenarioIndex << std::endl;
|
|
||||||
#endif
|
|
||||||
job.constrainedVertices.clear();
|
job.constrainedVertices.clear();
|
||||||
job.nodalExternalForces.clear();
|
job.nodalExternalForces.clear();
|
||||||
job.nodalForcedDisplacements.clear();
|
job.nodalForcedDisplacements.clear();
|
||||||
|
|
@ -1426,10 +1456,15 @@ void ReducedModelOptimizer::optimize(
|
||||||
m_pFullPatternSimulationMesh);
|
m_pFullPatternSimulationMesh);
|
||||||
// polyscope::removeAllStructures();
|
// polyscope::removeAllStructures();
|
||||||
|
|
||||||
|
results.baseTriangle = global.baseTriangle;
|
||||||
|
|
||||||
DRMSimulationModel::Settings simulationSettings;
|
DRMSimulationModel::Settings simulationSettings;
|
||||||
simulationSettings.shouldDraw = false;
|
simulationSettings.maxDRMIterations = 200000;
|
||||||
|
// simulationSettings.shouldDraw = true;
|
||||||
|
// simulationSettings.isDebugMode = true;
|
||||||
|
// simulationSettings.debugModeStep = 100000;
|
||||||
#ifdef POLYSCOPE_DEFINED
|
#ifdef POLYSCOPE_DEFINED
|
||||||
const bool drawFullPatternSimulationResults = true;
|
const bool drawFullPatternSimulationResults = false;
|
||||||
if (drawFullPatternSimulationResults) {
|
if (drawFullPatternSimulationResults) {
|
||||||
global.fullPatternSimulationJobs[0]->pMesh->registerForDrawing(
|
global.fullPatternSimulationJobs[0]->pMesh->registerForDrawing(
|
||||||
ReducedPatternOptimization::Colors::fullInitial);
|
ReducedPatternOptimization::Colors::fullInitial);
|
||||||
|
|
@ -1439,8 +1474,14 @@ void ReducedModelOptimizer::optimize(
|
||||||
for (int simulationScenarioIndex : global.simulationScenarioIndices) {
|
for (int simulationScenarioIndex : global.simulationScenarioIndices) {
|
||||||
const std::shared_ptr<SimulationJob> &pFullPatternSimulationJob
|
const std::shared_ptr<SimulationJob> &pFullPatternSimulationJob
|
||||||
= global.fullPatternSimulationJobs[simulationScenarioIndex];
|
= global.fullPatternSimulationJobs[simulationScenarioIndex];
|
||||||
|
|
||||||
SimulationResults fullPatternResults = simulator.executeSimulation(pFullPatternSimulationJob,
|
SimulationResults fullPatternResults = simulator.executeSimulation(pFullPatternSimulationJob,
|
||||||
simulationSettings);
|
simulationSettings);
|
||||||
|
if (!fullPatternResults.converged) {
|
||||||
|
results.wasSuccessful = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
results.wasSuccessful = true;
|
||||||
#ifdef POLYSCOPE_DEFINED
|
#ifdef POLYSCOPE_DEFINED
|
||||||
if (drawFullPatternSimulationResults) {
|
if (drawFullPatternSimulationResults) {
|
||||||
// SimulationResults fullPatternResults_linear = linearSimulator.executeSimulation(
|
// SimulationResults fullPatternResults_linear = linearSimulator.executeSimulation(
|
||||||
|
|
@ -1481,4 +1522,5 @@ void ReducedModelOptimizer::optimize(
|
||||||
std::cout << "Running reduced model optimization" << std::endl;
|
std::cout << "Running reduced model optimization" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
runOptimization(optimizationSettings, results);
|
runOptimization(optimizationSettings, results);
|
||||||
|
results.notes = optimizationNotes;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class ReducedModelOptimizer
|
||||||
m_fullPatternOppositeInterfaceViPairs;
|
m_fullPatternOppositeInterfaceViPairs;
|
||||||
std::unordered_map<size_t, size_t> nodeToSlot;
|
std::unordered_map<size_t, size_t> nodeToSlot;
|
||||||
std::unordered_map<size_t, std::unordered_set<size_t>> slotToNode;
|
std::unordered_map<size_t, std::unordered_set<size_t>> slotToNode;
|
||||||
|
std::string optimizationNotes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr static std::array<int, 5> simulationScenariosResolution = {10, 10, 20, 20, 20};
|
constexpr static std::array<int, 5> simulationScenariosResolution = {10, 10, 20, 20, 20};
|
||||||
|
|
@ -186,7 +187,7 @@ private:
|
||||||
ReducedPatternOptimization::Results &results);
|
ReducedPatternOptimization::Results &results);
|
||||||
std::vector<double> getFullPatternMaxSimulationForces();
|
std::vector<double> getFullPatternMaxSimulationForces();
|
||||||
double getFullPatternMaxSimulationForce(
|
double getFullPatternMaxSimulationForce(
|
||||||
const ReducedPatternOptimization::BaseSimulationScenario &scenario);
|
const ReducedPatternOptimization::BaseSimulationScenario &scenario, bool &wasSuccessfull);
|
||||||
};
|
};
|
||||||
void updateMesh(long n, const double *x);
|
void updateMesh(long n, const double *x);
|
||||||
#endif // REDUCEDMODELOPTIMIZER_HPP
|
#endif // REDUCEDMODELOPTIMIZER_HPP
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue