コード例 #1
0
ファイル: main.C プロジェクト: MSV-Project/IBAMR
void
update_triads(
    const double freq,
    tbox::Pointer<hier::PatchHierarchy<NDIM> > hierarchy,
    LDataManager* const l_data_manager,
    const double current_time,
    const double /*dt*/)
{
    // The angular velocity.
    static const double angw = 2.0*M_PI*freq;

    // The LMesh object provides the set of local Lagrangian nodes.
    const int finest_ln = hierarchy->getFinestLevelNumber();
    const tbox::Pointer<LMesh> mesh = l_data_manager->getLMesh(finest_ln);
    const std::vector<LNode*>& local_nodes = mesh->getNodes();

    // Update the director triads for all anchored points.
    tbox::Pointer<LData> D_data = l_data_manager->getLData("D", finest_ln);
    blitz::Array<double,2>& D_array = *D_data->getLocalFormVecArray();
    for (std::vector<LNode*>::const_iterator cit = local_nodes.begin();
         cit != local_nodes.end(); ++cit)
    {
        const LNode& node_idx = **cit;

        // If spec is NULL, then the IB point is NOT anchored.  Otherwise, the
        // IB point IS anchored.
        tbox::Pointer<IBAnchorPointSpec> spec = node_idx.getNodeDataItem<IBAnchorPointSpec>();
        if (!spec.isNull())
        {
            // `global_idx' is the index of the vertex in the input file.
            const int global_idx = node_idx.getLagrangianIndex();
            NULL_USE(global_idx);

            // `local_petsc_idx' is the index of the vertex in the internal
            // IBAMR data structures.  Generally, global_idx != local_petsc_idx.
            const int local_petsc_idx = node_idx.getLocalPETScIndex();

            double* D1 = &D_array(local_petsc_idx,0);
            D1[0] =  cos(angw*current_time);
            D1[1] =  sin(angw*current_time);
            D1[2] = 0.0;

            double* D2 = &D_array(local_petsc_idx,3);
            D2[0] = -sin(angw*current_time);
            D2[1] =  cos(angw*current_time);
            D2[2] = 0.0;

            double* D3 = &D_array(local_petsc_idx,6);
            D3[0] = 0.0;
            D3[1] = 0.0;
            D3[2] = 1.0;
        }
    }
    D_data->restoreArrays();
    return;
}// update_triads