void TestRemeshSingleBranch() throw(Exception) { //Load a single branch mesh file TrianglesMeshReader<1,3> reader("mesh/test/data/1D_in_3D_0_to_1mm_10_elements"); TetrahedralMesh<1,3> mesh; mesh.ConstructFromMeshReader(reader); //We need to add some attributes to the mesh for (TetrahedralMesh<1,3>::NodeIterator iter = mesh.GetNodeIteratorBegin(); iter != mesh.GetNodeIteratorEnd(); ++iter) { iter->AddNodeAttribute(0.05); } //Create remesher object AirwayRemesher remesher(mesh, 0u); //Check intermediate elements are removed. Poiseuille resistance of the branch is // C*0.1/((0.05^4) = C*1.6 * 10^4 MutableMesh<1,3> output_mesh_one; remesher.Remesh(output_mesh_one, 1e5); //With this tolerance all intermediate nodes should be removed. TS_ASSERT_EQUALS(output_mesh_one.GetNumNodes(), 2u); TS_ASSERT_EQUALS(output_mesh_one.GetNumElements(), 1u); TS_ASSERT_DELTA(output_mesh_one.GetElement(0)->GetAttribute(), 0.05, 1e-6); MutableMesh<1,3> output_mesh_two; remesher.Remesh(output_mesh_two, 0.8e4); //With this tolerance there should be one intermediate node. TS_ASSERT_EQUALS(output_mesh_two.GetNumNodes(), 3u); TS_ASSERT_EQUALS(output_mesh_two.GetNumElements(), 2u); TS_ASSERT_DELTA(output_mesh_two.GetElement(0)->GetAttribute(), 0.05, 1e-6); MutableMesh<1,3> output_mesh_three; remesher.Remesh(output_mesh_three, 1.6e3); //With this tolerance there should be ten elements. TS_ASSERT_EQUALS(output_mesh_three.GetNumNodes(), 11u); TS_ASSERT_EQUALS(output_mesh_three.GetNumElements(), 10u); TS_ASSERT_DELTA(output_mesh_three.GetElement(0)->GetAttribute(), 0.05, 1e-6); TS_ASSERT_DELTA(output_mesh_three.GetElement(5)->GetAttribute(), 0.05, 1e-6); //To visualise //VtkMeshWriter<1,3> writer("TestAirwayRemesher", "1D_remeshed"); //writer.WriteFilesUsingMesh(output_mesh_three); }
void TestMultipleFrequencies() throw(Exception) { TetrahedralMesh<1,3> mesh; //TrianglesMeshReader<1,3> mesh_reader("mesh/test/data/y_branch_3d_mesh"); TrianglesMeshReader<1,3> mesh_reader("lung/test/data/TestSubject002"); mesh.ConstructFromMeshReader(mesh_reader); //Scale all radii by 0.7 to give an FRC equivalent lung for (TetrahedralMesh<1,3>::NodeIterator node_iter = mesh.GetNodeIteratorBegin(); node_iter != mesh.GetNodeIteratorEnd(); ++node_iter) { node_iter->rGetNodeAttributes()[0] *= 0.7; } std::vector<double> test_frequencies; test_frequencies.push_back(1.0); test_frequencies.push_back(2.0); test_frequencies.push_back(3.0); test_frequencies.push_back(5.0); test_frequencies.push_back(10.0); test_frequencies.push_back(20.0); test_frequencies.push_back(30.0); SimpleImpedanceProblem problem(mesh, 0u); problem.SetMeshInMilliMetres(); problem.SetFrequencies(test_frequencies); //Set & get frequencies for coverage std::vector<double>& freqs = problem.rGetFrequencies(); TS_ASSERT_EQUALS(freqs.size(), 7u); problem.Solve(); std::vector<std::complex<double> > impedances = problem.rGetImpedances(); TS_ASSERT_EQUALS(impedances.size(), 7u); //These are hard coded from previous runs, but are as expected for //a patient with moderate to severe asthma TS_ASSERT_DELTA(real(impedances[0])*1e-3/98, 8.45, 1e-2); TS_ASSERT_DELTA(imag(impedances[0])*1e-3/98, -3.65, 1e-2); TS_ASSERT_DELTA(real(impedances[6])*1e-3/98, 5.77, 1e-2); TS_ASSERT_DELTA(imag(impedances[6])*1e-3/98, 4.12, 1e-2); }