manually modifying fea.sol.u

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

manually modifying fea.sol.u

peteri
Hi,

I have used the evalexpr to read data for a given location from the solution which is stored in fea.sol.u.  Is there a complementary function that can write a value of a variable to a given location and time in fea.sol.u?   If not, can you explain the structure of fea.sol.u so that I can manually write in values for specific variables (say for variable C if I am modeling variables A, B, C and D) at specific locations?

This is coming up in two contexts:

(1) I need to be able to define a spatially variable initial condition which depends on external calculations that I make before launching FEAtool via a matlab script (not GUI), and the spatial variability changes in a random way with each simulation.  The initial condition varies within the subdomains so the feature to specify it uniform within each subdomain is insufficient.

(2) In some cases I would like to substitute a dummy value of FEAtool's calculated value before plotting, as a post-processing and visualization step.

I could develop something on my own to do this but I'd need to understand the structure of fea.sol.u in detail.  I can see that the columns in fea.sol.u are the time levels, but the ordering of the rows is unclear and some simple attempts to figure it out failed.

Thanks in advance for help on this topic!

Best,
Peter

Reply | Threaded
Open this post in threaded view
|

Re: manually modifying fea.sol.u

Precise Simulation
Administrator
The solution vector is assumed to be generated from computations so there is no functionality to explicitly set it during the solution process. You can prescribe an initial solution vector to the solvers with the 'init' argument.

The solution vector format is briefly explaned here "https://featool.com/doc/feastruct":

"After solving a problem the sol field will contain the solution column vector in sol.u with rows corresponding to the degrees of freedom (ordered according to the order of the dependent variables in fea.dvar and fea.eqn.dofm). For time dependent and eigenvalue problems the columns in u correspond to solutions at different times/eigenvalues, and additionally the output times will be stored as a vector in the sol.t or sol.l field, respectively."

Basically, the rows in "sol.u" consists of the degrees of freedom for the dependent variables in blocks corresponding to the order in "fea.dvar". In the simple case of using 1st order conforming shape/basis functions ("fea.sfun = sflag1"), the location of the degrees of freedom (DOF) will correspond to the mesh vertices ("fea.grid.p' "), so that the coordinates for the degrees of freedom (corresponding to the rows in sol.u) would be equivalent to "repmat(fea.grid.p',length(fea.dvar),1)". For higher order discretizations the degrees of freedom also include values on edges, faces, and cell centers to it becomes more complicated, easiest is to use "evalinit" to get a corresponding coordinate mapping "x0" for the DOF locations (in sol.u):

  n_dvar = length(fea.dvar);
  x0 = [];
  for i=1:length(fea.sdim)
    x0 = [x0, evalinit(fea, repmat(fea.sdim(i), 1, n_dvar))];
  end

Moreover, the number of degrees of freedom for each dependent variable can be found in "fea.eqn.ndof", and the actual DOF to grid cell mapping/numbering in "fea.eqn.dofmap". From the same section:

"dofm is an array specifying the local to global degree of freedom numbering for each dependent variable (size n_ldof, n_c). The rows correspond to local degrees of freedoms on each cell and the columns give the cell numbers. (For linear conforming shape functions the dof mapping will be identical to the grid.c field.) This field is created when parseprob calls the "mapdofbdr" function.

ndof is simply an help array for the numbers of degrees of freedom for each dependent variable (equals to max(dofm(:)) and also automatically generated by mapdofbdr)."
Reply | Threaded
Open this post in threaded view
|

Re: manually modifying fea.sol.u

peteri
This is a very helpful response - thank you!  I'll chew on this for a bit and get back to you if more questions come up.