Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libheinz 2.0.0 (new formula) libformfactor 0.3.1 (new formula) #202225

Merged
merged 4 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions Formula/lib/libformfactor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
class Libformfactor < Formula
desc "C++ library for the efficient computation of scattering form factors"
homepage "https://jugit.fz-juelich.de/mlz/libformfactor"
url "https://jugit.fz-juelich.de/mlz/libformfactor/-/archive/v0.3.1/libformfactor-v0.3.1.tar.bz2"
sha256 "fc629a3e843e920b250393b0072f6673e26783b0776e8f08523534875950f298"
license "GPL-3.0-or-later"

depends_on "cmake" => :build
depends_on "libheinz"

def install
system "cmake", "-S", ".", "-B", "build",
"-DLibHeinz_DIR=#{Formula["libheinz"].opt_prefix}/cmake",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end

test do
(testpath/"fftest.cpp").write <<~CPP
#include <ff/Face.h>
#include <ff/Prism.h>
#include <ff/Polyhedron.h>
#include <cmath> // abs
bool CHECK_NEAR(const double value, const double expected, const double tol)
{
return std::abs(value - expected) <= tol;
}
bool test_asPolyhedron_prism()
{
ff::Prism prism(false, 1, {{-0.5, -0.5, 0}, {-0.5, 0.5, 0}, {0.5, 0.5, 0}, {0.5, -0.5, 0}});
ff::Polyhedron* polyhedron = prism.asPolyhedron();
const bool test0 = (polyhedron->faces().size() == 6);
const bool test1 = CHECK_NEAR(polyhedron->vertices()[4].z(), 0.5, 1E-13);
const bool test2 = CHECK_NEAR(polyhedron->vertices()[5].z(), 0.5, 1E-13);
const bool test3 = CHECK_NEAR(polyhedron->vertices()[6].z(), 0.5, 1E-13);
const bool test4 = CHECK_NEAR(polyhedron->vertices()[7].z(), 0.5, 1E-13);
return test0 && test1 && test2 && test3 && test4;
}
bool test_faceCenter_CenteredRectangle()
{
// FaceCenter:CenteredRectangle
ff::Face face({{-0.5, -1.4, 0}, {-0.5, 1.4, 0}, {0.5, 1.4, 0}, {0.5, -1.4, 0}}, true);
const R3 center = face.center_of_polygon();
const bool test1 = std::abs(center.x()) <= 1e-13;
const bool test2 = std::abs(center.y()) <= 1e-13;
const bool test3 = std::abs(center.z()) <= 1e-13;
return test1 && test2 && test3;
}
int main()
{
const bool all_tests = test_asPolyhedron_prism() && test_faceCenter_CenteredRectangle();
return all_tests? 0 : 1;
}
CPP

system ENV.cxx, "-std=c++17", "fftest.cpp", "-I#{include}", "-L#{lib}", "-lformfactor", "-o", "fftest"
system "./fftest"
end
end
34 changes: 34 additions & 0 deletions Formula/lib/libheinz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Libheinz < Formula
desc "C++ base library of Heinz Maier-Leibnitz Zentrum"
homepage "https://jugit.fz-juelich.de/mlz/libheinz"
url "https://jugit.fz-juelich.de/mlz/libheinz/-/archive/v2.0.0/libheinz-v2.0.0.tar.bz2"
sha256 "e1e67da3997de1c28e60a9c5c7a45e383526b0fa18aefbb6e7c7d671b487da8a"
license "0BSD"

depends_on "cmake" => :build

def install
system "cmake", "-S", ".", "-B", "build", *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end

test do
(testpath/"test.cpp").write <<~CPP
#include <heinz/Vectors3D.h>
#include <iostream>

int main() {
R3 vector(1.0, 2.0, 3.0);
if (vector.x() == 1.0 && vector.y() == 2.0 && vector.z() == 3.0) {
std::cout << "Success" << std::endl;
return 0;
}
return 1;
}
CPP

system ENV.cxx, "-std=c++17", "test.cpp", "-I#{include}", "-o", "test"
system "./test"
end
end
Loading