On Mon, 2 Oct 2017, Salazar De Troya, Miguel wrote:

If I have my custom derived System class, how can I save it to file
with EquationSystems::write() and read it with
EquationSystems::read(). It seems that they are not recognized and
cast directly to their parents types.

Nope.  What you'll probably want to do is do the add_system() calls
yourself, then only do the EquationSystems::read() *afterwards*, as we
do in examples/adjoints/adjoints_ex3.  That way when the read needs
to fill your system, it will get the already-added system of the
correct type, and it won't have to figure out how to construct one
itself.

I tried overriding System::system_type(), but now when reading, they
get stuck in
https://libmesh.github.io/doxygen/classlibMesh_1_1EquationSystems.html#a09450d5e4547d8b2e5690043da03dbd3,
since that function cannot call custom derived Systems.

I'm afraid so.  I originally considered replacing this logic with a
factory method, but then the "add a custom system yourself then read
into it" idiom turned out to be so easy that I didn't think "make
user code construct its own factory map entry" would be an
improvement.

However, that idiom only works in apps that know what sort at compile
time what subclass of system they want to solve, and merely read in
data at run time.  If you're trying to write a more flexible run-time
tool, then you're out of luck unless you want to be the one who puts
factory support in add_system().
---
Roy

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to