Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ endif
ifneq (@HAVE_PETSC33@,yes)
EXCLUDE_TAGS := $(EXCLUDE_TAGS) -e petsc33
endif
ifneq (@HAVE_LIBGMSH@,yes)
EXCLUDE_TAGS := $(EXCLUDE_TAGS) -e libgmsh
endif

.SUFFIXES: .f90 .F90 .c .cpp .o .a

Expand Down
130 changes: 116 additions & 14 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ INSTALL_SCRIPT
INSTALL_PROGRAM
UNROLL_LOOPS
OPENMP_CXXFLAGS
HAVE_LIBGMSH
LAPACK_LIBS
BLAS_LIBS
HAVE_CGAL
Expand Down Expand Up @@ -734,7 +735,6 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -850,7 +850,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
Expand Down Expand Up @@ -1103,15 +1102,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;

-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;

-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
Expand Down Expand Up @@ -1249,7 +1239,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
Expand Down Expand Up @@ -1402,7 +1392,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
Expand Down Expand Up @@ -9928,6 +9917,119 @@ if test "$have_udunits" = "yes"; then
#define HAVE_LIBUDUNITS 1
EOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Checking for libGmsh support" >&5
$as_echo_n "checking Checking for libGmsh support... " >&6; }
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

LIBS_bck="$LIBS"
LIBS="-lGmsh"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

#include <gmsh/Gmsh.h>

#ifdef F77_DUMMY_MAIN

# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }

