# Question about 'Constant' function

**URL:** <https://fenicsproject.discourse.group/t/question-about-constant-function/8820>\
**Category:** dolfinx\
**Created:** [July 21, 2022, 8:30am UTC](https://fenicsproject.discourse.group/t/question-about-constant-function/8820 "2022-07-21T08:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swani](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/swani/32/3940_2.png) [@Swani](https://fenicsproject.discourse.group/u/Swani)\
**Post date:** [July 21, 2022, 8:30am UTC](https://fenicsproject.discourse.group/t/question-about-constant-function/8820/1 "2022-07-21T08:30:00Z")

</div>

Hello 🙂  
(A question arose from the error obtained while using dot product of my edited code in the dolfinx environment.)

**I want to express the vector coordinates defined as coefficients in the dolfinx environment** , but I do not know how to express it, so I leave a question.

For example,  
When expressing a vector element with (0, -3) dimension in the existing dolfin environment,  
It could be expressed as

```auto
Constant((0.0, -3.0))

```

If I check the code result using jupyter notebook, the code is expressed as follows.  
 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/7/719fa2cffe84b97247f5c192fc2a5de64dfeda70.png)

The calculation was made when the

```auto
v = TestFunction(U)

```

and dot product defined as

```auto
U = VectorFunctionSpace(mesh, ("CG", 1))

```

were applied to the above coefficient such that  
 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/9/98939b572ac39be5089f912707889fc9dd5d41ad.png)

Unlike the dolfin environment, ‘Constant’ in dolfinx was essential to declare the domain.  
 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/5/518f9bdf4a97d4eecdd6d259ebb72ae51eb1679d.png)

In the dolfin environment, the coefficient came out, whereas in the dolfinx environment, it was declared as Constant.  
As a result of that, an error occurred when dot product was performed.

 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/b/b47791c6666b75208564807b037bfa92be27b27e.jpeg)

I think it is because of ‘Constant’ declared in the dolfinx environment. As written in bold in the first paragraph of writing, **is there a way to declare a vector element as a constant coefficient in the dolfinx environment?**

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [July 21, 2022, 9:36am UTC](https://fenicsproject.discourse.group/t/question-about-constant-function/8820/2 "2022-07-21T09:36:59Z")

</div>

Please create an example that reproduces this error, as having screenshots of bits of code is not sufficient to replicate the error.  
As you can see in: [Test problem 1: Channel flow (Poiseuille flow) — FEniCSx tutorial](https://jorgensd.github.io/dolfinx-tutorial/chapter2/ns_code1.html#implementation)  
a vector valued constant can be written as:

```python
f = Constant(mesh, PETSc.ScalarType((0,0)))

```
