当前位置: 首页>>代码示例>>C++>>正文


C++ TetrahedralMesh::GetDistributedVectorFactory方法代码示例

本文整理汇总了C++中TetrahedralMesh::GetDistributedVectorFactory方法的典型用法代码示例。如果您正苦于以下问题:C++ TetrahedralMesh::GetDistributedVectorFactory方法的具体用法?C++ TetrahedralMesh::GetDistributedVectorFactory怎么用?C++ TetrahedralMesh::GetDistributedVectorFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TetrahedralMesh的用法示例。


在下文中一共展示了TetrahedralMesh::GetDistributedVectorFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestSolveCellSystemsInclUpdateVoltage

    void TestSolveCellSystemsInclUpdateVoltage() throw(Exception)
    {
        HeartConfig::Instance()->Reset();
        TetrahedralMesh<1,1> mesh;
        mesh.ConstructRegularSlabMesh(1.0, 1.0); // [0,1] with h=1.0, ie 2 node mesh

        MyCardiacCellFactory cell_factory;
        cell_factory.SetMesh(&mesh);

        MonodomainTissue<1> monodomain_tissue( &cell_factory );

        Vec voltage = PetscTools::CreateAndSetVec(2, -81.4354); // something that isn't resting potential
        monodomain_tissue.SolveCellSystems(voltage, 0, 1, false); // solve for 1ms without updating the voltage

        if (mesh.GetDistributedVectorFactory()->IsGlobalIndexLocal(0))
        {
            TS_ASSERT_DELTA(monodomain_tissue.GetCardiacCell(0)->GetVoltage(), -81.4354, 1e-3);
        }

        if (mesh.GetDistributedVectorFactory()->IsGlobalIndexLocal(1))
        {
            TS_ASSERT_DELTA(monodomain_tissue.GetCardiacCell(1)->GetVoltage(), -81.4354, 1e-3);
        }

        Vec voltage2 = PetscTools::CreateAndSetVec(2, -75);
        monodomain_tissue.SolveCellSystems(voltage2, 1, 2, true); // solve another ms, using this new voltage, but now updating the voltage too
        ReplicatableVector voltage2_repl(voltage2); // should have changed following solve

        // check the new voltage in the cell is NEAR -75 (otherwise the passed in voltage wasn't used, but
        // NOT EXACTLY -75, ie that the voltage was solved for.
        if (mesh.GetDistributedVectorFactory()->IsGlobalIndexLocal(0))
        {
            // check has been updated
            TS_ASSERT_DIFFERS(monodomain_tissue.GetCardiacCell(0)->GetVoltage(), -75);
            // check near -75
            TS_ASSERT_DELTA(monodomain_tissue.GetCardiacCell(0)->GetVoltage(), -75, 2.0); // within 2mV
            // check the passed in voltage was updated
            TS_ASSERT_DELTA(voltage2_repl[0], monodomain_tissue.GetCardiacCell(0)->GetVoltage(), 1e-10);
        }
        if (mesh.GetDistributedVectorFactory()->IsGlobalIndexLocal(1))
        {
            TS_ASSERT_DIFFERS(monodomain_tissue.GetCardiacCell(1)->GetVoltage(), -75);
            TS_ASSERT_DELTA(monodomain_tissue.GetCardiacCell(1)->GetVoltage(), -75, 2.0); // within 2mV
            TS_ASSERT_DELTA(voltage2_repl[1], monodomain_tissue.GetCardiacCell(1)->GetVoltage(), 1e-10);
        }

        PetscTools::Destroy(voltage);
        PetscTools::Destroy(voltage2);
    }
开发者ID:getshameer,项目名称:Chaste,代码行数:49,代码来源:TestMonodomainTissue.hpp

示例2: TestMonodomainTissueGetCardiacCell

    void TestMonodomainTissueGetCardiacCell() throw(Exception)
    {
        HeartConfig::Instance()->Reset();
        TetrahedralMesh<1,1> mesh;
        mesh.ConstructRegularSlabMesh(1.0, 1.0); // [0,1] with h=1.0, ie 2 node mesh

        MyCardiacCellFactory cell_factory;
        cell_factory.SetMesh(&mesh);

        MonodomainTissue<1> monodomain_tissue( &cell_factory );

        if (mesh.GetDistributedVectorFactory()->IsGlobalIndexLocal(0))
        {
            AbstractCardiacCellInterface* cell = monodomain_tissue.GetCardiacCell(0);
            TS_ASSERT_DELTA(cell->GetStimulus(0.001),-80,1e-10);
        }

        if (mesh.GetDistributedVectorFactory()->IsGlobalIndexLocal(1))
        {
            AbstractCardiacCellInterface* cell = monodomain_tissue.GetCardiacCell(1);
            TS_ASSERT_DELTA(cell->GetStimulus(0.001),0,1e-10);
        }
    }
