unit in the input file

65 views
Skip to first unread message

陈奕纯

unread,
Apr 10, 2025, 11:39:43 AMApr 10
to IBAMR Users
i'm currently using IB and want to use pIB, and i found that i can simply apply mass in input file by adding uniform_bdry_mass. 
I am confused about the unit of the bdry_mass_density. In an example input2d file, it is written as follow
uniform_bdry_mass = bdry_mass_density*ds
the comment for bdry_mass_density is "g cm^-1". If I want the strcuture to have the same or x times the mass density of the surrouding flow, then this value is set to x times of RHO, am I correct?

Boyce Griffith

unread,
Apr 11, 2025, 4:40:27 PMApr 11
to IBAMR Users
The units in the input file are correct. In that example, the structure is a boundary (one-dimensional structure), and so there is not a clear way to have it have the same mass density as the surrounding fluid.

If you use the IB method with a codimension-0 structure (2D structure region in a 2D computation, 3D structure region in a 3D computation), then the structure will automatically have the same mass density as the background fluid — there is no need to use the pIB method.

The way to think about it is that, in the regular IB method — not the pIB method — if the codimension of the structure is >= 1, then the structure is fully massless. If the codimension is 0, then the structure’s mass density is the same as the fluid’s mass density.

— Boyce

Boyce Griffith

unread,
Apr 12, 2025, 9:13:18 AMApr 12
to IBAMR Users, 陈奕纯
Please reply to the list.

On Apr 12, 2025, at 1:50 AM, 陈奕纯 <a1185...@gmail.com> wrote:

Thanks! 
So if I set up a 2D-structure with a closed-curve gemotry using springs and beams (for example, a circle that can deform), which has x times the mass density of the background flow in a 2D computation, then the boundary mass should be set   x*RHO*area_of_the_closed_curve/perimeter_of_the_closed_curve ?  

I am a little confused - is this a codimension-1 or codimension-0 case?

In the codimension-0 case, then the default behavior of the IB method (without using pIB) is for the structure to be neutrally buoyant: the mass density of the structure is the same as the mass density of the fluid. Using the pIB method in this case will only allow you to make the mass density of the structure larger than the mass density of the fluid.

In the codimension-1 case, then the default behavior of the IB method (without using pIB) is for the structure to be massless. In fact, there is no way for the fluid and structure to have the same pointwise mass densities, because the units are not compatible. To make things concrete, let’s consider a 2D surface immersed in a 3D fluid. Mass density for the structure has units of mass/area. Mass density for the fluid has units of mass/volume.

If you want to view the codimension-1 case as a reduced-order model for the codimension-0 case, like what you would do in a shell theory, then you could assign some thickness to the surface and use that to define the relevant volume element. However, if you wanted to make the mass density of this shell the same as the fluid, you still would not want to use the pIB method, because the mass associated with the shell is already accounted for in the Eulerian momentum equation.

Do I and when do I need to swich to IBFE for codimension-0 structure instead of using only vertexes for its boundary?

You can model codimension-0 structures with either IB or IBFE. The main reason to use IBFE method is because it makes it much easier to use standard continuum mechanics models and meshes from standard mesh generator tools.

陈奕纯

unread,
Apr 15, 2025, 11:13:06 AMApr 15
to IBAMR Users
Thanks so much for the reply!
I meant a codimension-0 case. For example, a 2D cylinder in a 2D domain. I use N vertexes to form a circle with radius R and I want this cylinder to have X times the mass density of the background flow. Do I set the boundary mass density to be (X-1)*RHO*(pi*R^2)/(2*pi*R) ?
Besides, if I want to add gravity, do I simply add "ForcingFunction" attribute to the input file and set  function_1 = "-9.8*RHO"? I tried this and I found the calculation threw error of "time step size changed". Does adding gravity makes the calculation more unstable and requires smaller time step size?

Boyce Griffith

unread,
Apr 15, 2025, 5:30:29 PMApr 15
to IBAMR Users

On Apr 15, 2025, at 11:13 AM, 陈奕纯 <a1185...@gmail.com> wrote:

Thanks so much for the reply!
I meant a codimension-0 case. For example, a 2D cylinder in a 2D domain. I use N vertexes to form a circle with radius R and I want this cylinder to have X times the mass density of the background flow. Do I set the boundary mass density to be (X-1)*RHO*(pi*R^2)/(2*pi*R) ?

Basically yes — although you have to be careful with the units. Notice, however, that in the pIB implementation in IBAMR, you are actually assigning a mass to each point, so you would need to decide the volume element associated with the points to get the mass, as was done in the example.

Besides, if I want to add gravity, do I simply add "ForcingFunction" attribute to the input file and set  function_1 = "-9.8*RHO"?

I think so — although it has been a very long time since I’ve messed around with that part of the code.

I tried this and I found the calculation threw error of "time step size changed". Does adding gravity makes the calculation more unstable and requires smaller time step size?

If it generates very high speeds or uses very stiff penalty parameter values, yes. The maximum stable time step size is inversely related to the penalty parameter.

