Changed simulation scenarios for axial and shear
This commit is contained in:
parent
3d404a9153
commit
4a03c435c2
|
|
@ -783,6 +783,22 @@ ReducedModelOptimizer::createScenarios(
|
||||||
|
|
||||||
//// Axial
|
//// Axial
|
||||||
SimulationScenario scenarioName = SimulationScenario::Axial;
|
SimulationScenario scenarioName = SimulationScenario::Axial;
|
||||||
|
// NewMethod
|
||||||
|
// for (auto viPairIt = m_fullPatternOppositeInterfaceViMap.begin();
|
||||||
|
// viPairIt != m_fullPatternOppositeInterfaceViMap.end(); viPairIt++) {
|
||||||
|
// if (viPairIt != m_fullPatternOppositeInterfaceViMap.begin()) {
|
||||||
|
// CoordType forceDirection(1, 0, 0);
|
||||||
|
// const auto viPair = *viPairIt;
|
||||||
|
// nodalForces[viPair.first] =
|
||||||
|
// Vector6d({forceDirection[0], forceDirection[1], forceDirection[2],
|
||||||
|
// 0,
|
||||||
|
// 0, 0}) *
|
||||||
|
// forceMagnitude * 10;
|
||||||
|
// fixedVertices[viPair.second] =
|
||||||
|
// std::unordered_set<DoFType>{0, 1, 2, 3, 4, 5};
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// OldMethod
|
||||||
for (const auto &viPair : m_fullPatternOppositeInterfaceViMap) {
|
for (const auto &viPair : m_fullPatternOppositeInterfaceViMap) {
|
||||||
CoordType forceDirection =
|
CoordType forceDirection =
|
||||||
(pMesh->vert[viPair.first].cP() - pMesh->vert[viPair.second].cP())
|
(pMesh->vert[viPair.first].cP() - pMesh->vert[viPair.second].cP())
|
||||||
|
|
@ -801,6 +817,22 @@ ReducedModelOptimizer::createScenarios(
|
||||||
scenarioName = SimulationScenario::Shear;
|
scenarioName = SimulationScenario::Shear;
|
||||||
fixedVertices.clear();
|
fixedVertices.clear();
|
||||||
nodalForces.clear();
|
nodalForces.clear();
|
||||||
|
// NewMethod
|
||||||
|
// for (auto viPairIt = m_fullPatternOppositeInterfaceViMap.begin();
|
||||||
|
// viPairIt != m_fullPatternOppositeInterfaceViMap.end(); viPairIt++) {
|
||||||
|
// if (viPairIt != m_fullPatternOppositeInterfaceViMap.begin()) {
|
||||||
|
// CoordType forceDirection(0, 1, 0);
|
||||||
|
// const auto viPair = *viPairIt;
|
||||||
|
// nodalForces[viPair.first] =
|
||||||
|
// Vector6d({forceDirection[0], forceDirection[1], forceDirection[2],
|
||||||
|
// 0,
|
||||||
|
// 0, 0}) *
|
||||||
|
// forceMagnitude * 10;
|
||||||
|
// fixedVertices[viPair.second] =
|
||||||
|
// std::unordered_set<DoFType>{0, 1, 2, 3, 4, 5};
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// OldMethod
|
||||||
for (const auto &viPair : m_fullPatternOppositeInterfaceViMap) {
|
for (const auto &viPair : m_fullPatternOppositeInterfaceViMap) {
|
||||||
CoordType v =
|
CoordType v =
|
||||||
(pMesh->vert[viPair.first].cP() - pMesh->vert[viPair.second].cP())
|
(pMesh->vert[viPair.first].cP() - pMesh->vert[viPair.second].cP())
|
||||||
|
|
@ -913,9 +945,7 @@ ReducedModelOptimizer::createScenarios(
|
||||||
void ReducedModelOptimizer::computeObjectiveValueNormalizationFactors() {
|
void ReducedModelOptimizer::computeObjectiveValueNormalizationFactors() {
|
||||||
assert(global.optimizationSettings.shouldNormalizeObjectiveValue);
|
assert(global.optimizationSettings.shouldNormalizeObjectiveValue);
|
||||||
if (global.optimizationSettings.normalizationStrategy ==
|
if (global.optimizationSettings.normalizationStrategy ==
|
||||||
Settings::NormalizationStrategy::Epsilon ||
|
Settings::NormalizationStrategy::Epsilon) {
|
||||||
global.optimizationSettings.normalizationStrategy ==
|
|
||||||
Settings::NormalizationStrategy::EqualDisplacements) {
|
|
||||||
|
|
||||||
// Compute the sum of the displacement norms
|
// Compute the sum of the displacement norms
|
||||||
std::vector<double> fullPatternDisplacementNormSum(
|
std::vector<double> fullPatternDisplacementNormSum(
|
||||||
|
|
@ -946,49 +976,8 @@ void ReducedModelOptimizer::computeObjectiveValueNormalizationFactors() {
|
||||||
global.objectiveNormalizationValues[simulationScenarioIndex] = std::max(
|
global.objectiveNormalizationValues[simulationScenarioIndex] = std::max(
|
||||||
fullPatternDisplacementNormSum[simulationScenarioIndex], epsilon);
|
fullPatternDisplacementNormSum[simulationScenarioIndex], epsilon);
|
||||||
// displacementNormSum;
|
// displacementNormSum;
|
||||||
} else { // NormalizationStrategy::EqualDisplacements
|
|
||||||
global.objectiveNormalizationValues[simulationScenarioIndex] =
|
|
||||||
fullPatternDisplacementNormSum[simulationScenarioIndex] /
|
|
||||||
fullPatternDisplacementNormSum[SimulationScenario::Shear];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (global.optimizationSettings.normalizationStrategy ==
|
|
||||||
Settings::NormalizationStrategy::MaxDisplacement) {
|
|
||||||
for (int simulationScenarioIndex : global.simulationScenarioIndices) {
|
|
||||||
// Compute the quantities for normalizing the obj value
|
|
||||||
const double minB = global.optimizationSettings.xRanges[0].min;
|
|
||||||
const double maxRatio = global.optimizationSettings.xRanges[1].max;
|
|
||||||
const double minE = global.optimizationSettings.xRanges[2].min;
|
|
||||||
const double minHS = 0.3;
|
|
||||||
std::vector<double> mostFlexibleOptimizationParameters{minB, maxRatio,
|
|
||||||
minE, minHS};
|
|
||||||
if (global.optimizeInnerHexagonSize) {
|
|
||||||
updateMesh(4, mostFlexibleOptimizationParameters.data());
|
|
||||||
} else {
|
|
||||||
updateMesh(3, mostFlexibleOptimizationParameters.data());
|
|
||||||
}
|
|
||||||
reducedPatternMaximumDisplacementSimulationJobs[simulationScenarioIndex] =
|
|
||||||
global.reducedPatternSimulationJobs[simulationScenarioIndex]
|
|
||||||
->getCopy();
|
|
||||||
reducedPatternMaximumDisplacementSimulationJobs[simulationScenarioIndex]
|
|
||||||
.pMesh->setLabel("reduced_maxDisplacement");
|
|
||||||
SimulationResults reducedModelResults = simulator.executeSimulation(
|
|
||||||
global.reducedPatternSimulationJobs[simulationScenarioIndex]);
|
|
||||||
const double errorOfMaxDisplacedReduced = computeRawError(
|
|
||||||
reducedModelResults.displacements,
|
|
||||||
global.fullPatternDisplacements[simulationScenarioIndex],
|
|
||||||
global.reducedToFullInterfaceViMap);
|
|
||||||
const double errorOfNonDisplacedReduced = computeRawError(
|
|
||||||
std::vector<Vector6d>(reducedModelResults.displacements.size(),
|
|
||||||
Vector6d(0)),
|
|
||||||
global.fullPatternDisplacements[simulationScenarioIndex],
|
|
||||||
global.reducedToFullInterfaceViMap);
|
|
||||||
const double displacementMultiplier =
|
|
||||||
global.optimizationSettings.normalizationParameter;
|
|
||||||
global.objectiveNormalizationValues[simulationScenarioIndex] =
|
|
||||||
displacementMultiplier *
|
|
||||||
std::max(errorOfMaxDisplacedReduced, errorOfNonDisplacedReduced);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,14 +62,9 @@ public:
|
||||||
struct Results;
|
struct Results;
|
||||||
|
|
||||||
struct Settings {
|
struct Settings {
|
||||||
enum NormalizationStrategy {
|
enum NormalizationStrategy { NonNormalized, Epsilon };
|
||||||
NonNormalized,
|
|
||||||
Epsilon,
|
|
||||||
MaxDisplacement,
|
|
||||||
EqualDisplacements
|
|
||||||
};
|
|
||||||
inline static vector<std::string> normalizationStrategyStrings{
|
inline static vector<std::string> normalizationStrategyStrings{
|
||||||
"NonNormalized", "Epsilon", "MaxDsiplacement", "EqualDisplacements"};
|
"NonNormalized", "Epsilon"};
|
||||||
std::vector<xRange> xRanges;
|
std::vector<xRange> xRanges;
|
||||||
int numberOfFunctionCalls{100};
|
int numberOfFunctionCalls{100};
|
||||||
double solutionAccuracy{1e-2};
|
double solutionAccuracy{1e-2};
|
||||||
|
|
@ -115,8 +110,11 @@ public:
|
||||||
}
|
}
|
||||||
os << numberOfFunctionCalls;
|
os << numberOfFunctionCalls;
|
||||||
os << solutionAccuracy;
|
os << solutionAccuracy;
|
||||||
os << normalizationStrategyStrings[normalizationStrategy] + "_" +
|
if (normalizationStrategy == Epsilon) {
|
||||||
std::to_string(normalizationParameter);
|
os << "Epsilon_" + std::to_string(normalizationParameter);
|
||||||
|
} else {
|
||||||
|
os << "NonNormalized";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct Results {
|
struct Results {
|
||||||
|
|
@ -227,8 +225,8 @@ public:
|
||||||
const std::string screenshotFilename =
|
const std::string screenshotFilename =
|
||||||
"/home/iason/Coding/Projects/Approximating shapes with flat "
|
"/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||||
"patterns/RodModelOptimizationForPatterns/Results/Images/" +
|
"patterns/RodModelOptimizationForPatterns/Results/Images/" +
|
||||||
pFullPatternSimulationJob->pMesh->getLabel() + "_" +
|
fullPatternSimulationJobs[0]->pMesh->getLabel() + "_" +
|
||||||
simulationScenarioStrings[simulationJobIndex];
|
pFullPatternSimulationJob->getLabel();
|
||||||
polyscope::screenshot(screenshotFilename, false);
|
polyscope::screenshot(screenshotFilename, false);
|
||||||
fullModelResults.unregister();
|
fullModelResults.unregister();
|
||||||
reducedModelResults.unregister();
|
reducedModelResults.unregister();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue