Пример #1
0
IdxData* IdxData::findChildWithBadPosition() const
{
    IdxDataComparer<RelaxedTagValueComparer> comparer(m_order);
    IdxData* result = nullptr;

    for(size_t i = 1; i < m_children.size(); i++)
        if (comparer(m_children[i - 1], m_children[i]) == false)
        {
            result = m_children[i - 1];
            break;
        }

    return result;
}
    void TestBidomainWithBathCanOutputVariables() throw(Exception)
    {
        HeartConfig::Instance()->SetSimulationDuration(0.01);  //ms
        HeartConfig::Instance()->SetMeshFileName("mesh/test/data/1D_0_to_1_10_elements_with_two_attributes");
        HeartConfig::Instance()->SetOutputDirectory("BidomainBathOutputVariables");
        HeartConfig::Instance()->SetOutputFilenamePrefix("BidomainLR91_1d");
        HeartConfig::Instance()->SetVisualizeWithMeshalyzer();

        std::vector<std::string> output_variables;
        output_variables.push_back("cytosolic_calcium_concentration");
        HeartConfig::Instance()->SetOutputVariables(output_variables);

        std::set<unsigned> tissue_ids;
        tissue_ids.insert(0); // Same as default value defined in HeartConfig
        std::set<unsigned> bath_ids;
        bath_ids.insert(1);
        HeartConfig::Instance()->SetTissueAndBathIdentifiers(tissue_ids, bath_ids);

        PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 1> cell_factory;
        BidomainWithBathProblem<1> bidomain_problem(&cell_factory);

        bidomain_problem.Initialise();
        bidomain_problem.Solve();

        FileFinder calcium_results("BidomainBathOutputVariables/output/BidomainLR91_1d_cytosolic_calcium_concentration.dat",
                                   RelativeTo::ChasteTestOutput);

        TS_ASSERT_EQUALS(calcium_results.IsFile(), true);

        FileFinder reference_results("heart/test/data/BidomainBathOutputVariables/BidomainLR91_1d_cytosolic_calcium_concentration.dat",
                                     RelativeTo::ChasteSourceRoot);

        NumericFileComparison comparer(calcium_results, reference_results);
        TS_ASSERT_EQUALS(comparer.CompareFiles(), true);
    }
Пример #3
0
/**
 * @brief Recherche un Etat dans une liste
 * @param[in] e l'Etat a rechercher
 * @param[in,out] l la Liste dans laquelle chercher
 * @return true si l'Etat a été trouvé, false sinon
 */
bool rechercher(const Etat& e, Liste& l) {
	for (unsigned int i = 0; i< longueur(l); ++i) {
		if (comparer(e.damier, lire(l, i).damier))
			return true;
	}
	return false;
}
Пример #4
0
    /**
     * This tests the HDF5 to .txt converter using a 3D example
     * taken from a bidomain simulation.
     */
    void TestBidomainTxtConversion3D() throw(Exception)
    {
        std::string working_directory = "TestHdf5ToTxtConverter_bidomain";

        /*
         * Firstly, copy the .h5 file to CHASTE_TEST_OUTPUT/TestHdf5ToTxtConverter_bidomain,
         * as that is where the reader reads from.
         */
        CopyToTestOutputDirectory("pde/test/data/cube_2mm_12_elements.h5",
                                  working_directory);

        TrianglesMeshReader<3,3> mesh_reader("mesh/test/data/cube_2mm_12_elements");
        TetrahedralMesh<3,3> mesh;
        mesh.ConstructFromMeshReader(mesh_reader);

        // Convert
        Hdf5ToTxtConverter<3,3> converter(FileFinder(working_directory, RelativeTo::ChasteTestOutput),
                                          "cube_2mm_12_elements", &mesh);

        std::vector<std::string> files_to_compare;
        files_to_compare.push_back("cube_2mm_12_elements_V_0.txt");
        files_to_compare.push_back("cube_2mm_12_elements_V_1.txt");
        files_to_compare.push_back("cube_2mm_12_elements_Phi_e_0.txt");
        files_to_compare.push_back("cube_2mm_12_elements_Phi_e_1.txt");

        for (unsigned i=0; i<files_to_compare.size(); i++)
        {
            std::cout << "Comparing generated and reference " << files_to_compare[i] << std::endl;
            FileFinder generated_file(working_directory +"/txt_output/" + files_to_compare[i], RelativeTo::ChasteTestOutput);
            FileFinder reference_file("pde/test/data/" + files_to_compare[i], RelativeTo::ChasteSourceRoot);
            NumericFileComparison comparer(generated_file, reference_file);
            TS_ASSERT(comparer.CompareFiles());
        }
    }
