Did it complain it can't find the header file first?
My includes for libmesh all start libmesh/foo.h
if you run "make -n example-opt" and copy the output it should work
although without the libmesh dir in the includes I guess you would have
to add it to the include paths.
________________________________
> From: harroontheg...@gmail.com
> Date: Fri, 5 Aug 2016 14:07:58 -0700
> Subject: Re: [Libmesh-users] FW: libmesh problem: libmesh_nullptr was
> not declared in scope
> To: marchy...@hotmail.com
> CC: royst...@ices.utexas.edu; libmesh-users@lists.sourceforge.net
>
>>"I skimmed most of the messages and it did sound like it would be something
>>easy to find by looking at the exact code so I was a bit surprised
> with that last post :)"
>
> Just in case it is something easy to spot I have the code at the bottom
> of the email highlighted. If you don't need the code you can just
> ignore the highlighted part of the email.
>
>>The linking is a bit unorthodox, indeed I think you had some specific
>>recommendations for linking to libmesh that hid most of the details, but
>>actually building it and compiling with it were pretty easy. I turned
> on some debug info
>>from the example make script, just copied its invokation of g++ and libtool
>>and that seems to work for some simple case.
>
> This is my first time compiling a libmesh code so I tried to figure out
> what compiler flags to use in the suggested manner
> for simple codes (according to
> http://libmesh.github.io/installation.html) which is libmesh-config
> --cxx` -o HPeigenproblems_PZ_8_2_16_2 HPeigenproblems_PZ_8_2_16_2.C
> `libmesh-config --cxxflags --include --ldflags --libs`.
>
> This is my first time compiling a libmesh code so I thought maybe I
> should use a Makefile.am from a regular libmesh example.
> (My other example files compiled properly) so I was thinking that it
> might work to follow the instructions for adding a new libmesh example
> (https://github.com/libMesh/libmesh/wiki/Adding-a-new-example) which
> invoves changing the Makefile.am and run.sh from another example file
> to run the program.
>
> I started following the directions for adding a new example and am not
> sure what line to put into AC_CONFIG_FILES in
> configure.ac<http://configure.ac> at the top level of libmesh. I would
> have thought it would have been the directory of the example file I am
> adding or the Makefile that goes with it but I do not see the
> directories of any other example programs in AC_CONFIG_FILES within the
> configure.ac<http://configure.ac> program.
>
>
>
>
>
> Harry Pearce
>
> Just in case highlighting doesn't show up on the libmesh users archive,
> the highlighted code is below:
> #include <fstream>
> #include "libmesh.h"
> #include "mesh.h"
> #include "libmesh_config.h"
> //#include "mesh_generation.h"
> // #include "exodusII_io.h"
> #include "eigen_system.h"
> #include "equation_systems.h"
> // #include "fe.h"
> // #include "quadrature_gauss.h"
> // #include "dense_matrix.h"
> // #include "sparse_matrix.h"
> // #include "numeric_vector.h"
> // #include "dof_map.h"
> #include "libmesh_nullptr.h"
> #include <string.h>
> // #include "parallel_algebra.h"
> //#include "parallel.h"
> //#include <auto_ptr.h>
>
>
> using namespace libMesh;
>
> char prefix[80];
>
> void assemble_mass(EquationSystems& es,
>
> const std::string& system_name);
>
> int main (int argc, char** argv)
>
> {
>
> LibMeshInit init (argc, argv);
>
> #ifndef LIBMESH_HAVE_SLEPC
>
> if (libMesh::processor_id() == 0)
>
> std::cerr << "ERROR: This example requires libMesh to be\n"
>
> << "compiled with SLEPc eigen solvers support!"
>
> << std::endl;
>
> return 0;
>
> #else
>
> #ifdef LIBMESH_DEFAULT_SINGLE_PRECISION
>
> libmesh_example_assert(false, "--disable-singleprecision");
>
> #endif
>
> if (argc < 3)
>
> {
>
> if (libMesh::processor_id() == 0)
>
> std::cerr << "\nUsage: " << argv[0]
>
> << " -n <number of eigen values>"
>
> << std::endl;
>
> libmesh_error();
>
> }
>
>
>
> else
>
> {
>
> std::cout << "Running " << argv[0];
>
>
>
> for (int i=1; i<argc; i++)
>
> std::cout << " " << argv[i];
>
>
>
> std::cout << std::endl << std::endl;
>
> }
>
> const unsigned int nev = std::atoi(argv[2]);
>
> // libmesh_example_assert(3 <= LIBMESH_DIM, "2D support");
>
>
>
> Mesh mesh;
>
> MeshTools::Generation::build_cube (mesh,
>
> 10, 10, 10,
>
> -1., 1.,
>
> -1., 1.,
>
> -1., 1.,
>
> HEX27);
>
> mesh.print_info();
>
>
>
> char xyzfilename[80];
>
> strcpy(prefix,argv[3]);
>
> strcpy(xyzfilename,argv[3]);
>
> strcat(xyzfilename,".xyz");
>
> std::cout << "Writing nodal xyz coordinates to file: " <<
> xyzfilename << std::endl;
>
> std::ofstream xyzfile;
>
> xyzfile.open (xyzfilename);
>
> MeshBase::const_node_iterator node_it = mesh.nodes_begin();
>
>
>
>
> const MeshBase::const_node_iterator node_end = mesh.nodes_end();
>
> xyzfile << "Number of nodes: " << mesh.n_nodes() << "\n";
>
> for (; node_it != node_end; ++node_it)
>
> {
>
> //count++;
>
> const Point& p = **node_it;
>
> const Real px = p(0);
>
> const Real py = p(1);
>
> xyzfile << px << " " << py << " \n";
>
> }
>
> xyzfile.close();
>
> std::cout << "Finished writing nodal xyz coordinates to file: " <<
> xyzfilename << std::endl;
>
>
> EquationSystems equation_systems (mesh);
>
> EigenSystem & eigen_system =
>
> equation_systems.add_system<EigenSystem> ("Eigensystem");
>
>
>
>
> eigen_system.add_variable("u", SECOND);
>
> eigen_system.attach_assemble_function (assemble_mass);
>
> equation_systems.parameters.set<unsigned int>("eigenpairs") = nev;
>
> equation_systems.parameters.set<unsigned int>("basis vectors") = nev*3;
>
> eigen_system.eigen_solver->set_eigensolver_type(KRYLOVSCHUR);
>
> // eigen_system.eigen_solver->set_eigensolver_type(LAPACK);
>
> eigen_system.eigen_solver->set_position_of_spectrum(SMALLEST_REAL);
>
> equation_systems.parameters.set<Real>("linear solver tolerance") =
> pow(TOLERANCE, 5./3.);
>
> equation_systems.parameters.set<unsigned int>
>
> ("linear solver maximum iterations") = 1000;
>
> eigen_system.set_eigenproblem_type(GHEP);
>
> equation_systems.init();
>
> equation_systems.print_info();
>
>
>
> eigen_system.solve();
>
> unsigned int nconv = eigen_system.get_n_converged();
>
> std::cout << "Number of converged eigenpairs: " << nconv
>
> << "\n" << std::endl;
>
> if (nconv != 0)
>
> {
>
> eigen_system.get_eigenpair(nconv-1);
>
>
>
> #ifdef LIBMESH_HAVE_EXODUS_API
>
> ExodusII_IO (mesh).write_equation_systems ("out.e", equation_systems);
>
> #endif // #ifdef LIBMESH_HAVE_EXODUS_API
>
> }
>
> else
>
> {
>
> std::cout << "WARNING: Solver did not converge!\n" << nconv <<
> std::endl;
>
> }
>
> #endif // LIBMESH_HAVE_SLEPC
>
> return 0;
>
> }
>
> void assemble_mass(EquationSystems& es,
>
> const std::string& system_name)
>
> {
>
> char potfilename[80];
>
> strcpy(potfilename,prefix);
>
> strcat(potfilename,".pot.out");
>
> std::fstream potfile;
>
> potfile.open(potfilename, std::ios::out);
>
> if(!potfile) {std::cerr << "Error opening PES output file."; return;}
>
> libmesh_assert (system_name == "Eigensystem");
>
> #ifdef LIBMESH_HAVE_SLEPC
>
> const MeshBase& mesh = es.get_mesh();
>
> const unsigned int dim = mesh.mesh_dimension();
>
> EigenSystem & eigen_system = es.get_system<EigenSystem> (system_name);
>
> FEType fe_type = eigen_system.get_dof_map().variable_type(0);
>
> SparseMatrix<Number>& matrix_A = *eigen_system.matrix_A;
>
> SparseMatrix<Number>& matrix_B = *eigen_system.matrix_B;
>
> AutoPtr<FEBase> fe (FEBase::build(dim, fe_type));
>
> QGauss qrule (dim, fe_type.default_quadrature_order());
>
> fe->attach_quadrature_rule (&qrule);
>
> const std::vector<Real>& JxW = fe->get_JxW();
>
> const std::vector<Point>& q_point = fe->get_xyz();
>
> const std::vector<std::vector<Real>>& phi = fe->get_phi();
>
> const std::vector<std::vector<RealGradient>>& dphi = fe->get_dphi();
>
> const DofMap& dof_map = eigen_system.get_dof_map();
>
> DenseMatrix<Number> Me;
>
> DenseMatrix<Number> Ke;
>
> std::vector<unsigned int> dof_indices;
>
> MeshBase::const_element_iterator el =
> mesh.active_local_elements_begin();
>
> const MeshBase::const_element_iterator end_el =
> mesh.active_local_elements_end();
>
>
>
> std::cout << "Writing PES data to file: " << potfilename << std::endl;
>
> double V, gxx, gxy, gyy, gzx, gzy, gzz;
>
> for ( ; el != end_el; ++el)
>
> {
>
> const Elem* elem = *el;
>
> dof_map.dof_indices (elem, dof_indices);
>
> fe->reinit (elem);
>
> Ke.resize (dof_indices.size(), dof_indices.size());
>
> Me.resize (dof_indices.size(), dof_indices.size());
>
> for (unsigned int qp=0; qp<qrule.n_points(); qp++)
>
> {
>
> const double x = q_point[qp](0);
>
> const double y = q_point[qp](1);
>
> const double z = q_point[qp](2);
>
> /*
>
> Doub potpoint(ndim);
>
> potpoint[0] = x;
>
> potpoint[1] = y;
>
> potpoint[2] = z;
>
> */
>
> V=x*x + y*y + z*z;
>
> gxx=0.10;
>
> gyy=1.20;
>
> gxy=1.10;
>
> gzx=0.003;
>
> gzy=0.40;
>
> gzz=0.50;
>
>
> potfile << x << '\t' << y << '\t' << z << '\t' << V << '\t' << "\n";
>
>
> /*
>
> const Elem* elem = *el;
>
> dof_map.dof_indices (elem, dof_indices);
>
> fe->reinit (elem);
>
> Ke.resize (dof_indices.size(), dof_indices.size());
>
> Me.resize (dof_indices.size(), dof_indices.size());
>
> */
>
> // for (unsigned int qp=0; qp<qrule.n_points(); qp++)
>
> for (unsigned int i=0; i<phi.size(); i++)
>
> for (unsigned int j=0; j<phi.size(); j++)
>
> {
>
>
> Ke(i,j) += JxW[qp]*(
>
> 0.5*( gxx*dphi[i][qp](0)*dphi[j][qp](0)
>
> + gyy*dphi[i][qp](1)*dphi[j][qp](1)
>
> + gzz*dphi[i][qp](2)*dphi[j][qp](2)
>
> + gxy*dphi[i][qp](0)*dphi[j][qp](1)
>
> + gxy*dphi[i][qp](1)*dphi[j][qp](0)
>
> + gzx*dphi[i][qp](0)*dphi[j][qp](2)
>
> + gzx*dphi[i][qp](2)*dphi[j][qp](0)
>
> + gzy*dphi[i][qp](1)*dphi[j][qp](2)
>
> + gzy*dphi[i][qp](2)*dphi[j][qp](1)
>
> // + dgxxdx*dphi[i][qp](0)
>
> // + dgyydy*dphi[i][qp](1)
>
> // + dgzzdz*dphi[i][qp](2)
>
> // + dgxydx*dphi[i][qp](1)
>
> // + dgxydy*dphi[i][qp](0)
>
> // + dgxzdx*dphi[i][qp](2)
>
> // + dgzxdz*dphi[i][qp](0)
>
> // + dgyzdy*dphi[i][qp](2)
>
> // + dgzydz*dphi[i][qp](1)
>
> )*33.71526 + V*phi[i][qp]*phi[j][qp]);
>
>
>
> Me(i,j) += JxW[qp]*phi[i][qp]*phi[j][qp];
>
> }
>
> matrix_A.add_matrix (Ke, dof_indices);
>
> matrix_B.add_matrix (Me, dof_indices);
>
> }
>
> } // end of element loop
>
> std::cout << "Finished writing PES data to file: " << potfilename
> << std::endl;
>
> potfile.close();
>
> std::cout << "Matrix A assembly completed! " << "\n" << std::endl;
>
> std::cout << "Matrix B assembly completed! " << "\n" << std::endl;
>
> std::cout << "Exporting Matrix A in matlab sparse matrix format...
> " << "\n" << std::endl;
>
> char buf1[14];
>
> sprintf (buf1, "A.m");
>
> matrix_A.print_matlab(buf1);
>
> std::cout << "Matrix A Exported! " << "\n" << std::endl;
>
> // matrix_A.clear();
>
> std::cout << "Matrix A Cleared from Memory! " << "\n" << std::endl;
>
> std::cout << "Exporting Matrix B in matlab sparse matrix format...
> " << "\n" << std::endl;
>
> char buf2[14];
>
> sprintf (buf2, "B.m");
>
> matrix_B.print_matlab(buf2);
>
> std::cout << "Matrix B Exported! " << "\n" << std::endl;
>
> // matrix_B.clear();
>
> std::cout << "Matrix B Cleared from Memory! " << "\n" << std::endl;
>
> #endif // LIBMESH_HAVE_SLEPC
>
> /**
>
> * All done!
>
> */
>
> return;
>
> On Thu, Aug 4, 2016 at 5:41 PM, Mike Marchywka
> <marchy...@hotmail.com<mailto:marchy...@hotmail.com>> wrote:
>
>
>
>
> ----------------------------------------
>> Date: Thu, 4 Aug 2016 19:11:03 -0500
>> From: royst...@ices.utexas.edu<mailto:royst...@ices.utexas.edu>
>> To: marchy...@hotmail.com<mailto:marchy...@hotmail.com>
>> CC:
> libmesh-users@lists.sourceforge.net<mailto:libmesh-users@lists.sourceforge.net>
>
>> Subject: Re: [Libmesh-users] FW: libmesh problem: libmesh_nullptr was
> not declared in scope
>>
>>
>>
>> On Thu, 4 Aug 2016, Mike Marchywka wrote:
>>
>>>> I have not followed the exchange but sometimes I end up including
> headers within a namespace or
>>>> something. Is libmesh being included within something? Not sure
> what that does with some
>>>> macros and others not lol.
>>
>> That was my first guess, too! That's actually why I was asking about
>> the config macros - if he was in the nullptr-workaround case, then
>> accidentally including a libMesh header within a namespace would have
>> exactly the effect seen: the class we define wouldn't exist in the
>> global namespace and the compiler wouldn't recognize it.
>
> I skimmed most of the messages and it did sound like it would be something
> easy to find by looking at the exact code so I was a bit surprised with
> that last post :)
>
> For problems in unfamiliar code grep can be amazingly
> useful even if you expect 1000's of hits they usually end up being easy
> to sort out.
>
> The linking is a bit unorthodox, indeed I think you had some specific
> recommendations for linking to libmesh that hid most of the details, but
> actually building it and compiling with it were pretty easy. I turned
> on some debug info
> from the example make script, just copied its invokation of g++ and libtool
> and that seems to work for some simple case.
>
>
>
>
>> ---
>> Roy
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Libmesh-users mailing list
> Libmesh-users@lists.sourceforge.net<mailto:Libmesh-users@lists.sourceforge.net>
>
> https://lists.sourceforge.net/lists/listinfo/libmesh-users
>
------------------------------------------------------------------------------
_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users