The error always appears when init_value is completed executed 
by project_solution. So I think _func is valid indeed. 


In fact _func is assigned as follows in another function like


_func=std::tr1::shared_ptr<libMesh::FunctionBase<libMesh::Number> > 
    (new ParsedFunction<Number>(func_string));



Zhenyu


------------------ Original ------------------
From:  "John Peterson";<[email protected]>;
Send time: Monday, Apr 20, 2015 10:37 PM
To: "grandrabbit"<[email protected]>; 
Cc: "libmesh-users"<[email protected]>; 
Subject:  Re: [Libmesh-users] segmentation fault after projection solution





On Mon, Apr 20, 2015 at 8:04 AM, grandrabbit <[email protected]> wrote:
Hello,
 
 I wrote a class for set up initial values and called it by
               system.attach_init_function (init_sys);
 
 Here is the part of init_sys
 
 void init_sys(EquationSystems& es,const std::string& system_name)
 {
     System & system =
         es.get_system<System>(system_name);
     vector< string > formulas;
     boost::split(formulas, system_name, boost::is_any_of("_"), 
token_compress_on );
 
     if(boost::iequals(formulas[0], string("ns")))
     {
 //        TransientNonlinearImplicitSystem & system =
 //            es.get_system<TransientNonlinearImplicitSystem>(system_name);
         system.project_solution(init_value, NULL, es.parameters); // run-time 
error by petsc, segfault
         cout<<"init_sys OK, "<<system_name<<endl; // this line never run due 
to the following error
     }
     else
     {
       cout<<"unknown type from system_name yet"<<endl;
       exit(-1);
     }
 }
 
 Number init_value (const Point& p,
                    const Parameters& parameters,
                    const std::string& sysname,
                    const std::string& varname)
 {
     auto _func=_init_conditioner->get_func(sysname,varname);
 
     if(!_func)
     {
         std::cerr<<"!!! init_value(...): _func is nullptr"<<endl;
         exit(-1);
     }
 
     Real _time =parameters.get<Real> ("time");
     Number result=(*_func)(p, _time);
     ipoint++;
 #if 1
     cout<< sysname<<"."<<varname<<":";
     cout<<"("<<p(0)<<","<<p(1)<<","<<p(2)<<"), "
         <<"t= "<<_time
         <<", value= "<<result
         <<", ipoint="<<ipoint<<endl;
 #endif
     return result;
 }
 
 The whole code is cuessfully built and linked.
 Now the question is when it runs, in the main() function
 errors aborted the run when it reached
     equation_systems.init ();
 Then I located the error more precisely, say,
 the above system.project_solution() in init_sys was partly executed.
 
 I am sorry the original codes is long enough, but if any of you think it 
necessary,
 I can upload it afterwards,
 
 Here are some screenshot of the errors:
 
 ns_0.v:(5.98457,4.68673,0), t= 0, value= 0.069756, ipoint=783857
 ns_0.v:(5.87916,4.9296,0), t= 0, value= 0.069756, ipoint=783858
 ns_0.v:(5.93191,4.9295,0), t= 0, value= 0.069756, ipoint=783859
 ns_0.v:(5.98465,4.92939,0), t= 0, value= 0.069756, ipoint=783860
 ns_0.p:(5.86218,4.37566,0), t= 0, value= 0, ipoint=783861
 ns_0.p:(6,4.37319,0), t= 0, value= 0, ipoint=783862
 ns_0.p:(6,5,0), t= 0, value= 0, ipoint=783863
 ns_0.p:(5.86402,5,0), t= 0, value= 0, ipoint=783864
 [0]PETSC ERROR: 
------------------------------------------------------------------------
 [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably 
memory access out of range




Looks like the segfault is in "_func" which I don't think you sent the code 
for...


-- 
John
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to