#ifndef REDUCEDMODELOPTIMIZER_HPP #define REDUCEDMODELOPTIMIZER_HPP #include "beamformfinder.hpp" #include "edgemesh.hpp" #include "elementalmesh.hpp" #include "matplot/matplot.h" #include using FullPatternVertexIndex = VertexIndex; using ReducedPatternVertexIndex = VertexIndex; class ReducedModelOptimizer { std::shared_ptr m_pReducedPatternSimulationMesh; std::shared_ptr m_pFullPatternSimulationMesh; std::unordered_map m_fullToReducedInterfaceViMap; std::unordered_map m_fullPatternOppositeInterfaceViMap; std::unordered_map nodeToSlot; std::unordered_map> slotToNode; std::vector initialGuess; public: enum SimulationScenario { Axial, Shear, Bending, Dome, Saddle, NumberOfSimulationScenarios }; inline static const std::string simulationScenarioStrings[] = { "Axial", "Shear", "Bending", "Double", "Saddle"}; void optimize(const std::vector &simulationScenarios = std::vector()); double operator()(const Eigen::VectorXd &x, Eigen::VectorXd &) const; ReducedModelOptimizer(const std::vector &numberOfNodesPerSlot); static void computeReducedModelSimulationJob( const SimulationJob &simulationJobOfFullModel, const std::unordered_map &simulationJobFullToReducedMap, SimulationJob &simulationJobOfReducedModel); SimulationJob getReducedSimulationJob(const SimulationJob &fullModelSimulationJob); void initializePatterns( FlatPattern &fullPattern, FlatPattern &reducedPatterm, const std::unordered_set &reducedModelExcludedEges); void setInitialGuess(std::vector v); static void runBeamOptimization(); static void runSimulation(const std::string &filename, std::vector &x); static double objective(double x0, double x1, double x2, double x3); private: void visualizeResults(const std::vector> &fullPatternSimulationJobs, const std::vector &simulationScenarios); static void computeDesiredReducedModelDisplacements( const SimulationResults &fullModelResults, const std::unordered_map &displacementsReducedToFullMap, Eigen::MatrixX3d &optimalDisplacementsOfReducedModel); static Eigen::VectorXd runOptimization(double (*pObjectiveFunction)(long, const double *)); std::vector> createScenarios(const std::shared_ptr &pMesh); void computeMaps(FlatPattern &fullModel, FlatPattern &reducedPattern, const std::unordered_set &reducedModelExcludedEges); void createSimulationMeshes(FlatPattern &fullModel, FlatPattern &reducedModel); static void initializeStiffnesses(const std::shared_ptr &mesh); static double computeError(const SimulationResults &reducedPatternResults, const Eigen::MatrixX3d &optimalReducedPatternDisplacements); static double objective(long n, const double *x); }; #endif // REDUCEDMODELOPTIMIZER_HPP