If you're not sure where your database is located on disk, but you can connect to the database, the location of this and other important files on the server is available from pg_settings view. This particular detail is in the data_directory setting; here is an example of locating it, and  a query showing the locations of other interesting files related to the server:

Note: All SQLs tested on pg9.1,pg9.2,pg9.3, and pg9.4

Locate PostgreSQL data directory

# show data_directory;
     data_directory      
-------------------------
 /var/lib/pgsql/9.4/data
(1 row)

Locate Database directory

Second step is to find the physical directory for each database, they are located under data_directory/base

# ls -l /var/lib/pgsql/9.4/data/base
total 96
drwx------ 2 postgres postgres 12288 Jun 12 14:15 1
drwx------ 2 postgres postgres  4096 Jan 22  2015 12891
drwx------ 2 postgres postgres  4096 Jun 12 14:16 12896
drwx------ 2 postgres postgres 12288 Jun 12 14:16 16389
drwx------ 2 postgres postgres 12288 Jun 12 14:16 16390
drwx------ 2 postgres postgres 12288 Jul  2 23:23 16391
drwx------ 2 postgres postgres 20480 Jul 17 16:41 16392
drwx------ 2 postgres postgres  4096 Jun 12 14:15 16393
drwx------ 2 postgres postgres 12288 Jun 12 14:15 16394
drwx------ 2 postgres postgres  4096 Jan 22  2015 pgsql_tmp

The physical file are all named as so called OID

# select datname,oid from pg_database where datname='postgres';
 datname  |  oid  
----------+-------
 postgres | 12896

Together with the list of files under base directory, you see the database directory for database postgres is

drwx------ 2 postgres postgres  4096 Jun 12 14:16 12896

Note: OID stands for Object Identifier. Each database, relation(including a table) has an OID.

Locae table or relations file.

# select relname,oid,relfilenode from pg_class limit 3;
    relname    | oid  | relfilenode
---------------+------+-------------
 pg_statistic  | 2619 |       12629
 pg_type       | 1247 |           0
 pg_toast_2619 | 2840 |       12631
(3 rows)

relfilenode is the file store table 'pg_buffercache'

# ls -l /var/lib/pgsql/9.4/data/base/12896/12629
-rw------- 1 postgres postgres 122880 Jan 30  2015 /var/lib/pgsql/9.4/data/base/12896/12629

One thing should be kept in mind is that I just showed the name of the first segment of the main fork of the relation — you may need to append a segment number and/or _fsm, _vm, or _init to find all the files associated with the relation