Small help with velocity function to vary along the side walls in 3D

So I have a 3D model of extension and I am trying to vary velocity along the side walls left and right so that extension vary from 5mm/yr at upper corner to 15mm/yr at lower corner, I wrote this function, but seems there is issue, is this a good way to construct it? The expression of variying velocity [ -1*ymax / y * (vmax-vmin) + vmax ] is correct if the code consider y as a variable of all ponts along the y coordnates of the left and right walls.

subsection Boundary velocity model
set Tangential velocity boundary indicators = bottom
set Prescribed velocity boundary indicators = left: function, right:function

subsection Function
set Coordinate system = cartesian
set Variable names = x,y,z,t

set Function constants  = ymax= 400.e3, xmin=0.e3, xmax=200.e3, vmax=15, vmin=5, v= -1*ymax / y * (vmax-vmin) + vmax
set Function expression = if (x=xmax, v*mm/yr, -v*mm/yr);

end
end

Dear Hany,

A couple of things:

  • Your v isn’t a constant, so it shouldn’t be in the Function constants parameter.
  • Testing that a float (x) is exactly equal to another float is generally a bad idea because of floating point precision. Better to use an inequality.

If you still have problems, please describe what you expect the code to do, attach a minimal non-working prm file that demonstrates the unexpected behaviour, and provide the associated error message if there is one.

Best wishes,
Bob

Hey Bob,
so I rewrote the function and got another small error, so basically i try to vary the velocity to start from 5mm/yr and increases to 15mm/yr along the left and right sides of the model.

my function I wrote is:
subsection Boundary velocity model
#set Tangential velocity boundary indicators = bottom
set Prescribed velocity boundary indicators = left x: function, right x:function, bottom z: function

subsection Function
set Coordinate system = cartesian
set Variable names = x,y,z,t

set Function constants  = mm=0.001, yr=1,y_max= 400e3 ,vx_full_min=5.000 , vx_full_max=15.000 , vy_full=0.0000, DZ=200e3, DX=200e3 

set Function expression = if(x<100e3, -1*(-1*y_max / y * ((vx_full_max/2)-(vx_full_min/2)) + (vx_full_max/2)) *mm/yr), (-1*y_max / y * ((vx_full_max/2)-(vx_full_min/2)) + (vx_full_max/2)) *mm/yr); \
                          if(x<100e3, vy_full/2*mm/yr, -vy_full/2*mm/yr); \

end
end

but I got this error:
Message: <Too few parameters for function “if” at expression position 89>
Formula: <if(x<100e3, -1*(-1*y_max/ y * ((vx_full_max/2)-(vx_full_min/2)) + (vx_full_max/2)) mm/yr), (-1y_max/ y * ((vx_full_max/2)-(vx_full_min/2)) + (vx_full_max/2)) *mm/yr) >
Token:
Position: <89>
Errc: <15>

Perhaps check your brackets?

Best wishes,
Bob

Thanks Bob alot, any idea what does that error means??

The solver reported the following error:

--------------------------------------------------------
An error occurred in line <2688> of file
</home/bbkeheck/aspect/source/utilities.cc> in function
void aspect::Utilities::linear_solver_failed(const string&, const
string&, const std::vector<dealii::SolverControl>&, const
std::exception&, ompi_communicator_t* const&, const string&)
The violated condition was:
false
Additional information:
The iterative (top left) solver in BlockSchurPreconditioner::vmult did
not converge.

The required residual for convergence is: -nan

The solver reported the following error:

--------------------------------------------------------
An error occurred in line <497> of file
</home/projects/bbp00039/fastscape_build_files/misc/deal.IIdev-master-15th-feb-22/tmp/unpack/deal.II-master/source/lac/trilinos_solver.cc>

in function
void dealii::TrilinosWrappers::SolverBase::do_solve(const
Preconditioner&) [with Preconditioner =
dealii::TrilinosWrappers::PreconditionBase]
The violated condition was:
false
Additional information:
AztecOO::Iterate error code -2: numerical breakdown

I recommend checking your function. The division by y is surprising to me and could produce a divide by zero error.