Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable 1D and 3D: mesh construction and X3D parsing. #633

Merged
merged 7 commits into from
Jun 10, 2019

Conversation

RyanWollaeger
Copy link
Contributor

@RyanWollaeger RyanWollaeger commented Jun 8, 2019

Background

  • Currently, the Draco_Mesh class only supports 2D mesh objects.
  • However, unstructured meshes can be constructed from dimension-agnostic topological data.
  • The Layout data structures in Draco_Mesh are already compatible with 1D and 3D cell topologies.
  • In 3D, node orientation about a face with respect to the interior of a cell can be constrained to be counter-clockwise, assuming the face does not have internal nodes.

Purpose of Pull Request

  • Add alternate mesh construction to enable 1D and 3D unstructured meshes.
  • Enable the X3D mesh parser to provide dimension-agnostic data to Draco_Mesh_Builder.
  • Support backwards-compatibility with older 2D-specific method.
  • Note this new algorithm preserves the layout, but changes some of the other data Draco_Mesh stores (cell_type, cell_to_node_linkage).
  • Fixes Redmine Issue #1503

Description of changes

  • Add optional input parameter to Draco_Mesh ctor, face_type, which is the number of nodes per face per cell.
  • When face_type is given (size > 0):
    • interpret cell_type as the number of faces per cell instead of the number of nodes per cell,
    • call a corresponding overload of compute_cell_to_cell_linkage that uses face_type.
  • Add optional ctor argument to X3D_Draco_Mesh_Reader, use_face_types, which tells the class to provide data to build face_type in Draco_Mesh_Builder.
  • Test to ensure Layout data is unchanged in 2D when using new compute_cell_to_cell_linkage in tstDraco_Mesh.cc.
  • Test X3D reader and builder when use_face_types=true in tstX3D_Draco_Mesh_Reader.cc.

Status

+ Add optional face type (nodes per face) argument to mesh ctor.
+ Use face type to compute dimension-agnostic cell connectivity.
+ Add 1D and 2D tests to tstDraco_Mesh.cc.
+ Add default boundary data generation when face types are given.
+ Add test of default boundary generation to new 1D unit test.
+ Instantiate reader with optional use_face_type parameter.
+ Set cell type and as faces per cell when use_face_type is true.
+ Preserve cell->face->node in linkage when use_face_type is true.
+ Set face_type vector in mesh builder when use_face_type is true.
+ Enforce use_face_type in mesh reader virtual base class.
+ Add corresponding function stubs to RTT (not implemented).
+ Update unit test to test alternate mesh reader/builder.
@RyanWollaeger RyanWollaeger self-assigned this Jun 8, 2019
+ Remove DLL_PUBLIC macros from X3D and RTT functions.
+ Update X3D unit test with newer failure macros.
Copy link
Collaborator

@KineticTheory KineticTheory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really nice. I've added a few comments but nothing that should prevent this from being merged. Let me know if you want to make one more set of changes or if you want me to merge this one.


#include "Draco_Mesh.hh"
#include "ds++/Assert.hh"
#include <algorithm>
#include <iostream>
// #include <iostream>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this isn't needed, go ahead and delete this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this - it has been removed.

@@ -166,7 +177,8 @@ Draco_Mesh_Builder<FRT>::build_mesh(rtt_mesh_element::Geometry geometry) {

std::shared_ptr<Draco_Mesh> mesh(new Draco_Mesh(
dimension, geometry, cell_type, cell_to_node_linkage, side_set_flag,
side_node_count, side_to_node_linkage, coordinates, global_node_number));
side_node_count, side_to_node_linkage, coordinates, global_node_number,
{}, {}, {}, {}, face_type));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not crazy about the empty brackets here. It's not hard to look up the argument list as defined by the constructor, but maybe we could use inline named argument declarations here. What do you think? Is it worth the hassle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are keyword arguments possible? Apologies for my confusion... Some variables have been initialized as empty and used here, with consistent naming.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about it for this UseCase. Have you tried {} --> vector<int> foobar{} or a similar signature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't appear to work... vector<int>() works, which is somewhat more descriptive. What about this?

@@ -34,14 +34,15 @@ private:

public:
//! Constructor
DLL_PUBLIC_mesh explicit RTT_Draco_Mesh_Reader(const std::string filename_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice to see these disappearing slowly. Alex and have a plan to remove all the remaining entries after the release. (except for the handful that are still needed.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem - good to know!

size_t /*face*/) const {
Insist(false, "cell-face nodes not implemented with RTT reader.");
return std::vector<unsigned>();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to add the function decoration [[noreturn]] (see ds++/Assert.hh for an example) to avoid any compiler confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the recommendation - this is a useful feature. A [[noreturn]] decoration has been added and the return line has been removed.

@KineticTheory
Copy link
Collaborator

Also - CDash is reporting this warning: X3D_Draco_Mesh_Reader.cc:252:16: warning: unused variable ‘num_faces’ [-Wunused-variable]

+ Put variable unused in release builds in Remember macro.
+ Add noreturn decorator to function that only throws assertion.
+ Remove commented out code.
@RyanWollaeger
Copy link
Contributor Author

The unused num_faces has been placed in a Remember macro. Thank you for catching this.

@KineticTheory
Copy link
Collaborator

LGTM. merging...

@KineticTheory KineticTheory merged commit 4128713 into lanl:develop Jun 10, 2019
@KineticTheory KineticTheory mentioned this pull request Jun 17, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants