Skip to content

Commit 0d8cb2c

Browse files
committed
update polyfem
1 parent 4f15f37 commit 0d8cb2c

11 files changed

+834
-797
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
################################################################################
22
# Check required CMake version
3-
set(REQUIRED_CMAKE_VERSION "3.14.0")
3+
set(REQUIRED_CMAKE_VERSION "3.25.0")
44
cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})
55

66
if(INPUT_POLYFEMPY_DATA_ROOT)
@@ -13,11 +13,18 @@ if(NOT EXISTS ${POLYFEMPY_DATA_ROOT})
1313
endif()
1414

1515
project(polyfempy)
16+
17+
set(CMAKE_CXX_STANDARD 17)
18+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
19+
set(CMAKE_CXX_EXTENSIONS OFF)
20+
1621
################################################################################
1722

1823
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1924
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/recipes/")
2025

26+
include(polyfem_cpm_cache)
27+
2128
# Color output
2229
include(UseColors)
2330

cmake/recipes/CPM.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
set(CPM_DOWNLOAD_VERSION 0.39.0)
2+
3+
if(CPM_SOURCE_CACHE)
4+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
5+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
6+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
7+
else()
8+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9+
endif()
10+
11+
# Expand relative path. This is important if the provided path contains a tilde (~)
12+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
13+
14+
function(download_cpm)
15+
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
16+
file(DOWNLOAD
17+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
18+
${CPM_DOWNLOAD_LOCATION}
19+
)
20+
endfunction()
21+
22+
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
23+
download_cpm()
24+
else()
25+
# resume download if it previously failed
26+
file(READ ${CPM_DOWNLOAD_LOCATION} check)
27+
if("${check}" STREQUAL "")
28+
download_cpm()
29+
endif()
30+
unset(check)
31+
endif()
32+
33+
include(${CPM_DOWNLOAD_LOCATION})

cmake/recipes/polyfem.cmake

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ endif()
77

88
message(STATUS "Third-party: creating target 'polyfem::polyfem'")
99

10-
include(FetchContent)
11-
FetchContent_Declare(
12-
polyfem
13-
GIT_REPOSITORY https://github.com/polyfem/polyfem.git
14-
GIT_TAG 12ac634833f91a3946cff26db01972fdb2ec3214
15-
GIT_SHALLOW FALSE
16-
)
17-
FetchContent_MakeAvailable(polyfem)
18-
10+
# include(FetchContent)
11+
# FetchContent_Declare(
12+
# polyfem
13+
# GIT_REPOSITORY https://github.com/polyfem/polyfem.git
14+
# GIT_TAG 07ee824f836c445699bbc47ee6f19afbfe39bad4
15+
# GIT_SHALLOW FALSE
16+
# )
17+
# FetchContent_MakeAvailable(polyfem)
1918

19+
include(CPM)
20+
CPMAddPackage("gh:polyfem/polyfem#07ee824f836c445699bbc47ee6f19afbfe39bad4")

cmake/recipes/polyfem_cpm_cache.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Copyright 2021 Adobe. All rights reserved.
3+
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License. You may obtain a copy
5+
# of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software distributed under
8+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
# OF ANY KIND, either express or implied. See the License for the specific language
10+
# governing permissions and limitations under the License.
11+
#
12+
13+
if(DEFINED ENV{CPM_SOURCE_CACHE})
14+
set(CPM_SOURCE_CACHE_DEFAULT $ENV{CPM_SOURCE_CACHE})
15+
else()
16+
# Set CPM cache folder if unset
17+
file(REAL_PATH "~/.cache/CPM" CPM_SOURCE_CACHE_DEFAULT EXPAND_TILDE)
18+
endif()
19+
20+
set(CPM_SOURCE_CACHE
21+
${CPM_SOURCE_CACHE_DEFAULT}
22+
CACHE PATH "Directory to download CPM dependencies"
23+
)
24+
message(STATUS "Using CPM cache folder: ${CPM_SOURCE_CACHE}")

cmake/recipes/polyfem_data.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include(FetchContent)
77
FetchContent_Declare(
88
polyfem_data
99
GIT_REPOSITORY https://github.com/polyfem/polyfem-data
10-
GIT_TAG 29a46df1fd90c237a82c219f346a956e72bd17d3
10+
GIT_TAG f2089eb6eaa22071f7490e0f144e10afe85d4eba
1111
GIT_SHALLOW FALSE
1212
SOURCE_DIR ${POLYFEMPY_DATA_ROOT}
1313
)

