function P0Em = TriMesh_ConvCP1toP0(TriMesh,CP1NdVal)
% TriMesh: Converting CP1 (cont.poly.deg1) to P0 (pcws.const.) 
% James Liu, ColoState; 2012/07--2017/02 

%% Converting 
% NOTE: CP1NdlVal has size NumNds-by-1 
% NOTE: P0Em has size NumEms-by-1 
val = CP1NdVal(TriMesh.elem(:,1:3));
P0Em = (1/3)*sum(val,2);

return;