Пример #5
0
    /**
    * This tests the HDF5 to XDMF converter
    */
    void TestHdf5ToXdmfConverter() throw(Exception)
    {
#ifndef _MSC_VER
        std::string working_directory = "TestHdf5Converters_TestHdf5ToXdmfConverter";

        CopyToTestOutputDirectory("pde/test/data/cube_2mm_12_elements.h5",
                                  working_directory);

        TrianglesMeshReader<3,3> mesh_reader("mesh/test/data/cube_2mm_12_elements");
        TetrahedralMesh<3,3> mesh;
        mesh.ConstructFromMeshReader(mesh_reader);

        // Convert
        Hdf5ToXdmfConverter<3,3> converter(FileFinder(working_directory, RelativeTo::ChasteTestOutput),
                                           "cube_2mm_12_elements",
                                           &mesh);

        std::vector<std::string> files_to_compare;
        files_to_compare.push_back("cube_2mm_12_elements.xdmf");
        files_to_compare.push_back("cube_2mm_12_elements_geometry_0.xml");
        files_to_compare.push_back("cube_2mm_12_elements_topology_0.xml");

        for (unsigned i=0; i<files_to_compare.size(); i++)
        {
            std::cout << "Comparing generated and reference " << files_to_compare[i] << std::endl;
            FileFinder generated_file(working_directory +"/xdmf_output/" + files_to_compare[i], RelativeTo::ChasteTestOutput);
            FileFinder reference_file("pde/test/data/xdmf_output/" + files_to_compare[i], RelativeTo::ChasteSourceRoot);
            FileComparison comparer(generated_file, reference_file);
            TS_ASSERT(comparer.CompareFiles());
        }
#endif // _MSC_VER
    }
