-
Notifications
You must be signed in to change notification settings - Fork 2
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
Discussion for redesign #159
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
from pydantic import ConfigDict, RootModel | ||
from pydantic.dataclasses import dataclass | ||
from pydantic.types import conlist | ||
from typing import Callable, NewType | ||
import numpy as np | ||
|
||
Marker = NewType('Marker', int) | ||
|
||
@dataclass(config=dict(arbitrary_types_allowed=True)) | ||
class DirichletBCDefinition: | ||
""" | ||
Definition of a time- and position-dependent Dirichlet boundary condition. | ||
Note that functions cannot be serialized to JSON! | ||
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. using the eval function, you could define a string and then convert that to a python function. The string can be stored in json 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. We can do that. To me, it screams security risk but then again, so would be importing any code you haven't written yourself |
||
""" | ||
marker: Marker | list[float] | Callable[[np.ndarray], np.ndarray] | ||
value: conlist(float, min_length=1, max_length=3) | Callable[[np.ndarray, float], np.ndarray] | ||
subspace: int | None | ||
variable: str | ||
|
||
@dataclass(config=dict(arbitrary_types_allowed=True)) | ||
class NeumannBCDefinition: | ||
""" | ||
Definition of a time- and position-dependent Neumann boundary condition. | ||
""" | ||
marker: Marker | ||
value: conlist(float, min_length=1, max_length=3) | Callable[[np.ndarray, float], np.ndarray] | ||
|
||
@dataclass(config=dict(arbitrary_types_allowed=True)) | ||
class BodyForceDefinition: | ||
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. body force is very much mechanics driven, for the heat equation,this would be different (volumetric heat flux). I guess this would also just be a function of x and t and returns the corresponding term. 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. Yeah, I wasn't sure what to do here. What would be the general term for body force? So any integral 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. source term? 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. I am not sure how we should generalize this. As far as I see it, the body-force definition is constant because gravity is constant. But how is it with heat flux? From this doc https://www.simscale.com/docs/simulation-setup/boundary-conditions/volume-heat-flux/ I get that it could vary with time and position 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. wouldn't that be the same as the functional representation of boundary conditions being a function of space and time? So there could certainly be constant or linear functions as standard (both relevant for body forces or linearly increasing boundary conditions) and then have the functional representation as additional option. 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. True, but my question is more related to what should be allowed. In an ideal world, the data structure would ensure that only valid values (like constant gravity) are allowed, but I guess that should then be the responsibility of the user. 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. Well, I guess it will be very hard to be able to define problems and test the validity beforehand (just from the syntax). And for Dirichlet BC I see now way around that, otherwise we are very limited, so then it makes no difference it that is added here again. But we could define two functions, one for BodyForce = constant and SpaceTimeDependentBodyForce(x,t). |
||
value: conlist(float, min_length=1, max_length=3) | ||
|
||
@dataclass(config=dict(arbitrary_types_allowed=True)) | ||
class InitialConditionDefinition: | ||
value: list[float] | ||
variable: str |
This file was deleted.
This file was deleted.
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.
How would the Dirichlet boundary condition be defined in time? Just passing a np.ndarray or a function?
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.
That would need to be a function$f(x,t)\mapsto y,\quad x\in\partial\Omega$ , so in python a
Callable[[np.ndarray, float],np.ndarray]
. For simplicity, a numpy array would be interpreted as a constant BC at every point in time