clc
clear all
%description: utilize COMSOL to produce the mesh data

%read comsol project and get mesh data
model=mphload('Fem4.mph');
[~, m2]=mphmeshstats(model);

%processing mesh data
Mesh.Nodes=m2.vertex';%vertex position
Elements=m2.elem{2}'+1;
Mesh.Elements = sort(Elements,2);%mesh connectivity n*3
Mesh.Domains=m2.elementity{2};%domain index n*1
Faces=m2.elem{3}'+1;%boundary face
Mesh.Faces = sort(Faces,2);
Mesh.FacesIndex=m2.elementity{3};%boundary face index


%save mesh data as a file
save('MeshData2BW','Mesh');
