-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hi there,
two questions:
i) Are there any utility functions to change the default node ordering to some of the common FE-codes? If no and you have ideas what the proper ordering algorithms are, I would be happy to contribute.
ii) I try to derive the matrix for a monomial of order n. For some predetermined n, no problem, but I wanted to do it in a general way. The integral looks like this N.T @ (N.T @ c)^(n-1) N.T where N are the shape functions and c is the vector of nodal variables of interest (e. g. concentration). As a result I get a very ugly Piecewise defined function:
Matrix([
[Piecewise((2*l1*(n**2*u1**n*u2**2 - 2*n**2*u1**(n + 1)*u2 + n**2*u1**(n + 2) + 3*n*u1**n*u2**2 - 4*n*u1**(n + 1)*u2 + n*u1**(n + 2) + 2*u1**n*u2**2 - 2*u2**(n + 2))/(n*(n**2*u1**3 - 3*n**2*u1**2*u2 + 3*n**2*u1*u2**2 - n**2*u2**3 + 3*n*u1**3 - 9*n*u1**2*u2 + 9*n*u1*u2**2 - 3*n*u2**3 + 2*u1**3 - 6*u1**2*u2 + 6*u1*u2**2 - 2*u2**3)), Ne(u1, u2)), (2*l1*u2**(n - 1)/3, True)), Piecewise((2*l1*(n*u1*u2**(n + 1) - n*u1**(n + 1)*u2 + n*u1**(n + 2) - n*u2**(n + 2) + 2*u1*u2**(n + 1) - 2*u1**(n + 1)*u2)/(n*(n**2*u1**3 - 3*n**2*u1**2*u2 + 3*n**2*u1*u2**2 - n**2*u2**3 + 3*n*u1**3 - 9*n*u1**2*u2 + 9*n*u1*u2**2 - 3*n*u2**3 + 2*u1**3 - 6*u1**2*u2 + 6*u1*u2**2 - 2*u2**3)), Ne(u1, u2)), (l1*u2**(n - 1)/3, True))],
[ Piecewise((2*l1*(n*u1*u2**(n + 1) - n*u1**(n + 1)*u2 + n*u1**(n + 2) - n*u2**(n + 2) + 2*u1*u2**(n + 1) - 2*u1**(n + 1)*u2)/(n*(n**2*u1**3 - 3*n**2*u1**2*u2 + 3*n**2*u1*u2**2 - n**2*u2**3 + 3*n*u1**3 - 9*n*u1**2*u2 + 9*n*u1*u2**2 - 3*n*u2**3 + 2*u1**3 - 6*u1**2*u2 + 6*u1*u2**2 - 2*u2**3)), Ne(u1, u2)), (l1*u2**(n - 1)/3, True)), Piecewise((2*l1*(-n**2*u1**2*u2**n + 2*n**2*u1*u2**(n + 1) - n**2*u2**(n + 2) - 3*n*u1**2*u2**n + 4*n*u1*u2**(n + 1) - n*u2**(n + 2) - 2*u1**2*u2**n + 2*u1**(n + 2))/(n*(n**2*u1**3 - 3*n**2*u1**2*u2 + 3*n**2*u1*u2**2 - n**2*u2**3 + 3*n*u1**3 - 9*n*u1**2*u2 + 9*n*u1*u2**2 - 3*n*u2**3 + 2*u1**3 - 6*u1**2*u2 + 6*u1*u2**2 - 2*u2**3)), Ne(u1, u2)), (2*l1*u2**(n - 1)/3, True))]])(I guess) sympy tries to deal with the case n =< 0, but this case is of no interest (at least to me). My question is now how can I switch of this behaviour as I am only interested in the case of n being an integer and greater/equal 2. Below is the full code to check.
Thanks and Regards
Stefan