Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Call a function in "mesh size" node

Please login with a confirmed email address before reporting spam

It is a very simple test model:

A fluid flows in a rectangular 2-d channel (from the left to the rigth).

Global ->Parameters : H = 0.1 (it is the heigth of the channel)
Mesh ->Size -> Maximum element size : H

It works. But if I define a function

model ->analytic : myfun(x) = x/10
Mesh ->Size -> Maximum element size : myfun(H)

It doesnt works. I think that it means that a Mesh cannot be defined by a function. I tried to enter

Mesh ->Size -> Maximum element size : max(H)

and it didnt work. Can you confirm that a mesh cannot be defined with functions ? Is there a way to define a mesh with a complicated function of a global parameter ? (e.g, piecewise function of H)

Thank you.

5 Replies Last Post Apr 23, 2011, 4:19 p.m. EDT
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 21, 2011, 7:02 p.m. EDT
Hi

Indeed you cannot call a function, but you can write H/10 directly in the formula field

--
Good luck
Ivar
Hi Indeed you cannot call a function, but you can write H/10 directly in the formula field -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 22, 2011, 2:42 p.m. EDT

Hi

Indeed you cannot call a function, but you can write H/10 directly in the formula field

--
Good luck
Ivar


I would like to set my "Mesh->MaximumElementSize" as a piecewise function. In fact, I found that:

1. when H is large, (MaximumElementSize = H/10) provides a good initial mesh (for adaptive mesh)
2. when H is very small, (MaximumElementSize = 1) provides a good initial mesh (for adaptive mesh)

In this case I need a piecewise function of H to set a good initial mesh regarless for all value of H.

How would you do that ?
[QUOTE] Hi Indeed you cannot call a function, but you can write H/10 directly in the formula field -- Good luck Ivar [/QUOTE] I would like to set my "Mesh->MaximumElementSize" as a piecewise function. In fact, I found that: 1. when H is large, (MaximumElementSize = H/10) provides a good initial mesh (for adaptive mesh) 2. when H is very small, (MaximumElementSize = 1) provides a good initial mesh (for adaptive mesh) In this case I need a piecewise function of H to set a good initial mesh regarless for all value of H. How would you do that ?

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 22, 2011, 5:17 p.m. EDT
Hi

have you tried a chain of boolean expresions ?

Something like
h = 1/(1+ 2*(H<3) + 4*(H<6) ...)

It might work, haven't checked ;)

--
Good luck
Ivar
Hi have you tried a chain of boolean expresions ? Something like h = 1/(1+ 2*(H

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 23, 2011, 1:04 p.m. EDT

Hi

have you tried a chain of boolean expresions ?

Something like
h = 1/(1+ 2*(H<3) + 4*(H<6) ...)

It might work, haven't checked ;)

--
Good luck
Ivar


I tried boolean expresion and unfortunately it is not accepted in the mesh size settings..
Any other ideas ?
[QUOTE] Hi have you tried a chain of boolean expresions ? Something like h = 1/(1+ 2*(H

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 23, 2011, 4:19 p.m. EDT
Hi

then for me it means that the mesh fields it accepts only "Parameters" (=Constants).

Pameters are be defined once at solver launch, and may be changed via a reference in a "Parametric sweep", or a "Solver Continuation sweep"

--
Good luck
Ivar
Hi then for me it means that the mesh fields it accepts only "Parameters" (=Constants). Pameters are be defined once at solver launch, and may be changed via a reference in a "Parametric sweep", or a "Solver Continuation sweep" -- Good luck Ivar

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.