Пример #6
0
Pokemon * Trainer::mergeLevelArrays(Pokemon * a, Pokemon * b)
{
	if (!a || !b)
	{
		return NULL;
	}
	int numOfPokemons = idTree.getSize();
	Pokemon* merged = new Pokemon[numOfPokemons];
	if (!merged)
	{
		return NULL;
	}
	int aIndex = 0, bIndex = 0;
	pokemonCompareByLevel comparer = pokemonCompareByLevel();
	for (int i = 0; i < numOfPokemons; i++)
	{
		if (comparer(a[aIndex], b[bIndex]))
		{
			merged[i] = a[aIndex];
			aIndex++;
		}
		else
		{
			merged[i] = b[bIndex];
			bIndex++;
		}
	}

	return merged;
}
Пример #7
0
static TOffsetMap FindEquivalentSubtries(const TOpaqueTrie& trie, bool verbose, size_t minMergeSize) {
    // Tree nodes, arranged by span length.
    // When all nodes of a given size are considered, they pop off the queue.
    TPieceIndex subtries;
    TOffsetMap merger;
    // Start walking the trie from head.
    AddPiece(subtries, 0, trie.Length);

    size_t counter = 0;
    // Now consider all nodes with sizeable continuations
    for (size_t curlen = trie.Length; curlen >= minMergeSize && !subtries.empty(); curlen--) {
        TPieceIndex::iterator iit = subtries.find(curlen);

        if (iit == subtries.end())
            continue; // fast forward to the next available length value

        TOffsetList& batch = iit->second;
        TPieceComparer comparer(trie.Data, curlen);
        Sort(batch.begin(), batch.end(), comparer);

        TOffsetList::iterator it = batch.begin();
        while (it != batch.end()) {
            if (verbose)
                ShowProgress(++counter);

            size_t offset = *it;

            // Fill the array with the subnodes of the element
            TNode node(trie.Data, offset, trie.SkipFunction);
            size_t end = offset + curlen;
            if (size_t rightOffset = node.GetRightOffset()) {
                AddPiece(subtries, rightOffset, end - rightOffset);
                end = rightOffset;
            }
            if (size_t leftOffset = node.GetLeftOffset()) {
                AddPiece(subtries, leftOffset, end - leftOffset);
                end = leftOffset;
            }
            if (size_t forwardOffset = node.GetForwardOffset()) {
                AddPiece(subtries, forwardOffset, end - forwardOffset);
            }

            while (++it != batch.end()) {
                // Find next different; until then, just add the offsets to the list of merged nodes.
                size_t nextoffset = *it;

                if (memcmp(trie.Data + offset, trie.Data + nextoffset, curlen))
                    break;

                merger.Add(nextoffset, offset);
            }
        }

        subtries.erase(curlen);
    }
    if (verbose) {
        Cerr << counter << Endl;
    }
    return merger;
}
SyntheticVolumeComparerPtr ReconstructionManagerTestFixture::getComparerForOutput(SyntheticReconstructInputPtr input, int index)
{
	SyntheticVolumeComparerPtr comparer(new SyntheticVolumeComparer());
	comparer->setVerbose(this->getVerbose());
	comparer->setPhantom(input->getPhantom());
	comparer->setTestImage(this->getOutput()[index]);
	return comparer;
}
Пример #9
0
long IdxData::findPositionFor(const IdxData* child) const
{
    IdxDataComparer<TagValueComparer> comparer(m_order);

    const auto pos = std::upper_bound(m_children.cbegin(), m_children.cend(), child, comparer);

    return pos - m_children.cbegin();
}
Пример #10
0
static void write_data(io::stream& e, bsdata* pd, bool(*comparer)(void* object, const bsreq* type)) {
	if(!pd)
		return;
	for(int index = 0; index < (int)pd->getcount(); index++) {
		auto object = pd->get(index);
		if(comparer && !comparer(object, pd->fields))
			write_object(e, object);
	}
}
Пример #11
0
bool IdxData::sortingRequired() const
{
    IdxDataComparer<TagValueComparer> comparer(m_order);

    const bool sorted = std::is_sorted(m_children.cbegin(), m_children.cend(), comparer);
    const bool required = !sorted;

    return required;
}
Пример #12
0
static const struct optioninfo *find1(const char **optp,
				      const struct optioninfo *table,
				      comparer_type *comparer) {
  for (;;) {
    if (table->type == ot_end) return 0;
    if (comparer(optp,table)) return table;
    table++;
  }
}
Пример #13
0
bool Style::equals(const Style* style) const {
	// The StyleEqualComparer is dependent on the serialize method that isn't
	// const. But we know that we aren't changing anything so we removes the
	// const to make it compile.
	Style* rhs = const_cast<Style*>(style);
	Style* lhs = const_cast<Style*>(this);
	StyleEqualComparer comparer(lhs, rhs);
	rhs->serialize(comparer);
	return comparer.equal;
}
Пример #14
0
bool areTangentialAtPoint(const Vector<T, 2>& point,
                          Vector<T, 2> fromA, Vector<T, 2> toA,
                          Vector<T, 2> fromB, Vector<T, 2> toB,
                          double tolerance)
{
    DirectionComparer2<T> comparer(point, tolerance);
    if (!comparer(fromA, toA))
      std::swap(fromA, toA);
    if (!comparer(fromB, toB))
      std::swap(fromB, toB);

    if (comparer.compare(toA, fromB) <= 0)
      return true;
    else if (comparer.compare(fromA, toB) >= 0)
      return true;
    else
      return std::abs(comparer.compare(fromA, fromB) +
                      comparer.compare(toA, toB)) != 2;
}
    void TestWritingBinaryFormat()
    {
        //Read as ascii
        TrianglesMeshReader<2,2> reader("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements");

        //Write as binary
        TrianglesMeshWriter<2,2> writer_from_reader("TestMixedDimensionMesh", "CableMeshBinary", false);
        writer_from_reader.SetWriteFilesAsBinary();
        writer_from_reader.WriteFilesUsingMeshReader(reader);

        PetscTools::Barrier();
        //Read created binary file into a mesh
        std::string results_dir = OutputFileHandler::GetChasteTestOutputDirectory() + "TestMixedDimensionMesh/";
        TrianglesMeshReader<2,2> binary_reader(results_dir + "CableMeshBinary");
        MixedDimensionMesh<2,2> binary_mesh(DistributedTetrahedralMeshPartitionType::DUMB);
        binary_mesh.ConstructFromMeshReader(binary_reader);

        //Read original file into a mesh
        std::string mesh_base("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements");
        TrianglesMeshReader<2,2> original_reader(mesh_base);
        MixedDimensionMesh<2,2> original_mesh(DistributedTetrahedralMeshPartitionType::DUMB);
        original_mesh.ConstructFromMeshReader(original_reader);

        //Compare to original
        TS_ASSERT_EQUALS(binary_mesh.GetNumNodes(), original_mesh.GetNumNodes());
        TS_ASSERT_EQUALS(binary_mesh.GetNumElements(), original_mesh.GetNumElements());

        TS_ASSERT_EQUALS(binary_mesh.GetNumCableElements(), original_mesh.GetNumCableElements());

        MixedDimensionMesh<2,2>::CableElementIterator original_iter = original_mesh.GetCableElementIteratorBegin();
        for (MixedDimensionMesh<2,2>::CableElementIterator binary_iter = binary_mesh.GetCableElementIteratorBegin();
             binary_iter != binary_mesh.GetCableElementIteratorEnd();
             ++binary_iter)
        {
            TS_ASSERT_EQUALS((*binary_iter)->GetNumNodes(), (*original_iter)->GetNumNodes());
            TS_ASSERT_EQUALS((*binary_iter)->GetNodeGlobalIndex(0u), (*original_iter)->GetNodeGlobalIndex(0u));
            TS_ASSERT_EQUALS((*binary_iter)->GetNodeGlobalIndex(1u), (*original_iter)->GetNodeGlobalIndex(1u));
            TS_ASSERT_DELTA((*binary_iter)->GetAttribute(), (*original_iter)->GetAttribute(), 1e-12);

            ++original_iter;
        }

        //Write a binary from the original mesh
        TrianglesMeshWriter<2,2> writer_from_mesh("TestMixedDimensionMesh", "CableMeshBinaryFromMesh", false);
        writer_from_mesh.SetWriteFilesAsBinary();
        writer_from_mesh.WriteFilesUsingMesh(original_mesh);

        //Compare the binary written from the reader to the binary written from the mesh
        FileFinder generated(results_dir + "/CableMeshBinary.cable");
        FileFinder reference(results_dir + "/CableMeshBinaryFromMesh.cable");
        FileComparison comparer(generated,reference);
        TS_ASSERT(comparer.CompareFiles());
    }
