# Tag Info

4

For a closed surface such as this one, a slight modification of the function MakeTriangleMesh[] in this answer can be used: MakeTriangleMesh[vl_List, {closedu : (True | False) : False, closedv : (True | False) : False}, opts___] := Module[{dims = Most[Dimensions[vl]], v = vl, idx}, idx = Partition[Range[Times ...

7

Needs["NDSolveFEM"] mesh = ToElementMesh[Disk[]]; ufun = NDSolveValue[ {-Laplacian[u[x, y], {x, y}] == 1, DirichletCondition[u[x, y] == 0, True]}, u, {x, y} ∈ mesh]; Plot3D[ufun[x, y], {x, y} ∈ mesh, Mesh -> All] Two things to note: Plot3D directly takes an ElementMesh giving the option Mesh->All uses that specific mesh in the ...

1

This is a hack, but it seems to do what you are asking by creating a new mesh object from the old one. pts = {{-3, -4}, {-2, 1}, {3, -2}}; vm = VoronoiMesh@pts; oldcoords = MinMax /@ Transpose[MeshCoordinates@vm] // Flatten; plot1 = ListPlot[2 pts, PlotRange -> Automatic, AspectRatio -> 1, Frame -> True, Axes -> False]; newcoords = ...

3

One can also use the built-in graph-theoretic functions for this task: BlockRandom[SeedRandom[42, Method -> "Legacy"]; (* for reproducibility *) mesh = DelaunayMesh[RandomReal[10, {30, 2}]]]; vd = VertexDegree[Graph[Range[Length[MeshCoordinates[mesh]]], MeshCells[mesh, 1] /. Line[l_] :> UndirectedEdge @@ l]]; ...

6

This is due to the interpolation. If you turn off the interpolation by InterpolationOrder -> 0 you will see symmetric plot. data = Flatten[Table[{x, y, If[x == y, 1, 0]}, {x, 0, 1, 1/10}, {y, 0, 1, 1/10}], 1]; dataR = data; dataL = data /. {x_, y_, z_} :> {-x, y, z}; data0 = Join[dataL,dataR] ListDensityPlot[data0, ...

5

It's not a bug this is what is expected. Here is what I get in 10.4.1 << NDSolveFEM GraphicsRow[Table[x0 = 2.5; cords = {{-x0, 0, 0}, {x0, 0, 0}}; r = RegionDifference[Cuboid[{-L, -L, -L}, {L, L, L}], RegionUnion[Ball[#, 1] & /@ cords]]; mesh2 = ToElementMesh[r, "RegionHoles" -> cords]; mesh2["Wireframe"[PlotRange -> {{-L, L}, ...

1

If you look at what RegionMember[First@features, {x, y, z}] actually finds you see something like this (after a small re-write) ply = {Polygon[{{85/2, 46.7, 46.7}, {85/2, 46.7, 53.3}, {85/2, 53.3, 53.3}, {85/2, 53.3, 46.7}}], Polygon[{{115/2, 46.7, 46.7}, {115/2, 46.7, 53.3}, {115/2, 53.3, 53.3}, {115/2, 53.3, 46.7}}]}; features = ...

4

You can use newcoords = updatecoords[XC]; meshupdated = ToElementMesh["Coordinates" -> newcoords, "MeshElements" -> ME, "BoundaryElements" -> meshoriginal["BoundaryElements"], "PointElements" -> meshoriginal["PointElements"]]; That can be sped up (if you are absolutely sure the structure ...

6

Here is another approach. Mathematica uses Triangle as it's 2D mesh generator. Triangle is very efficient and returns good results for numerical routines like the Finite Element Method or interpolation functions. However, to the best of my knowledge, there is not way to tell Triangle to use not generate triangles that have a angles that are larger than a ...

5

The following works reasonably well, up to a minimum area cutoff that is needed to limit the evaluation time: TriLengths[{a_, b_, c_}] := Module[{A, B, C}, A = Sqrt[(b - a).(b - a)]; B = Sqrt[(c - b).(c - b)]; C = Sqrt[(a - c).(a - c)]; {A, B, C}]; TriAngles[{a_, b_, c_}] := Module[{A, B, C, α, β, γ}, {A, B, C} = TriLengths[{a, b, c}]; ...

1

Something about your function TriAngles is interfering with MeshRefinementFunction. If I evaluate TriAngles inside the MeshRefinementFunction, then MeshRefinementFunction is ignored, even when the output of TriAngles isn't used. DiscretizeRegion[Disk[], MeshRefinementFunction -> Function[{vlist, area}, N@TriAngles[vlist]; If[area < 0.001, Return[...

0

There is one possible answer to my question: just introduce two extra dependent variables that are the gradients of my function f and set the Dirichlet boundary condition on the gradients. NOOOOOOOOOOO! This does NOT work! I get a error: "Cross-coupling of dependent variables in ... is not supported in this version." Edit: The only solution that MUST ...

1

Here are two functions that compute the edge length of the elements and the boundary elements: Needs["NDSolveFEM"]; EdgeLength[mesh_] := Block[{ec, edgelength}, ec = NDSolveFEMGetElementCoordinates[mesh["Coordinates"], Join @@ ElementIncidents[mesh["MeshElements"]]]; edgelength = Sqrt[Total[((ec - RotateLeft /@ ec)^2), {3}]]; edgelength ] ...

Top 50 recent answers are included