#endif
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{

GmshInitialize ();

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LIBS="$LIBS $LIBS_bck"
$as_echo "#define HAVE_LIBGMSH 1" >>confdefs.h

HAVE_LIBGMSH="yes"

else

LIBS="-lgmsh"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

#include <gmsh/Gmsh.h>
#ifdef F77_DUMMY_MAIN

# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }

#endif
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{

GmshInitialize ();

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LIBS="$LIBS $LIBS_bck"
$as_echo "#define HAVE_LIBGMSH 1" >>confdefs.h

HAVE_LIBGMSH="yes"

else

HAVE_LIBGMSH="no"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
LIBS="$LIBS_bck"

fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext

fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu


# Check whether --enable-openmp was given.
if test "${enable_openmp+set}" = set; then :
Expand Down Expand Up @@ -13877,7 +13979,7 @@ fi

#####
#
LIBS="$LIBS -L./lib"
LIB="$LIBS -L./lib"

##############################################################
# Stream I/O
Expand Down
33 changes: 32 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,37 @@ if test "$have_udunits" = "yes"; then
#define HAVE_LIBUDUNITS 1
EOF
fi
AC_MSG_CHECKING([Checking for libGmsh support])
AC_LANG_PUSH([C++])
LIBS_bck="$LIBS"
LIBS="-lGmsh"
AC_TRY_LINK([
#include <gmsh/Gmsh.h>
],[
GmshInitialize ();
],[
AC_MSG_RESULT([yes])
LIBS="$LIBS $LIBS_bck"
AC_DEFINE(HAVE_LIBGMSH, [1])
HAVE_LIBGMSH="yes"
],[
LIBS="-lgmsh"
AC_TRY_LINK([
#include <gmsh/Gmsh.h>],[
GmshInitialize ();
],[
AC_MSG_RESULT([yes])
LIBS="$LIBS $LIBS_bck"
AC_DEFINE(HAVE_LIBGMSH, [1])
HAVE_LIBGMSH="yes"
],[
HAVE_LIBGMSH="no"
AC_MSG_RESULT([no])
LIBS="$LIBS_bck"
])
])
AC_SUBST(HAVE_LIBGMSH)
AC_LANG_POP([C++])

AC_ARG_ENABLE(openmp,
[AC_HELP_STRING([--enable-openmp],
Expand Down Expand Up @@ -1067,7 +1098,7 @@ fi

#####
#
LIBS="$LIBS -L./lib"
LIB="$LIBS -L./lib"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong


##############################################################
# Stream I/O
Expand Down
23 changes: 22 additions & 1 deletion femtools/Field_Options.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module field_options
& extract_pressure_mesh, extract_velocity_mesh, &
& postprocess_periodic_mesh, get_diagnostic_coordinate_field, &
& get_nodal_coordinate_field, extract_prognostic_pressure, &
& extract_prognostic_velocity
& extract_prognostic_velocity, get_surface_ids

integer, parameter, public :: FIELD_EQUATION_UNKNOWN = 0, &
FIELD_EQUATION_ADVECTIONDIFFUSION = 1, &
Expand Down Expand Up @@ -1337,4 +1337,25 @@ function extract_prognostic_velocity(state, stat) result(vfield)

end function extract_prognostic_velocity

subroutine get_surface_ids(bc_path, mesh, surface_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a one line comment saying exactly what this routine does (or more if required).

character(len=*), intent(in) :: bc_path
type(mesh_type) :: mesh
integer, dimension(:), allocatable, intent(out) :: surface_ids
integer shape_option(2)
character(len = OPTION_PATH_LEN) :: surface_names
character(len = FIELD_NAME_LEN), dimension(:), allocatable :: name_list

if (have_option(bc_path//"/surface_ids")) then
shape_option=option_shape(bc_path//"/surface_ids")
allocate(surface_ids(1:shape_option(1)))
call get_option(bc_path//"/surface_ids", surface_ids)
else if (have_option(bc_path//"/surface_names")) then
call get_option(bc_path//"/surface_names", surface_names)
call tokenize(trim(surface_names), name_list, ",")
allocate(surface_ids(size(name_list)))
call get_surface_ids_from_names(mesh, name_list, surface_ids)
end if

end subroutine get_surface_ids

end module field_options
9 changes: 9 additions & 0 deletions femtools/Fields_Allocates.F90
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ subroutine deallocate_mesh(mesh)
deallocate(mesh%element_halos)
end if

if (associated(mesh%surface_names)) then
deallocate(mesh%surface_names)
nullify(mesh%surface_names)
end if

call deallocate_faces(mesh)

if(associated(mesh%subdomain_mesh)) then
Expand Down Expand Up @@ -1097,6 +1102,10 @@ function make_mesh (model, shape, continuity, name) &
size(mesh%faces%surface_node_list), name='Surface'//trim(mesh%name))
#endif
end if
if (associated(model%surface_names)) then
allocate(mesh%surface_names(size(model%surface_names)))
mesh%surface_names(:) = model%surface_names(:)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedantic: spurious (:)

end if
call addref(mesh)

end function make_mesh
Expand Down
38 changes: 37 additions & 1 deletion femtools/Fields_Base.F90
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ module fields_base
extract_scalar_field_from_tensor_field, ele_curl_at_quad,&
eval_shape, ele_jacobian_at_quad, ele_div_at_quad_tensor,&
ele_2d_curl_at_quad, getsndgln, local_coords_matrix,&
local_coords_interpolation
local_coords_interpolation, set_surface_names, &
get_surface_ids_from_names

contains

Expand Down Expand Up @@ -4199,4 +4200,39 @@ subroutine write_minmax_tensor(tfield, field_expression)

end subroutine write_minmax_tensor

subroutine set_surface_names(mesh, names, ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: "docstring" please

type(mesh_type), intent(inout) :: mesh
character(len=*), intent(in) :: names(:)
integer, intent(in) :: ids(:)

integer :: i

allocate(mesh%surface_names(size(ids)))

do i=1, size(ids)
mesh%surface_names(i)%id = ids(i)
mesh%surface_names(i)%name = names(i)
end do
end subroutine set_surface_names

subroutine get_surface_ids_from_names(mesh, names, ids)
type(mesh_type), intent(in) :: mesh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

character(len=*), intent(in) :: names(:)
integer, intent(out) :: ids(:)

integer :: i, j

ids = -1

do i=1, size(ids)
do j=1, size(mesh%surface_names)
if (trim(mesh%surface_names(j)%name) == trim(names(i))) then
ids(i) = mesh%surface_names(j)%id
exit
end if
end do
end do

end subroutine get_surface_ids_from_names

end module fields_base
7 changes: 7 additions & 0 deletions femtools/Fields_Data_Types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ module fields_data_types
integer, public, parameter :: FIELD_TYPE_NORMAL=0, FIELD_TYPE_CONSTANT=1, FIELD_TYPE_PYTHON=2, &
FIELD_TYPE_DEFERRED=3

type surface_name
integer :: id
character (len=FIELD_NAME_LEN) :: name
end type surface_name

type adjacency_cache
type(csr_sparsity), pointer :: nnlist => null()
type(csr_sparsity), pointer :: nelist => null()
Expand Down Expand Up @@ -89,6 +94,8 @@ module fields_data_types
!! A list of ids marking different parts of the mesh
!! so that initial conditions can be associated with it.
integer, dimension(:), pointer :: region_ids=>null()
!! list mapping surface names to ids
type(surface_name), dimension(:), pointer :: surface_names=>null()
!! Halo information for parallel simulations.
type(halo_type), dimension(:), pointer :: halos=>null()
type(halo_type), dimension(:), pointer :: element_halos=>null()
Expand Down
Loading