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

Reference elem #62

Merged
merged 20 commits into from
Apr 1, 2013
Merged

Reference elem #62

merged 20 commits into from
Apr 1, 2013

Conversation

benkirk
Copy link
Member

@benkirk benkirk commented Mar 28, 2013

For the cut cell quadrature subintegration, it would be nice to have singletons that provide acces to the reference cell for each element type. That is, a full-featured Elem that is posed on the reference domain. Consider for example:

Elem *phys_elem;

Elem const * ref_elem = phys_elem->reference_elem();

This patchset implements the singleton objects. They are read from static strinstream data to avoid disk I/O, and the singleton cache is updated only once, at first access.

Opening this up for comments before I add the Elem interface and implement the missing edges.

-Ben

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #376 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #377 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #378 SUCCESS
This pull request looks good
(what's this?)

@roystgnr
Copy link
Member

ReferenceElem::get() is never going to return NULL, so we might as well return a reference instead of a pointer.

But that's just a nitpick and otherwise this looks great so far. My horror at the string parsing is outweighed by my awe at the fact that you've managed to thereby make this Don't Repeat Yourself compliant.

@benkirk
Copy link
Member Author

benkirk commented Mar 28, 2013

Thanks, will to.

My first thought was to actually read the reference elements into a file-scope mesh and return pointers to it, and I may later, but not until I can do something like

  SerialMesh one_hex8 (libMesh::COMM_SELF);
  one_hex8.read("one_hex8.xda");

because there is just so much of an underlying assumption at the moment that the mesh lives on comm world.

Even still, it'll be nice even in that case to use stringstreams instead of file IO to avoid disk contention in parallel.

@benkirk
Copy link
Member Author

benkirk commented Mar 28, 2013

*will do.

I'll continue working on the larger feature set for a few days and let the queue of other requests thin out...

@friedmud
Copy link
Member

I guess I don't understand. It seems like there should be lots of ways to do this without needing to have a file that has all of this info in it.

Off the top of my head, how about just adding a:

static Elem * ref_elem;

To each Elem class... then the first time someone calls elem->reference_elem() for a particular type of elem it will build the reference elem if needed and store it in ref_elem for that class. Each successive call will just return ref_elem.

So reference_elem() is pure virtual and is implemented by each type of Elem to construct a reference elem of that type.

This is probably not the only idea... but I don't see a need for reading this stuff from a file. But of course I haven't thought it through quite as thoroughly as you probably have...

@benkirk
Copy link
Member Author

benkirk commented Mar 29, 2013

On Mar 28, 2013, at 7:01 PM, "Derek Gaston" <[email protected]mailto:[email protected]> wrote:

I guess I don't understand. It seems like there should be lots of ways to do this without needing to have a file that has all of this info in it.

That would work as well, right now I'm using code generated automatically from the mesh files we already have, and there is no actual disk access involved.

This way we just don't repeatedly define the reference element node locations in different parts of the library.

-Ben

@friedmud
Copy link
Member

I understand - I'll trust your judgement on these issues ;-)

@roystgnr
Copy link
Member

You know, parsing objects from the files via that string layer is
acceptable, and I agree that it's preferable to having the files vs
objects be completely distinct as I'd have naively done...

but would it be possible instead to have the reference objects
more natively hard-coded, and then use them to autogenerate the
reference files? That way we'd be using existing xda interfaces alone
without static strings and new parsing code.

@benkirk
Copy link
Member Author

benkirk commented Mar 29, 2013

You know, parsing objects from the files via that string layer is
acceptable, and I agree that it's preferable to having the files vs
objects be completely distinct as I'd have naively done...

but would it be possible instead to have the reference objects
more natively hard-coded, and then use them to autogenerate the
reference files? That way we'd be using existing xda interfaces alone
without static strings and new parsing code.

I'd think we could do that. Up front it will touch a lot more code to implement - each concrete elem class will need a static pointer or reference to is reference, some code to safely initialize that at first call, and a destruction method, but it should be doable.

The major complication is that the Elem is a reference counted object, so we need to be sure our static reference counting stuff is initialized before any Elems, and that they are destructed in the proper order. That's the only thing that prevents just defining a static object in each derived class and letting the static creation order fiasco ensue.

So an option would be a static function in each Elem that holds such an object and returns a reference, which is more code proliferation but doable if that is the group preference?

Actually getting those into a mesh to write out the xda files would require some gymnastics, and probably a standalone utility code "libmesh_reference_elements" or something...

@benkirk benkirk mentioned this pull request Mar 29, 2013
@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #382 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #385 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #390 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #394 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #396 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #397 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #398 SUCCESS
This pull request looks good
(what's this?)

benkirk added 11 commits March 30, 2013 15:28
This patch implements singleton objects for each reference element type.  At presenent they are read from our "reference_elements/" files, but that does not scale.  My next attempt will be to embed those definitions automatically through static stringstream objects.

This is an incrimental feature to support the following usage:

Elem *phys_elem;

Elem const * ref_elem = phys_elem->reference_elem();

where phys_elem is a typical element and ref_elem is its reference element in parametric coordinates.
@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #401 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #404 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

libMesh - C++ Finite Element Library » libmesh #405 SUCCESS
This pull request looks good
(what's this?)

@benkirk
Copy link
Member Author

benkirk commented Apr 1, 2013

Speak now - I'm happy with this implementation and will merge it later today so I can rebase the subcell quadrature off of this. I am still building the singletons from static strings - this could easily be refactored later if it is preferable to do static per-Elem instantiations.

-Ben

@roystgnr
Copy link
Member

roystgnr commented Apr 1, 2013

Fine with me for now.

benkirk added a commit that referenced this pull request Apr 1, 2013
@benkirk benkirk merged commit 009544c into libMesh:master Apr 1, 2013
@benkirk benkirk deleted the reference_elem branch April 1, 2013 17:26
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.

4 participants