Commit 657df759 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#302 Write the very simple test.

parent 48bff4d3
......@@ -15,6 +15,7 @@
# include <iostream>
# include <memory>
# include <cassert>
# include <unordered_map>
# include "ThirdParty/IncludeWithoutWarning/Seldon/Seldon.hpp"
# include "ThirdParty/IncludeWithoutWarning/Petsc/PetscSys.hpp"
......@@ -421,6 +422,24 @@ namespace HappyHeart
//! Specialization for Volume.
template<>
unsigned int GeometricMeshRegion::DetermineNInterface<Volume>() const;
/*!
* \brief Computes coloring for a \a geometric_mesh_region.
*
* The present algorithm attributes 'colors' to each GeometricElt so that two adjacent GeometricElt never
* share the same color. As few colors as possible are used here.
*
* \param[in] geometric_mesh_region GeometricMeshRegion for which the coloring is computed.
* \param[in] dimension Only geometric elements of a given dimension are considered here.
*
* Beware: this algorithm acts processor-wise: if it is called after the reduction to processor-wise data,
* it will actupon them alone and not on the whole initial object.
*
* \return The coloring attributed for each geometric elements.
*/
std::unordered_map<GeometricElt::shared_ptr, unsigned int> ComputeColoring(const GeometricMeshRegion& geometric_mesh_region,
unsigned int dimension);
......
......@@ -6,13 +6,25 @@
// Copyright (c) 2014 Inria. All rights reserved.
//
#include "*REPLACE_WITH_FOLDER_PATH*/GeometricMeshRegion_ComputeColoring.hpp"
#include "Utilities/Containers/UnorderedMap.hpp"
#include "Geometry/GeometricMeshRegion.hpp"
namespace HappyHeart
{
std::unordered_map<GeometricElt::shared_ptr, unsigned int> ComputeColoring(const GeometricMeshRegion& geometric_mesh_region,
unsigned int dimension)
{
std::unordered_map<GeometricElt::shared_ptr, unsigned int> ret;
ret.max_load_factor(Utilities::DefaultMaxLoadFactor());
return std::move(ret);
}
......
......@@ -7,70 +7,48 @@
//
#include <iostream>
#include <sstream>
#include "Utilities/TimeKeep/TimeKeep.hpp"
#include "Geometry/GeometricMeshRegion.hpp"
#include "Geometry/GeometricReferenceElements/Triangle3.hpp"
#include "Geometry/GeometricReferenceElements/Segment3.hpp"
#include "Geometry/GeometricReferenceElements/Segment2.hpp"
#include "Geometry/GeometricReferenceElements/Triangle6.hpp"
int main(int argc, char** argv)
{
using namespace HappyHeart;
Wrappers::Mpi::InitEnvironment(argc, argv);
std::string felisce_mesh_directory = "/Volumes/Data/sebastien/Felisce/Data/mesh/";
std::string work_directory = "/Volumes/Data/sebastien/Tmp/";
Wrappers::Mpi::shared_ptr mpi_world_ptr = std::make_shared<Wrappers::Mpi>(0, Wrappers::MpiNS::Comm::World); // must be called before Petsc RAII
Wrappers::Mpi::shared_ptr mpi_world_ptr = std::make_shared<Wrappers::Mpi>(0, MPI_COMM_WORLD);
std::string time_log_filename;
try
{
{
GeometricMeshRegion mesh(mpi_world_ptr);
mesh.Init(felisce_mesh_directory + "tube_tetra_10kv.mesh",
GeometricMeshRegion::Format::Medit,
work_directory);
mesh.Write<GeometricMeshRegion::Format::Medit>(work_directory + "tube_tetra_10kv.mesh", 1);
}
{
GeoRef::Triangle6 triangle;
std::cout << triangle.ShapeFunctionList().size() << std::endl;
Utilities::PrintContainer(triangle.ReferenceNodeOnVertex());
}
// {
// GeometricMeshRegion mesh(mpi_world_ptr);
// mesh.Init(felisce_mesh_directory + "fibre_tetra_1172v.geo",
// GeometricMeshRegion::Format::Ensight,
// work_directory);
//
// mesh.Write<GeometricMeshRegion::Format::Ensight>(work_directory + "fibre_tetra_1172v.geo");
// }
}
catch (const std::exception& e)
{
std::cout << "EXCEPTION CAUGHT" << std::endl;
std::cout << e.what() << std::endl;
std::ostringstream oconv;
oconv << "/Volumes/Data/sebastien/HappyHeart/Results/TestColoring/TimeLogs/time_log."
<< mpi_world_ptr->Rank<int>() << ".txt";
time_log_filename = std::move(oconv.str());
}
std::cout << "SUCCESS!" << std::endl;
std::ofstream log_time_elapsed(time_log_filename);
TimeKeep::CreateOrGetInstance(log_time_elapsed);
GeometricMeshRegion mesh(mpi_world_ptr,
"/Volumes/Data/sebastien/Freefem/Elasticity/Data/Medit/elasticity_Nx50_Ny20.mesh",
Format::Type::Medit,
GeometricMeshRegion::BuildEdge::no,
GeometricMeshRegion::BuildFace::no,
GeometricMeshRegion::BuildVolume::no);
auto coloring = std::move(ComputeColoring(mesh, 2));
for (const auto& pair : coloring)
std::cout << "Geometric element " << pair.first->GetIndex() << " gets color " << pair.second << std::endl;
std::cout << "Coloring is ok!" << std::endl;
return EXIT_SUCCESS;
}
......@@ -28,7 +28,17 @@ test_ondomatic_numbering = env.Program('test_ondomatic_numbering', main_ondomati
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
list_exec.extend((test, test_ondomatic_numbering))
main_coloring_src = Split('''
Geometry/main_test_coloring.cpp
''')
test_coloring = env.Program('test_coloring', main_coloring_src,
LIBS=all_libs,
LIBPATH=env['LIBPATH'])
list_exec.extend((test, test_ondomatic_numbering, test_coloring))
Return('list_exec')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment