Accessing IBFE Mesh Points

106 views
Skip to first unread message

Wanda Strychalski

unread,
Jun 7, 2022, 2:44:22 PM6/7/22
to IBAMR Users
Hello,

I would like to access the points on the boundary of an IBFE mesh (created using libmesh) at each time point. My goal is to compute the smallest distance from an IBFE mesh to an IBAMR structure. I wanted to create a curve file that stores this distance over time. I saw the nice document by Aaron on how to access IB points, but I don’t see anything for IBFE data.

Thank you,
Wanda

Wells, David

unread,
Jun 8, 2022, 9:36:31 AM6/8/22
to ibamr...@googlegroups.com
Hi Wanda,

This requires a couple of steps since we need to pull stuff out of some internal IBAMR objects.

The system name we use for the position is FEMechanicsBase::COORDS_SYSTEM_NAME, so you can do

    auto &X_system = equation_systems.get_system<libMesh::System>(FEMechanicsBase::COORDS_SYSTEM_NAME);
    NumericVector<double> &positions = *X_system.solution;

to get the vector containing the present nodal coordinates (not displacements) out. You can then get the position of each node via

    const unsigned int X_sys_num = X_system.number();
    auto it = mesh.local_nodes_begin();
    const auto end_it = mesh.local_nodes_end();
    for (; it != end_it; ++it)
    {
        libMesh::Node* n = *it;
        {
            libMesh::Point X;
            for (unsigned int d = 0; d < NDIM; ++d)
            {
                X(d) = positions[n->dof_number(X_sys_num, d, 0)];
            }
        }
    }


Let me know if this works!

Best,
David

From: ibamr...@googlegroups.com <ibamr...@googlegroups.com> on behalf of Wanda Strychalski <wi...@case.edu>
Sent: Tuesday, June 7, 2022 2:44 PM
To: IBAMR Users <ibamr...@googlegroups.com>
Subject: [ibamr-users] Accessing IBFE Mesh Points
 
--
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 on the web visit https://groups.google.com/d/msgid/ibamr-users/DF01CB39-3146-49B4-81D4-C3E20EBB3732%40case.edu.

Boyce Griffith

unread,
Jun 8, 2022, 9:39:16 AM6/8/22
to noreply-spamdigest via IBAMR Users

On Jun 8, 2022, at 9:36 AM, Wells, David <drw...@email.unc.edu> wrote:

Hi Wanda,

This requires a couple of steps since we need to pull stuff out of some internal IBAMR objects.

The system name we use for the position is FEMechanicsBase::COORDS_SYSTEM_NAME, so you can do

    auto &X_system = equation_systems.get_system<libMesh::System>(FEMechanicsBase::COORDS_SYSTEM_NAME);
    NumericVector<double> &positions = *X_system.solution;

to get the vector containing the present nodal coordinates (not displacements) out. You can then get the position of each node via

    const unsigned int X_sys_num = X_system.number();
    auto it = mesh.local_nodes_begin();
    const auto end_it = mesh.local_nodes_end();
    for (; it != end_it; ++it)
    {
        libMesh::Node* n = *it;
        {
            libMesh::Point X;
            for (unsigned int d = 0; d < NDIM; ++d)
            {
                X(d) = positions[n->dof_number(X_sys_num, d, 0)];
            }
        }
    }


Let me know if this works!

PS: Note also that this will only give you access to the local (on processor) nodal positions. It will be more work to do this in parallel.

Best,
David

From: ibamr...@googlegroups.com <ibamr...@googlegroups.com> on behalf of Wanda Strychalski <wi...@case.edu>
Sent: Tuesday, June 7, 2022 2:44 PM
To: IBAMR Users <ibamr...@googlegroups.com>
Subject: [ibamr-users] Accessing IBFE Mesh Points
 
Hello,

I would like to access the points on the boundary of an IBFE mesh (created using libmesh) at each time point. My goal is to compute the smallest distance from an IBFE mesh to an IBAMR structure. I wanted to create a curve file that stores this distance over time. I saw the nice document by Aaron on how to access IB points, but I don’t see anything for IBFE data.

Thank you,
Wanda

-- 
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 on the web visit https://groups.google.com/d/msgid/ibamr-users/DF01CB39-3146-49B4-81D4-C3E20EBB3732%40case.edu.

-- 
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.

