Exporting mesh
In[]:=
Quit
In[]:=
Needs["NDSolve`FEM`"]
In[]:=
Needs["FEMAddOns`"]
.msh export
.msh export
Unfortunately, .msh is not supported. You can find out the list of supported format by querying $ExportFormats
In[]:=
$ExportFormats
Out[]=
{3DS,ACO,AIFF,AU,AVI,Base64,Binary,Bit,BMP,BSON,Byte,BYU,BZIP2,C,CDF,Character16,Character32,Character8,Complex128,Complex256,Complex64,CSV,CUR,DAE,DICOM,DIF,DIMACS,DOT,DXF,EMF,EPS,ExpressionJSON,ExpressionML,FASTA,FASTQ,FCS,FITS,FLAC,FLV,FMU,GeoJSON,GIF,Graph6,Graphlet,GraphML,GXL,GZIP,HarwellBoeing,HDF,HDF5,HTML,HTMLFragment,HTTPRequest,HTTPResponse,ICNS,ICO,Ini,Integer128,Integer16,Integer24,Integer32,Integer64,Integer8,JavaProperties,JavaScriptExpression,JPEG,JPEG2000,JSON,JSONLD,JVX,KML,LEDA,List,LWO,M4A,MAT,MathML,Maya,MCTT,MGF,MIDI,MO,MOL,MOL2,MP3,MTX,MX,MXNet,NASACDF,NB,NetCDF,NEXUS,NOFF,NQuads,NTriples,OBJ,OFF,OGG,Package,Pajek,PBM,PCX,PDB,PDF,PGM,PHPIni,PICT,PLY,PNG,PNM,POV,PPM,PXR,PythonExpression,QuickTime,RawBitmap,RawJSON,RDFXML,Real128,Real32,Real64,RIB,RTF,SCT,SDF,SMA,SMILES,SND,SPARQLQuery,SPARQLResultsJSON,SPARQLResultsXML,SPARQLUpdate,Sparse6,STL,String,SurferGrid,SVG,SWF,Table,TAR,TerminatedString,TeX,TeXFragment,Text,TGA,TGF,TIFF,TriG,TSV,Turtle,UBJSON,UnsignedInteger128,UnsignedInteger16,UnsignedInteger24,UnsignedInteger32,UnsignedInteger64,UnsignedInteger8,UUE,VideoFrames,VRML,VTK,WAV,Wave64,WDX,WebP,WLNet,WMLF,WXF,X3D,XBM,XHTML,XHTMLMathML,XLS,XLSX,XML,XYZ,ZIP,ZPR}
In[]:=
MemberQ[$ExportFormats,"MSH"]
Out[]=
False
Region marker issue
Region marker issue
This is because MeshRegion does not preserve region marker without specifying.
◼
One way to do it is via Annotate
In[]:=
(*******Usingthemeshfromthenotebook*******)
In[]:=
(*Preparethesinuswavecoordinates*)nSin=50;xLoc=Range[0,1,1/(nSin-1)];yLoc=0.5+0.1*Sin[2*Pi*xLoc];coords=Transpose[{xLoc,yLoc}];(*Addtheboxoutline*)AppendTo[coords,{0,0}];AppendTo[coords,{1,0}];AppendTo[coords,{1,1}];AppendTo[coords,{0,1}];(*Createtheconnectionbetweenthevariouspoints*)lines=Table[{n,n+1},{n,nSin-1}];AppendTo[lines,{nSin+1,nSin+2}];AppendTo[lines,{nSin+2,nSin}];(*Addtheconnectionbetweenthesideandtheinterfaceontheright*)AppendTo[lines,{nSin,nSin+3}];AppendTo[lines,{nSin+3,nSin+4}];AppendTo[lines,{nSin+4,1}];(*Addtheconnectionbetweenthesideandtheinterfaceontheleft*)AppendTo[lines,{nSin+1,1}];(*Performtheactualmeshing*)boundaryMesh=ToBoundaryMesh["Coordinates"coords,"BoundaryElements"{LineElement[lines]}];triMesh=ToElementMesh[boundaryMesh,"RegionMarker"{{0.5,0.5},1},MaxCellMeasure0.01];quadMesh=triMesh//ToQuadMesh;
◼
ElementMarkers retrieves markers
In[]:=
(*findoutwhattheregionmarkersare*)
In[]:=
ElementMarkers[triMesh["MeshElements"]]
Out[]=
{{0,0,1,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,0,1,0,1,0,0,1,1,1,0,1,0,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,0,1,0,1,1,0,1,1,1,0,1,0,0,1,1,0,1,0,0,1,1,0,1,1,0,1,0,1,0,1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1}}
◼
Then you can pass the markers to the mesh. It will be the same as the element mesh
In[]:=
Annotate[{MeshRegion[triMesh],{2,All}},MeshCellLabelFirst[ElementMarkers[triMesh["MeshElements"]]]]
Out[]=
In[]:=
(*Itisthesameastheelementmesh*)
In[]:=
triMesh["Wireframe"["MeshElementMarkerStyle"Blue]]
Out[]=
In[]:=
(*Similarlywithquadmesh*)
In[]:=
{Annotate[{MeshRegion[quadMesh],{2,All}},MeshCellLabelFirst[ElementMarkers[quadMesh["MeshElements"]]]],quadMesh["Wireframe"["MeshElementMarkerStyle"Blue]]}
Out[]=
,
Mesh export
Mesh export
Some formats fail because of the capability of them handling MeshRegions. These should be listed in the ref pages for each of the format. Many of them work only with Graphics3D objects, so one may need to convert the output.
However, with that said, there are bugs with exporting. Formats other than VTK are buggy.
◼
Set up
In[]:=
dir="~/tryMeshing/";If[!DirectoryQ[dir],CreateDirectory[dir]];Print["Meshes will be written to "<>dir];
◼
Thus embedding the mesh to 3-space should solve the issue
VTK
VTK
◼
In ref/format/VTK
◼
VTK does export triMesh, but the problem is that it is not shown correctly