I would like to refine a mesh within a given path/volume, that is specified by the MeshRefinementFunction option given in ToElementMesh[]. For starting i took a simple 3D MeshRegion of a Tetrahedron
<< NDSolve`FEM`
reg=MeshRegion[{{0,0,0},{1,0,0},{0,1,0},{0,0,1}},Tetrahedron[{1,2,3,4}]]
Next i defined the MeshRefinementFunction
coord={{0,0,0},{1,0,0},{0,1,0},{0,0,1}};
cf = Function[{coordinates, vol},RegionMember[Ball[Mean[coord], 0.5], Mean[coordinates]]];
So that whenever the element lies within the balls region there should be a refinement. Then i proceed with
mesh = ToElementMesh[reg,MeshRefinementFunction -> cf]
which evaluates to the error code
ToElementMesh::mrff: The MeshRefinementFunction Function[{coordinates,vol},RegionMember[Ball[Mean[coord],0.5],Mean[coordinates]]] is not valid and will be ignored. Possibly the function does not return either True or False or the (auto) compiled function does not evaluate message free.
I dont understand whats the problem in here. cf evaluates to True or False as required.