void* queue_buffer_find(struct queue_buffer* qb, const void *item, 
		int (*comparer)(const void*, const void*)) {

	struct queue_buffer_s *i = qb->used_head;
	for(; i != NULL; i = i->next) {
		if (comparer(i->data, item)) {
			return i->data;
		}
	}

	return NULL;
}
    void TestWritingCableFilesUsingMeshReader() throw(Exception)
    {
        std::string mesh_base("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements");
        TrianglesMeshReader<2,2> reader(mesh_base);

        TrianglesMeshWriter<2,2> mesh_writer("TestMixedDimensionMesh", "CableMeshFromReader");
        mesh_writer.WriteFilesUsingMeshReader(reader);
        PetscTools::Barrier("TestWritingCableFilesUsingMeshReader");

        FileFinder generated("TestMixedDimensionMesh/CableMeshFromReader.cable",RelativeTo::ChasteTestOutput);
        FileFinder reference("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements.cable", RelativeTo::ChasteSourceRoot);
        FileComparison comparer(generated,reference);
        TS_ASSERT(comparer.CompareFiles());
    }
    void TestCellCycleModelOutputParameters()
    {
        std::string output_directory = "TestCellCycleModelOutputParameters";
        OutputFileHandler output_file_handler(output_directory, false);

        // Test with Alarcon2004OxygenBasedCellCycleModel
        Alarcon2004OxygenBasedCellCycleModel alarcon_oxygen_based_cell_cycle_model;
        TS_ASSERT_EQUALS(alarcon_oxygen_based_cell_cycle_model.GetIdentifier(), "Alarcon2004OxygenBasedCellCycleModel");

        out_stream alarcon_oxygen_based_parameter_file = output_file_handler.OpenOutputFile("alarcon_oxygen_based_results.parameters");
        alarcon_oxygen_based_cell_cycle_model.OutputCellCycleModelParameters(alarcon_oxygen_based_parameter_file);
        alarcon_oxygen_based_parameter_file->close();

        {
            FileFinder generated_file = output_file_handler.FindFile("alarcon_oxygen_based_results.parameters");
            FileFinder reference_file("cell_based/test/data/TestCellCycleModels/alarcon_oxygen_based_results.parameters",
                                      RelativeTo::ChasteSourceRoot);
            FileComparison comparer(generated_file,reference_file);
            TS_ASSERT(comparer.CompareFiles());
        }

        // Test with TysonNovakCellCycleModel
        TysonNovakCellCycleModel tyson_novak_based_cell_cycle_model;
        TS_ASSERT_EQUALS(tyson_novak_based_cell_cycle_model.GetIdentifier(), "TysonNovakCellCycleModel");

        out_stream tyson_novak_based_parameter_file = output_file_handler.OpenOutputFile("tyson_novak_based_results.parameters");
        tyson_novak_based_cell_cycle_model.OutputCellCycleModelParameters(tyson_novak_based_parameter_file);
        tyson_novak_based_parameter_file->close();

        {
            FileFinder generated_file = output_file_handler.FindFile("tyson_novak_based_results.parameters");
            FileFinder reference_file("cell_based/test/data/TestCellCycleModels/tyson_novak_based_results.parameters",
                                      RelativeTo::ChasteSourceRoot);
            FileComparison comparer(generated_file,reference_file);
            TS_ASSERT(comparer.CompareFiles());
        }
    }
    void TestUseInPopulationWriteResultsToFile()
    {
        EXIT_IF_PARALLEL;

        // Set up SimulationTime (needed if VTK is used)
        SimulationTime::Instance()->SetEndTimeAndNumberOfTimeSteps(1.0, 1);

        // Create a simple mesh-based cell population, comprising various cell types in various cell cycle phases
        TrianglesMeshReader<2,2> mesh_reader("mesh/test/data/square_4_elements");
        MutableMesh<2,2> mesh;
        mesh.ConstructFromMeshReader(mesh_reader);

        std::vector<CellPtr> cells;
        CellsGenerator<VanLeeuwen2009WntSwatCellCycleModelHypothesisOne, 2> cells_generator;
        cells_generator.GenerateBasic(cells, mesh.GetNumNodes());

        MeshBasedCellPopulation<2> cell_population(mesh, cells);

        // Create an instance of a Wnt concentration
        WntConcentration<2>::Instance()->SetType(LINEAR);
        WntConcentration<2>::Instance()->SetCellPopulation(cell_population);
        WntConcentration<2>::Instance()->SetCryptLength(1.0);

        cell_population.InitialiseCells();

        // This is where we add the writer
        cell_population.AddCellWriter<CellBetaCateninWriter>();

        // This method is usually called by Update()
        cell_population.CreateVoronoiTessellation();

        std::string output_directory = "TestUseInPopulationWriteResultsToFile";
        OutputFileHandler output_file_handler(output_directory, false);

        cell_population.OpenWritersFiles(output_file_handler);
        cell_population.WriteResultsToFiles(output_directory);

        SimulationTime::Instance()->IncrementTimeOneStep();
        cell_population.Update();

        cell_population.WriteResultsToFiles(output_directory);
        cell_population.CloseWritersFiles();

        // Compare output with saved file of what they should look like
        std::string results_dir = output_file_handler.GetOutputDirectoryFullPath();

        FileComparison comparer(results_dir + "results.vizbetacatenin","crypt/test/data/TestCellBetaCateninWriter/results2.vizbetacatenin");
        TS_ASSERT(comparer.CompareFiles());
    }