在2025年4月12日星期六 UTC+8 21:13:18<Boyce Griffith> 写道:
Please reply to the list.

On Apr 12, 2025, at 1:50 AM, 陈奕纯 <a1185...@gmail.com> wrote:

Thanks! 
So if I set up a 2D-structure with a closed-curve gemotry using springs and beams (for example, a circle that can deform), which has x times the mass density of the background flow in a 2D computation, then the boundary mass should be set   x*RHO*area_of_the_closed_curve/perimeter_of_the_closed_curve ?  

I am a little confused - is this a codimension-1 or codimension-0 case?

In the codimension-0 case, then the default behavior of the IB method (without using pIB) is for the structure to be neutrally buoyant: the mass density of the structure is the same as the mass density of the fluid. Using the pIB method in this case will only allow you to make the mass density of the structure larger than the mass density of the fluid.

In the codimension-1 case, then the default behavior of the IB method (without using pIB) is for the structure to be massless. In fact, there is no way for the fluid and structure to have the same pointwise mass densities, because the units are not compatible. To make things concrete, let’s consider a 2D surface immersed in a 3D fluid. Mass density for the structure has units of mass/area. Mass density for the fluid has units of mass/volume.

If you want to view the codimension-1 case as a reduced-order model for the codimension-0 case, like what you would do in a shell theory, then you could assign some thickness to the surface and use that to define the relevant volume element. However, if you wanted to make the mass density of this shell the same as the fluid, you still would not want to use the pIB method, because the mass associated with the shell is already accounted for in the Eulerian momentum equation.

Do I and when do I need to swich to IBFE for codimension-0 structure instead of using only vertexes for its boundary?

You can model codimension-0 structures with either IB or IBFE. The main reason to use IBFE method is because it makes it much easier to use standard continuum mechanics models and meshes from standard mesh generator tools.

在2025年4月12日星期六 UTC+8 04:40:27<Boyce Griffith> 写道:


> On Apr 10, 2025, at 11:39 AM, 陈奕纯 <a1185...@gmail.com> wrote: 
> 
> i'm currently using IB and want to use pIB, and i found that i can simply apply mass in input file by adding uniform_bdry_mass. 
> I am confused about the unit of the bdry_mass_density. In an example input2d file, it is written as follow 
> uniform_bdry_mass = bdry_mass_density*ds 
> the comment for bdry_mass_density is "g cm^-1". If I want the strcuture to have the same or x times the mass density of the surrouding flow, then this value is set to x times of RHO, am I correct? 

The units in the input file are correct. In that example, the structure is a boundary (one-dimensional structure), and so there is not a clear way to have it have the same mass density as the surrounding fluid. 

If you use the IB method with a codimension-0 structure (2D structure region in a 2D computation, 3D structure region in a 3D computation), then the structure will automatically have the same mass density as the background fluid — there is no need to use the pIB method. 

The way to think about it is that, in the regular IB method — not the pIB method — if the codimension of the structure is >= 1, then the structure is fully massless. If the codimension is 0, then the structure’s mass density is the same as the fluid’s mass density. 

— Boyce

-- 
You received this message because you are subscribed to the Google Groups "IBAMR Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ibamr-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ibamr-users/4106fb91-3f57-4e7a-aefe-dec713145df9n%40googlegroups.com.

陈奕纯

unread,
Apr 16, 2025, 3:55:37 AMApr 16
to IBAMR Users
Thanks for your kind reply.  
I want to use pIB for a cylinder as I mentioned above which has a larger mass density, does the "ForcingFunction" apply gravity to its vertex as well?
I know pIB assigns a mass to each point,  then the force applied to the point should be " elastic force plus penalty force plus gravity ".  But the " function_1 = "-9.8*RHO" "  in  "ForcingFunction" seems to me only an addictive RHS term in N-S equation for background flow.
I tried applying boundary density to my structure and "ForcingFunction" in input file, and it is falling slowly. I found it quite confusing. Is each mass point simply applied a "-9.8*RHO" in y-direction when solving its own Newton equation?


Boyce Griffith

unread,
Apr 16, 2025, 8:08:17 AMApr 16
to IBAMR Users

On Apr 16, 2025, at 12:55 AM, 陈奕纯 <a1185...@gmail.com> wrote:

Thanks for your kind reply.  
I want to use pIB for a cylinder as I mentioned above which has a larger mass density, does the "ForcingFunction" apply gravity to its vertex as well?
I know pIB assigns a mass to each point,  then the force applied to the point should be " elastic force plus penalty force plus gravity ".  But the " function_1 = "-9.8*RHO" "  in  "ForcingFunction" seems to me only an addictive RHS term in N-S equation for background flow.
I tried applying boundary density to my structure and "ForcingFunction" in input file, and it is falling slowly. I found it quite confusing. Is each mass point simply applied a "-9.8*RHO" in y-direction when solving its own Newton equation?

Yes, I think you are right that there needs to be an additional gravitational force. In IBMethod models that use IBStandardForceGen, you can specify an additional uniform body force using IBStandardForceGen::setUniformBodyForce(). It doesn’t appear that there is an easy way to set that in the input file. (If you were interested in adding that, we’d certainly welcome a patch!)

