error: cannot declare field ‘CoupledTH<3>::triangulation’ to be of abstract type ‘dealii::parallel::distributed::Triangulation<3, 3>’

48 views
Skip to first unread message

孙翔

unread,
Aug 5, 2020, 5:01:40 AM8/5/20
to deal.II User Group
Hi, I want to declare a variable triangulation as the type dealii::parallel::distributed::Triangulation<3, 3>.  The code is :

in main function, 

using namespace dealii;

Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);

CoupledTH<3coupled_TH_solver(1);
coupled_TH_solver.run();

in class CoupledTH,

parallel::distributed::Triangulation<dim> triangulation;

I also included the .h files which are shown in Step-40.

When I compile the code, I got the error:  

error: cannot declare field ‘CoupledTH<3>::triangulation’ to be of abstract type ‘dealii::parallel::distributed::Triangulation<3, 3>’

Thank you very much.

Best,

Xiang


Wolfgang Bangerth

unread,
Aug 5, 2020, 11:23:00 AM8/5/20
to dea...@googlegroups.com
On 8/5/20 3:01 AM, 孙翔 wrote:
>
> error: cannot declare field ‘CoupledTH<3>::triangulation’ to be of abstract
> type ‘dealii::parallel::distributed::Triangulation<3, 3>’

I suspect that you forgot in
#include <deal.II/distributed/tria.h>

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

孙翔

unread,
Aug 5, 2020, 12:13:24 PM8/5/20
to deal.II User Group
Hi, Wolfgang,

I have included it actually, and also the distributed/grid_refinement.h was also included. Because I want to import the outside mesh to build up the triangulation, I also used Gridin to work on the triangulation, which is like as the following:

