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

[MeshLib] Replacement of element classes with new implementation using TemplateElement #572

Merged
merged 23 commits into from
Feb 10, 2015

Conversation

norihiro-w
Copy link
Collaborator

This PR is based on discussion in #506 and introduces new implementations of mesh element classes by combining TemplateElement class and element-specific topological/geometrical rules.

Note: It includes two commits in #571

const MathLib::Vector3 cx (c, x);
const double s = MathLib::scalarProduct(face->getSurfaceNormal(), cx);
delete face;
if (s >= 0)
Copy link
Member

Choose a reason for hiding this comment

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

Real number comparison.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@TomFischer @rinkk how do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I can not see a problem here. @wenqing What are your concerns?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

we just check if two vectors are pointing in roughly the same direction. in practice, s should be nowhere near 0, if it is the element is degenerated. the test is still correct here because we are testing just for node order so technically s=0 is a valid value, even if other tests will fail because of that. (I am not 100% sure without looking up the theory again, but s=0 almost certainly means this will be a zero volume element)

@wenqing
Copy link
Member

wenqing commented Jan 26, 2015

I think the current implementation has a flexibility in handling different element orders.

for (unsigned j=0; j<nFaces; ++j)
{
MeshLib::Face const*const face (dynamic_cast<const MeshLib::Face*>(e->getFace(j)));
const MeshLib::Node x (*(face->getNode(1)));
Copy link
Member

Choose a reason for hiding this comment

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

I am curious: Is there a special reason to take node 1 of the face?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i have no idea. please ask @rinkk

Copy link
Member

Choose a reason for hiding this comment

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

This is the documentation I wrote:

     * Checks if the node order of an element is correct by testing surface normals.
     * For 3D elements true is returned if the normals of all faces points away from the centre of 
     * the element.
     * Note: This method might give wrong results if something else is wrong with the element 
     * (non-planar faces, non-convex geometry, possibly zero volume) which causes the calculated 
     * center of gravity to lie outside of the actual element

I think I chose node 1 because that way all nodes are used for the test at some point, while for node 0 at least one node in every element type would be used for checking twice and one wouldn't be checked at all. (based on the definition of the _face_nodes variable)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rinkk shall I add your comment (about checking node 1) into the source so that we can avoid repating of the same question in the future?

Copy link
Member

Choose a reason for hiding this comment

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

good idea, thank you :) ✅

@rinkk
Copy link
Member

rinkk commented Jan 27, 2015

For what it's worth: everything works fine under windows and with gui.
If I see this correctly, debugging will be more difficult using this implementation. (I don't like this fact but I suppose that it is not a priority.)

A general comment:
You should probably also adjust the schematics for the higher order elements, e.g. for Quad9: ✅

 *              
 *        3-----6-----2
 *        |           |
 *        |           |
 *        7     9     5
 *        |           |
 *        |           |
 *        0-----4-----1
 *              

@rinkk
Copy link
Member

rinkk commented Jan 27, 2015

Another question:
I see that your higher order implementation-rules are currently very small.
Can you somehow use methods from another rule (e.g. the getVolume() method) or do you simply need none of that for higher order methods?

@norihiro-w
Copy link
Collaborator Author

@rinkk

  • you are right and agree with you. debugging is more difficult. I also don't like it. Any alternative idea for easier debugging is welcome
  • Thanks, I'll modify the schematics for the higher order elements
  • With this implementation, it is possible to override getVolume() for non-linear shape elements (e.g. quad with curved edgs). I'm not doing this at the moment, because so far we are using only linear shape. Someone like TN may want to use non-linear shape for representing coverns.

@rinkk
Copy link
Member

rinkk commented Jan 27, 2015

thanks for the info

/**
* Checks if the node order of an element is correct by testing surface normals.
*/
static bool testElementNodeOrder(const Element* e);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the same function exists in Cell class ✅

@norihiro-w
Copy link
Collaborator Author

rebased, changed according to the comments

#define QUADRULE8_H_

#include "MeshLib/MeshEnums.h"
#include "Element.h"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not needed

@norihiro-w
Copy link
Collaborator Author

maybe it is better to define rule functions in header files so that it helps optimization?


/// 2D elements have no faces.
unsigned getNFaces() const { return 0; }
virtual double getArea() const { return _content; }
Copy link
Member

Choose a reason for hiding this comment

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

I think getArea is nowhere used, and there is the new getContent method in the base class.
Same for the Cell::getVolume.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rinkk is it true that getArea is nowhere used?
@endJunction getContent() is not new.

Copy link
Member

Choose a reason for hiding this comment

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

yes, getArea is not used ... it is one of the methods we included when we first implemented the MeshLib but in reality we always end up using getContent() instead ...

@norihiro-w
Copy link
Collaborator Author

Follwoing Dima's suggestion, removed T_BASE parameter from TemplateElement class

@endJunction
Copy link
Member

Good work!
Someone please look one more time for typos etc. The class hierarchy and overall structure looks good. (And we have more functionality with less code in total!)

@bilke
Copy link
Member

bilke commented Feb 10, 2015

👍

endJunction added a commit that referenced this pull request Feb 10, 2015
[MeL] Replacement of element classes with TemplateElement<Rule>
@endJunction endJunction merged commit 1016cda into ufz:master Feb 10, 2015
@norihiro-w norihiro-w deleted the new-imp-ele branch February 24, 2015 14:02
@ogsbot
Copy link
Member

ogsbot commented Jun 19, 2020

OpenGeoSys development has been moved to GitLab.

See this pull request on GitLab.

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.

7 participants