Hello,
I’m currently trying to compute a boundary flux from the solution of an already solved PDE (Poisson equation) and I’m failing miserably. What works so far is
uh = problem.solve()
n = FacetNormal(mesh)
ds = Measure('ds', domain = mesh, subdomain_data=dofsRight)
flux = inner(grad(uh), n)*ds
On the other hand, I am failing at really getting the value of the flux. I have tried with
assemble_scalar (form(flux))
as well as assemble_scalar (form(flux))
(see the error logs below).
I’ve found a few examples which seem to use the command assemble
, but it is I believe outdated… Since this is a simple problem, I would imagine I only fail to understand something simple but I can’t figure out what… If someone has an idea, I’ll be very grateful!
Thanks a lot!
form(flux)
returns
File "/usr/local/dolfinx-real/lib/python3.8/dist-packages/dolfinx/fem/forms.py", line 48, in __init__
super().__init__(ffi.cast("uintptr_t", ffi.addressof(self._ufcx_form)),
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. dolfinx.cpp.fem.Form_float64(spaces: List[dolfinx::fem::FunctionSpace], integrals: Dict[dolfinx::fem::IntegralType, Tuple[List[Tuple[int, object]], dolfinx.cpp.mesh.MeshTags_int32]], coefficients: List[dolfinx.cpp.fem.Function_float64], constants: List[dolfinx.cpp.fem.Constant_float64], need_permutation_data: bool, mesh: dolfinx.cpp.mesh.Mesh = None)
2. dolfinx.cpp.fem.Form_float64(arg0: int, arg1: List[dolfinx::fem::FunctionSpace], arg2: List[dolfinx.cpp.fem.Function_float64], arg3: List[dolfinx.cpp.fem.Constant_float64], arg4: Dict[dolfinx::fem::IntegralType, dolfinx.cpp.mesh.MeshTags_int32], arg5: dolfinx.cpp.mesh.Mesh)
Invoked with: <cdata 'uintptr_t' 139961674859552>, [], [<dolfinx.cpp.fem.Function_float64 object at 0x7f4b64ac8fb0>], [], {<IntegralType.cell: 0>: None, <IntegralType.exterior_facet: 1>: array([ 1, 2, 5, 9, 14, 20, 27, 35, 44,
54, 65, 77, 90, 104, 119, 135, 152, 170,
189, 209, 230, 252, 275, 299, 324, 350, 377,
405, 434, 464, 495, 527, 560, 594, 629, 665,
702, 740, 779, 819, 860, 902, 945, 989, 1034,
1080, 1127, 1175, 1224, 1274, 1325, 1377, 1430, 1484,
1539, 1595, 1652, 1710, 1769, 1829, 1890, 1952, 2015,
2079, 2144, 2210, 2277, 2345, 2414, 2484, 2555, 2627,
2700, 2774, 2849, 2925, 3002, 3080, 3159, 3239, 3320,
3402, 3485, 3569, 3654, 3740, 3827, 3915, 4004, 4094,
4185, 4277, 4370, 4464, 4559, 4655, 4752, 4850, 4949,
5049, 5150, 5252, 5355, 5459, 5564, 5670, 5777, 5885,
5994, 6104, 6215, 6327, 6440, 6554, 6669, 6785, 6902,
7020, 7139, 7259, 7380, 7502, 7625, 7749, 7874, 8000,
8127, 8255, 8384, 8514, 8645, 8777, 8910, 9044, 9179,
9315, 9452, 9590, 9729, 9869, 10010, 10152, 10295, 10439,
10584, 10730, 10877, 11025, 11174, 11324, 11475, 11627, 11780,
11934, 12089, 12245, 12402, 12560, 12719, 12879, 13040, 13202,
13365, 13529, 13694, 13860, 14027, 14195, 14364, 14534, 14705,
14877, 15050, 15224, 15399, 15575, 15752, 15930, 16109, 16289,
16470, 16652, 16835, 17019, 17204, 17390, 17577, 17765, 17954,
18144, 18335, 18527, 18720, 18914, 19109, 19305, 19502, 19700,
19899, 20099, 20300, 20502, 20705, 20909, 21114, 21320, 21527,
21735, 21944, 22154, 22365, 22577, 22790, 23004, 23219, 23435,
23652, 23870, 24089, 24309, 24530, 24752, 24975, 25199, 25424,
25650, 25877, 26105, 26334, 26564, 26795, 27027, 27260, 27494,
27729, 27965, 28202, 28440, 28679, 28919, 29160, 29402, 29645,
29889, 30134, 30380, 30627, 30875, 31124, 31374, 31625, 31877,
32130, 32384, 32639, 32895, 33152, 33410, 33669, 33929, 34190,
34452, 34715, 34979, 35244, 35510, 35777, 36045, 36314, 36584,
36855, 37127, 37400, 37674, 37949, 38225, 38502, 38780, 39059,
39339, 39620, 39902, 40185, 40469, 40754, 41040, 41327, 41615,
41904, 42194, 42485, 42777, 43070, 43364, 43659, 43955, 44252,
44550, 44849, 45149, 45450, 45752, 46055, 46359, 46664, 46970,
47277, 47585, 47894, 48204, 48515, 48827, 49140, 49454, 49769,
50085, 50402, 50720, 51039, 51359, 51680, 52002, 52325, 52649,
52974, 53300, 53627, 53955, 54284, 54614, 54945, 55277, 55610,
55944, 56279, 56615, 56952, 57290, 57629, 57969, 58310, 58652,
58995, 59339, 59684, 60030, 60377, 60725, 61074, 61424, 61775,
62127, 62480, 62834, 63189, 63545, 63902, 64260, 64619, 64979,
65340, 65702, 66065, 66429, 66794, 67160, 67527, 67895, 68264,
68634, 69005, 69377, 69750, 70124, 70499, 70875, 71252, 71630,
72009, 72389, 72770, 73152, 73535, 73919, 74304, 74690, 75077,
75465, 75854, 76244, 76635, 77027, 77420, 77814, 78209, 78605,
79002, 79400, 79799, 80199, 80600], dtype=int32), <IntegralType.interior_facet: 2>: None, <IntegralType.vertex: 3>: None}, <dolfinx.mesh.Mesh object at 0x7f4b6d577040>
and assemble_scalar(flux)
returns
File "/usr/local/dolfinx-real/lib/python3.8/dist-packages/dolfinx/fem/assemble.py", line 128, in assemble_scalar
constants = constants or _pack_constants(M)
TypeError: pack_constants(): incompatible function arguments. The following argument types are supported:
1. (arg0: dolfinx::fem::Form<double>) -> numpy.ndarray[numpy.float64]
2. (arg0: dolfinx::fem::Expression<double>) -> numpy.ndarray[numpy.float64]
3. (arg0: dolfinx::fem::Form<float>) -> numpy.ndarray[numpy.float32]
4. (arg0: dolfinx::fem::Expression<float>) -> numpy.ndarray[numpy.float32]
5. (arg0: dolfinx::fem::Form<std::complex<double> >) -> numpy.ndarray[numpy.complex128]
6. (arg0: dolfinx::fem::Expression<std::complex<double> >) -> numpy.ndarray[numpy.complex128]
Invoked with: Form([Integral(Conj(Inner(FacetNormal(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 0)), Grad(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 0), FiniteElement('Lagrange', triangle, 1)), 0)))), 'exterior_facet', Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 0), 'everywhere', {}, array([ 1, 2, 5, 9, 14, 20, 27, 35, 44,
54, 65, 77, 90, 104, 119, 135, 152, 170,
189, 209, 230, 252, 275, 299, 324, 350, 377,
405, 434, 464, 495, 527, 560, 594, 629, 665,
702, 740, 779, 819, 860, 902, 945, 989, 1034,
1080, 1127, 1175, 1224, 1274, 1325, 1377, 1430, 1484,
1539, 1595, 1652, 1710, 1769, 1829, 1890, 1952, 2015,
2079, 2144, 2210, 2277, 2345, 2414, 2484, 2555, 2627,
2700, 2774, 2849, 2925, 3002, 3080, 3159, 3239, 3320,
3402, 3485, 3569, 3654, 3740, 3827, 3915, 4004, 4094,
4185, 4277, 4370, 4464, 4559, 4655, 4752, 4850, 4949,
5049, 5150, 5252, 5355, 5459, 5564, 5670, 5777, 5885,
5994, 6104, 6215, 6327, 6440, 6554, 6669, 6785, 6902,
7020, 7139, 7259, 7380, 7502, 7625, 7749, 7874, 8000,
8127, 8255, 8384, 8514, 8645, 8777, 8910, 9044, 9179,
9315, 9452, 9590, 9729, 9869, 10010, 10152, 10295, 10439,
10584, 10730, 10877, 11025, 11174, 11324, 11475, 11627, 11780,
11934, 12089, 12245, 12402, 12560, 12719, 12879, 13040, 13202,
13365, 13529, 13694, 13860, 14027, 14195, 14364, 14534, 14705,
14877, 15050, 15224, 15399, 15575, 15752, 15930, 16109, 16289,
16470, 16652, 16835, 17019, 17204, 17390, 17577, 17765, 17954,
18144, 18335, 18527, 18720, 18914, 19109, 19305, 19502, 19700,
19899, 20099, 20300, 20502, 20705, 20909, 21114, 21320, 21527,
21735, 21944, 22154, 22365, 22577, 22790, 23004, 23219, 23435,
23652, 23870, 24089, 24309, 24530, 24752, 24975, 25199, 25424,
25650, 25877, 26105, 26334, 26564, 26795, 27027, 27260, 27494,
27729, 27965, 28202, 28440, 28679, 28919, 29160, 29402, 29645,
29889, 30134, 30380, 30627, 30875, 31124, 31374, 31625, 31877,
32130, 32384, 32639, 32895, 33152, 33410, 33669, 33929, 34190,
34452, 34715, 34979, 35244, 35510, 35777, 36045, 36314, 36584,
36855, 37127, 37400, 37674, 37949, 38225, 38502, 38780, 39059,
39339, 39620, 39902, 40185, 40469, 40754, 41040, 41327, 41615,
41904, 42194, 42485, 42777, 43070, 43364, 43659, 43955, 44252,
44550, 44849, 45149, 45450, 45752, 46055, 46359, 46664, 46970,
47277, 47585, 47894, 48204, 48515, 48827, 49140, 49454, 49769,
50085, 50402, 50720, 51039, 51359, 51680, 52002, 52325, 52649,
52974, 53300, 53627, 53955, 54284, 54614, 54945, 55277, 55610,
55944, 56279, 56615, 56952, 57290, 57629, 57969, 58310, 58652,
58995, 59339, 59684, 60030, 60377, 60725, 61074, 61424, 61775,
62127, 62480, 62834, 63189, 63545, 63902, 64260, 64619, 64979,
65340, 65702, 66065, 66429, 66794, 67160, 67527, 67895, 68264,
68634, 69005, 69377, 69750, 70124, 70499, 70875, 71252, 71630,
72009, 72389, 72770, 73152, 73535, 73919, 74304, 74690, 75077,
75465, 75854, 76244, 76635, 77027, 77420, 77814, 78209, 78605,
79002, 79400, 79799, 80199, 80600], dtype=int32))])