Chaining boundary conditions
Hi All,
I have a boundary condition on a region that's defined by a function, and applies the same (time-dependent) deflection to all coordinates. Now I'm looking to precede this part of the movement by another part, which is more specific and changes by coordinate. This means that the previously simple part needs to provide not the same uniform deflection to all coordinates, but some accumulated deflection that adds to the last deflection in the first part of the movement. That is, previously I had d(x) = f(t), and now I want d(x) = d_0(x) + f(t - t_0), where 0 is the end of the 1st part.
Chaining the two parts technically is simple, either manually or (probably) with the times keyword to EssentialBC. But the second part still needs to have d_0(x). I could, I guess, repeat the calculation for the last frame of the 1st part in each call to the 2nd-part function, but that seems excessive. What would be the best way to get that information in a BC function, or else to achieve that chaining by different means?
Thanks, Yosef Meller.
Hi Yosef,
On 5/7/23 08:42, Yosef Meller wrote:
If I understand correctly, you want to first pull one part of the boundary and then in the second phase to pull another part, starting from the displacements of that another part at the end of the first phase?
IMO the easiest would be to store the phase one final displacements of the phase two boundary into a file, or an outer scope mutable object (e.g. a list in the problem description file module). Something like:
stored = [None]
def post_process(...): if "final time": stored[0] = "the displacements in phase2 region"
def get_ebc_phase2(...): dx = stored[0] + f(t - t_0) ...
r.
For posterity: I ended up doing something similar but without using globals.
Instead of using a simple function, I'm using a callable object. For each region that needs this I can create an instance, and the last state after each piece is kept in the instance, under the assumption that for the same region, the input coordinates will always be referencing the same vertices/integration points in the same order.
So it looks something like (highly abridged):
class BCFunc:
...
def __call__(self, ts, coords: np.ndarray, bc=None, problem=None) ->
np.ndarray:
# select piece based on ts.step # calculate piece function
piece_res = ...
# combine:
piece_res += self._piece_results[piece - 1]
# or if you're at the end of piece: self._piece_results[piece -
1] = ...
Thanks for the answer.
On Mon, May 8, 2023 at 5:26 PM Robert Cimrman <cimrman3@ntc.zcu.cz> wrote:
participants (2)
-
Robert Cimrman
-
Yosef Meller