Wanda Strychalski

unread,
Jun 14, 2022, 5:33:13 PM6/14/22
to IBAMR Users

These are the error messages (file attached):
main.C: In function ‘int main(int, char**)’:
main.C:501:45: error: request for member ‘get_system’ in ‘mesh_equation_systems’, which is of pointer type ‘libMesh::EquationSystems*’ (maybe you meant to use ‘->’ ?)
      auto &X_system = mesh_equation_systems.get_system<libMesh::System>(FEMechanicsBase::COORDS_SYSTEM_NAME);
                                             ^~~~~~~~~~
main.C:501:71: error: expected primary-expression before ‘>’ token
      auto &X_system = mesh_equation_systems.get_system<libMesh::System>(FEMechanicsBase::COORDS_SYSTEM_NAME);

Thanks,
Wanda
main.C

Wells, David

unread,
Jun 16, 2022, 11:15:40 AM6/16/22
to IBAMR Users
Hi Wanda,

I think the compiler's suggested fix is the right one: if you have an EquationSystems * instead of a reference then you will need to dereference (i.e., use the -> operator).

Best,
David


From: ibamr...@googlegroups.com <ibamr...@googlegroups.com> on behalf of Wanda Strychalski <wi...@case.edu>
Sent: Tuesday, June 14, 2022 5:33 PM
To: IBAMR Users <ibamr...@googlegroups.com>
Subject: Re: [ibamr-users] Accessing IBFE Mesh Points
 

Wanda Strychalski

unread,
Jun 16, 2022, 2:59:30 PM6/16/22
to IBAMR Users
Ok, then this is the error that I get:

main.C: In function ‘int main(int, char**)’:
main.C:517:26: error: no match for ‘operator[]’ (operand types are ‘libMesh::NumericVector<double>’ and ‘libMesh::dof_id_type {aka unsigned int}’)
          X(d) = positions[n->dof_number(X_sys_num, d, 0)];


Also, do you know how to access just the nodes on the boundary? It will waste a lot of time to integrate over all of the mesh nodes. I was unable to find any useful examples on the libmesh GitHub.

Thanks,
Wanda

On Jun 16, 2022, at 11:15 AM, Wells, David <drw...@email.unc.edu> wrote:

Hi Wanda,

main.C

Wells, David

unread,
Jun 17, 2022, 2:17:47 PM6/17/22
to IBAMR Users
Hi Wanda,

