The linear simulation model is used for optimizing the reduced model.
This commit is contained in:
parent
bde1e029bb
commit
9884cd175f
|
@ -0,0 +1,21 @@
|
||||||
|
#include "linearsimulationmodel.hpp"
|
||||||
|
#include <Eigen/Core>
|
||||||
|
#include <filesystem>
|
||||||
|
//#include <igl/list_to_matrix.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vcg/complex/algorithms/create/platonic.h>
|
||||||
|
#include <vcg/complex/algorithms/update/normal.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,215 @@
|
||||||
|
#ifndef LINEARSIMULATIONMODEL_HPP
|
||||||
|
#define LINEARSIMULATIONMODEL_HPP
|
||||||
|
|
||||||
|
//#include "beam.hpp"
|
||||||
|
#include "simulationresult.hpp"
|
||||||
|
#include "threed_beam_fea.h"
|
||||||
|
#include <filesystem>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// struct BeamSimulationProperties {
|
||||||
|
// float crossArea;
|
||||||
|
// float I2;
|
||||||
|
// float I3;
|
||||||
|
// float polarInertia;
|
||||||
|
// float G;
|
||||||
|
// // Properties used by fea
|
||||||
|
// float EA;
|
||||||
|
// float EIz;
|
||||||
|
// float EIy;
|
||||||
|
// float GJ;
|
||||||
|
|
||||||
|
// BeamSimulationProperties(const BeamDimensions &dimensions,
|
||||||
|
// const BeamMaterial &material);
|
||||||
|
//};
|
||||||
|
|
||||||
|
// struct NodalForce {
|
||||||
|
// int index;
|
||||||
|
// int dof;
|
||||||
|
// double magnitude;
|
||||||
|
//};
|
||||||
|
|
||||||
|
// struct SimulationJob {
|
||||||
|
// Eigen::MatrixX3d nodes;
|
||||||
|
// Eigen::MatrixX2i elements;
|
||||||
|
// Eigen::MatrixX3d elementalNormals;
|
||||||
|
// Eigen::VectorXi fixedNodes;
|
||||||
|
// std::vector<NodalForce> nodalForces;
|
||||||
|
// std::vector<BeamDimensions> beamDimensions;
|
||||||
|
// std::vector<BeamMaterial> beamMaterial;
|
||||||
|
//};
|
||||||
|
|
||||||
|
// struct SimulationResults {
|
||||||
|
// std::vector<Eigen::VectorXd> edgeForces; ///< Force values per force
|
||||||
|
// component
|
||||||
|
// ///< #force components x #edges
|
||||||
|
// Eigen::MatrixXd
|
||||||
|
// nodalDisplacements; ///< The displacement of each node #nodes x 3
|
||||||
|
// SimulationResults(const fea::Summary &feaSummary);
|
||||||
|
// SimulationResults() {}
|
||||||
|
//};
|
||||||
|
|
||||||
|
class LinearSimulationModel {
|
||||||
|
public:
|
||||||
|
LinearSimulationModel(){
|
||||||
|
|
||||||
|
}
|
||||||
|
static std::vector<fea::Elem>
|
||||||
|
getFeaElements(const std::shared_ptr<SimulationJob> &job) {
|
||||||
|
const int numberOfEdges = job->pMesh->EN();
|
||||||
|
std::vector<fea::Elem> elements(numberOfEdges);
|
||||||
|
for (int edgeIndex = 0; edgeIndex < numberOfEdges; edgeIndex++) {
|
||||||
|
const SimulationMesh::CoordType &evn0 =
|
||||||
|
job->pMesh->edge[edgeIndex].cV(0)->cN();
|
||||||
|
const SimulationMesh::CoordType &evn1 =
|
||||||
|
job->pMesh->edge[edgeIndex].cV(1)->cN();
|
||||||
|
const std::vector<double> nAverageVector{(evn0[0] + evn1[0]) / 2,
|
||||||
|
(evn0[1] + evn1[1]) / 2,
|
||||||
|
(evn0[2] + evn1[2]) / 2};
|
||||||
|
const Element &element = job->pMesh->elements[edgeIndex];
|
||||||
|
const double E = element.material.youngsModulus;
|
||||||
|
fea::Props feaProperties(E * element.A, E * element.I3, E * element.I2,
|
||||||
|
element.G * element.J, nAverageVector);
|
||||||
|
const int vi0 = job->pMesh->getIndex(job->pMesh->edge[edgeIndex].cV(0));
|
||||||
|
const int vi1 = job->pMesh->getIndex(job->pMesh->edge[edgeIndex].cV(1));
|
||||||
|
elements[edgeIndex] = fea::Elem(vi0, vi1, feaProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
static std::vector<fea::Node>
|
||||||
|
getFeaNodes(const std::shared_ptr<SimulationJob> &job) {
|
||||||
|
const int numberOfNodes = job->pMesh->VN();
|
||||||
|
std::vector<fea::Node> feaNodes(numberOfNodes);
|
||||||
|
for (int vi = 0; vi < numberOfNodes; vi++) {
|
||||||
|
const CoordType &p = job->pMesh->vert[vi].cP();
|
||||||
|
feaNodes[vi] = fea::Node(p[0], p[1], p[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return feaNodes;
|
||||||
|
}
|
||||||
|
static std::vector<fea::BC>
|
||||||
|
getFeaFixedNodes(const std::shared_ptr<SimulationJob> &job) {
|
||||||
|
std::vector<fea::BC> boundaryConditions;
|
||||||
|
boundaryConditions.reserve(job->constrainedVertices.size() * 6);
|
||||||
|
for (auto fixedVertex : job->constrainedVertices) {
|
||||||
|
const int vertexIndex = fixedVertex.first;
|
||||||
|
for (int dofIndex : fixedVertex.second) {
|
||||||
|
boundaryConditions.emplace_back(
|
||||||
|
fea::BC(vertexIndex, static_cast<fea::DOF>(dofIndex), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return boundaryConditions;
|
||||||
|
}
|
||||||
|
static std::vector<fea::Force>
|
||||||
|
getFeaNodalForces(const std::shared_ptr<SimulationJob> &job) {
|
||||||
|
std::vector<fea::Force> nodalForces;
|
||||||
|
nodalForces.reserve(job->nodalExternalForces.size() * 6);
|
||||||
|
|
||||||
|
for (auto nodalForce : job->nodalExternalForces) {
|
||||||
|
for (int dofIndex = 0; dofIndex < 6; dofIndex++) {
|
||||||
|
if (nodalForce.second[dofIndex] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
nodalForces.emplace_back(
|
||||||
|
fea::Force(nodalForce.first, dofIndex, nodalForce.second[dofIndex]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodalForces;
|
||||||
|
}
|
||||||
|
static SimulationResults getResults(const fea::Summary &feaSummary) {
|
||||||
|
SimulationResults results;
|
||||||
|
|
||||||
|
results.executionTime = feaSummary.total_time_in_ms * 1000;
|
||||||
|
// displacements
|
||||||
|
results.displacements.resize(feaSummary.num_nodes);
|
||||||
|
for (int vi = 0; vi < feaSummary.num_nodes; vi++) {
|
||||||
|
results.displacements[vi] = Vector6d(feaSummary.nodal_displacements[vi]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// // Convert forces
|
||||||
|
// // Convert to vector of eigen matrices of the form force component-> per
|
||||||
|
// // Edge
|
||||||
|
// const int numDof = 6;
|
||||||
|
// const size_t numberOfEdges = feaSummary.element_forces.size();
|
||||||
|
// edgeForces =
|
||||||
|
// std::vector<Eigen::VectorXd>(numDof, Eigen::VectorXd(2 *
|
||||||
|
// numberOfEdges));
|
||||||
|
// for (gsl::index edgeIndex = 0; edgeIndex < numberOfEdges; edgeIndex++) {
|
||||||
|
// for (gsl::index forceComponentIndex = 0; forceComponentIndex < numDof;
|
||||||
|
// forceComponentIndex++) {
|
||||||
|
// (edgeForces[forceComponentIndex])(2 * edgeIndex) =
|
||||||
|
// feaSummary.element_forces[edgeIndex][forceComponentIndex];
|
||||||
|
// (edgeForces[forceComponentIndex])(2 * edgeIndex + 1) =
|
||||||
|
// feaSummary.element_forces[edgeIndex][numDof +
|
||||||
|
// forceComponentIndex];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimulationResults
|
||||||
|
executeSimulation(const std::shared_ptr<SimulationJob> &simulationJob) {
|
||||||
|
assert(simulationJob->pMesh->VN() != 0);
|
||||||
|
fea::Job job(getFeaNodes(simulationJob), getFeaElements(simulationJob));
|
||||||
|
// printInfo(job);
|
||||||
|
|
||||||
|
// create the default options
|
||||||
|
fea::Options opts;
|
||||||
|
opts.save_elemental_forces = false;
|
||||||
|
opts.save_nodal_displacements = false;
|
||||||
|
opts.save_nodal_forces = false;
|
||||||
|
opts.save_report = false;
|
||||||
|
opts.save_tie_forces = false;
|
||||||
|
// if (!elementalForcesOutputFilepath.empty()) {
|
||||||
|
// opts.save_elemental_forces = true;
|
||||||
|
// opts.elemental_forces_filename = elementalForcesOutputFilepath;
|
||||||
|
// }
|
||||||
|
// if (!nodalDisplacementsOutputFilepath.empty()) {
|
||||||
|
// opts.save_nodal_displacements = true;
|
||||||
|
// opts.nodal_displacements_filename = nodalDisplacementsOutputFilepath;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// have the program output status updates
|
||||||
|
opts.verbose = false;
|
||||||
|
|
||||||
|
// form an empty vector of ties
|
||||||
|
std::vector<fea::Tie> ties;
|
||||||
|
|
||||||
|
// also create an empty list of equations
|
||||||
|
std::vector<fea::Equation> equations;
|
||||||
|
auto fixedVertices = getFeaFixedNodes(simulationJob);
|
||||||
|
auto nodalForces = getFeaNodalForces(simulationJob);
|
||||||
|
fea::Summary feaResults =
|
||||||
|
fea::solve(job, fixedVertices, nodalForces, ties, equations, opts);
|
||||||
|
|
||||||
|
SimulationResults results = getResults(feaResults);
|
||||||
|
results.job = simulationJob;
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
// SimulationResults getResults() const;
|
||||||
|
// void setResultsNodalDisplacementCSVFilepath(const std::string
|
||||||
|
// &outputPath); void setResultsElementalForcesCSVFilepath(const std::string
|
||||||
|
// &outputPath);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// std::string nodalDisplacementsOutputFilepath{"nodal_displacement.csv"};
|
||||||
|
// std::string elementalForcesOutputFilepath{"elemental_forces.csv"};
|
||||||
|
// SimulationResults results;
|
||||||
|
|
||||||
|
static void printInfo(const fea::Job &job) {
|
||||||
|
std::cout << "Details regarding the fea::Job:" << std::endl;
|
||||||
|
std::cout << "Nodes:" << std::endl;
|
||||||
|
for (fea::Node n : job.nodes) {
|
||||||
|
std::cout << n << std::endl;
|
||||||
|
}
|
||||||
|
std::cout << "Elements:" << std::endl;
|
||||||
|
for (Eigen::Vector2i e : job.elems) {
|
||||||
|
std::cout << e << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LINEARSIMULATIONMODEL_HPP
|
12
src/main.cpp
12
src/main.cpp
|
@ -1,7 +1,6 @@
|
||||||
#include "beamformfinder.hpp"
|
#include "beamformfinder.hpp"
|
||||||
#include "csvfile.hpp"
|
#include "csvfile.hpp"
|
||||||
#include "edgemesh.hpp"
|
#include "edgemesh.hpp"
|
||||||
#include "flatpattern.hpp"
|
|
||||||
#include "reducedmodeloptimizer.hpp"
|
#include "reducedmodeloptimizer.hpp"
|
||||||
#include "simulationhistoryplotter.hpp"
|
#include "simulationhistoryplotter.hpp"
|
||||||
#include "trianglepattterntopology.hpp"
|
#include "trianglepattterntopology.hpp"
|
||||||
|
@ -29,13 +28,13 @@ int main(int argc, char *argv[]) {
|
||||||
// Populate the pattern pair to be optimized
|
// Populate the pattern pair to be optimized
|
||||||
////Full pattern
|
////Full pattern
|
||||||
const std::string filepath_fullPattern = argv[1];
|
const std::string filepath_fullPattern = argv[1];
|
||||||
FlatPattern 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);
|
||||||
////Reduced pattern
|
////Reduced pattern
|
||||||
const std::string filepath_reducedPattern = argv[2];
|
const std::string filepath_reducedPattern = argv[2];
|
||||||
FlatPattern 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);
|
||||||
|
@ -44,15 +43,16 @@ int main(int argc, char *argv[]) {
|
||||||
ReducedModelOptimizer::xRange beamWidth{"B", 0.5, 1.5};
|
ReducedModelOptimizer::xRange beamWidth{"B", 0.5, 1.5};
|
||||||
ReducedModelOptimizer::xRange beamDimensionsRatio{"bOverh", 0.7, 1.3};
|
ReducedModelOptimizer::xRange beamDimensionsRatio{"bOverh", 0.7, 1.3};
|
||||||
ReducedModelOptimizer::xRange beamE{"E", 0.1, 1.9};
|
ReducedModelOptimizer::xRange beamE{"E", 0.1, 1.9};
|
||||||
ReducedModelOptimizer::xRange innerHexagonSize{"HS", 0.1, 0.9};
|
ReducedModelOptimizer::xRange innerHexagonSize{"HexSize", 0.1, 0.8};
|
||||||
|
ReducedModelOptimizer::xRange innerHexagonAngle{"HexAngle", -29.5, 29.5};
|
||||||
ReducedModelOptimizer::Settings settings_optimization;
|
ReducedModelOptimizer::Settings settings_optimization;
|
||||||
settings_optimization.xRanges = {beamWidth, beamDimensionsRatio, beamE,
|
settings_optimization.xRanges = {beamWidth, beamDimensionsRatio, beamE,
|
||||||
innerHexagonSize};
|
innerHexagonSize, innerHexagonAngle};
|
||||||
const bool input_numberOfFunctionCallsDefined = argc >= 4;
|
const bool input_numberOfFunctionCallsDefined = argc >= 4;
|
||||||
settings_optimization.numberOfFunctionCalls =
|
settings_optimization.numberOfFunctionCalls =
|
||||||
input_numberOfFunctionCallsDefined ? std::atoi(argv[3]) : 100;
|
input_numberOfFunctionCallsDefined ? std::atoi(argv[3]) : 100;
|
||||||
settings_optimization.normalizationStrategy =
|
settings_optimization.normalizationStrategy =
|
||||||
ReducedModelOptimizer::Settings::NormalizationStrategy::NonNormalized;
|
ReducedModelOptimizer::Settings::NormalizationStrategy::Epsilon;
|
||||||
settings_optimization.normalizationParameter = 0.0003;
|
settings_optimization.normalizationParameter = 0.0003;
|
||||||
settings_optimization.solutionAccuracy = 0.01;
|
settings_optimization.solutionAccuracy = 0.01;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,6 +5,7 @@
|
||||||
#include "csvfile.hpp"
|
#include "csvfile.hpp"
|
||||||
#include "edgemesh.hpp"
|
#include "edgemesh.hpp"
|
||||||
#include "elementalmesh.hpp"
|
#include "elementalmesh.hpp"
|
||||||
|
#include "linearsimulationmodel.hpp"
|
||||||
#include "matplot/matplot.h"
|
#include "matplot/matplot.h"
|
||||||
#include <Eigen/Dense>
|
#include <Eigen/Dense>
|
||||||
|
|
||||||
|
@ -23,7 +24,6 @@ class ReducedModelOptimizer {
|
||||||
m_fullPatternOppositeInterfaceViMap;
|
m_fullPatternOppositeInterfaceViMap;
|
||||||
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::vector<double> initialGuess;
|
|
||||||
#ifdef POLYSCOPE_DEFINED
|
#ifdef POLYSCOPE_DEFINED
|
||||||
struct StaticColors {
|
struct StaticColors {
|
||||||
glm::vec3 fullInitial;
|
glm::vec3 fullInitial;
|
||||||
|
@ -41,6 +41,8 @@ class ReducedModelOptimizer {
|
||||||
#endif // POLYSCOPE_DEFINED
|
#endif // POLYSCOPE_DEFINED
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
inline static int fanSize{6};
|
||||||
|
inline static VectorType patternPlaneNormal{0, 0, 1};
|
||||||
enum SimulationScenario {
|
enum SimulationScenario {
|
||||||
Axial,
|
Axial,
|
||||||
Shear,
|
Shear,
|
||||||
|
@ -49,9 +51,8 @@ public:
|
||||||
Saddle,
|
Saddle,
|
||||||
NumberOfSimulationScenarios
|
NumberOfSimulationScenarios
|
||||||
};
|
};
|
||||||
|
struct xRange{
|
||||||
struct xRange {
|
std::string label;
|
||||||
std::string label;
|
|
||||||
double min;
|
double min;
|
||||||
double max;
|
double max;
|
||||||
std::string toString() const {
|
std::string toString() const {
|
||||||
|
@ -62,9 +63,14 @@ public:
|
||||||
struct Results;
|
struct Results;
|
||||||
|
|
||||||
struct Settings {
|
struct Settings {
|
||||||
enum NormalizationStrategy { NonNormalized, Epsilon };
|
enum NormalizationStrategy {
|
||||||
|
NonNormalized,
|
||||||
|
Epsilon,
|
||||||
|
MaxDisplacement,
|
||||||
|
EqualDisplacements
|
||||||
|
};
|
||||||
inline static vector<std::string> normalizationStrategyStrings{
|
inline static vector<std::string> normalizationStrategyStrings{
|
||||||
"NonNormalized", "Epsilon"};
|
"NonNormalized", "Epsilon", "MaxDsiplacement", "EqualDisplacements"};
|
||||||
std::vector<xRange> xRanges;
|
std::vector<xRange> xRanges;
|
||||||
int numberOfFunctionCalls{100};
|
int numberOfFunctionCalls{100};
|
||||||
double solutionAccuracy{1e-2};
|
double solutionAccuracy{1e-2};
|
||||||
|
@ -110,11 +116,8 @@ public:
|
||||||
}
|
}
|
||||||
os << numberOfFunctionCalls;
|
os << numberOfFunctionCalls;
|
||||||
os << solutionAccuracy;
|
os << solutionAccuracy;
|
||||||
if (normalizationStrategy == Epsilon) {
|
os << normalizationStrategyStrings[normalizationStrategy] + "_" +
|
||||||
os << "Epsilon_" + std::to_string(normalizationParameter);
|
std::to_string(normalizationParameter);
|
||||||
} else {
|
|
||||||
os << "NonNormalized";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct Results {
|
struct Results {
|
||||||
|
@ -183,7 +186,7 @@ public:
|
||||||
const auto filepath = fileEntry.path();
|
const auto filepath = fileEntry.path();
|
||||||
if (filepath.extension() == ".json") {
|
if (filepath.extension() == ".json") {
|
||||||
SimulationJob job;
|
SimulationJob job;
|
||||||
job.load(filepath.string());
|
job.load(filepath.string());
|
||||||
reducedPatternSimulationJobs.push_back(
|
reducedPatternSimulationJobs.push_back(
|
||||||
std::make_shared<SimulationJob>(job));
|
std::make_shared<SimulationJob>(job));
|
||||||
}
|
}
|
||||||
|
@ -194,12 +197,13 @@ public:
|
||||||
void draw() const {
|
void draw() const {
|
||||||
initPolyscope();
|
initPolyscope();
|
||||||
FormFinder simulator;
|
FormFinder simulator;
|
||||||
|
LinearSimulationModel linearSimulator;
|
||||||
assert(fullPatternSimulationJobs.size() ==
|
assert(fullPatternSimulationJobs.size() ==
|
||||||
reducedPatternSimulationJobs.size());
|
reducedPatternSimulationJobs.size());
|
||||||
fullPatternSimulationJobs[0]->pMesh->registerForDrawing(
|
fullPatternSimulationJobs[0]->pMesh->registerForDrawing(
|
||||||
colors.fullInitial);
|
colors.fullInitial);
|
||||||
reducedPatternSimulationJobs[0]->pMesh->registerForDrawing(
|
reducedPatternSimulationJobs[0]->pMesh->registerForDrawing(
|
||||||
colors.reducedInitial);
|
colors.reducedInitial, false);
|
||||||
|
|
||||||
const int numberOfSimulationJobs = fullPatternSimulationJobs.size();
|
const int numberOfSimulationJobs = fullPatternSimulationJobs.size();
|
||||||
for (int simulationJobIndex = 0;
|
for (int simulationJobIndex = 0;
|
||||||
|
@ -212,14 +216,24 @@ public:
|
||||||
SimulationResults fullModelResults =
|
SimulationResults fullModelResults =
|
||||||
simulator.executeSimulation(pFullPatternSimulationJob);
|
simulator.executeSimulation(pFullPatternSimulationJob);
|
||||||
fullModelResults.registerForDrawing(colors.fullDeformed);
|
fullModelResults.registerForDrawing(colors.fullDeformed);
|
||||||
|
SimulationResults fullModelLinearResults =
|
||||||
|
linearSimulator.executeSimulation(pFullPatternSimulationJob);
|
||||||
|
fullModelLinearResults.setLabelPrefix("linear");
|
||||||
|
fullModelLinearResults.registerForDrawing(colors.fullDeformed, false);
|
||||||
// Drawing of reduced pattern results
|
// Drawing of reduced pattern results
|
||||||
const std::shared_ptr<SimulationJob> &pReducedPatternSimulationJob =
|
const std::shared_ptr<SimulationJob> &pReducedPatternSimulationJob =
|
||||||
reducedPatternSimulationJobs[simulationJobIndex];
|
reducedPatternSimulationJobs[simulationJobIndex];
|
||||||
SimulationResults reducedModelResults =
|
SimulationResults reducedModelResults =
|
||||||
simulator.executeSimulation(pReducedPatternSimulationJob);
|
simulator.executeSimulation(pReducedPatternSimulationJob);
|
||||||
reducedModelResults.registerForDrawing(colors.reducedDeformed);
|
reducedModelResults.registerForDrawing(colors.reducedDeformed);
|
||||||
|
SimulationResults reducedModelLinearResults =
|
||||||
|
linearSimulator.executeSimulation(pReducedPatternSimulationJob);
|
||||||
|
reducedModelLinearResults.setLabelPrefix("linear");
|
||||||
|
reducedModelLinearResults.registerForDrawing(colors.reducedDeformed,
|
||||||
|
false);
|
||||||
polyscope::options::programName =
|
polyscope::options::programName =
|
||||||
fullPatternSimulationJobs[0]->pMesh->getLabel();
|
fullPatternSimulationJobs[0]->pMesh->getLabel();
|
||||||
|
polyscope::view::resetCameraToHomeView();
|
||||||
polyscope::show();
|
polyscope::show();
|
||||||
// Save a screensh
|
// Save a screensh
|
||||||
const std::string screenshotFilename =
|
const std::string screenshotFilename =
|
||||||
|
@ -230,12 +244,14 @@ public:
|
||||||
polyscope::screenshot(screenshotFilename, false);
|
polyscope::screenshot(screenshotFilename, false);
|
||||||
fullModelResults.unregister();
|
fullModelResults.unregister();
|
||||||
reducedModelResults.unregister();
|
reducedModelResults.unregister();
|
||||||
|
reducedModelLinearResults.unregister();
|
||||||
|
fullModelLinearResults.unregister();
|
||||||
// double error = computeError(
|
// double error = computeError(
|
||||||
// reducedModelResults.displacements,fullModelResults.displacements,
|
// reducedModelResults.displacements,fullModelResults.displacements,
|
||||||
// );
|
// );
|
||||||
// std::cout << "Error of simulation scenario "
|
// std::cout << "Error of simulation scenario "
|
||||||
// <<
|
// <<
|
||||||
// simulationScenarioStrings[simulationScenarioIndex]
|
// simula simulationScenarioStrings[simulationScenarioIndex]
|
||||||
// << " is "
|
// << " is "
|
||||||
// << error << std::endl;
|
// << error << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -333,31 +349,29 @@ public:
|
||||||
getReducedSimulationJob(const SimulationJob &fullModelSimulationJob);
|
getReducedSimulationJob(const SimulationJob &fullModelSimulationJob);
|
||||||
|
|
||||||
void initializePatterns(
|
void initializePatterns(
|
||||||
FlatPattern &fullPattern, FlatPattern &reducedPatterm,
|
PatternGeometry &fullPattern, PatternGeometry &reducedPatterm,
|
||||||
const std::unordered_set<size_t> &reducedModelExcludedEges);
|
const std::unordered_set<size_t> &reducedModelExcludedEges);
|
||||||
|
|
||||||
void setInitialGuess(std::vector<double> v);
|
|
||||||
|
|
||||||
static void runBeamOptimization();
|
|
||||||
|
|
||||||
static void runSimulation(const std::string &filename,
|
static void runSimulation(const std::string &filename,
|
||||||
std::vector<double> &x);
|
std::vector<double> &x);
|
||||||
|
|
||||||
static double objective(double x0, double x1, double x2, double x3);
|
static double objective(double x0, double x1, double x2, double x3,
|
||||||
|
double innerHexagonRotationAngle);
|
||||||
static double objective(double b, double r, double E);
|
static double objective(double b, double r, double E);
|
||||||
|
|
||||||
static std::vector<std::shared_ptr<SimulationJob>>
|
static std::vector<std::shared_ptr<SimulationJob>>
|
||||||
createScenarios(const std::shared_ptr<SimulationMesh> &pMesh,
|
createScenarios(const std::shared_ptr<SimulationMesh> &pMesh,
|
||||||
const std::unordered_map<size_t, size_t>
|
const std::unordered_map<size_t, size_t>
|
||||||
&fullPatternOppositeInterfaceViMap);
|
&fullPatternOppositeInterfaceViMap);
|
||||||
|
|
||||||
static void createSimulationMeshes(
|
static void createSimulationMeshes(
|
||||||
FlatPattern &fullModel, FlatPattern &reducedModel,
|
PatternGeometry &fullModel, PatternGeometry &reducedModel,
|
||||||
std::shared_ptr<SimulationMesh> &pFullPatternSimulationMesh,
|
std::shared_ptr<SimulationMesh> &pFullPatternSimulationMesh,
|
||||||
std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh);
|
std::shared_ptr<SimulationMesh> &pReducedPatternSimulationMesh);
|
||||||
static void computeMaps(
|
static void computeMaps(
|
||||||
const std::unordered_set<size_t> &reducedModelExcludedEdges,
|
const std::unordered_set<size_t> &reducedModelExcludedEdges,
|
||||||
const std::unordered_map<size_t, std::unordered_set<size_t>> &slotToNode,
|
const std::unordered_map<size_t, std::unordered_set<size_t>> &slotToNode,
|
||||||
FlatPattern &fullPattern, FlatPattern &reducedPattern,
|
PatternGeometry &fullPattern, PatternGeometry &reducedPattern,
|
||||||
std::unordered_map<ReducedPatternVertexIndex, FullPatternVertexIndex>
|
std::unordered_map<ReducedPatternVertexIndex, FullPatternVertexIndex>
|
||||||
&reducedToFullInterfaceViMap,
|
&reducedToFullInterfaceViMap,
|
||||||
std::unordered_map<FullPatternVertexIndex, ReducedPatternVertexIndex>
|
std::unordered_map<FullPatternVertexIndex, ReducedPatternVertexIndex>
|
||||||
|
@ -396,17 +410,17 @@ public:
|
||||||
const double &normalizationFactor);
|
const double &normalizationFactor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void computeDesiredReducedModelDisplacements(
|
static void computeDesiredReducedModelDisplacements(
|
||||||
const SimulationResults &fullModelResults,
|
const SimulationResults &fullModelResults,
|
||||||
const std::unordered_map<size_t, size_t> &displacementsReducedToFullMap,
|
const std::unordered_map<size_t, size_t> &displacementsReducedToFullMap,
|
||||||
Eigen::MatrixX3d &optimalDisplacementsOfReducedModel);
|
Eigen::MatrixX3d &optimalDisplacementsOfReducedModel);
|
||||||
static Results runOptimization(const Settings &settings);
|
static Results runOptimization(const Settings &settings);
|
||||||
std::vector<std::shared_ptr<SimulationJob>>
|
std::vector<std::shared_ptr<SimulationJob>>
|
||||||
createScenarios(const std::shared_ptr<SimulationMesh> &pMesh);
|
createScenarios(const std::shared_ptr<SimulationMesh> &pMesh);
|
||||||
void computeMaps(FlatPattern &fullModel, FlatPattern &reducedPattern,
|
void computeMaps(PatternGeometry &fullModel, PatternGeometry &reducedPattern,
|
||||||
const std::unordered_set<size_t> &reducedModelExcludedEges);
|
const std::unordered_set<size_t> &reducedModelExcludedEges);
|
||||||
void createSimulationMeshes(FlatPattern &fullModel,
|
void createSimulationMeshes(PatternGeometry &fullModel,
|
||||||
FlatPattern &reducedModel);
|
PatternGeometry &reducedModel);
|
||||||
static void
|
static void
|
||||||
initializeOptimizationParameters(const std::shared_ptr<SimulationMesh> &mesh);
|
initializeOptimizationParameters(const std::shared_ptr<SimulationMesh> &mesh);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue