Hi developers and users,

There is  another question on the setting of initial condition, is that 
possible to set the random number to the variable on each node? I put a 
rand() in the function of "exact_solution", it returns the same value to 
all nodes as shown on bottom.  the system.project_solution function may 
only return the single exact_value to all the nodes, so I am thinking 
add a loop over system.project_solution may solve this problem, but the 
number of node and node ID are unknown to me, so which c++ files contain 
these information or any other ideas to assign random initial conditions 
to variable? Thanks a lot!

Liang


==================================

void init_lc (EquationSystems& es,
              const std::string& system_name)
{
  libmesh_assert (system_name == "hw8-2d");
  TransientLinearImplicitSystem & system =
        es.get_system<TransientLinearImplicitSystem>("hw8-2d");
  es.parameters.set<Real> ("time") = 0;

  system.project_solution(exact_value, NULL, es.parameters);

}



Number exact_value (const Point& p,
                         const Parameters& parameters,
                         const std::string&,
                         const std::string& unknown_name) // fptr
{
    if(unknown_name == "v")
      for(unsigned int i=0; i<parameters.get<Real> ("time"); ++i)

        return exact_solution(p(0), p(1), parameters.get<Real> ("time")
                                ,"v");
}


Real exact_solution (const Real x,
                     const Real y,
                     const Real t,
                     const std::string unknown_name)
{
    time_t curTime;
    std::time(&curTime);
    std::srand(curTime);

    if (unknown_name == "v"){
        Real d = (double) std::rand()/RAND_MAX;
        return (d*2-1)*1e-1;
    }

}

=============================

Variables=x,y,z,u,v
Zone f=fepoint, n=441, e=400, et=quadrilateral, c=black
0.00000 0.00000 0.00000 0.00000 0.0673101
0.100000 0.00000 0.00000 0.00000 0.0673101
0.100000 0.100000 0.00000 0.00000 0.0673101
0.00000 0.100000 0.00000 0.00000 0.0673101
0.0500000 0.00000 0.00000 0.00000 0.0673101
0.100000 0.0500000 0.00000 0.00000 0.0673101
0.0500000 0.100000 0.00000 0.00000 0.0673101
0.00000 0.0500000 0.00000 0.00000 0.0673101
0.0500000 0.0500000 0.00000 0.00000 0.0673101
0.200000 0.00000 0.00000 0.00000 0.0673101
0.200000 0.100000 0.00000 0.00000 0.0673101
0.150000 0.00000 0.00000 0.00000 0.0673101
0.200000 0.0500000 0.00000 0.00000 0.0673101
0.150000 0.100000 0.00000 0.00000 0.0673101



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to