cmake/recipes/pybind11.cmake

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
#
2-
# Copyright 2020 Adobe. All rights reserved.
3-
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License. You may obtain a copy
5-
# of the License at http://www.apache.org/licenses/LICENSE-2.0
6-
#
7-
# Unless required by applicable law or agreed to in writing, software distributed under
8-
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9-
# OF ANY KIND, either express or implied. See the License for the specific language
10-
# governing permissions and limitations under the License.
11-
#
1+
# pybind11 (https://github.com/pybind/pybind11)
2+
# License: BSD-style
123
if(TARGET pybind11::pybind11)
134
return()
145
endif()
156

167
message(STATUS "Third-party: creating target 'pybind11::pybind11'")
178

18-
include(FetchContent)
19-
FetchContent_Declare(
20-
pybind11
21-
GIT_REPOSITORY https://github.com/pybind/pybind11.git
22-
GIT_TAG v2.9.2
23-
GIT_SHALLOW FALSE
24-
)
25-
269
if (POLICY CMP0094) # https://cmake.org/cmake/help/latest/policy/CMP0094.html
2710
cmake_policy(SET CMP0094 NEW) # FindPython should return the first matching Python
2811
endif ()
@@ -39,7 +22,8 @@ endif ()
3922
# Pybind11 still uses the deprecated FindPythonInterp. So let's call CMake's
4023
# new FindPython module and set PYTHON_EXECUTABLE for Pybind11 to pick up.
4124
# This works well with conda environments.
42-
find_package(Python REQUIRED COMPONENTS Interpreter Development)
25+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
4326
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
4427

45-
FetchContent_MakeAvailable(pybind11)
28+
include(CPM)
29+
CPMAddPackage("gh:pybind/pybind11@2.9.2")

polyfempy/Settings.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ def __init__(self, discr_order=1, pressure_discr_order=1, pde=polyfempy.PDEs.Lap
1414

1515
self.BDF_order = 1
1616

17-
self.scalar_formulation = "Laplacian"
18-
self.tensor_formulation = "LinearElasticity"
17+
self.formulation = "Laplacian"
1918
self.has_collision = contact_problem
2019
self.BDF_order = BDF_order
2120

@@ -39,7 +38,6 @@ def __init__(self, discr_order=1, pressure_discr_order=1, pde=polyfempy.PDEs.Lap
3938
self.pde = pde
4039

4140
self.selection = None
42-
raise RuntimeError("Old Version Deprecated. Use version <0.5.2 on conda for the old interface")
4341

4442
def get_problem(self):
4543
"""Get the problem"""
@@ -62,23 +60,13 @@ def set_problem(self, problem):
6260

6361
def get_pde(self, pde):
6462
"""Get the PDE"""
65-
if self._is_scalar:
66-
return self.scalar_formulation
67-
else:
68-
self.tensor_formulation
63+
return self.formulation
6964

7065
def set_pde(self, pde):
7166
"""Sets the PDE to solve, use any of the polyfempy.PDEs"""
7267

73-
if pde == "NonLinearElasticity":
74-
pde = "NeoHookean"
75-
7668
self._is_scalar = not polyfempy.polyfempy.is_tensor(pde)
77-
78-
if self._is_scalar:
79-
self.scalar_formulation = pde
80-
else:
81-
self.tensor_formulation = pde
69+
self.formulation = pde
8270

8371
def set_material_params(self, name, value):
8472
"""set the material parameters, for instance set_material_params("E", 200) sets the Young's modulus E to 200. See https://polyfem.github.io/documentation/#formulations for full list"""

polyfempy/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from .polyfempy import Solver
22
from .polyfempy import PDEs
3-
from .polyfempy import ScalarFormulations
4-
from .polyfempy import TensorFormulations
5-
from .polyfempy import solve_febio
6-
from .polyfempy import solve
3+
# from .polyfempy import ScalarFormulations
4+
# from .polyfempy import TensorFormulations
5+
# from .polyfempy import solve_febio
6+
# from .polyfempy import solve
77

88
from .Settings import Settings
99
from .Selection import Selection

0 commit comments

Comments
 (0)