[From Oliver]
[From Oliver]
2D example
2D example
Create the graph (and note that there are not 3D Graph examples in the documentation)
In[]:=
rg=RandomGraph[{20,30}]
Out[]=
Replace the Line edges with StadiumShape to get a 2D area that can be meshed.
In[]:=
graphics=Normal[Show[rg]];lineToRectangle[Line[{{x1_,y1_},{x2_,y2_}}],d_:0.03]:=StadiumShape[{{x1,y1},{x2,y2}},d]edges2D=lineToRectangle/@Cases[graphics,_Line,Infinity];Graphics[edges2D]
Out[]=
Make the union and the mesh.
In[]:=
reg=RegionUnion[edges2D];mesh=DiscretizeRegion[reg]
Out[]=
Compute some eigenvalues and functions.
In[]:=
{vals,funs}=NDEigensystem[Laplacian[u[x,y],{x,y}]-1,u,Element[{x,y},mesh],5]
Out[]=
Generate some random boundary conditions.
In[]:=
boundaryConditons=DirichletCondition[u[x,y]RandomChoice[{0,1}],(x-#[[1,1]])^2+(y-#[[1,2]])^2≤#[[2]]]&/@RandomChoice[Cases[graphics,_Disk,Infinity],4];
Solve an equation.
In[]:=
ifun=NDSolveValue[{Laplacian[u[x,y],{x,y}]1,boundaryConditons},u,Element[{x,y},mesh]]
Out[]=
Visualize.
In[]:=
Plot3D[ifun[x,y],Element[{x,y},mesh],BoxedFalse,AxesNone,ColorFunction"TemperatureMap"]
Out[]=
Alternative way:
am=AdjacencyMatrix[rg];Eigensystem[N[am],-4,Method"Arnoldi"]
Out[]=