Пример #20
0
    void TestAxiWriterAscii()
    {
        FileFinder file_finder("heart/test/data/fibre_tests/SimpleAxisymmetric2.axi", RelativeTo::ChasteSourceRoot);
        FibreReader<3> fibre_reader(file_finder, AXISYM);
        std::vector< c_vector<double, 3> > fibre_vector;
        fibre_reader.GetAllAxi(fibre_vector);

        // Write ascii file
        FibreWriter<3> fibre_writer("TestFibreWriter", "SimpleAxisymmetric2", true);
        fibre_writer.WriteAllAxi(fibre_vector);

        std::string results_dir = OutputFileHandler::GetChasteTestOutputDirectory() + "TestFibreWriter/";
        FileComparison comparer(results_dir + "/SimpleAxisymmetric2.axi","heart/test/data/fibre_tests/SimpleAxisymmetric2.axi");
        TS_ASSERT(comparer.CompareFiles());
    }
    void TestWritingCableFiles() throw(Exception)
    {
        std::string mesh_base("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements");
        TrianglesMeshReader<2,2> reader(mesh_base);
        MixedDimensionMesh<2,2> mesh(DistributedTetrahedralMeshPartitionType::DUMB);
        mesh.ConstructFromMeshReader(reader);

        TrianglesMeshWriter<2,2> mesh_writer("TestMixedDimensionMesh", "CableMesh", true);

        mesh_writer.WriteFilesUsingMesh(mesh);

        FileFinder generated("TestMixedDimensionMesh/CableMesh.cable",RelativeTo::ChasteTestOutput);
        FileFinder reference("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements.cable", RelativeTo::ChasteSourceRoot);
        FileComparison comparer(generated,reference);
        TS_ASSERT(comparer.CompareFiles());
    }
