///A novel vector finite element method (FEM) was proposed to simulate the response of logging-while-drilling (LWD) resistivity tool in 3D inhomogeneous medium. Layered medium combined with dipping borehole and invaded zones is partitioned into tetrahedrons. Each tetrahedron has six vector edge elements. The number of unknowns can be over 1 million for 3D LWD applications. In this case, an algebraic multi-grain (AMG) method combined with multi-frontal solver is developed to solve this very large scale problem with personal computers. The resulting program is validated through the published results derived from finite difference time-domain (FDTD) method and the borehole measurement data.