Skip to content

Commit

Permalink
wip - vlm now compiles
Browse files Browse the repository at this point in the history
but still doesnt work.
  • Loading branch information
samayala22 committed Aug 5, 2024
1 parent 3d7306a commit c6eb145
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 366 deletions.
15 changes: 3 additions & 12 deletions tests/test_vlm_elliptic_coeffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,16 @@ int main(int /*argc*/, char ** /*argv*/) {
const std::vector<std::string> backends = get_available_backends();
std::vector<f32> test_alphas = {0, 1, 2, 3, 4, 5, 10, 15};
std::transform(test_alphas.begin(), test_alphas.end(), test_alphas.begin(), to_radians);

const MeshIO mesh_io{"plot3d"};
MeshGeom mesh_geom{}; // DEPRECATE

auto solvers = tiny::make_combination(meshes, backends);
for (const auto& [mesh_name, backend_name] : solvers) {
std::printf(">>> MESH: %s | BACKEND: %s\n", mesh_name.get().c_str(), backend_name.get().c_str());

auto dims = mesh_io.get_dims(mesh_name);
// LinearVLM solver{backend_name, }

mesh_io_read_file(mesh_name, &mesh_geom); // DEPRECATE
mesh_quarterchord(&mesh_geom); // DEPRECATE
LinearVLM solver{create_backend(backend_name, &mesh_geom, 1)};
VLM simulation{backend_name, {mesh_name}};

for (u64 i = 0; i < test_alphas.size(); i++) {
const FlowData flow{test_alphas[i], 0.0f, 1.0f, 1.0f};
const auto coeffs = solver.solve(flow);
const auto coeffs = simulation.run(flow);
const f32 analytical_cl = compute_analytical_cl(flow.alpha, a, b);
const f32 analytical_cd = compute_analytical_cd(analytical_cl, a, b);
const f32 cl_aerr = std::abs(coeffs.cl - analytical_cl);
Expand All @@ -142,8 +135,6 @@ int main(int /*argc*/, char ** /*argv*/) {
std::printf(">>> Analytical CD: %.7f | Abs Error: %.3E | Relative Error: %.5f%% \n", analytical_cd, cd_aerr, cd_rerr*100.f);
if (cl_rerr > 0.03f || cd_rerr > 0.03f) return 1;
}

delete[] mesh_geom.vertices;
}
return 0;
}
11 changes: 6 additions & 5 deletions vlm/backends/cpu/include/vlm_backend_cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ class BackendCPU final : public Backend {
void rhs_assemble_wake_influence(View<f32, MultiSurface>& rhs, const View<f32, MultiSurface>& gamma, const View<f32, MultiSurface>& colloc, const View<f32, MultiSurface>& normals, const View<f32, MultiSurface>& verts_wake, u32 iteration) override;
void displace_wake_rollup(View<f32, MultiSurface>& wake_rollup, const View<f32, MultiSurface>& verts_wake, const View<f32, MultiSurface>& verts_wing, const View<f32, MultiSurface>& gamma_wing, const View<f32, MultiSurface>& gamma_wake, f32 dt, u32 iteration) override;
// void displace_wing(const linalg::alias::float4x4& transform) override;
void displace_wing_and_shed(const std::vector<linalg::alias::float4x4>& transform, View<f32, MultiSurface>& verts_wing, View<f32, MultiSurface>& verts_wake) override;
void displace_wing(const std::vector<linalg::alias::float4x4>& transforms, View<f32, MultiSurface>& verts_wing, View<f32, MultiSurface>& verts_wing_init) override;
void wake_shed(const View<f32, MultiSurface>& verts_wing, View<f32, MultiSurface>& verts_wake, u32 iteration) override;
void gamma_shed(View<f32, MultiSurface>& gamma_wing, View<f32, MultiSurface>& gamma_wing_prev, View<f32, MultiSurface>& gamma_wake, u32 iteration) override;
void gamma_delta(View<f32, MultiSurface>& gamma_delta, const View<f32, MultiSurface>& gamma) override;
void lu_allocate(View<f32, Matrix<MatrixLayout::ColMajor>>& lhs) override;
void lu_factor(View<f32, Matrix<MatrixLayout::ColMajor>>& lhs) override;
void lu_solve(View<f32, Matrix<MatrixLayout::ColMajor>>& lhs, View<f32, MultiSurface>& rhs, View<f32, MultiSurface>& gamma) override;

// Per mesh kernels
f32 coeff_steady_cl_single(const View<f32, SingleSurface>& verts_wing, const View<f32, SingleSurface>& gamma_delta, const FlowData& flow, f32 area) override;
f32 coeff_steady_cl_multi(const View<f32, MultiSurface>& verts_wing, const View<f32, MultiSurface>& areas, const View<f32, MultiSurface>& gamma_delta, const FlowData& flow) override;
f32 coeff_unsteady_cl_single(const View<f32, SingleSurface>& verts_wing, const View<f32, SingleSurface>& gamma_delta, const View<f32, SingleSurface>& gamma, const View<f32, SingleSurface>& gamma_prev, const View<f32, SingleSurface>& local_velocities, const View<f32, SingleSurface>& areas, const View<f32, SingleSurface>& normals, const linalg::alias::float3& freestream, f32 dt, f32 area) override;
f32 coeff_unsteady_cl_multi(const View<f32, MultiSurface>& verts_wing, const View<f32, MultiSurface>& areas, const View<f32, MultiSurface>& gamma_delta, const View<f32, MultiSurface>& gamma, const View<f32, MultiSurface>& gamma_prev, const View<f32, MultiSurface>& local_velocities, const View<f32, MultiSurface>& normals, const linalg::alias::float3& freestream, f32 dt) override;
// f32 coeff_unsteady_cl_single(const View<f32, SingleSurface>& verts_wing, const View<f32, SingleSurface>& gamma_delta, const View<f32, SingleSurface>& gamma, const View<f32, SingleSurface>& gamma_prev, const View<f32, SingleSurface>& local_velocities, const View<f32, SingleSurface>& areas, const View<f32, SingleSurface>& normals, const linalg::alias::float3& freestream, f32 dt, f32 area) override;
// f32 coeff_unsteady_cl_multi(const View<f32, MultiSurface>& verts_wing, const View<f32, MultiSurface>& areas, const View<f32, MultiSurface>& gamma_delta, const View<f32, MultiSurface>& gamma, const View<f32, MultiSurface>& gamma_prev, const View<f32, MultiSurface>& local_velocities, const View<f32, MultiSurface>& normals, const linalg::alias::float3& freestream, f32 dt) override;
// linalg::alias::float3 coeff_steady_cm(const FlowData& flow, const f32 area, const f32 chord, const u64 j, const u64 n) override;
// f32 coeff_steady_cd(const FlowData& flow, const f32 area, const u64 j, const u64 n) override;

void mesh_metrics(const f32 alpha_rad, const View<f32, MultiSurface>& verts_wing, View<f32, MultiSurface>& colloc, View<f32, MultiSurface>& normals, View<f32, MultiSurface>& areas) override;
// f32 mesh_mac(const u64 j, const u64 n) override;
// f32 mesh_area(const u64 i, const u64 j, const u64 m, const u64 n) override;
f32 mesh_mac(const View<f32, SingleSurface>& verts_wing, const View<f32, SingleSurface>& areas) override;
};

} // namespace vlm
Loading

0 comments on commit c6eb145

Please sign in to comment.