void CoupledTH<dim>::make_grid_and_dofs() {

  GridIn<dim> gridin;  // instantiate a gridinput
  gridin.attach_triangulation(triangulation);
  std::ifstream f("inputfiles/mesh.msh");
  gridin.read_msh(f);
...

I am not sure if this impacts the declaration.

Thank you very much.

Best,

Xiang

Wolfgang Bangerth

unread,
Aug 5, 2020, 12:14:51 PM8/5/20
to dea...@googlegroups.com
On 8/5/20 10:13 AM, 孙翔 wrote:
>
> I have included it actually, and also the distributed/grid_refinement.h was
> also included. Because I want to import the outside mesh to build up the
> triangulation, I also used Gridin to work on the triangulation, which is like
> as the following:

Then I have no other idea -- send us the file that produces the error, I think
that's the only way we can help :-)

孙翔

unread,
Aug 5, 2020, 12:42:09 PM8/5/20
to deal.II User Group
Hi, Wolfgang,

Please see the attached file, which is the head file that used the library. Thank you very much.

Best,

Xiang
sample

Wolfgang Bangerth

unread,
Aug 5, 2020, 7:23:07 PM8/5/20
to dea...@googlegroups.com
On 8/5/20 10:42 AM, 孙翔 wrote:
>
> Please see the attached file, which is the head file that used the library.
> Thank you very much.

That's not enough -- you're using a file "interpolation.h" that I don't have,
and parts of the rest of that file depend on this. You need to give me
something that's sufficiently complete for me to try and compile this to
obtain the error you see.

孙翔

unread,
Aug 5, 2020, 8:14:42 PM8/5/20
to deal.II User Group
Hi, Wolfgang,

Thank you for your reply. The complete code can be found on GitHub and we also have the instruction for compiling the code on TACC in UTA. This code is in the branch thm_seg_distributed. You may like to download it and build it. 


Best,

Xiang

Wolfgang Bangerth

unread,
Aug 7, 2020, 11:10:10 AM8/7/20
to dea...@googlegroups.com

> Thank you for your reply. The complete code can be found on GitHub and we also
> have the instruction for compiling the code on TACC in UTA. This code is in
> the branch thm_seg_distributed. You may like to download it and build it.
>
> https://github.com/cb-geo/thm/tree/thm_seg_distributed
> <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcb-geo%2Fthm%2Ftree%2Fthm_seg_distributed&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7C27086d193c0142af7bd808d8399db8bc%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637322696859927190&sdata=Q40LdQEQ0g6X8dv%2BFnn%2BF44xtnrlGGiVg%2Fnp1rDaaL8%3D&reserved=0>

Xiang,
this compiles fine for me. Can you show me the exact and complete error
message you get with the version on github?

孙翔

unread,
Aug 7, 2020, 2:05:06 PM8/7/20
to deal.II User Group
Hi, Wolfgang,

Thank you very much. Please see the following error message (red parts) which is all I get from the Github version.


Scanning dependencies of target thm
[ 20%] Building CXX object CMakeFiles/thm.dir/src/main.cc.o
In file included from /home/shyaan/thm/src/main.cc:8:0:
/home/shyaan/thm/./include/geothermal.h: In instantiation of ‘class CoupledTH<3>’:
/home/shyaan/thm/src/main.cc:30:35:   required from here
/home/shyaan/thm/./include/geothermal.h:112:45: error: cannot declare field ‘CoupledTH<3>::triangulation’ to be of abstract type ‘dealii::parallel::distributed::Triangulation<3, 3>’
   parallel::distributed::Triangulation<dim> triangulation;  // grid
                                             ^~~~~~~~~~~~~
In file included from /home/shyaan/thm/./include/geothermal.h:32:0,
                 from /home/shyaan/thm/src/main.cc:8:
/home/shyaan/dealii/include/deal.II/distributed/tria.h:1402:11: note:   because the following virtual functions are pure within ‘dealii::parallel::distributed::Triangulation<3, 3>’:
     class Triangulation
           ^~~~~~~~~~~~~
In file included from /home/shyaan/dealii/include/deal.II/dofs/dof_handler.h:29:0,
                 from /home/shyaan/dealii/include/deal.II/numerics/vector_tools_boundary.h:22,
                 from /home/shyaan/dealii/include/deal.II/numerics/vector_tools.h:22,
                 from /home/shyaan/thm/./include/boundaryvalues.h:8,
                 from /home/shyaan/thm/src/main.cc:1:
/home/shyaan/dealii/include/deal.II/distributed/tria_base.h:105:5: note:        bool dealii::parallel::TriangulationBase<dim, spacedim>::is_multilevel_hierarchy_constructed() const [with int dim = 3; int spacedim = 3]
     is_multilevel_hierarchy_constructed() const = 0;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/shyaan/thm/src/main.cc:8:0:
/home/shyaan/thm/./include/geothermal.h: In instantiation of ‘CoupledTH<dim>::CoupledTH(unsigned int) [with int dim = 3]’:
/home/shyaan/thm/src/main.cc:30:37:   required from here
/home/shyaan/thm/./include/geothermal.h:125:22: warning: ‘CoupledTH<3>::degree’ will be initialized after [-Wreorder]
   const unsigned int degree;  // element degree
                      ^~~~~~
/home/shyaan/thm/./include/geothermal.h:116:15: warning:   ‘dealii::QGauss<3> CoupledTH<3>::quadrature_formula’ [-Wreorder]
   QGauss<dim> quadrature_formula;
               ^~~~~~~~~~~~~~~~~~
/home/shyaan/thm/./include/geothermal.h:161:1: warning:   when initialized here [-Wreorder]
 CoupledTH<dim>::CoupledTH(const unsigned int degree)  // initialization
 ^~~~~~~~~~~~~~
/home/shyaan/thm/./include/geothermal.h:150:16: warning: ‘CoupledTH<3>::T_iteration_namber’ will be initialized after [-Wreorder]
   unsigned int T_iteration_namber;
                ^~~~~~~~~~~~~~~~~~
/home/shyaan/thm/./include/geothermal.h:109:22: warning:   ‘dealii::ConditionalOStream CoupledTH<3>::pcout’ [-Wreorder]
   ConditionalOStream pcout;
                      ^~~~~
/home/shyaan/thm/./include/geothermal.h:161:1: warning:   when initialized here [-Wreorder]
 CoupledTH<dim>::CoupledTH(const unsigned int degree)  // initialization
 ^~~~~~~~~~~~~~
/home/shyaan/thm/./include/geothermal.h:183:63: error: no matching function for call to ‘dealii::parallel::distributed::Triangulation<3, 3>::Triangulation(ompi_communicator_t*&)’
                          EquationData::file_name_interpolation) {
                                                               ^
In file included from /home/shyaan/thm/./include/geothermal.h:32:0,
                 from /home/shyaan/thm/src/main.cc:8:
/home/shyaan/dealii/include/deal.II/distributed/tria.h:1410:7: note: candidate: dealii::parallel::distributed::Triangulation<dim, spacedim>::Triangulation() [with int dim = 3; int spacedim = 3] <deleted>
       Triangulation() = delete;
       ^~~~~~~~~~~~~
/home/shyaan/dealii/include/deal.II/distributed/tria.h:1410:7: note:   candidate expects 0 arguments, 1 provided
/home/shyaan/dealii/include/deal.II/distributed/tria.h:1402:11: note: candidate: dealii::parallel::distributed::Triangulation<3, 3>::Triangulation(const dealii::parallel::distributed::Triangulation<3, 3>&) <deleted>
     class Triangulation
           ^~~~~~~~~~~~~
/home/shyaan/dealii/include/deal.II/distributed/tria.h:1402:11: note:   no known conversion for argument 1 from ‘MPI_Comm {aka ompi_communicator_t*}’ to ‘const dealii::parallel::distributed::Triangulation<3, 3>&’
/home/shyaan/dealii/include/deal.II/distributed/tria.h:1402:11: note: candidate: dealii::parallel::distributed::Triangulation<3, 3>::Triangulation(dealii::parallel::distributed::Triangulation<3, 3>&&) <deleted>
/home/shyaan/dealii/include/deal.II/distributed/tria.h:1402:11: note:   no known conversion for argument 1 from ‘MPI_Comm {aka ompi_communicator_t*}’ to ‘dealii::parallel::distributed::Triangulation<3, 3>&&’
In file included from /home/shyaan/thm/src/main.cc:8:0:
/home/shyaan/thm/./include/geothermal.h: In instantiation of ‘void CoupledTH<dim>::assemble_P_system() [with int dim = 3]’:
/home/shyaan/thm/./include/geothermal.h:875:24:   required from ‘void CoupledTH<dim>::run() [with int dim = 3]’
/home/shyaan/thm/src/main.cc:31:27:   required from here
/home/shyaan/thm/./include/geothermal.h:428:50: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           if (cell->face(face_no)->boundary_id() ==
/home/shyaan/thm/./include/geothermal.h: In instantiation of ‘void CoupledTH<dim>::assemble_T_system() [with int dim = 3]’:
/home/shyaan/thm/./include/geothermal.h:879:24:   required from ‘void CoupledTH<dim>::run() [with int dim = 3]’
/home/shyaan/thm/src/main.cc:31:27:   required from here
/home/shyaan/thm/./include/geothermal.h:622:51: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(cell->face(face_no)->boundary_id() ==
In file included from /home/shyaan/thm/src/main.cc:1:0:
/home/shyaan/thm/./include/boundaryvalues.h: In instantiation of ‘double EquationData::TemperatureNeumanBoundaryValues<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/src/main.cc:84:1:   required from here
/home/shyaan/thm/./include/boundaryvalues.h:165:16: warning: unused variable ‘time’ [-Wunused-variable]
   const double time = this->get_time();
                ^~~~
/home/shyaan/thm/./include/boundaryvalues.h:159:23: warning: unused parameter ‘p’ [-Wunused-paramete]
     const Point<dim>& p, const unsigned int /*component*/) const {
                       ^
In file included from /home/shyaan/thm/src/main.cc:6:0:
/home/shyaan/thm/./include/sourceterm.h: In instantiation of ‘double EquationData::TemperatureSourceTerm<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/src/main.cc:84:1:   required from here
/home/shyaan/thm/./include/sourceterm.h:74:16: warning: unused variable ‘time’ [-Wunused-variable]
   const double time = this->get_time();  // get time
                ^~~~
/home/shyaan/thm/./include/sourceterm.h:69:60: warning: unused parameter ‘p’ [-Wunused-parameter]
 double TemperatureSourceTerm<dim>::value(const Point<dim>& p,
                                                            ^
In file included from /home/shyaan/thm/src/main.cc:1:0:
/home/shyaan/thm/./include/boundaryvalues.h: In instantiation of ‘double EquationData::PressureNeumanBoundaryValues<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/src/main.cc:84:1:   required from here
/home/shyaan/thm/./include/boundaryvalues.h:133:10: warning: unused variable ‘time’ [-Wunused-variable]
   double time = this->get_time();  // get time
          ^~~~
/home/shyaan/thm/./include/boundaryvalues.h:128:23: warning: unused parameter ‘p’ [-Wunused-paramete]
     const Point<dim>& p, const unsigned int /*component*/) const {
                       ^
In file included from /home/shyaan/thm/src/main.cc:6:0:
/home/shyaan/thm/./include/sourceterm.h: In instantiation of ‘double EquationData::PressureSourceTerm<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/src/main.cc:84:1:   required from here
/home/shyaan/thm/./include/sourceterm.h:35:16: warning: unused variable ‘time’ [-Wunused-variable]
   const double time = this->get_time();  // get time
                ^~~~
/home/shyaan/thm/./include/sourceterm.h:30:57: warning: unused parameter ‘p’ [-Wunused-parameter]
 double PressureSourceTerm<dim>::value(const Point<dim>& p,
                                                         ^
In file included from /home/shyaan/thm/src/main.cc:1:0:
/home/shyaan/thm/./include/boundaryvalues.h: In instantiation of ‘double EquationData::TemperatureDirichletBoundaryValues<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/src/main.cc:84:1:   required from here
/home/shyaan/thm/./include/boundaryvalues.h:81:16: warning: unused variable ‘time’ [-Wunused-variabl]
   const double time = this->get_time();
                ^~~~
/home/shyaan/thm/./include/boundaryvalues.h: In instantiation of ‘double EquationData::PressureDirichletBoundaryValues<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/src/main.cc:84:1:   required from here
/home/shyaan/thm/./include/boundaryvalues.h:40:16: warning: unused variable ‘time’ [-Wunused-variabl]
   const double time = this->get_time();  // get time
                ^~~~
In file included from /home/shyaan/thm/src/main.cc:6:0:
/home/shyaan/thm/./include/sourceterm.h: In member function ‘double EquationData::PressureSourceTerm<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/./include/sourceterm.h:44:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
In file included from /home/shyaan/thm/src/main.cc:1:0:
/home/shyaan/thm/./include/boundaryvalues.h: In member function ‘double EquationData::PressureNeumanBoundaryValues<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/./include/boundaryvalues.h:137:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/home/shyaan/thm/./include/boundaryvalues.h: In member function ‘double EquationData::TemperatureNeumanBoundaryValues<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/./include/boundaryvalues.h:174:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/home/shyaan/thm/./include/boundaryvalues.h: In member function ‘double EquationData::PressureDirichletBoundaryValues<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/./include/boundaryvalues.h:53:1: warning: control reaches end of non-void function -Wreturn-type]
 }
 ^
/home/shyaan/thm/./include/boundaryvalues.h: In member function ‘double EquationData::TemperatureDirichletBoundaryValues<dim>::value(const dealii::Point<dim>&, unsigned int) const [with int dim = 3]’:
/home/shyaan/thm/./include/boundaryvalues.h:98:1: warning: control reaches end of non-void function -Wreturn-type]
 }
 ^
CMakeFiles/thm.dir/build.make:62: recipe for target 'CMakeFiles/thm.dir/src/main.cc.o' failed
make[2]: *** [CMakeFiles/thm.dir/src/main.cc.o] Error 1
CMakeFiles/Makefile2:163: recipe for target 'CMakeFiles/thm.dir/all' failed
make[1]: *** [CMakeFiles/thm.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Wolfgang Bangerth

unread,
Aug 7, 2020, 2:12:18 PM8/7/20
to dea...@googlegroups.com
On 8/7/20 12:05 PM, 孙翔 wrote:
> Hi, Wolfgang,
>
> Thank you very much. Please see the following error message (red parts) which
> is all I get from the Github version.
>
>
> Scanning dependencies of target thm
> [ 20%] Building CXX object CMakeFiles/thm.dir/src/main.cc.o
> In file included from /home/shyaan/thm/src/main.cc:8:0:
> /home/shyaan/thm/./include/geothermal.h: In instantiation of ‘class CoupledTH<3>’:
> /home/shyaan/thm/src/main.cc:30:35:   required from here
> /home/shyaan/thm/./include/geothermal.h:112:45: error: cannot declare field
> ‘CoupledTH<3>::triangulation’ to be of abstract type
> ‘dealii::parallel::distributed::Triangulation<3, 3>’
>    parallel::distributed::Triangulation<dim> triangulation;  // grid
>                                              ^~~~~~~~~~~~~

Ah -- you are trying to use parallel::distributed::Triangulation but you don't
have the p4est library available (or, at least, cmake has not detected it).

In your build directory, run 'cmake .' and in the summary at the end, check
that DEAL_II_WITH_P4EST says "set up with external dependencies". If it isn't,
then you probably forgot to install p4est on that machine, or you forgot to
tell cmake where it can be found.

There are a *lot* of warnings below. You should really try to address those --
otherwise, how will you know whether all of these things the compiler tells
you about are harmless or not?

Best
W.
> <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcb-geo%2Fthm%2Ftree%2Fthm_seg_distributed&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cb0e1ddaef91d4f79ecf308d83afc6cd0%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637324203116115798&sdata=4hDFUzAdKHSL0kF83cwsiHjbvGcq%2BPJr59%2FD2wQfdng%3D&reserved=0>
>
> >
> <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcb-geo%2Fthm%2Ftree%2Fthm_seg_distributed&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7C27086d193c0142af7bd808d8399db8bc%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637322696859927190&sdata=Q40LdQEQ0g6X8dv%2BFnn%2BF44xtnrlGGiVg%2Fnp1rDaaL8%3D&reserved=0
> <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcb-geo%2Fthm%2Ftree%2Fthm_seg_distributed&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cb0e1ddaef91d4f79ecf308d83afc6cd0%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637324203116115798&sdata=4hDFUzAdKHSL0kF83cwsiHjbvGcq%2BPJr59%2FD2wQfdng%3D&reserved=0>>
>
>
> Xiang,
> this compiles fine for me. Can you show me the exact and complete error
> message you get with the version on github?
>
> Best
>   W.
>
>
> --
> ------------------------------------------------------------------------
> Wolfgang Bangerth          email: bang...@colostate.edu <javascript:>
>                             www: http://www.math.colostate.edu/~bangerth/
> <http://www.math.colostate.edu/~bangerth/>
>
> --
> The deal.II project is located at http://www.dealii.org/
> <https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cb0e1ddaef91d4f79ecf308d83afc6cd0%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637324203116125756&sdata=sSukzGHvugAa01B8vgaOGnWkrdmcBouem5U%2BIzTiAtk%3D&reserved=0>
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cb0e1ddaef91d4f79ecf308d83afc6cd0%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637324203116125756&sdata=u%2FYh5sjGAUCaOwfNfLBgBAKURU88KHaEKGzJkw9GzhQ%3D&reserved=0>
> ---
> You received this message because you are subscribed to the Google Groups
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dealii+un...@googlegroups.com
> <mailto:dealii+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/a2d3bdfc-96aa-4b41-8be4-26547750d6cao%40googlegroups.com
> <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2Fa2d3bdfc-96aa-4b41-8be4-26547750d6cao%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cb0e1ddaef91d4f79ecf308d83afc6cd0%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637324203116135708&sdata=fe9RRpWz%2F2OVG6Kk7B8mz4crjqhEx9WtHbC3qMGxWKw%3D&reserved=0>.

孙翔

unread,
Aug 7, 2020, 8:08:22 PM8/7/20
to deal.II User Group
Hi, Wolfgang,

Oh, I see. Thank you very much.

Best,

Xiang
Reply all
Reply to author
Forward
0 new messages