error: allocating an object of abstract class type

867 views
Skip to first unread message

floyd...@gmail.com

unread,
Jun 13, 2016, 12:12:21 PM6/13/16
to moose-users
Dear Moose-Users,

I am attempting to create a new initial condition that functions just like MultiSmoothCirclesIC except i would like an ellipse shape instead to create anisotropy in the structure. Since this is my first bit of MOOSE code i started by just taking the SmootheCirlceBaseIC.h/.C files and changing every instance of Circle with Ellipse. After adding the new files to the include and src folders then registering them in the PhaseFieldAPP.C file and tried to compile it. I hoped that this would give me a stable base to work on before changing its functionality. Unfortunately i seem to have started off on the wrong foot here and i am getting this when i compile.


MOOSE Compiling C++ (in opt mode) /Users/fwh5041/Projects/marmot/moose/modules/phase_field/src/base/PhaseFieldApp.C...
In file included from /Users/fwh5041/Projects/marmot/moose/modules/phase_field/src/base/PhaseFieldApp.C:7:
In file included from /Users/fwh5041/Projects/marmot/moose/modules/phase_field/include/base/PhaseFieldApp.h:10:
In file included from /Users/fwh5041/Projects/marmot/moose/framework/include/base/MooseApp.h:22:
/Users/fwh5041/Projects/marmot/moose/framework/include/base/Factory.h:131:29: error: allocating an object of abstract class type 'SmoothEllipseBaseIC'
  return MooseObjectPtr(new T(parameters));
                            ^
/Users/fwh5041/Projects/marmot/moose/framework/include/base/Factory.h:162:45: note: in instantiation of function template specialization 'buildObject<SmoothEllipseBaseIC>' requested here
        _name_to_build_pointer[obj_name] = &buildObject<T>;
                                            ^
/Users/fwh5041/Projects/marmot/moose/modules/phase_field/src/base/PhaseFieldApp.C:313:11: note: in instantiation of function template specialization 'Factory::reg<SmoothEllipseBaseIC>' requested here
  factory.reg<SmoothEllipseBaseIC>("SmoothEllipseBaseIC");
          ^
/Users/fwh5041/Projects/marmot/moose/modules/phase_field/include/ics/SmoothEllipseBaseIC.h:38:16: note: unimplemented pure virtual method 'computeEllipseRadii' in 'SmoothEllipseBaseIC'
  virtual void computeEllipseRadii() = 0;
               ^
/Users/fwh5041/Projects/marmot/moose/modules/phase_field/include/ics/SmoothEllipseBaseIC.h:39:16: note: unimplemented pure virtual method 'computeEllipseCenters' in 'SmoothEllipseBaseIC'
  virtual void computeEllipseCenters() = 0;
               ^
1 error generated.
make: *** [/Users/fwh5041/Projects/marmot/moose/modules/phase_field/src/base/PhaseFieldApp.x86_64-apple-darwin14.5.0.opt.lo] Error 1

Can anyone tell me what i have done wrong? I have attached the .h/.C files i created.

-Floyd
SmoothEllipseBaseIC.h
SmoothEllipseBaseIC.C

Cody Permann

unread,
Jun 13, 2016, 12:39:03 PM6/13/16
to moose-users
In an object-oriented language you can define and interface without an implementation (i.e. I want my object to be able to computeElipseRadii() without saying how to actually do it). This is a really good thing. When you inherit from a class where one more more methods don't have implementations, you are required to provide those implementations, otherwise the code won't be able to run when it actually needs to call those methods. 

Every place where you see an " = 0;" at the end of a method indicates a place where you need to provide a definition your derived class before you can compile.

There are lot of good discussions about this concept if you Google that error.

Cody

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/6ea1c8d2-1411-4569-a75f-6b3fcfc905b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aagesen, Larry K

unread,
Jun 13, 2016, 12:54:20 PM6/13/16
to moose...@googlegroups.com
Floyd, I think we already have an IC to do what you are looking for. Check out BimodalSuperellipsoidsIC:


A super ellipsoid is a generalization of a regular ellipsoid where (x/a)^n + (y/b)^n = 1. To get a regular ellipsoid set the exponent n = 2. The BimodalSuperellipsoidIC will allow you to place a few larger superellipsoids in the input file and fill the rest in randomly similar to MultiSmoothCirclesIC, but with super (or regular) ellipsoids. If you don't need the specified particles, you should be able to just leave that field blank (but let me know if you have trouble with that).

--

floyd...@gmail.com

unread,
Jun 13, 2016, 3:07:52 PM6/13/16
to moose-users
Cody,

Thanks for the reply, i will spend some time reading about C++ classes to better understand what is going on.

-Floyd

floyd...@gmail.com

unread,
Jun 13, 2016, 3:11:48 PM6/13/16
to moose-users
Larry,

Thank you for bringing this IC to my attention, i did not realize it existed. I will get familiar with it to see if it can accomplish what i need. At the very least it provides more code related to what i want to do to study.

-Floyd

Aagesen, Larry K

unread,
Jun 13, 2016, 3:32:33 PM6/13/16
to moose...@googlegroups.com
Yes, and if BimodalSuperellipsoids doesn't do exactly what you want it to, you can likely create a derived class from SmoothSuperellipsoidBaseIC to customize the existing code to do what you want (similar to how MultiSmoothCircleIC is derived from SmoothCircleBaseIC).

Reply all
Reply to author
Forward
0 new messages