Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,70 +28,66 @@
#include <string>
#include <string_view>

#include <vector>

#include <absl/container/flat_hash_set.h>
#include <absl/functional/function_ref.h>
#include <absl/types/span.h>

#include <geode/io/time_series/common.hpp>
#include <geode/io/time_series/internal/brep_blocks_matcher.hpp>
#include <geode/io/time_series/internal/pvd_point_sets.hpp>

namespace geode
{
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMesh );
ALIAS_3D( SolidMesh );
class AttributeManager;
class BRep;
} // namespace geode

namespace geode::internal
{
class BRepTimeAttributesTransfer
// Writes the attributes of the .pvd datasets on the PVDPointSets
class PVDAttributesTransfer
{
// Elements of one dataset of a time step and their mappings to
// the Block elements
// Elements of one dataset of a time step, the point set vertices they
// fill and the mapping to them
struct DatasetElements
{
AttributeManager& manager;
const absl::flat_hash_map< uuid, GenericMapping< index_t > >&
block_mappings;
AttributeManager& target;
const GenericMapping< index_t >& mapping;
};

public:
BRepTimeAttributesTransfer( BRep& brep,
explicit PVDAttributesTransfer(
absl::Span< const std::string_view > ignored_attributes );

/*!
* Write the attributes of all the datasets of a time step (e.g. one
* per GEOS region and per MPI rank) as time step attributes of the
* Block meshes.
* time series point sets (unique vertices and cell barycenters).
* Attributes sharing a name across the datasets are merged into a
* single time step attribute per Block.
* single time step attribute.
* @warning The attributes of the given meshes are modified: those
* sharing a name are given the same id.
*/
void write_step( double time,
absl::Span< const std::unique_ptr< SolidMesh3D > > meshes,
absl::Span< const SolidToBlocksMappings > mappings );
const PVDPointSets& point_sets );

private:
void write_elements_step( double time,
absl::Span< const DatasetElements > datasets,
absl::FunctionRef< AttributeManager&( const SolidMesh3D& ) >
block_manager );
void write_elements_step(
double time, absl::Span< const DatasetElements > datasets );

[[nodiscard]] absl::flat_hash_set< std::string > unify_attribute_ids(
absl::Span< const DatasetElements > datasets );

[[nodiscard]] std::optional< std::string > transferred_name(
const AttributeManager& manager, const uuid& attribute_id ) const;

void write_block_step( double time,
const AttributeManager& manager,
AttributeManager& block_manager,
const GenericMapping< index_t >& mesh2block );
void write_dataset_step(
double time, const DatasetElements& dataset ) const;

private:
BRep& brep_;
absl::flat_hash_set< std::string > ignored_attributes_;
};
} // namespace geode::internal
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,48 @@

#pragma once

#include <memory>
#include <vector>

#include <absl/container/flat_hash_map.h>
#include <absl/types/span.h>

#include <geode/basic/mapping.hpp>
#include <geode/basic/uuid.hpp>

#include <geode/geometry/nn_search.hpp>
#include <geode/mesh/core/point_set.hpp>

#include <geode/io/time_series/common.hpp>

namespace geode
{
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMesh );
ALIAS_3D( SolidMesh );
class BRep;
} // namespace geode

namespace geode::internal
{
// Solid elements to Block elements, per Block id
struct SolidToBlocksMappings
// Vertices of a .pvd dataset to unique vertices, its polyhedra to cell
// barycenters
struct PVDDatasetMappings
{
absl::flat_hash_map< uuid, GenericMapping< index_t > > polyhedra;
absl::flat_hash_map< uuid, GenericMapping< index_t > > vertices;
GenericMapping< index_t > vertices;
GenericMapping< index_t > polyhedra;
};

class BRepBlocksMatcher
// Point sets of a .pvd time series, given to the ExternalTimeSeries
// once all the time steps are written
struct PVDPointSets
{
struct BlockElement
{
uuid block_id;
index_t element;
};

public:
explicit BRepBlocksMatcher( const BRep& brep );

[[nodiscard]] SolidToBlocksMappings mappings(
const SolidMesh3D& solid ) const;

private:
[[nodiscard]] std::vector< Point3D > compute_barycenters();

[[nodiscard]] std::vector< index_t > match_polyhedra(
const SolidMesh3D& solid ) const;

[[nodiscard]] SolidToBlocksMappings build_mappings(
const SolidMesh3D& solid,
absl::Span< const index_t > matched_ids ) const;

private:
const BRep& brep_;
std::vector< BlockElement > polyhedra_;
NNSearch3D barycenters_;
std::unique_ptr< PointSet3D > unique_vertices;
std::unique_ptr< PointSet3D > cell_barycenters;
std::vector< PVDDatasetMappings > mappings;
};

/*!
* Create the .pvd point sets from the datasets of a time step
* (e.g. one per GEOS region and per MPI rank): the dataset vertices,
* colocated ones merged, and the dataset polyhedron barycenters, with
* the mappings of each dataset to them.
*/
[[nodiscard]] PVDPointSets create_pvd_point_sets(
absl::Span< const std::unique_ptr< SolidMesh3D > > meshes );
} // namespace geode::internal
8 changes: 4 additions & 4 deletions src/geode/io/time_series/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ add_geode_library(
NAME time_series
FOLDER "geode/io/time_series"
SOURCES
"brep_blocks_matcher.cpp"
"common.cpp"
"pvd_input.cpp"
"brep_time_attributes_transfer.cpp"
"pvd_attributes_transfer.cpp"
"pvd_point_sets.cpp"
PUBLIC_HEADERS
"common.hpp"
INTERNAL_HEADERS
"internal/brep_blocks_matcher.hpp"
"internal/pvd_input.hpp"
"internal/brep_time_attributes_transfer.hpp"
"internal/pvd_attributes_transfer.hpp"
"internal/pvd_point_sets.hpp"
PRIVATE_DEPENDENCIES
OpenGeode::basic
OpenGeode::geometry
Expand Down
165 changes: 0 additions & 165 deletions src/geode/io/time_series/brep_blocks_matcher.cpp

This file was deleted.

Loading
Loading