Sorry, that should use parentheses, not brackets (I wrote this code and didn't run it - can you tell?) Try

    X(d) = positions(n->dof_number(X_sys_num, d, 0));

I don't think libMesh has a function for looping over boundary nodes. I think the best solution here is to put all the libMesh::Node *s you need in a std::set and use that whenever you want to loop across boundary nodes. In general, since nodes are shared by lots of elements, looping over all of them shouldn't be that bad.

Best,
David

From: ibamr...@googlegroups.com <ibamr...@googlegroups.com> on behalf of Wanda Strychalski <wi...@case.edu>
Sent: Thursday, June 16, 2022 2:59 PM

To: IBAMR Users <ibamr...@googlegroups.com>
Subject: Re: [ibamr-users] Accessing IBFE Mesh Points
--
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.

Best,
David


From: ibamr...@googlegroups.com <ibamr...@googlegroups.com> on behalf of Wanda Strychalski <wi...@case.edu>
Sent: Tuesday, June 14, 2022 5:33 PM
To: IBAMR Users <ibamr...@googlegroups.com>
Subject: Re: [ibamr-users] Accessing IBFE Mesh Points
 

These are the error messages (file attached):
main.C: In function ‘int main(int, char**)’:
main.C:501:45: error: request for member ‘get_system’ in ‘mesh_equation_systems’, which is of pointer type ‘libMesh::EquationSystems*’ (maybe you meant to use ‘->’ ?)
      auto &X_system = mesh_equation_systems.get_system<libMesh::System>(FEMechanicsBase::COORDS_SYSTEM_NAME);
                                             ^~~~~~~~~~
main.C:501:71: error: expected primary-expression before ‘>’ token
      auto &X_system = mesh_equation_systems.get_system<libMesh::System>(FEMechanicsBase::COORDS_SYSTEM_NAME);

Thanks,
Wanda
On Wednesday, June 8, 2022 at 9:39:16 AM UTC-4 boy...@gmail.com wrote:
On Jun 8, 2022, at 9:36 AM, Wells, David <drw...@email.unc.edu> wrote:

Hi Wanda,

This requires a couple of steps since we need to pull stuff out of some internal IBAMR objects.

The system name we use for the position is FEMechanicsBase::COORDS_SYSTEM_NAME, so you can do

    auto &X_system = equation_systems.get_system<libMesh::System>(FEMechanicsBase::COORDS_SYSTEM_NAME);
    NumericVector<double> &positions = *X_system.solution;

to get the vector containing the present nodal coordinates (not displacements) out. You can then get the position of each node via

    const unsigned int X_sys_num = X_system.number();
    auto it = mesh.local_nodes_begin();
    const auto end_it = mesh.local_nodes_end();
    for (; it != end_it; ++it)
    {
        libMesh::Node* n = *it;
        {
            libMesh::Point X;
            for (unsigned int d = 0; d < NDIM; ++d)
            {
                X(d) = positions[n->dof_number(X_sys_num, d, 0)];
            }
        }
    }

-- 
You received this message because you are subscribed to a topic in the Google Groups "IBAMR Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ibamr-users/VoYc0dvrfAE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ibamr-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/MN2PR03MB4879D8762E991C84953BCA17EDAC9%40MN2PR03MB4879.namprd03.prod.outlook.com.

--
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.

Aaron Barrett

unread,
Jun 17, 2022, 2:27:42 PM6/17/22
to IBAMR Users
Wanda,

One option is to sync a BoundaryMesh object to a volumetric mesh using the BoundaryInfo object. The BoundaryInfo object then has mappings between nodes and sides of the boundary mesh to the volumetric mesh. You can loop over the nodes or sides of the BoundaryMesh, and use the BoundaryInfo object to determine the corresponding parent node / element on the volumetric mesh.


Aaron

Wanda Strychalski

unread,
Jun 17, 2022, 9:51:00 PM6/17/22
to IBAMR Users

Hi Aaron,

Thanks, that was what I was trying to figure out. Could you please point me to an example code? 

- Wanda

--
You received this message because you are subscribed to a topic in the Google Groups "IBAMR Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ibamr-users/VoYc0dvrfAE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ibamr-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ibamr-users/5871c124-7ee3-47ed-a831-a00bc4a7b44dn%40googlegroups.com.

Aaron Barrett

unread,
Jun 20, 2022, 12:22:52 PM6/20/22
to IBAMR Users
I don't think there's an example in IBAMR that does this. You can take a look at this class:

This class is designed to create a boundary mesh and keep it updated with a volumetric mesh via the displacements stored in the volumetric FEDataManager. There are two relevant parts.

This function creates a boundary mesh from a volumetric mesh
and this function pulls out the boundary location and stores it in a separate EquationSystems object



Aaron

Wanda Strychalski

unread,
Jun 28, 2022, 2:31:11 PM6/28/22
to IBAMR Users
In case anyone else needs to do this, here is my solution:

1. Set the boundary nodes (in my case, points on the circle)
    BoundaryInfo & boundary_info =  solid_mesh.get_boundary_info(); // ws
    double dist = 0;
    for (MeshBase::node_iterator it = solid_mesh.nodes_begin(); it != solid_mesh.nodes_end(); ++it)
        {
            Node* n = *it;
            libMesh::Point& x = *n;
            dist = sqrt(x(0)*x(0)+x(1)*x(1));
            if( abs(R_scaled-dist)<1e-14) {
                boundary_info.add_node(n,(boundary_id_type) 0); // create a new class of boundary nodes with the identifier "0"
            }
    }
2. Modify the iterator within the time loop

         auto it = mesh.bid_nodes_begin(0); // iterate over the boundary nodes (0 indicates the type of boundary node)
         const auto end_it = mesh.bid_nodes_end(0);

         for (; it != end_it; ++it)
           {
         libMesh::Node* n = *it;
         {
           libMesh::Point X;
           for (unsigned int d = 0; d < NDIM; ++d)
             {
               X(d) = positions(n->dof_number(X_sys_num, d, 0));
               pout<<X(d)<<"\t"; // print out the nodes to make sure it's just the boundary
       
             }
            pout<<"\n";
         }
           }

Reply all
Reply to author
Forward
0 new messages