陈奕纯

unread,
Apr 16, 2025, 11:16:41 AMApr 16
to IBAMR Users
Thanks for the information.
I found the function in IBStandardForceGen.cpp, which reads
IBStandardForceGen::setUniformBodyForce(IBTK::Vector F, int structure_id, int level_number)
{
    d_uniform_body_force_data[level_number][structure_id] = std::move(F);
    return;
} // setUniformBodyForce
I tried to find how to use it in an example.cpp file, and found lines like this
Pointer<IBStandardForceGen> ib_force_fcn = new IBStandardForceGen();
        ib_force_fcn->registerSpringForceFunction(0, &linear_spring_force, &linear_spring_force_deriv);
        ib_method_ops->registerIBLagrangianForceFunction(ib_force_fcn);
and I checked the doc of the function that reads
void setUniformBodyForce (IBTK::Vector F, int structure_id, int level_number)
Set a uniform body force that is applied on each point in the structure with the given structure_id.

So I guess if I want to add gravity to my structure, what I need to do is to add a few lines like this:
Pointer<IBStandardForceGen> ib_force_fcn = new IBStandardForceGen();
       
        //ib_force_fcn->registerSpringForceFunction(0, &linear_spring_force, &linear_spring_force_deriv);
        IBTK::vector<float> F(0, -mass_structure*9.8);
        ib_force_fcn->setUniformBodyForce(F, 0, level_number);

        ib_method_ops->registerIBLagrangianForceFunction(ib_force_fcn);
Is my code correct? 
I understand that structure_id starts from 0 but what does level_number means?
Let me sum up what needs to be done if I want to simulate a 2D cylinder with radius R and larger mass density which has N vertex in a 2D domain:
1. In input file, add ForcingFunction attribute and specify function_1 = "-RHO*9.8" to apply gravity term on N-S equation for background flow
2. In input file, add uniform_boundary_mass attribute to my structure (let's view it as a ring with mass M) and set it to M/N ,and the unit for M should be g not kg
3. In example.cpp file, add lines shown above
Am I correct?

Boyce Griffith

unread,
Apr 17, 2025, 12:17:09 PMApr 17
to IBAMR Users

On Apr 16, 2025, at 8:16 AM, 陈奕纯 <a1185...@gmail.com> wrote:

Thanks for the information.
I found the function in IBStandardForceGen.cpp, which reads
IBStandardForceGen::setUniformBodyForce(IBTK::Vector F, int structure_id, int level_number)
{
    d_uniform_body_force_data[level_number][structure_id] = std::move(F);
    return;
} // setUniformBodyForce
I tried to find how to use it in an example.cpp file, and found lines like this
Pointer<IBStandardForceGen> ib_force_fcn = new IBStandardForceGen();
        ib_force_fcn->registerSpringForceFunction(0, &linear_spring_force, &linear_spring_force_deriv);
        ib_method_ops->registerIBLagrangianForceFunction(ib_force_fcn);
and I checked the doc of the function that reads
void setUniformBodyForce (IBTK::Vector F, int structure_id, int level_number)
Set a uniform body force that is applied on each point in the structure with the given structure_id.

Yes.

So I guess if I want to add gravity to my structure, what I need to do is to add a few lines like this:
Pointer<IBStandardForceGen> ib_force_fcn = new IBStandardForceGen();
       
        //ib_force_fcn->registerSpringForceFunction(0, &linear_spring_force, &linear_spring_force_deriv);
        IBTK::vector<float> F(0, -mass_structure*9.8);
        ib_force_fcn->setUniformBodyForce(F, 0, level_number);

        ib_method_ops->registerIBLagrangianForceFunction(ib_force_fcn);
Is my code correct? 
I understand that structure_id starts from 0 but what does level_number means?

Each IB structure is assigned to a level of the AMR grid hierarchy, and the structure ID corresponds to the order in which structures are listed in the input file for a given level. It is zero-indexed, and so if there is only one structure, it will have structure_id == 0.

In terms of the level number, you are probably assigning the structure to the finest level of the grid, in which case level_number would be patch_hierarchy->getFinestLevelNumber()-1.

Let me sum up what needs to be done if I want to simulate a 2D cylinder with radius R and larger mass density which has N vertex in a 2D domain:
1. In input file, add ForcingFunction attribute and specify function_1 = "-RHO*9.8" to apply gravity term on N-S equation for background flow
2. In input file, add uniform_boundary_mass attribute to my structure (let's view it as a ring with mass M) and set it to M/N ,and the unit for M should be g not kg

Yes — for a codimension-1 case — for a codimension-0 case, you would want to use the “excess” mass of the structure.

3. In example.cpp file, add lines shown above
Am I correct?

I think so!

— Boyce

陈奕纯

unread,
Apr 18, 2025, 12:36:07 AMApr 18
to IBAMR Users
Thanks! I'll try it asap
Reply all
Reply to author
Forward
0 new messages