开发者ID:getshameer,项目名称:Chaste,代码行数:23,代码来源:TestMonodomainTissue.hpp

示例3: throw

    void TestExtendedTissueHeterogeneousGgap3D() throw (Exception)
    {
        HeartConfig::Instance()->Reset();
        TrianglesMeshReader<3,3> mesh_reader("mesh/test/data/cube_2mm_12_elements");
        TetrahedralMesh<3,3> mesh;
        mesh.ConstructFromMeshReader(mesh_reader);

        std::vector<boost::shared_ptr<AbstractChasteRegion<3> > > heterogeneity_areas;
        std::vector<double> Ggap_values;

        //first cuboid include node 0
        ChastePoint<3> cornerA(-1, -1, 0);
        ChastePoint<3> cornerB(0.001, 0.001, 0.001);
        boost::shared_ptr<ChasteCuboid<3> > p_cuboid_1(new ChasteCuboid<3>(cornerA, cornerB));
        heterogeneity_areas.push_back(p_cuboid_1);

        //second cuboid include node 6
        ChastePoint<3> cornerC(0.199, 0.199, 0.199);
        ChastePoint<3> cornerD(0.25, 0.25, 0.25);
        boost::shared_ptr<ChasteCuboid<3> > p_cuboid_2(new ChasteCuboid<3>(cornerC, cornerD));
        ChasteCuboid<3> cuboid_2(cornerC, cornerD);

        heterogeneity_areas.push_back(p_cuboid_2);

        //within the first area
        Ggap_values.push_back(143.0);
        //within the second area
        Ggap_values.push_back(9143.0);
        //elsewhere
        double isotropic_ggap=586.0;

        StimulatedCellFactory stimulated_cell_factory;
        UnStimulatedCellFactory unstimulated_cell_factory;
        ExtracellularStimulusFactory extracellular_stimulus_factory;

        stimulated_cell_factory.SetMesh(&mesh);
        unstimulated_cell_factory.SetMesh(&mesh);
        extracellular_stimulus_factory.SetMesh(&mesh);

        ExtendedBidomainTissue<3>  extended_bidomain_tissue( &stimulated_cell_factory,  &unstimulated_cell_factory, &extracellular_stimulus_factory);

        extended_bidomain_tissue.SetGGap(isotropic_ggap);//this is what the problem class does first

        extended_bidomain_tissue.SetGgapHeterogeneities(heterogeneity_areas, Ggap_values);
        extended_bidomain_tissue.CreateGGapConductivities();

        unsigned probe_node_1 = 0u;
        unsigned probe_node_2 = 6u;
        unsigned probe_node_3 = 5u;

        const std::vector<unsigned>& r_permutation = mesh.rGetNodePermutation();
        if (!r_permutation.empty())
        {
            probe_node_1 = r_permutation[0u];//within first cuboid
            probe_node_2 = r_permutation[6u];//within second cuboid
            probe_node_3 = r_permutation[5u];//elsewhere
        }

        Vec vector =  mesh.GetDistributedVectorFactory()->CreateVec();
        DistributedVector dist_solution = mesh.GetDistributedVectorFactory()->CreateDistributedVector(vector);
        for (DistributedVector::Iterator index = dist_solution.Begin();
             index != dist_solution.End();
             ++index)
        {
            extended_bidomain_tissue.UpdateAdditionalCaches(index.Global, index.Local, 2.0);
        }
        extended_bidomain_tissue.ReplicateAdditionalCaches();

        //Ggap
        TS_ASSERT_EQUALS(extended_bidomain_tissue.rGetGgapCacheReplicated()[probe_node_1],143.0);//within first cuboid
        TS_ASSERT_EQUALS(extended_bidomain_tissue.rGetGgapCacheReplicated()[probe_node_2],9143.0);//within second cuboid
        TS_ASSERT_EQUALS(extended_bidomain_tissue.rGetGgapCacheReplicated()[probe_node_3],586.0);//elsewhere

        PetscTools::Destroy(vector);
    }
开发者ID:Chaste,项目名称:Old-Chaste-svn-mirror,代码行数:75,代码来源:TestExtendedBidomainTissue.hpp


注:本文中的TetrahedralMesh::GetDistributedVectorFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。