Skip to content

Commit

Permalink
Topo opt paramerization implementation and script
Browse files Browse the repository at this point in the history
  • Loading branch information
LonnieWebb committed Nov 9, 2023
1 parent 29ab45e commit 91a5fbe
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
33 changes: 29 additions & 4 deletions examples/topology_optimization_2d/2d_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,30 @@ int main(int argc, char *argv[]) {
};

index_t num_boundary_verts = 0;

switch (selected_case) {
case 0:
// Bridge Case

// Boundary vertex labels
num_boundary_verts = 2 * (ny + 1);
break;
case 1:
// Pillars Case

// Boundary vertex labels
num_boundary_verts = (nx + 1);

break;
case 2:
// Cantilever Case

// Boundary vertex labels
num_boundary_verts = (nx + 1);
break;
}

// There's a better way to do this than two switch statements
index_t boundary_verts[num_boundary_verts];

switch (selected_case) {
Expand Down Expand Up @@ -478,10 +502,11 @@ int main(int argc, char *argv[]) {
filter, analysis);

// Set up the topology optimization problem
std::string prefix = std::string("./results_") + std::to_string(nx) +
std::string("x") + std::to_string(ny) +
std::string("_") + std::to_string(fact) +
std::string("/");
std::string prefix =
std::string("./results/") + std::to_string(nx) + std::string("x") +
std::to_string(ny) + std::string("_") + std::to_string(selected_case) +
std::string("_") + std::to_string(fact) + std::string("_") +
std::to_string(bf) + std::string("/");
TopOptProb<FltrImpl_t, AnlyImpl_t> prob(prefix, comm, topo, functional,
volume, target_volume, dfdx);
prob.incref();
Expand Down
30 changes: 30 additions & 0 deletions examples/topology_optimization_2d/run_cases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Define arrays of values for each variable
ny_values=(64)
selected_case_values=(0 1)
bf_values=(5.0)
fact_values=(0.2)

# Loop through each combination of values and run the program
for ny in "${ny_values[@]}"; do
for selected_case in "${selected_case_values[@]}"; do
for bf in "${bf_values[@]}"; do
for fact in "${fact_values[@]}"; do
# Build the command
command="./2d_analysis ny=${ny} selected_case=${selected_case} bf=${bf} fact=${fact}"
echo "Running command: $command"
# Run the command
$command
# Check if the command was successful
if [ $? -ne 0 ]; then
echo "Command failed: $command"
# Uncomment the next line if you want the script to exit on failure
# exit 1
fi
done
done
done
done

echo "All combinations have been run."

0 comments on commit 91a5fbe

Please sign in to comment.