Refactoring
This commit is contained in:
parent
9884cd175f
commit
1a27ec16a2
|
|
@ -31,13 +31,13 @@ int main(int argc, char *argv[]) {
|
||||||
PatternGeometry fullPattern(filepath_fullPattern);
|
PatternGeometry fullPattern(filepath_fullPattern);
|
||||||
fullPattern.setLabel(
|
fullPattern.setLabel(
|
||||||
std::filesystem::path(filepath_fullPattern).stem().string());
|
std::filesystem::path(filepath_fullPattern).stem().string());
|
||||||
fullPattern.scale(0.03);
|
fullPattern.scale(0.03,3);
|
||||||
////Reduced pattern
|
////Reduced pattern
|
||||||
const std::string filepath_reducedPattern = argv[2];
|
const std::string filepath_reducedPattern = argv[2];
|
||||||
PatternGeometry reducedPattern(filepath_reducedPattern);
|
PatternGeometry reducedPattern(filepath_reducedPattern);
|
||||||
reducedPattern.setLabel(
|
reducedPattern.setLabel(
|
||||||
std::filesystem::path(filepath_reducedPattern).stem().string());
|
std::filesystem::path(filepath_reducedPattern).stem().string());
|
||||||
reducedPattern.scale(0.03);
|
reducedPattern.scale(0.03,3);
|
||||||
|
|
||||||
// Set the optization settings
|
// Set the optization settings
|
||||||
ReducedModelOptimizer::xRange beamWidth{"B", 0.5, 1.5};
|
ReducedModelOptimizer::xRange beamWidth{"B", 0.5, 1.5};
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,8 @@ double ReducedModelOptimizer::objective(long n, const double *x) {
|
||||||
|
|
||||||
// run simulations
|
// run simulations
|
||||||
double totalError = 0;
|
double totalError = 0;
|
||||||
LinearSimulationModel simulator;
|
// LinearSimulationModel simulator;
|
||||||
|
FormFinder simulator;
|
||||||
for (const int simulationScenarioIndex : global.simulationScenarioIndices) {
|
for (const int simulationScenarioIndex : global.simulationScenarioIndices) {
|
||||||
SimulationResults reducedModelResults = simulator.executeSimulation(
|
SimulationResults reducedModelResults = simulator.executeSimulation(
|
||||||
global.reducedPatternSimulationJobs[simulationScenarioIndex]);
|
global.reducedPatternSimulationJobs[simulationScenarioIndex]);
|
||||||
|
|
@ -700,20 +701,8 @@ ReducedModelOptimizer::runOptimization(const Settings &settings) {
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute raw objective value
|
|
||||||
if (global.optimizationSettings.normalizationStrategy !=
|
|
||||||
Settings::NormalizationStrategy::NonNormalized) {
|
|
||||||
auto temp = global.optimizationSettings.normalizationStrategy;
|
|
||||||
global.optimizationSettings.normalizationStrategy =
|
|
||||||
Settings::NormalizationStrategy::NonNormalized;
|
|
||||||
results.rawObjectiveValue = objective(results.x.size(), results.x.data());
|
|
||||||
global.optimizationSettings.normalizationStrategy = temp;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
results.rawObjectiveValue = results.objectiveValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute obj value per simulation scenario
|
// Compute obj value per simulation scenario
|
||||||
|
results.rawObjectiveValue=0;
|
||||||
updateMesh(results.x.size(), results.x.data());
|
updateMesh(results.x.size(), results.x.data());
|
||||||
results.objectiveValuePerSimulationScenario.resize(
|
results.objectiveValuePerSimulationScenario.resize(
|
||||||
NumberOfSimulationScenarios);
|
NumberOfSimulationScenarios);
|
||||||
|
|
@ -730,7 +719,9 @@ ReducedModelOptimizer::runOptimization(const Settings &settings) {
|
||||||
global.fullPatternDisplacements[simulationScenarioIndex],
|
global.fullPatternDisplacements[simulationScenarioIndex],
|
||||||
global.reducedToFullInterfaceViMap,
|
global.reducedToFullInterfaceViMap,
|
||||||
global.objectiveNormalizationValues[simulationScenarioIndex]);
|
global.objectiveNormalizationValues[simulationScenarioIndex]);
|
||||||
|
results.rawObjectiveValue+=computeRawError(reducedModelResults.displacements,
|
||||||
|
global.fullPatternDisplacements[simulationScenarioIndex],
|
||||||
|
global.reducedToFullInterfaceViMap);
|
||||||
results.objectiveValuePerSimulationScenario[simulationScenarioIndex] =
|
results.objectiveValuePerSimulationScenario[simulationScenarioIndex] =
|
||||||
error;
|
error;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue