Commit 808d52c8 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#772 VertexMatching: renaming, clean-up and documentation.

parent 1c18b201
......@@ -719,7 +719,7 @@ FiniteElementSpace7 = {
-- Solid
DofProgramWiseIndexListPerVertexCoordIndex1 = {
InitVertexMatchingInterpolator1 = {
-- Finite element space for which the dofs index will be associated to each vertex.
-- Expected format: VALUE
......@@ -729,11 +729,11 @@ DofProgramWiseIndexListPerVertexCoordIndex1 = {
-- Expected format: "VALUE"
numbering_subset = 7
} -- DofProgramWiseIndexListPerVertexCoordIndex1
} -- InitVertexMatchingInterpolator1
-- Fluid
DofProgramWiseIndexListPerVertexCoordIndex2 = {
InitVertexMatchingInterpolator2 = {
-- Finite element space for which the dofs index will be associated to each vertex.
-- Expected format: VALUE
......@@ -743,7 +743,7 @@ DofProgramWiseIndexListPerVertexCoordIndex2 = {
-- Expected format: "VALUE"
numbering_subset = 6
} -- DofProgramWiseIndexListPerVertexCoordIndex2
} -- InitVertexMatchingInterpolator2
Petsc1 = {
......
......@@ -118,13 +118,10 @@ namespace HappyHeart
}
void DofProgramWiseIndexListPerVertexCoordIndex::ReduceToProcessorWise()
DofProgramWiseIndexListPerVertexCoordIndex::storage_type
DofProgramWiseIndexListPerVertexCoordIndex::ComputeProcessorWiseStorage() const
{
#ifndef NDEBUG
assert(!is_reduced_to_processor_wise_);
is_reduced_to_processor_wise_ = true;
#endif // NDEBUG
const auto& felt_space = GetFEltSpace();
const auto god_of_dof_ptr = felt_space.GetGodOfDofPtr();
......@@ -133,17 +130,9 @@ namespace HappyHeart
const auto& coords_list = mesh.GetCoordsList();
storage_type reduced_storage;
auto& storage = GetNonCstDofProgramWiseIndexPerCoordIndex();
const auto& storage = GetDofProgramWiseIndexPerCoordIndex();
const auto end_storage = storage.cend();
std::cout << "Possibilities: ";
Utilities::PrintKeys(storage);
// auto& Nprocessor_wise_dof = Nprocessor_wise_dof_;
std::cout << "Check " << storage.size() << " ";
for (const auto& coords_ptr : coords_list)
{
assert(!(!coords_ptr));
......@@ -154,21 +143,14 @@ namespace HappyHeart
auto it = storage.find(coords_index);
if (it != end_storage)
{
reduced_storage.insert(*it);
// Nprocessor_wise_dof += it->second.size();
}
}
std::cout << "\n" << felt_space.MpiHappyHeart().GetRankPreffix() << " STORAGE before/after for " << felt_space.GetUniqueId() << " = " << storage.size() << "\t" << reduced_storage.size() << std::endl;
std::swap(storage, reduced_storage);
return reduced_storage;
}
unsigned int DofProgramWiseIndexListPerVertexCoordIndex::ComputeNprocessorWisedof()
unsigned int DofProgramWiseIndexListPerVertexCoordIndex::ComputeNprocessorWisedof() const
{
const auto& felt_space = GetFEltSpace();
decltype(auto) complete_dof_list = felt_space.GetProcessorWiseDofList();
......
......@@ -68,6 +68,9 @@ namespace HappyHeart
* the fact a shared_pointer is no longer useful, so I can't use it at this moment.
*
* A VertexMatching interpolator actually requires two such class: one for source and the other for target.
*
* \attention This class is intended at a very specific point of GodOfDof initialization (namely in GodOfDof::Init2(),
* after some data have been initializaed but before any processor-wise redutciton occurred).
*/
class DofProgramWiseIndexListPerVertexCoordIndex
: public ::HappyHeart::Crtp::UniqueId<DofProgramWiseIndexListPerVertexCoordIndex, UniqueIdNS::AssignationMode::manual>
......@@ -79,7 +82,7 @@ namespace HappyHeart
using self = DofProgramWiseIndexListPerVertexCoordIndex;
//! Alias to unique pointer.
using unique_ptr = std::unique_ptr<self>;
using const_unique_ptr = std::unique_ptr<const self>;
//! Friendship to manager.
friend DofProgramWiseIndexListPerVertexCoordIndexManager;
......@@ -101,8 +104,8 @@ namespace HappyHeart
//! Constructor.
explicit DofProgramWiseIndexListPerVertexCoordIndex(unsigned int unique_id,
const FEltSpace& felt_space,
const NumberingSubset& numbering_subset);
const FEltSpace& felt_space,
const NumberingSubset& numbering_subset);
//! Destructor.
~DofProgramWiseIndexListPerVertexCoordIndex() = default;
......@@ -123,41 +126,63 @@ namespace HappyHeart
public:
//!
//! Finite element space considered.
const FEltSpace& GetFEltSpace() const noexcept;
//! Numbering subset considered.
const NumberingSubset& GetNumberingSubset() const noexcept;
//! Number of (program-wise) dofs.
unsigned int NprogramWisedof() const noexcept;
unsigned int ComputeNprocessorWisedof();
/*!
* \brief Compute the number of processor-wise dofs.
*
* \attention This method must be called once all GodOfDofs are fully initialized (so NOT in the constructor
* for instance).
*/
unsigned int ComputeNprocessorWisedof() const;
/*!
* \brief Constant access to the actual storage: key is the index of the Coords (which must be a vertex)
* and values are the program-wise indexes of the dofs.
*/
const storage_type& GetDofProgramWiseIndexPerCoordIndex() const noexcept;
void ReduceToProcessorWise();
//! Return a reduced storage in which only the processor-wise Coords are considered.
storage_type ComputeProcessorWiseStorage() const;
private:
/*!
* \brief Non constant access to the actual storage: key is the index of the Coords (which must be a vertex)
* and values are the program-wise indexes of the dofs.
*/
storage_type& GetNonCstDofProgramWiseIndexPerCoordIndex() noexcept;
private:
//! Finite element space considered.
const FEltSpace& felt_space_;
//! Numbering subset considered.
const NumberingSubset& numbering_subset_;
/*!
* \brief Actual storage: key is the index of the Coords (which must be a vertex) and values are the
* program-wise indexes of the dofs.
*/
storage_type dof_program_wise_index_per_coord_index_;
/*!
* \brief Number of (program-wise) dofs considered.
*
* \internal It should be noticed that when the object is created the number of processor-wise dofs
* is not known.
*/
unsigned int Nprogram_wise_dof_ = 0u;
// unsigned int Nprocessor_wise_dof_ = 0u;
# ifndef NDEBUG
bool is_reduced_to_processor_wise_ = false;
# endif // NDEBUG
};
......
......@@ -53,7 +53,7 @@ namespace HappyHeart
DofProgramWiseIndexListPerVertexCoordIndex* buf
= new DofProgramWiseIndexListPerVertexCoordIndex(unique_id, felt_space, numbering_subset);
auto&& ptr = DofProgramWiseIndexListPerVertexCoordIndex::unique_ptr(buf);
auto&& ptr = DofProgramWiseIndexListPerVertexCoordIndex::const_unique_ptr(buf);
assert(ptr->GetUniqueId() == unique_id);
......@@ -67,10 +67,10 @@ namespace HappyHeart
}
DofProgramWiseIndexListPerVertexCoordIndex& DofProgramWiseIndexListPerVertexCoordIndexManager
::GetNonCstDofProgramWiseIndexListPerVertexCoordIndex(unsigned int unique_id)
const DofProgramWiseIndexListPerVertexCoordIndex& DofProgramWiseIndexListPerVertexCoordIndexManager
::GetDofProgramWiseIndexListPerVertexCoordIndex(unsigned int unique_id) const
{
auto& list = GetNonCstStorage();
const auto& list = GetStorage();
auto it = list.find(unique_id);
assert(it != list.cend());
......
......@@ -80,7 +80,8 @@ namespace HappyHeart
~DofProgramWiseIndexListPerVertexCoordIndexManager() = default;
//! Fetch the object associated with \a unique_id unique identifier.
DofProgramWiseIndexListPerVertexCoordIndex& GetNonCstDofProgramWiseIndexListPerVertexCoordIndex(unsigned int unique_id);
const DofProgramWiseIndexListPerVertexCoordIndex&
GetDofProgramWiseIndexListPerVertexCoordIndex(unsigned int unique_id) const;
private:
......@@ -113,7 +114,7 @@ namespace HappyHeart
private:
//! Store the god of dof objects by their unique identifier.
std::unordered_map<unsigned int, DofProgramWiseIndexListPerVertexCoordIndex::unique_ptr> list_;
std::unordered_map<unsigned int, DofProgramWiseIndexListPerVertexCoordIndex::const_unique_ptr> list_;
};
......
......@@ -36,8 +36,6 @@ namespace HappyHeart
template<class SolidVariationalFormulationPolicyT>
void Model<SolidVariationalFormulationPolicyT>::SupplInitialize(const InputParameterList& input_parameter_data)
{
std::cout << "SUPPL INIT 0" << std::endl;
const auto& fluid_god_of_dof = this->GetGodOfDof(EnumUnderlyingType(MeshIndex::fluid));
const auto& unknown_manager = UnknownManager::GetInstance();
const auto& mpi = this->MpiHappyHeart();
......@@ -65,7 +63,7 @@ namespace HappyHeart
sum_fluid_residual_ = std::make_unique<GlobalVector>(formulation.GetSystemRhs(numbering_subset));
}
std::cout << "SUPPL INIT 10" << std::endl;
{
const auto& numbering_subset =
fluid_god_of_dof.GetNumberingSubset(EnumUnderlyingType(NumberingSubsetIndex::fluid_velocity_pressure));
......@@ -93,7 +91,7 @@ namespace HappyHeart
auto& formulation = this->GetNonCstImplicitStepFluidVariationalFormulation();
formulation.Init(input_parameter_data);
}
std::cout << "SUPPL INIT 20" << std::endl;
const auto& solid_god_of_dof = this->GetGodOfDof(EnumUnderlyingType(MeshIndex::solid));
{
const auto& solid_numbering_subset =
......@@ -101,7 +99,7 @@ namespace HappyHeart
solid_residual_ = std::make_unique<GlobalVector>(solid_numbering_subset);
AllocateGlobalVector(solid_god_of_dof, *solid_residual_);
}
std::cout << "SUPPL INIT 30" << std::endl;
{
const auto& solid_displacement = unknown_manager.GetUnknown(EnumUnderlyingType(UnknownIndex::solid_displacement));
const auto& main_felt_space = solid_god_of_dof.GetFEltSpace(EnumUnderlyingType(FEltSpaceIndex::solid));
......@@ -165,21 +163,8 @@ namespace HappyHeart
}
}
std::cout << "SUPPL INIT 50" << std::endl;
{
const auto& fsi_solid_felt_space =
solid_god_of_dof.GetFEltSpace(EnumUnderlyingType(FEltSpaceIndex::fsi_solid));
const auto& fsi_solid_numbering_subset =
solid_god_of_dof.GetNumberingSubset(EnumUnderlyingType(NumberingSubsetIndex::solid_velocity_on_interface));
const auto& fsi_fluid_numbering_subset =
fluid_god_of_dof.GetNumberingSubset(EnumUnderlyingType(NumberingSubsetIndex::fluid_on_interface));
const auto& fsi_fluid_felt_space =
fluid_god_of_dof.GetFEltSpace(EnumUnderlyingType(FEltSpaceIndex::fsi_fluid));
{
NonConformInterpolatorNS::pairing_type pairing
{
std::make_pair(unknown_manager.GetUnknownPtr(EnumUnderlyingType(UnknownIndex::solid_velocity)),
......@@ -191,8 +176,8 @@ namespace HappyHeart
solid_to_fluid_velocity_on_fsi_interpolator_ =
std::make_unique<NonConformInterpolatorNS::FromVertexMatching>(input_parameter_data,
init_vertex_matching_manager.GetNonCstDofProgramWiseIndexListPerVertexCoordIndex(EnumUnderlyingType(InitVertexMatchingInterpolator::solid)),
init_vertex_matching_manager.GetNonCstDofProgramWiseIndexListPerVertexCoordIndex(EnumUnderlyingType(InitVertexMatchingInterpolator::fluid)),
init_vertex_matching_manager.GetDofProgramWiseIndexListPerVertexCoordIndex(EnumUnderlyingType(InitVertexMatchingInterpolator::solid)),
init_vertex_matching_manager.GetDofProgramWiseIndexListPerVertexCoordIndex(EnumUnderlyingType(InitVertexMatchingInterpolator::fluid)),
std::move(pairing));
}
......
......@@ -27,14 +27,14 @@ namespace HappyHeart
void FromVertexMatching::Construct(const GeometryNS::InterpolationNS::VertexMatching& vertex_matching,
Private::DofProgramWiseIndexListPerVertexCoordIndex& source,
Private::DofProgramWiseIndexListPerVertexCoordIndex& target,
const Private::DofProgramWiseIndexListPerVertexCoordIndex& source,
const Private::DofProgramWiseIndexListPerVertexCoordIndex& target,
pairing_type&& pairing)
{
interpolation_matrix_ = std::make_unique<GlobalMatrix>(target.GetNumberingSubset(),
source.GetNumberingSubset());
target.ReduceToProcessorWise();
Unknown::vector_const_shared_ptr source_unknown_list;
Unknown::vector_const_shared_ptr target_unknown_list;
......@@ -56,9 +56,6 @@ namespace HappyHeart
const auto Nprogram_wise_source_dof = source.NprogramWisedof();
const auto Nprogram_wise_target_dof = target.NprogramWisedof();
std::cout << source.GetFEltSpace().MpiHappyHeart().GetRankPreffix() << " SOURCE " << Nprocessor_wise_source_dof << " - "<< Nprogram_wise_source_dof << std::endl;
std::cout << source.GetFEltSpace().MpiHappyHeart().GetRankPreffix() << " TARGET " << Nprocessor_wise_target_dof << " - "<< Nprogram_wise_target_dof << std::endl;
assert(Nprogram_wise_source_dof == Nprogram_wise_target_dof);
assert(!source_dof_index_list_per_coord_index.empty());
......@@ -74,8 +71,9 @@ namespace HappyHeart
const auto end_dof_list_target = complete_dof_list_target.cend();
const auto target_dof_list_per_proc_wise_coord_index = target.ComputeProcessorWiseStorage();
for (const auto& pair : target_dof_index_list_per_coord_index)
for (const auto& pair : target_dof_list_per_proc_wise_coord_index)
{
// Use geometric data to make source and target vertices match.
// Consider only Coords handled processor-wisely.
......
......@@ -88,8 +88,8 @@ namespace HappyHeart
*/
template<class InputParameterDataT>
explicit FromVertexMatching(const InputParameterDataT& input_parameter_data,
Private::DofProgramWiseIndexListPerVertexCoordIndex& source,
Private::DofProgramWiseIndexListPerVertexCoordIndex& target,
const Private::DofProgramWiseIndexListPerVertexCoordIndex& source,
const Private::DofProgramWiseIndexListPerVertexCoordIndex& target,
pairing_type&& pairing);
//! Destructor.
......@@ -116,8 +116,8 @@ namespace HappyHeart
//! Construct the object. Should not be called outside of constructor.
void Construct(const GeometryNS::InterpolationNS::VertexMatching& vertex_matching,
Private::DofProgramWiseIndexListPerVertexCoordIndex& source,
Private::DofProgramWiseIndexListPerVertexCoordIndex& target,
const Private::DofProgramWiseIndexListPerVertexCoordIndex& source,
const Private::DofProgramWiseIndexListPerVertexCoordIndex& target,
pairing_type&& pairing);
private:
......
......@@ -20,8 +20,8 @@ namespace HappyHeart
template<class InputParameterDataT>
FromVertexMatching::FromVertexMatching(const InputParameterDataT& input_parameter_data,
Private::DofProgramWiseIndexListPerVertexCoordIndex& source,
Private::DofProgramWiseIndexListPerVertexCoordIndex& target,
const Private::DofProgramWiseIndexListPerVertexCoordIndex& source,
const Private::DofProgramWiseIndexListPerVertexCoordIndex& target,
pairing_type&& pairing)
{
GeometryNS::InterpolationNS::VertexMatching vertex_matching(input_parameter_data);
......
Markdown is supported
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