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

Viezly #1

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8a41a39
First implementation metadata report
danielandresarcones May 9, 2023
19c4133
Testing sensor metadata reporting
danielandresarcones May 9, 2023
cc96dc7
Fix format and units
danielandresarcones May 9, 2023
e06cd40
Fixed units for push tests
danielandresarcones May 9, 2023
4dc82e8
Initial schema
danielandresarcones May 9, 2023
d519065
Implemented sensor metadata report and schema
danielandresarcones May 10, 2023
bae469d
Validation of sensors against schema
danielandresarcones May 11, 2023
78b8d3b
Updated environment
danielandresarcones May 11, 2023
b909283
Fixed test_sensor
danielandresarcones May 11, 2023
aa7bb1c
Initial rebuilding sensor
danielandresarcones May 11, 2023
b039860
Rebuild sensors works without units
danielandresarcones May 12, 2023
6e1caad
Set units in rebuilt sensors
danielandresarcones May 12, 2023
a4a46a1
Delete settings.json
danielandresarcones May 12, 2023
0612020
Merge branch '79-add-random-field-feature' of https://github.com/BAMr…
danielandresarcones May 12, 2023
d8d88d0
Initial GRF translation
danielandresarcones May 12, 2023
05e76bb
Working GRF problem
danielandresarcones May 12, 2023
452cc0a
Modified paraview output
danielandresarcones May 15, 2023
d75f441
Made DisplacementSensor JSON serializable
danielandresarcones May 15, 2023
ed89c6a
GRF parameters as input
danielandresarcones May 15, 2023
cf9154d
Descriptive names to ReactionForceSensors in test
danielandresarcones May 17, 2023
e7c91ae
Updated ReactionForceSensor for reproductibility
danielandresarcones May 17, 2023
216e4e2
Merge branch 'main' into 104-report-sensor-metadata
danielandresarcones May 17, 2023
4639954
Update format of merge
danielandresarcones May 17, 2023
ddf2564
Moved local repo
danielandresarcones May 22, 2023
d39bf08
Test sensor schema completeness
danielandresarcones May 22, 2023
1460591
Test sensor schema
danielandresarcones May 31, 2023
8fbcff7
Merge branch '104-report-sensor-metadata' of https://github.com/BAMre…
danielandresarcones May 31, 2023
4e52050
Revert "Moved local repo"
danielandresarcones May 31, 2023
6d51f4e
Merge branch '104-report-sensor-metadata' into my-grf
danielandresarcones May 31, 2023
5b83290
Updated with new solution fields
danielandresarcones May 31, 2023
dadc43a
Added deepcopy method to SensorDict
danielandresarcones Aug 18, 2023
624caee
122 make sure that parameter have correct units (#141)
aradermacher Oct 5, 2023
a41414a
Set dolfinx version to 0.6.0 (#144)
srosenbu Oct 25, 2023
8866fc8
Update environment.yml
danielandresarcones Dec 6, 2023
5f96c11
Added temperature to quadrature field
danielandresarcones Jan 31, 2024
34baf42
Merge branch 'my-grf' of https://github.com/danielandresarcones/Fenic…
danielandresarcones Jan 31, 2024
d799cbf
Merge branch 'main' into my-grf
danielandresarcones Jan 31, 2024
4347af5
Not check dimensions for bool
danielandresarcones Feb 1, 2024
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
4,908 changes: 4,908 additions & 0 deletions conda-lock.yml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/examples/3_point_bending.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Setting up the Beam
# -------------------
# First, initialize the setup for the simply supported beam with a distributed load.
# Define the geometry, the mesh, and the load.
# Define the geometry, the mesh, and the load. Not defined parameters are set to default values (from class function default_parameters).
# Note, all parameters must be pint objects:

parameters = {}
Expand All @@ -36,6 +36,7 @@
# Initializing the Linear Elasticity Problem
# ------------------------------------------
# Second, initialize the linear elastic problem using the setup object and further material parameters:
# Again not defined parameters are set to default values (from class function default_parameters).

parameters["rho"] = 7750 * ureg("kg/m^3")
parameters["E"] = 210e9 * ureg("N/m^2")
Expand Down
1 change: 1 addition & 0 deletions docs/examples/cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# * `mesh_density` (mesh density) in 1/m
#
# The parameters must be defined as `pint` objects
# Parameters required but not defined are set to default values (from class function default_parameters).
#
# Example code
# ------------
Expand Down
28 changes: 25 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,30 @@ channels:
- conda-forge
dependencies:
- python>=3.10
- pip
# runtime
- fenics-dolfinx=0.6.0
- mpi4py=3.1.4
- scipy
- pint
- matplotlib
- python-gmsh=4.11.1
- meshio=5.3.4
- jsonschema
# tests
- pytest
- coverage
- toml
# docs
- sphinx
- sphinx-gallery
- myst-parser
- sphinx_rtd_theme
# environment
- conda-ecosystem-user-package-isolation
- fenics-dolfinx
# formatting
- black
- isort
- pip
- pip:
- -e .[tests,docs]
- -e .

14 changes: 4 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,17 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"fenics-dolfinx",
"pint",
"gmsh",
"jsonschema",
"scipy",
]
dependencies = []
description = "Implementation of structural problems for concrete structures using FEniCSx"
license = {file = "LICENSE"}
name = "fenicsxconcrete"
readme = "REAMDE.md"
requires-python = ">=3.10"
version = "0.0.8"

[project.optional-dependencies]
tests = ["pytest", "coverage", "toml"]
docs = ["sphinx", "sphinx-gallery", "sphinx-rtd-theme", "myst-parser", "matplotlib"]
#[project.optional-dependencies]
#tests = ["pytest", "coverage", "toml"]
#docs = ["sphinx", "sphinx-gallery", "sphinx-rtd-theme", "myst-parser", "matplotlib"]

[project.urls]
repository = "https://github.com/BAMresearch/FenicsXConcrete.git"
Expand Down
9 changes: 2 additions & 7 deletions src/fenicsxconcrete/experimental_setup/am_multiple_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ def __init__(self, parameters: dict[str, pint.Quantity]):

"""

# initialize default parameters for the setup
default_p = Parameters()
# default_p['dummy'] = 'example' * ureg('') # example default parameter for this class

# updating parameters, overriding defaults
default_p.update(parameters)
super().__init__(default_p)
super().__init__(parameters)

@staticmethod
def default_parameters() -> dict[str, pint.Quantity]:
Expand All @@ -52,6 +46,7 @@ def default_parameters() -> dict[str, pint.Quantity]:
"""

setup_parameters = {}
setup_parameters["degree"] = 2 * ureg("") # polynomial degree
# geometry
setup_parameters["dim"] = 2 * ureg("")
setup_parameters["num_layers"] = 10 * ureg("") # number of layers in y
Expand Down
31 changes: 26 additions & 5 deletions src/fenicsxconcrete/experimental_setup/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,33 @@ def __init__(self, parameters: dict[str, pint.Quantity]) -> None:
"""

# initialize parameter attributes
default_setup_parameters = Parameters()
# setting up default setup parameters
default_setup_parameters["degree"] = 2 * ureg("") # polynomial degree
setup_parameters = Parameters()

# setting up default setup parameters defined in each child
default_p = self.default_parameters()
setup_parameters.update(default_p)
# update with input parameters
default_setup_parameters.update(parameters)
setup_parameters.update(parameters)

# get logger info which parameters are set to default values
# plus check dimensionality of input parameters
keys_set_default = []
for key in dict(default_p):
if key not in parameters:
keys_set_default.append(key)
else:
# check if units are compatible
dim_given = parameters[key].dimensionality
dim_default = default_p[key].dimensionality
if dim_given != dim_default:
raise ValueError(
f"given units for {key} are not compatible with default units: {dim_given} != {dim_default}"
)
self.logger.info(f"for the following parameters, the default values are used: {keys_set_default}")

# as attribute
self.parameters = default_setup_parameters
self.parameters = setup_parameters

# remove units for use in fem model
self.p = self.parameters.to_magnitude()

Expand All @@ -59,6 +78,8 @@ def default_parameters() -> dict[str, pint.Quantity]:

"""

pass

@abstractmethod
def create_displacement_boundary(self, V: df.fem.FunctionSpace) -> list[df.fem.bcs.DirichletBCMetaClass] | None:
"""defines empty displacement boundary conditions (to be done in child)
Expand Down
10 changes: 2 additions & 8 deletions src/fenicsxconcrete/experimental_setup/cantilever_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ def __init__(self, parameters: dict[str, pint.Quantity] | None = None):

"""

# initialize default parameters for the setup
default_p = Parameters()
# default_p['dummy'] = 'example' * ureg('') # example default parameter for this class

# updating parameters, overriding defaults
default_p.update(parameters)

super().__init__(default_p)
super().__init__(parameters)

def setup(self) -> None:
"""defines the mesh for 2D or 3D
Expand Down Expand Up @@ -77,6 +70,7 @@ def default_parameters() -> dict[str, pint.Quantity]:
"""

setup_parameters = {}

setup_parameters["length"] = 1 * ureg("m")
setup_parameters["height"] = 0.3 * ureg("m")
setup_parameters["width"] = 0.3 * ureg("m") # only relevant for 3D case
Expand Down
10 changes: 3 additions & 7 deletions src/fenicsxconcrete/experimental_setup/compression_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ def __init__(self, parameters: dict[str, pint.Quantity] | None = None) -> None:

"""

# initialize a set of default parameters
p = Parameters()

p.update(parameters)

super().__init__(p)
super().__init__(parameters)

# initialize variable top_displacement
self.top_displacement = df.fem.Constant(domain=self.mesh, c=0.0) # applied via fkt: apply_displ_load(...)
Expand Down Expand Up @@ -127,7 +122,7 @@ def setup(self) -> None:
# until the bottom surface area matches that of a circle with the initially defined radius
def create_cylinder_mesh(radius, p):
# generate cylinder mesh using gmsh
mesh = generate_cylinder_mesh(radius, p["height"], p["mesh_density"], p["degree"])
mesh = generate_cylinder_mesh(radius, p["height"], p["mesh_density"], p["element_order"])
facets = df.mesh.locate_entities_boundary(mesh, 2, plane_at(0.0, 2))
tdim = mesh.topology.dim
f_v = mesh.topology.connectivity(tdim - 1, 0).array.reshape(-1, 3)
Expand Down Expand Up @@ -169,6 +164,7 @@ def default_parameters() -> dict[str, pint.Quantity]:
"""

default_parameters = {}
default_parameters["element_order"] = 2 * ureg("") # polynomial degree

# boundary setting
default_parameters["bc_setting"] = "free" * ureg("") # boundary setting, two options available: fixed and free
Expand Down
10 changes: 2 additions & 8 deletions src/fenicsxconcrete/experimental_setup/simple_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ def __init__(self, parameters: dict[str, pint.Quantity]) -> None:

"""

# initialize default parameters for the setup
default_p = Parameters()
default_p["degree"] = 2 * ureg("") # polynomial degree

# updating parameters, overriding defaults
default_p.update(parameters)

super().__init__(default_p)
super().__init__(parameters)

def setup(self):
"""defines the mesh for 2D or 3D
Expand Down Expand Up @@ -81,6 +74,7 @@ def default_parameters() -> dict[str, pint.Quantity]:
"""

setup_parameters = {}

setup_parameters["load"] = 10000 * ureg("N/m^2")
setup_parameters["length"] = 1 * ureg("m")
setup_parameters["height"] = 0.3 * ureg("m")
Expand Down
19 changes: 7 additions & 12 deletions src/fenicsxconcrete/experimental_setup/simple_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from fenicsxconcrete.boundary_conditions.bcs import BoundaryConditions
from fenicsxconcrete.experimental_setup.base_experiment import Experiment
from fenicsxconcrete.util import Parameters, ureg
from fenicsxconcrete.util import LogMixin, Parameters, ureg


class SimpleCube(Experiment):
Expand All @@ -33,17 +33,7 @@ def __init__(self, parameters: dict[str, pint.Quantity] | None = None) -> None:
see default_parameters for a first guess
"""

# initialize a set of default parameters
default_p = Parameters()
default_p["height"] = 1 * ureg("m")
default_p["width"] = 1 * ureg("m")
default_p["length"] = 1 * ureg("m")
default_p["T_0"] = ureg.Quantity(20.0, ureg.degC)
default_p["T_bc"] = ureg.Quantity(20.0, ureg.degC)

default_p.update(parameters)

super().__init__(default_p)
super().__init__(parameters)

@staticmethod
def default_parameters() -> dict[str, pint.Quantity]:
Expand All @@ -56,6 +46,11 @@ def default_parameters() -> dict[str, pint.Quantity]:

setup_parameters = {}

setup_parameters["height"] = 1 * ureg("m")
setup_parameters["width"] = 1 * ureg("m")
setup_parameters["length"] = 1 * ureg("m")
setup_parameters["T_0"] = ureg.Quantity(20.0, ureg.degC)
setup_parameters["T_bc"] = ureg.Quantity(20.0, ureg.degC)
setup_parameters["dim"] = 3 * ureg("")
setup_parameters["num_elements_length"] = 2 * ureg("")
setup_parameters["num_elements_width"] = 2 * ureg("")
Expand Down
9 changes: 2 additions & 7 deletions src/fenicsxconcrete/experimental_setup/tensile_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ def __init__(self, parameters: dict[str, pint.Quantity] | None = None) -> None:
see default_parameters for a first guess

"""
# initialize a set of "basic parameters"
default_p = Parameters()
# default_p['dummy'] = 'example' * ureg('') # example default parameter for this class

# updating parameters, overriding defaults
default_p.update(parameters)

super().__init__(default_p)
super().__init__(parameters)

def setup(self) -> None:
"""defines the mesh for 2D or 3D
Expand Down Expand Up @@ -76,6 +70,7 @@ def default_parameters() -> dict[str, pint.Quantity]:
"""

setup_parameters = {}

setup_parameters["length"] = 1 * ureg("m")
setup_parameters["height"] = 0.3 * ureg("m")
setup_parameters["width"] = 0.3 * ureg("m") # only relevant for 3D case
Expand Down
40 changes: 31 additions & 9 deletions src/fenicsxconcrete/finite_element_problem/base_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class QuadratureFields:
strain: ufl.core.expr.Expr | df.fem.Function | None = None
degree_of_hydration: ufl.core.expr.Expr | df.fem.Function | None = None
damage: ufl.core.expr.Expr | df.fem.Function | None = None
temperature: ufl.core.expr.Expr | df.fem.Function | None = None
compressive_strength: ufl.core.expr.Expr | df.fem.Function | None = None
tensile_strength: ufl.core.expr.Expr | df.fem.Function | None = None
youngs_modulus: ufl.core.expr.Expr | df.fem.Function | None = None
Expand Down Expand Up @@ -92,16 +93,35 @@ def __init__(
self.experiment = experiment
self.mesh = self.experiment.mesh

# setting up default material parameters
default_fem_parameters = Parameters()
default_fem_parameters["g"] = 9.81 * ureg("m/s^2")
default_fem_parameters["dt"] = 1.0 * ureg("s")

# adding experimental parameters to dictionary to combine to one
default_fem_parameters.update(self.experiment.parameters)
# initialize parameter attributes
setup_parameters = Parameters()
# setting up default setup parameters defined in each child
_, default_p = self.default_parameters()
setup_parameters.update(default_p)
# update with experiment parameters
setup_parameters.update(self.experiment.parameters)
# update with input parameters
default_fem_parameters.update(parameters)
self.parameters = default_fem_parameters
setup_parameters.update(parameters)

# get logger info which input parameters are set to default values
# plus check dimensionality of input parameters
keys_set_default = []
for key in dict(default_p):
if key not in parameters:
keys_set_default.append(key)
else:
# check if units are compatible
if not isinstance(parameters[key], bool):
dim_given = parameters[key].dimensionality
dim_default = default_p[key].dimensionality
if dim_given != dim_default:
raise ValueError(
f"given units for {key} are not compatible with default units: {dim_given} != {dim_default}"
)
self.logger.info(f"for the following parameters, the default values are used: {keys_set_default}")

# set parameters as attribute
self.parameters = setup_parameters
# remove units for use in fem model
self.p = self.parameters.to_magnitude()
self.experiment.p = self.p # update experimental parameter list for use in e.g. boundary definition
Expand Down Expand Up @@ -135,6 +155,8 @@ def default_parameters() -> tuple[Experiment, dict[str, pint.Quantity]]:
"""returns a dictionary with required parameters and a set of working values as example"""
# this must de defined in each setup class

pass

@abstractmethod
def setup(self) -> None:
# initialization of this specific problem
Expand Down
Loading
Loading