1
by hhiester
deleting initialisation as none of tools are used any longer. |
1 |
! Copyright (C) 2006 Imperial College London and others.
|
2 |
!
|
|
3 |
! Please see the AUTHORS file in the main source directory for a full list
|
|
4 |
! of copyright holders.
|
|
5 |
!
|
|
6 |
! Prof. C Pain
|
|
7 |
! Applied Modelling and Computation Group
|
|
8 |
! Department of Earth Science and Engineeringp
|
|
9 |
! Imperial College London
|
|
10 |
!
|
|
2392
by tmb1
Changing isntances of Chris' person email address to the group |
11 |
! amcgsoftware@imperial.ac.uk
|
1
by hhiester
deleting initialisation as none of tools are used any longer. |
12 |
!
|
13 |
! This library is free software; you can redistribute it and/or
|
|
14 |
! modify it under the terms of the GNU Lesser General Public
|
|
15 |
! License as published by the Free Software Foundation,
|
|
16 |
! version 2.1 of the License.
|
|
17 |
!
|
|
18 |
! This library is distributed in the hope that it will be useful,
|
|
19 |
! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 |
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 |
! Lesser General Public License for more details.
|
|
22 |
!
|
|
23 |
! You should have received a copy of the GNU Lesser General Public
|
|
24 |
! License along with this library; if not, write to the Free Software
|
|
25 |
! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
26 |
! USA
|
|
27 |
||
28 |
#include "fdebug.h"
|
|
29 |
||
1487
by acreech
Added partial GMSH support to Fluidity; now reads in serial GMSH meshes (parallel and write support on its way) |
30 |
subroutine project_to_continuous_parallel(vtuname, vtuname_len, meshname,& |
31 |
& meshname_len) |
|
1
by hhiester
deleting initialisation as none of tools are used any longer. |
32 |
!!< Given a vtu file containing fields on a discontinuous mesh, and the
|
1487
by acreech
Added partial GMSH support to Fluidity; now reads in serial GMSH meshes (parallel and write support on its way) |
33 |
!!< mesh files for the corresponding continuous mesh, produce a vtu
|
1
by hhiester
deleting initialisation as none of tools are used any longer. |
34 |
!!< with its fields projected onto the continuous mesh.
|
35 |
||
36 |
use fefields |
|
37 |
use fields |
|
38 |
use halos |
|
108
by maddison
Bye bye FLComms |
39 |
use global_parameters, only : current_debug_level |
1
by hhiester
deleting initialisation as none of tools are used any longer. |
40 |
use parallel_tools |
1487
by acreech
Added partial GMSH support to Fluidity; now reads in serial GMSH meshes (parallel and write support on its way) |
41 |
use mesh_files |
1
by hhiester
deleting initialisation as none of tools are used any longer. |
42 |
use solvers |
43 |
use sparsity_patterns |
|
44 |
use sparse_tools |
|
45 |
use state_module |
|
46 |
use vtk_interfaces |
|
47 |
||
48 |
implicit none
|
|
49 |
|
|
1487
by acreech
Added partial GMSH support to Fluidity; now reads in serial GMSH meshes (parallel and write support on its way) |
50 |
integer, intent(in):: vtuname_len, meshname_len |
1
by hhiester
deleting initialisation as none of tools are used any longer. |
51 |
character(len=vtuname_len), intent(in):: vtuname |
1487
by acreech
Added partial GMSH support to Fluidity; now reads in serial GMSH meshes (parallel and write support on its way) |
52 |
character(len=meshname_len), intent(in):: meshname |
1
by hhiester
deleting initialisation as none of tools are used any longer. |
53 |
|
54 |
character(len = *), parameter :: solver_option_path = "/dummy" |
|
55 |
integer :: i, nfields |
|
56 |
! VTK can store at most P2 fields. Hence degree 4 allows complete quadrature
|
|
57 |
! in the Galerkin projection.
|
|
58 |
integer, parameter :: quad_degree = 4 |
|
59 |
type(csr_matrix) :: mass |
|
60 |
type(csr_sparsity) :: sparsity |
|
61 |
type(mesh_type), pointer :: cg_mesh |
|
62 |
type(scalar_field) :: cg_s_field |
|
63 |
type(scalar_field), dimension(:), allocatable :: rhs |
|
64 |
type(scalar_field), dimension(:), pointer :: cg_state_fields, dg_state_fields |
|
65 |
type(scalar_field), pointer :: dg_s_field |
|
66 |
type(state_type) :: cg_state, dg_state |
|
67 |
type(tensor_field) :: cg_t_field |
|
68 |
type(tensor_field), pointer :: dg_t_field |
|
69 |
type(vector_field) :: cg_v_field |
|
70 |
type(vector_field), pointer :: dg_v_field |
|
71 |
type(vector_field), target :: cg_coordinate |
|
72 |
||
73 |
!current_debug_level = 2
|
|
278
by maddison
Adding Buoyancy diagnostic field, and adding serial support to project_to_continuous_parallel |
74 |
|
75 |
if(isparallel()) then |
|
76 |
call vtk_read_state(parallel_filename(vtuname, ".vtu"), dg_state, quad_degree = quad_degree) |
|
77 |
else
|
|
78 |
call vtk_read_state(trim(vtuname) //".vtu", dg_state, quad_degree = quad_degree) |
|
1
by hhiester
deleting initialisation as none of tools are used any longer. |
79 |
end if
|
80 |
|
|
1487
by acreech
Added partial GMSH support to Fluidity; now reads in serial GMSH meshes (parallel and write support on its way) |
81 |
cg_coordinate = read_mesh_files(meshname, quad_degree = quad_degree) |
82 |
if(isparallel()) call read_halos(meshname, cg_coordinate) |
|
1
by hhiester
deleting initialisation as none of tools are used any longer. |
83 |
cg_mesh => cg_coordinate%mesh |
84 |
||
85 |
do i = 1, scalar_field_count(dg_state) |
|
86 |
dg_s_field => extract_scalar_field(dg_state, i) |
|
87 |
call allocate(cg_s_field, cg_mesh, name = dg_s_field%name) |
|
88 |
call insert(cg_state, cg_s_field, cg_s_field%name) |
|
89 |
call deallocate(cg_s_field) |
|
90 |
end do
|
|
91 |
|
|
92 |
do i = 1, vector_field_count(dg_state) |
|
93 |
dg_v_field => extract_vector_field(dg_state, i) |
|
94 |
call allocate(cg_v_field, dg_v_field%dim, cg_mesh, name = dg_v_field%name) |
|
95 |
call insert(cg_state, cg_v_field, cg_v_field%name) |
|
96 |
call deallocate(cg_v_field) |
|
97 |
end do
|
|
98 |
|
|
99 |
do i = 1, tensor_field_count(dg_state) |
|
100 |
dg_t_field => extract_tensor_field(dg_state, i) |
|
101 |
call allocate(cg_t_field, cg_mesh, name = dg_t_field%name) |
|
102 |
call insert(cg_state, cg_t_field, cg_t_field%name) |
|
103 |
call deallocate(cg_t_field) |
|
104 |
end do
|
|
105 |
||
106 |
sparsity = make_sparsity(cg_mesh, cg_mesh, name = "MassSparsity") |
|
107 |
call allocate(mass, sparsity, name = "MassMatrix") |
|
108 |
call deallocate(sparsity) |
|
109 |
call compute_mass(cg_coordinate, cg_mesh, mass) |
|
110 |
||
111 |
call collapse_state(dg_state, dg_state_fields) |
|
112 |
nfields = size(dg_state_fields) |
|
113 |
||
114 |
allocate(rhs(nfields)) |
|
115 |
do i = 1, nfields |
|
116 |
call allocate(rhs(i), cg_mesh, name = trim(dg_state_fields(i)%name) // "Rhs") |
|
117 |
call zero(rhs(i)) |
|
118 |
end do
|
|
119 |
||
120 |
do i = 1, ele_count(cg_mesh) |
|
121 |
call assemble_gp_rhs_ele(i, cg_mesh, cg_coordinate, dg_state_fields, rhs) |
|
122 |
end do
|
|
123 |
deallocate(dg_state_fields) |
|
124 |
call deallocate(dg_state) |
|
125 |
||
126 |
call collapse_state(cg_state, cg_state_fields) |
|
127 |
call set_solver_options(solver_option_path, & |
|
128 |
& ksptype = "cg", pctype = "sor", atol = epsilon(0.0), rtol = 0.0, max_its = 2000, start_from_zero = .true.) |
|
129 |
call petsc_solve(cg_state_fields, mass, rhs, option_path = solver_option_path) |
|
130 |
||
131 |
deallocate(cg_state_fields) |
|
132 |
call deallocate(mass) |
|
133 |
do i = 1, nfields |
|
134 |
call deallocate(rhs(i)) |
|
135 |
end do
|
|
136 |
deallocate(rhs) |
|
137 |
||
138 |
call insert(cg_state, cg_coordinate, "Coordinate") |
|
139 |
call insert(cg_state, cg_mesh, "CoordinateMesh") |
|
140 |
call deallocate(cg_coordinate) |
|
141 |
||
278
by maddison
Adding Buoyancy diagnostic field, and adding serial support to project_to_continuous_parallel |
142 |
if(isparallel()) then |
143 |
call vtk_write_state(trim(vtuname) //"_continuous.pvtu", state = (/cg_state/)) |
|
144 |
else
|
|
145 |
call vtk_write_state(trim(vtuname) //"_continuous.vtu", state = (/cg_state/)) |
|
146 |
end if
|
|
1
by hhiester
deleting initialisation as none of tools are used any longer. |
147 |
call deallocate(cg_state) |
148 |
||
149 |
call print_references(0) |
|
150 |
||
151 |
contains
|
|
152 |
||
153 |
subroutine assemble_gp_rhs_ele(ele, mesh, positions, fields, rhs) |
|
154 |
integer, intent(in) :: ele |
|
155 |
type(mesh_type), intent(in) :: mesh |
|
156 |
type(vector_field), intent(in) :: positions |
|
157 |
type(scalar_field), dimension(:), intent(in) :: fields |
|
158 |
type(scalar_field), dimension(size(fields)), intent(inout) :: rhs |
|
159 |
||
160 |
integer :: i |
|
161 |
integer, dimension(:), pointer :: element_nodes |
|
162 |
real, dimension(ele_ngi(mesh, ele)) :: detwei |
|
163 |
type(element_type), pointer :: shape |
|
164 |
|
|
165 |
call transform_to_physical(positions, ele, detwei = detwei) |
|
166 |
||
167 |
shape => ele_shape(mesh, ele) |
|
168 |
element_nodes => ele_nodes(mesh, ele) |
|
169 |
||
170 |
do i = 1, size(fields) |
|
171 |
call addto(rhs(i), element_nodes, shape_rhs(shape, detwei * ele_val_at_quad(fields(i), ele))) |
|
172 |
end do
|
|
173 |
|
|
174 |
end subroutine assemble_gp_rhs_ele |
|
175 |
||
176 |
end subroutine project_to_continuous_parallel |