4#include <tclap/CmdLine.h>
6#include <unordered_map>
19template <
typename MeshElement>
23 constexpr int dim = MeshElement::dimension;
29 std::vector<std::array<double, 3>> coords;
30 coords.reserve(Ns.size());
32 for (
auto const& N : Ns)
42template <
typename Element>
45template <
typename ElementRule>
51std::unordered_map<MeshLib::CellType, std::vector<std::array<double, 3>> (*)(
57 std::vector<std::array<double, 3>> (*)(
60 map_cell_type_to_element_coords_interpolator;
62 map_cell_type_to_element_coords_interpolator.reserve(
63 boost::mp11::mp_size<NumLib::AllElementTraitsLagrange>::value);
65 boost::mp11::mp_for_each<NumLib::AllElementTraitsLagrange>(
66 [&map_cell_type_to_element_coords_interpolator]<
typename ETL>(ETL)
68 using MeshElement =
typename ETL::Element;
69 auto constexpr cell_type =
72 auto const [it, newly_inserted] =
73 map_cell_type_to_element_coords_interpolator.emplace(
79 "Coordinate interpolator for cell type {} is already "
85 return map_cell_type_to_element_coords_interpolator;
92 auto const map_cell_type_to_element_coords_interpolator =
95 std::vector<MeshLib::Node*> nodes;
99 auto const cell_type = element->getCellType();
102 map_cell_type_to_element_coords_interpolator.find(cell_type);
103 if (it == map_cell_type_to_element_coords_interpolator.end())
105 OGS_FATAL(
"Unsupported cell type {} for element #{}",
109 auto const& element_coords_interpolator = it->second;
110 auto const coords = element_coords_interpolator(*element, sm_cache);
112 for (
auto& cs : coords)
126 std::optional<unsigned> integration_order;
128 for (
auto const& [name, property] : properties)
130 if (property->getMeshItemType() !=
136 if (name ==
"IntegrationPointMetaData" || name ==
"OGS_VERSION")
145 if (!integration_order)
147 integration_order = order;
149 else if (integration_order != order)
151 OGS_FATAL(
"Integration orders differ: {} != {}", *integration_order,
156 if (!integration_order)
158 OGS_FATAL(
"Integration order could not be determined.");
161 return *integration_order;
166 std::size_t
const num_ips)
168 for (
auto const& [prop_name, prop_in] : props_in)
170 auto const mesh_item_type = prop_in->getMeshItemType();
177 auto const num_comp = prop_in->getNumberOfGlobalComponents();
178 auto const* prop_in_double =
181 if (prop_in_double ==
nullptr)
184 "Ignoring non-double-valued property '{}' with {} components "
186 prop_name, num_comp, toString(mesh_item_type));
190 DBUG(
"Converting property '{}' with {} components on {}", prop_name,
191 num_comp, toString(mesh_item_type));
196 "A property vector with name '{}' already exists. Not "
201 if (
auto const num_ips_actual = prop_in_double->getNumberOfTuples();
202 num_ips_actual != num_ips)
205 "Property vector '{}' has {} tuples, which differs from "
206 "the number of integration points ({}). Skipping this "
208 prop_name, num_ips_actual, num_ips);
214 prop_out->
assign(*prop_in_double);
234 "Creates a point cloud mesh for the integration point data existing on "
235 "a given input mesh.\n\n"
236 "OpenGeoSys-6 software, version " +
239 "Copyright (c) 2012-2026, OpenGeoSys Community "
240 "(http://www.opengeosys.org)",
242 TCLAP::ValueArg<std::string> arg_out_file(
243 "o",
"output-file",
"Output (.vtu). The output mesh (point cloud)",
244 true,
"",
"OUTPUT_FILE");
245 cmd.add(arg_out_file);
246 TCLAP::ValueArg<std::string> arg_in_file(
"i",
"input-file",
247 "Input (.vtu). The input mesh",
248 true,
"",
"INPUT_FILE");
249 cmd.add(arg_in_file);
252 cmd.add(log_level_arg);
253 cmd.parse(argc, argv);
258 std::unique_ptr<MeshLib::Mesh const> mesh_in(
264 MeshLib::Mesh point_cloud(
"point_cloud", std::move(nodes), {});
267 point_cloud.getProperties(),
268 point_cloud.getNumberOfNodes());
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Properties & getProperties()
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
bool existsPropertyVector(std::string_view name) const
PropertyVector< T > * createNewPropertyVector(std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
constexpr void assign(R &&r)
boost::mp11::mp_at< ShapeFunctionsHigherOrder, boost::mp11::mp_find< MeshElements, MeshElement > > ShapeFunctionHigherOrder
auto const & NsHigherOrder() const
unsigned determineIntegrationOrder(MeshLib::Mesh const &mesh)
int main(int argc, char **argv)
std::vector< MeshLib::Node * > computePointCloudNodes(MeshLib::Mesh const &mesh, unsigned const integration_order)
void copyDoubleValuedFieldDataToPointCloud(MeshLib::Properties const &props_in, MeshLib::Properties &props_out, std::size_t const num_ips)
std::vector< std::array< double, 3 > > interpolateElementCoords(MeshLib::Element const &e, NumLib::ShapeMatrixCache const &sm_cache)
std::unordered_map< MeshLib::CellType, std::vector< std::array< double, 3 > >(*)(MeshLib::Element const &, NumLib::ShapeMatrixCache const &)> createElementCoordInterpolatorsForAllElementTypes()
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > variable_output_names)
CellType
Types of mesh elements supported by OpenGeoSys.
std::optional< IntegrationPointMetaData > getIntegrationPointMetaData(MeshLib::Properties const &properties)
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
IntegrationPointMetaDataSingleField getIntegrationPointMetaDataSingleField(std::optional< IntegrationPointMetaData > const &ip_meta_data, std::string const &field_name)
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
static constexpr MeshLib::CellType value