# ALE::move in c++ running error

**URL:** <https://fenicsproject.discourse.group/t/ale-move-in-c-running-error/2110>\
**Category:** Uncategorized\
**Created:** [December 18, 2019, 5:56am UTC](https://fenicsproject.discourse.group/t/ale-move-in-c-running-error/2110 "2019-12-18T05:56:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![coyigg2008](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@coyigg2008](https://fenicsproject.discourse.group/u/coyigg2008)\
**Post date:** [December 18, 2019, 5:56am UTC](https://fenicsproject.discourse.group/t/ale-move-in-c-running-error/2110/1 "2019-12-18T05:56:09Z")

</div>

I use c++ to implement the ALE::Move. However, I met the following error:

\*\*\* Error: Unable to set/get mesh geometry coordinates from/to function.  
\*\*\* Reason: function has incorrect value rank 0, need 1.  
\*\*\* Where: This error was encountered inside fem\_utils.cpp.  
\*\*\* Process: 0

If possible, could you please tell me what is wrong? Thank you so much!

The original code is here:  
#include \<dolfin.h\>  
#include “OneDfreeboundary.h”  
#include “OneDfreeboundary\_velocity.h”

using namespace dolfin;

// Source term (right-hand side)  
class Source : public Expression  
{  
void eval(Array& values, const Array& x) const  
{  
values[0] = exp(x[0]-1.0);  
}  
};

// Normal derivative (Neumann boundary condition)  
class dUdN : public Expression  
{  
void eval(Array& values, const Array& x) const  
{  
values[0] = 0.0;  
}  
};

// Sub domain for Dirichlet boundary condition  
class DirichletBoundary : public SubDomain  
{  
bool inside(const Array& x, bool on\_boundary) const  
{  
return x[0] \> 1.0 - DOLFIN\_EPS and on\_boundary;  
}  
};

int main()  
{  
// Create mesh and function space  
auto mesh = std::make\_shared (40, 0, 1.0);  
auto Q = std::make\_sharedOneDfreeboundary::FunctionSpace(mesh);  
auto V = std::make\_shared\<OneDfreeboundary\_velocity::FunctionSpace\>(mesh);

auto p0 = std::make\_shared(1.0);  
auto boundary = std::make\_shared();

DirichletBC bc(Q, p0, boundary);  
std::vector \<DirichletBC\*\> bcp = {&bc};

//create function  
auto p1 = std::make\_shared (Q);  
auto u1 = std::make\_shared (V);  
auto delta\_u = std::make\_shared (V);

// Define variational forms  
OneDfreeboundary::BilinearForm a1(Q, Q);  
OneDfreeboundary::LinearForm L1(Q);  
OneDfreeboundary\_velocity::BilinearForm a2(V, V);  
OneDfreeboundary\_velocity::LinearForm L2(V);

auto f = std::make\_shared();  
L1.f = f; L2.p1 = p1;

Matrix A1, A2;  
assemble(A1, a1);  
assemble(A2, a2);

// Compute solution  
File file(“OneDfreeboundary.pvd”);  
double dt = 0.05;  
double t = 0;

Vector b1, b2;  
const std::string prec(has\_krylov\_solver\_preconditioner(“amg”) ? “amg” : “default”);

for (unsigned k=0; k\<10; k++){  
t += dt;  
begin(“computating poission equation”);  
assemble(b1, L1);  
for (std::size\_t i = 0; i \< bcp.size(); i++) bcp[i]-\> apply(A1,b1);  
solve(A1, \*p1-\>vector(), b1, “gmres”, “default”);  
end();

```
begin("computing velocity");
assemble(b2, L2);
solve(A2, *u1->vector(), b2, "gmres", "default");
end();

*(delta_u->vector()) = *(u1->vector()); 
*(delta_u->vector()) *= dt;  
ALE::move(*mesh, *delta_u);
file << *p1;

```

}  
return 0;  
}
