[Getdp] GetDP integrated in MATLAB?

Thomas_W e0208228 at student.tuwien.ac.at
Tue Oct 9 15:22:41 CEST 2012


Zitat von François Henrotte <francois.henrotte at uclouvain.be>:

>
> Le 13 sept. 2012 à 17:49, Thomas_W a écrit :
>
>>
>> Dear all,
>>
>> my aim is to apply an iterative procedure where I call a PDE solver  
>> with different coefficients each time and use the output to update  
>> the parameters. I think of prototyping this algorithm in MATLAB,  
>> and my question is whether the GetDP solver can be integrated in  
>> this environment. In the archive entries I did not find any  
>> definitive answer. So I hope you bear with me asking this global  
>> question.
>>
>> I think of a MATLAB function like this:
>>
>> 1:   function sol = algo(a,filename,options,n)
>> 2:
>> 3:   for i = 1:n
>> 4:
>> 5:    		sol = getDP(a,filename,options);
>> 6:
>> 7:  		if endcriterium(sol) < 0.01
>> 8:			break;
>> 9:  		end
>> 10:
>> 11:
>> 12: 		a = newparameter(sol);
>> 13:
>> 14:  end
>
>
> Hallo,
>
> you can of course make a system call in matlab:
> http://www.mathworks.nl/help/matlab/ref/system.html;jsessionid=3fedf590baa0193e36d40b603415
> but probably this is not what you want because
> you wish to supply getdp with parameters from within matlab.
>
> This kind of solver coupling is precisely what we are developing
> with the project ONELAB. See http://onelab.info
> It is still very much a work in progress but sufficiently mature already
> to make more or less what you are describing above.
>
> Take a look to the onelab.info website, and if you have gmsh  
> installed on your system
> check the tutorial example:
>
> http://onelab.info/wiki/Tutorial  (Feedback on this tutorial example  
> is very much appreciated!).
>
> I could be more specific in my answer if you would tell more about  
> your getDP model
> and the details of the retroaction you want  to establish with matlab.
>
> Fr.
>
>
>
>> Is there any way to integrate the GetDP package in a way like  
>> indicated in line 5 in the above code?
>> So that I have matlab strings specifying filename and options as  
>> well as a providing the INPUT, and the OUTPUT sol being provided by  
>> the package itself?
>>
>> As mentioned, I have not seen any example in this direction.
>> Is it
>> -possible
>> -complicated?
>> Does such an example already exist ?
>> (So probably, if it is possible and not so difficult, it would  
>> probably GetDP would be of use not only to me, but to many other  
>> users as well, who use MATLAB for prototyping their algorithms.)
>>
>> I suspect that the more complicated thing will be to make the  
>> getDP-function in line 5 managing the interface between the matlab  
>> vector of the parameter a and the geometric description of  
>> parameters required by the GetDP package. The matlab vector would  
>> just consist of one value per triangle in the mesh. By the  
>> iterative procedure as outline above, it will be adapted in each  
>> iterative step. Correct? Or would you think this is the easy part  
>> of the problem?
>>
>> Thank you!
>>
>> Thomas
>>
>>
>> _______________________________________________
>> getdp mailing list
>> getdp at geuz.org
>> http://www.geuz.org/mailman/listinfo/getdp
>
> --
> François Henrotte Dr Ir
> UCL - Bâtiment Euler - Av. G. Lemaître 4-6
> B-1348 Louvain-la-Neuve
> Tél: +32(0)10 47 80 56  Fax: id. 23 50
>
>
>

Dear François,

I have created a very simple electrostatic example with given boundary  
conditions in order have an example.
The geometry is coarse: just a rectangle, but the value of the  
parameters can principally vary on any point of the domain (and are  
provided by a separate data file, possibly created by MATLAB). The  
*.msh-files and the output *.pos-files can be integrated into MATLAB  
by scripts like Prof. Chessa's in  
http://www.youtube.com/watch?v=CXKp_Kj1lwk.

I've now implemented this in GetDP after the suggestion by Ruth in  
http://www.geuz.org/pipermail/getdp/2011/001407.html, with creating a  
new function space 'BF_sigma' for the conductivity parameter. Probably  
it may get simpler with more knowledge of the ONELAB-interface,  
probably, François, you can say more about this.

Thank you,
Thomas



Function {
listsigma=ListFromFile["mysigma.txt"];
mysigma[] = ValueFromIndex[]{listsigma{}};
}

Constraint {
    { Name Sta_V ; Type Assign;
      Case {
        { Region ltop; Value 1.; }
        { Region lbottom; Value -1; }
      }
    }
    {Name MySigma; Type Assign;
    Case {
    {Region vtopl; Value mysigma[];}
    }
    }
}

FunctionSpace {

    { Name spacea; Type Form0;
      BasisFunction {
        { Name sn; NameOfCoef Tn; Function BF_Node; Support vtopl; //
Region[{ftop,lborder}];
          Entity NodesOf[All]; }
      }
      Constraint {
       { NameOfCoef Tn; EntityType NodesOf ; NameOfConstraint Sta_V; }
     }
    }

    { Name BF_sigma; Type Form0;
    BasisFunction {
    	{Name sn; NameOfCoef s; Function BF_Node;
    	Support vtopl; Entity NodesOf[All]; }
    }
    SubSpace {
    	{Name sub; NameOfBasisFunction sn; }
    }
    Constraint {
      {NameOfCoef s;
      EntityType NodesOf; NameOfConstraint MySigma;}
    }
    }
}

Formulation {
    { Name f_v ; Type FemEquation;
      Quantity {
        { Name vtop;  Type Local; NameOfSpace spacea; }
        { Name sig; Type Local; NameOfSpace BF_sigma[sub];}
      }
      Equation {
   Galerkin { [ {sig}*Dof{d vtop} , {d vtop} ]; In vtopl; Integration
Int; Jacobian JVol;  }
    Galerkin{[Dof{sig}*0,{vtop}];In vtopl; Jacobian JVol; Integration
Int;}
      }
    }
}