-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Feature/add ofeli #8375
Feature/add ofeli #8375
Changes from all commits
cb9a9ea
6b54bff
3b51608
d46ea7d
ba0b21a
9ca059b
841c607
692c3f7
e01d2f2
3bc7aac
4f0dcc8
351fd9e
a7cb9ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.4) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory("source_subfolder") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"4.1.2": | ||
url: "https://github.com/rtouzani/ofeli/releases/download/ofeli-4.1.2/ofeli-4.1.2.tar.gz" | ||
sha256: "672723856be984b6ea423976c4d13748e327f04e6571694cd662bcda1ed1f8d4" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from conans import ConanFile, tools, AutoToolsBuildEnvironment | ||
import os | ||
from conans.errors import ConanInvalidConfiguration | ||
|
||
required_conan_version = ">=1.40.0" | ||
|
||
|
||
class OfeliConan(ConanFile): | ||
name = "ofeli" | ||
description = "An Object Finite Element Library" | ||
topics = ("ofeli", "finite element", "finite element library", | ||
"finite element analysis", "finite element solver") | ||
license = "LGPL-3.0-or-later" | ||
homepage = "http://ofeli.org/index.html" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
settings = "os", "arch", "compiler", "build_type" | ||
_autotools = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _doc_folder(self): | ||
return os.path.join( | ||
self._source_subfolder, | ||
"doc" | ||
) | ||
|
||
def validate(self): | ||
if self.settings.os != "Linux": | ||
raise ConanInvalidConfiguration( | ||
"Ofeli is just supported for Linux") | ||
if self.settings.compiler != "gcc": | ||
raise ConanInvalidConfiguration( | ||
"Ofeli is just supported for GCC") | ||
if self.settings.compiler.cppstd: | ||
tools.check_min_cppstd(self, 11) | ||
if self.settings.compiler.libcxx != "libstdc++11": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which scenario it doesn't work? I'm able to with gcc and libstdc++ without any error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cf #8375 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for these details! |
||
raise ConanInvalidConfiguration( | ||
"Ofeli supports only libstdc++'s new ABI") | ||
|
||
Kr4is marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], | ||
strip_root=True, destination=self._source_subfolder) | ||
|
||
def _configure_autotools(self): | ||
if self._autotools: | ||
return self._autotools | ||
self._autotools = AutoToolsBuildEnvironment(self) | ||
self._autotools.configure(args=["--enable-%s" % ("release" | ||
if self.settings.build_type == "Release" | ||
else "debug")]) | ||
return self._autotools | ||
|
||
def build(self): | ||
with tools.chdir(self._source_subfolder): | ||
autotools = self._configure_autotools() | ||
autotools.make() | ||
|
||
def package(self): | ||
self.copy("*.h", dst="include", | ||
src=os.path.join(self._source_subfolder, "include")) | ||
self.copy("*libofeli.a", dst="lib", | ||
src=os.path.join(self._source_subfolder, "src")) | ||
self.copy("*.md", dst="res", | ||
src=os.path.join(self._source_subfolder, "material")) | ||
self.copy("COPYING", dst="licenses", src=self._doc_folder) | ||
|
||
def package_info(self): | ||
self.cpp_info.names["cmake_find_package"] = "Ofeli" | ||
self.cpp_info.names["cmake_find_package_multi"] = "Ofeli" | ||
Comment on lines
+71
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where does it come from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Master branch offers cmake support, but still is all lowercase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix available on #9050 |
||
self.cpp_info.libs = ["ofeli"] | ||
self.env_info.OFELI_PATH_MATERIAL.append( | ||
os.path.join(self.package_folder, "res")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.4) | ||
project(test_package LANGUAGES CXX) | ||
|
||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} CONAN_PKG::ofeli) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/*============================================================================== | ||
|
||
O F E L I | ||
|
||
Object Finite Element Library | ||
|
||
============================================================================== | ||
|
||
Copyright (C) 1998 - 2015 Rachid Touzani | ||
|
||
This file is part of OFELI. | ||
|
||
OFELI is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
OFELI is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with OFELI. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
============================================================================== | ||
|
||
An example of a Finite Element Code using OFELI | ||
|
||
Solution of a 1-D Elliptic problem using P1 Finite elements | ||
|
||
==============================================================================*/ | ||
|
||
#include "OFELI.h" | ||
using namespace OFELI; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
double L=1; | ||
int N=10; | ||
|
||
/// Read and output mesh data | ||
banner(); | ||
if (argc>1) | ||
N = atoi(argv[1]); | ||
Mesh ms(L,N); | ||
int NbN = N+1; | ||
|
||
// Declare problem data (matrix, rhs, boundary conditions, body forces) | ||
TrMatrix<double> A(NbN); | ||
Vect<double> b(ms); | ||
b.set("16*pi*pi*sin(4*pi*x)"); | ||
|
||
// Build matrix and R.H.S. | ||
double h = L/double(N); | ||
b *= h; | ||
for (int i=2; i<NbN; i++) { | ||
A(i,i ) = 2./h; | ||
A(i,i+1) = -1./h; | ||
A(i,i-1) = -1./h; | ||
} | ||
|
||
// Impose boundary conditions | ||
A(1,1) = 1.; A(1,2) = 0.; b(1) = 0; | ||
A(NbN,NbN) = 1.; A(NbN-1,NbN) = 0.; b(NbN) = 0; | ||
|
||
// Solve the linear system of equations | ||
A.solve(b); | ||
|
||
// Output solution and error | ||
cout << "\nSolution:\n" << b; | ||
Vect<double> sol(ms); | ||
sol.set("sin(4*pi*x)"); | ||
cout << "Error = " << (b-sol).getNormMax() << endl; | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"4.1.2": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search engine interprets space as different topics.