A Circuit-Based Approach for the Solution of Electrothermal and Electromagnetic Problems