Пример #22
0
    inline STORAGE process_chunk(const SlicingIndex& indices) {
      int n = indices.size();
      if (n == 0 || idx > n || idx < -n) return def;

      int i = idx > 0 ? (idx -1) : (n+idx);

      typedef VectorSliceVisitor<ORDER_RTYPE> Slice;
      typedef OrderVectorVisitorImpl<ORDER_RTYPE,true,Slice> Visitor;
      typedef Compare_Single_OrderVisitor<Visitor> Comparer;

      Comparer comparer(Visitor(Slice(order, indices)));
      IntegerVector sequence = seq(0,n-1);
      std::nth_element(sequence.begin(), sequence.begin() + i, sequence.end(), comparer);

      return data[ indices[ sequence[i] ] ];
    }
Пример #23
0
    void TestOrthoWriterAscii()
    {
        FileFinder file_finder("heart/test/data/fibre_tests/Orthotropic3D.ortho", RelativeTo::ChasteSourceRoot);
        FibreReader<3> fibre_reader(file_finder, ORTHO);
        std::vector< c_vector<double, 3> > fibres;
        std::vector< c_vector<double, 3> > second;
        std::vector< c_vector<double, 3> > third;
        fibre_reader.GetAllOrtho(fibres, second, third);

        //Write ascii file
        FibreWriter<3> fibre_writer("TestFibreWriter", "Orthotropic3D", false);
        fibre_writer.WriteAllOrtho(fibres, second, third);

        std::string results_dir = OutputFileHandler::GetChasteTestOutputDirectory() + "TestFibreWriter/";

        FileComparison comparer(results_dir + "/Orthotropic3D.ortho","heart/test/data/fibre_tests/Orthotropic3D.ortho");
        TS_ASSERT(comparer.CompareFiles());
    }
