lululxvi/deepxde

Implementing a free slip BC on a cylinder

giakbottacini opened this issue · 2 comments

I'm solving a 2D Euler equation around a cylinder. I'm implementing the free slip condition using OperatorBC as done in #1046 but using exactly that implementation i have many errors and i'm arriving to this one

# Option 3 free-slip
def normal_vel(inputs, outputs, X):
    # Extract velocity components
    velocity = outputs[:, 0:2]
    
    # Ensure velocity is a TensorFlow tensor
    velocity = tf.convert_to_tensor(velocity, dtype=tf.float32)

    # Get boundary normals
    normal = cylinder.boundary_normal(X)
    
    # Ensure normal is a TensorFlow tensor
    normal = tf.convert_to_tensor(normal, dtype=tf.float32)

    # Element-wise multiplication
    multiplied = tf.multiply(velocity, normal)
    
    # Sum along axis 1 and keep dimensions
    res = tf.reduce_sum(multiplied, axis=1, keepdims=True)

    return res

# Define the boundary condition
bc_c1 = dde.icbc.OperatorBC(spatial_domain, normal_vel, boundary_cylinder)

This gives me this error in model.train 
Training model...

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py](https://localhost:8080/#) in _do_call(self, fn, *args)
   1401     try:
-> 1402       return fn(*args)
   1403     except errors.OpError as e:

10 frames
InvalidArgumentError: 2 root error(s) found.
  (0) INVALID_ARGUMENT: Incompatible shapes: [13539,2] vs. [2639,2]
	 [[{{node Mul_124}}]]
	tf2xla conversion failed while converting cluster_1[_XlaCompiledKernel=true,_XlaHasReferenceVars=true,_XlaNumConstantArgs=0,_XlaNumResourceArgs=0]. Run with TF_DUMP_GRAPH_PREFIX=/path/to/dump/dir and --vmodule=xla_compiler=2 to obtain a dump of the compiled functions.
	 [[cluster_1_1/xla_compile]]
	 [[cluster_1_1/merge_oidx_1/_9]]
  (1) INVALID_ARGUMENT: Incompatible shapes: [13539,2] vs. [2639,2]
	 [[{{node Mul_124}}]]
	tf2xla conversion failed while converting cluster_1[_XlaCompiledKernel=true,_XlaHasReferenceVars=true,_XlaNumConstantArgs=0,_XlaNumResourceArgs=0]. Run with TF_DUMP_GRAPH_PREFIX=/path/to/dump/dir and --vmodule=xla_compiler=2 to obtain a dump of the compiled functions.
	 [[cluster_1_1/xla_compile]]
0 successful operations.
0 derived errors ignored.

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py](https://localhost:8080/#) in _do_call(self, fn, *args)
   1419                     '\nsession_config.graph_options.rewrite_options.'
   1420                     'disable_meta_optimizer = True')
-> 1421       raise type(e)(node_def, op, message)  # pylint: disable=no-value-for-parameter
   1422 
   1423   def _extend_graph(self):

InvalidArgumentError: Graph execution error:

(I've inserted the second part of my message wrongly as python code, sorry).
Thanks for your help