Пример #24
0
    void TestSwitchingUpdateRuleOutputUpdateRuleInfo()
    {
        std::string output_directory = "TestCaSwitchingUpdateRulesOutputParameters";
        OutputFileHandler output_file_handler(output_directory, false);

        // Test with RandomCaSwitchingUpdateRule
        RandomCaSwitchingUpdateRule<2> random_switching_update_rule;
        random_switching_update_rule.SetSwitchingParameter(1.0);

        TS_ASSERT_EQUALS(random_switching_update_rule.GetIdentifier(), "RandomCaSwitchingUpdateRule-2");

        out_stream random_switching_update_rule_parameter_file = output_file_handler.OpenOutputFile("random_switching_update_rule_results.parameters");
        random_switching_update_rule.OutputUpdateRuleInfo(random_switching_update_rule_parameter_file);
        random_switching_update_rule_parameter_file->close();

        // Compare the generated file in test output with a reference copy in the source code.
        FileFinder generated = output_file_handler.FindFile("random_switching_update_rule_results.parameters");
        FileFinder reference("cell_based/test/data/TestCaUpdateRules/random_switching_update_rule_results.parameters",
                RelativeTo::ChasteSourceRoot);
        FileComparison comparer(generated, reference);
        TS_ASSERT(comparer.CompareFiles());
    }
    void TestSimpleTargetAreaModifierOutputParameters()
    {
        EXIT_IF_PARALLEL;
        std::string output_directory = "TestSimpleTargetAreaModifierOutputParameters";
        OutputFileHandler output_file_handler(output_directory, false);

        MAKE_PTR(SimpleTargetAreaModifier<2>, p_modifier);
        TS_ASSERT_EQUALS(p_modifier->GetIdentifier(), "SimpleTargetAreaModifier-2");

        out_stream modifier_parameter_file = output_file_handler.OpenOutputFile("SimpleTargetAreaModifier.parameters");
        p_modifier->OutputSimulationModifierParameters(modifier_parameter_file);
        modifier_parameter_file->close();

        {
            // Compare the generated file in test output with a reference copy in the source code
            FileFinder generated = output_file_handler.FindFile("SimpleTargetAreaModifier.parameters");
            FileFinder reference("cell_based/test/data/TestSimulationModifierOutputParameters/SimpleTargetAreaModifier.parameters",
                    RelativeTo::ChasteSourceRoot);
            FileComparison comparer(generated, reference);
            TS_ASSERT(comparer.CompareFiles());
        }
    }
Пример #26
0
    void TestUpdateRuleOutputUpdateRuleInfo()
    {
        std::string output_directory = "TestCaUpdateRulesOutputParameters";
        OutputFileHandler output_file_handler(output_directory, false);

        // Test with VolumeConstraintPottsUpdateRule
        DiffusionCaUpdateRule<2> diffusion_update_rule;
        diffusion_update_rule.SetDiffusionParameter(1.0);

        TS_ASSERT_EQUALS(diffusion_update_rule.GetIdentifier(), "DiffusionCaUpdateRule-2");

        out_stream diffusion_update_rule_parameter_file = output_file_handler.OpenOutputFile("diffusion_update_rule_results.parameters");
        diffusion_update_rule.OutputUpdateRuleInfo(diffusion_update_rule_parameter_file);
        diffusion_update_rule_parameter_file->close();

        // Compare the generated file in test output with a reference copy in the source code.
        FileFinder generated = output_file_handler.FindFile("diffusion_update_rule_results.parameters");
        FileFinder reference("cell_based/test/data/TestCaUpdateRules/diffusion_update_rule_results.parameters",
                RelativeTo::ChasteSourceRoot);
        FileComparison comparer(generated, reference);
        TS_ASSERT(comparer.CompareFiles());
    }
Пример #27
0
    void TestCellBasedPdeHandlerOutputParameters() throw(Exception)
    {
        EXIT_IF_PARALLEL;

        std::string output_directory = "TestCellBasedPdeHandlerOutputParameters";
        OutputFileHandler output_file_handler(output_directory, false);

        // Create a cell population
        HoneycombMeshGenerator generator(2, 2, 0);
        MutableMesh<2,2>* p_generating_mesh = generator.GetMesh();
        NodesOnlyMesh<2> mesh;
        mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);

        std::vector<CellPtr> cells;
        CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasic(cells, mesh.GetNumNodes());

        NodeBasedCellPopulation<2> cell_population(mesh, cells);

        // Create a PDE handler object using this cell population
        CellBasedPdeHandler<2> pde_handler(&cell_population);

        // Test output methods
        TS_ASSERT_EQUALS(pde_handler.GetIdentifier(), "CellBasedPdeHandler-2");

        out_stream pde_handler_parameter_file = output_file_handler.OpenOutputFile("CellBasedPdeHandler.parameters");
        pde_handler.OutputParameters(pde_handler_parameter_file);
        pde_handler_parameter_file->close();

        {
            // Compare the generated file in test output with a reference copy in the source code.
            FileFinder generated = output_file_handler.FindFile("CellBasedPdeHandler.parameters");
            FileFinder reference("cell_based/test/data/TestCellBasedPdeHandler/CellBasedPdeHandler.parameters",
                    RelativeTo::ChasteSourceRoot);
            FileComparison comparer(generated, reference);
            TS_ASSERT(comparer.CompareFiles());
        }
    }
Пример #28
0
int main(){
  int nombreutilisateur,nombreverifie,nombrealeatoire;
  bool victoire=false;
  int compteur=0,rejouer;

  nombrealeatoire = alea(1,10000);

  while(victoire==false){

    nombreutilisateur = demander();
    print_newline();
    print_newline();
    

    nombreverifie = verifier(nombreutilisateur);

    victoire = comparer(nombreverifie,nombrealeatoire);

    compteur = compteur+1;}

  print_text("Vous avez trouvé la solution en ");
  print_int(compteur);
  print_text(" coups");
  print_newline();
  print_newline();

  print_text("Voulez vous rejouer ? : Oui ? tapez(1), Non ? tapez (2) : ");
  print_newline();
  print_newline();

  rejouer=read_int();

  if(rejouer==1){main();}

  else{print_text("Au revoir !"); print_newline();print_newline();}

  return 0;}
    void EnergyService::FilterCloseNeighbors()
    {
        if (maxCloseNeighborsCount <= 0)
        {
            return;
        }

        const Packing& particlesRef = *particles;
        closeNeighborsMask.resize(neighborsCount);
        VectorUtilities::InitializeWith(&closeNeighborsMask, false);

        sortingPermutation.resize(neighborsCount);
        VectorUtilities::FillLinearScale(0, &sortingPermutation);

        distancesToNeighborSurfaces.resize(neighborsCount);
        for (ParticleIndex i = 0; i < neighborsCount; ++i)
        {
            ParticleIndex neighborIndex = neighborIndexes[i];
            const Particle* neighbor = &particlesRef[neighborIndex];

            //No need to subtract current particle radius, as it's equal for all the entries, and won't affect sorting results
            distancesToNeighborSurfaces[i] = distancesToNeighbors[i] - neighbor->diameter * 0.5;
        }

        // NOTE: Here we compare distances to neighbor sphere surfaces, not normalized distances,
        // as we would like to treat small and large particles equally while energy minimization (to ensure isostaticity as early as possible).
        // TODO: this is algorithm-specific, so we may extract it later into a separate IParticleEnergyService or add IPotentialCutoffService.
        IndexesComparer<FLOAT_TYPE> comparer(distancesToNeighborSurfaces);
        StlUtilities::SortByNthElement(&sortingPermutation, maxCloseNeighborsCount - 1, comparer);

        for (ParticleIndex i = 0; i < maxCloseNeighborsCount; ++i)
        {
            ParticleIndex closeNeighborIndex = sortingPermutation[i];
            closeNeighborsMask[closeNeighborIndex] = true;
        }
    }
void CMemSpyEngineHelperCodeSegment::GetCodeSegmentHandlesL( RArray<TAny*>& aHandles, TUint* aProcessId, TBool aRamOnly ) const
    {
	TAny* handles[ KMemSpyEngineMaxCodeSegmentCount ];
	TInt count = KMemSpyEngineMaxCodeSegmentCount;

	TInt r = KErrNone;
	
	if  ( aProcessId == NULL )
    	{
	    r = iEngine.Driver().GetCodeSegs( handles, count, aRamOnly );
	    }
    else
	    {
	    r = iEngine.Driver().GetCodeSegs( *aProcessId, handles, count );
	    }

	if  ( r == KErrNone )
    	{
        TInt index;
        TLinearOrder< TAny* > comparer( SortByAddress );
        
        // Remove duplicates - since we reqested code segments for all processes, there
        // might be some dupes.
        count = Min( count, KMemSpyEngineMaxCodeSegmentCount );
        for( index = 0; index < count; index++ )
            {
            TAny* handle = handles[ index ];
            const TInt error = aHandles.InsertInOrder( handle, comparer );
            //
            if  ( ! (error == KErrNone || error == KErrAlreadyExists ) )
                {
                User::Leave( error );
                }
            }
        }
    }