From 854cb6571e100b4259ca70861a226a0d8a14c2c1 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@fe.uni-lj.si>
Date: Mon, 15 Feb 2016 14:22:04 +0000
Subject: [PATCH] First attempt to add additional info to the vtu files as formatted xml. Pegs are still missing, however the vesicle is done

---
 src/Makefile.am |    2 
 src/snapshot.c  |   67 ++++++++++++++++++++++
 src/io.c        |    5 +
 src/tape        |    2 
 src/snapshot.o  |    0 
 src/energy.c    |    4 
 aclocal.m4      |   65 +--------------------
 src/snapshot.h  |   11 +++
 8 files changed, 91 insertions(+), 65 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 7657505..da47901 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -180,61 +180,6 @@
 fi[]dnl
 ])# PKG_CHECK_MODULES
 
-
-# PKG_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable pkgconfigdir as the location where a module
-# should install pkg-config .pc files. By default the directory is
-# $libdir/pkgconfig, but the default can be changed by passing
-# DIRECTORY. The user can override through the --with-pkgconfigdir
-# parameter.
-AC_DEFUN([PKG_INSTALLDIR],
-[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
-m4_pushdef([pkg_description],
-    [pkg-config installation directory @<:@]pkg_default[@:>@])
-AC_ARG_WITH([pkgconfigdir],
-    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
-    [with_pkgconfigdir=]pkg_default)
-AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
-m4_popdef([pkg_default])
-m4_popdef([pkg_description])
-]) dnl PKG_INSTALLDIR
-
-
-# PKG_NOARCH_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable noarch_pkgconfigdir as the location where a
-# module should install arch-independent pkg-config .pc files. By
-# default the directory is $datadir/pkgconfig, but the default can be
-# changed by passing DIRECTORY. The user can override through the
-# --with-noarch-pkgconfigdir parameter.
-AC_DEFUN([PKG_NOARCH_INSTALLDIR],
-[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
-m4_pushdef([pkg_description],
-    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
-AC_ARG_WITH([noarch-pkgconfigdir],
-    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
-    [with_noarch_pkgconfigdir=]pkg_default)
-AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
-m4_popdef([pkg_default])
-m4_popdef([pkg_description])
-]) dnl PKG_NOARCH_INSTALLDIR
-
-
-# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
-# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# -------------------------------------------
-# Retrieves the value of the pkg-config variable for the given module.
-AC_DEFUN([PKG_CHECK_VAR],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
-
-_PKG_CONFIG([$1], [variable="][$3]["], [$2])
-AS_VAR_COPY([$1], [pkg_cv_][$1])
-
-AS_VAR_IF([$1], [""], [$5], [$4])dnl
-])# PKG_CHECK_VAR
-
 # Copyright (C) 2002-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -318,9 +263,10 @@
 # configured tree to be moved without reconfiguration.
 
 AC_DEFUN([AM_AUX_DIR_EXPAND],
-[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-# Expand $ac_aux_dir to an absolute path.
-am_aux_dir=`cd "$ac_aux_dir" && pwd`
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
 ])
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
@@ -787,8 +733,7 @@
 END
     AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
   fi
-fi
-])
+fi])
 
 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
diff --git a/src/Makefile.am b/src/Makefile.am
index 5091e90..120a518 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,5 @@
 bin_PROGRAMS = trisurf
-trisurf_SOURCES = general.c vertex.c bond.c triangle.c cell.c vesicle.c initial_distribution.c io.c dumpstate.c frame.c energy.c timestep.c vertexmove.c bondflip.c main.c poly.c stats.c sh.c shcomplex.c constvol.c
+trisurf_SOURCES = general.c vertex.c bond.c triangle.c cell.c vesicle.c initial_distribution.c io.c dumpstate.c frame.c energy.c timestep.c vertexmove.c bondflip.c main.c poly.c stats.c sh.c shcomplex.c constvol.c snapshot.c
 AM_CFLAGS = -Wall -Werror
 AM_CPPFLAGS = ${libxml2_CFLAGS}
 trisurf_LDADD = ${libcurl_LIBS} ${libxml2_LIBS}
diff --git a/src/energy.c b/src/energy.c
index 695247c..3173f67 100644
--- a/src/energy.c
+++ b/src/energy.c
@@ -48,7 +48,7 @@
  *  Main function that calculates energy of the vertex \f$i\f$. Nearest neighbors (NN) must be ordered in counterclockwise direction for this function to work.
  *  Firstly NNs that form two neighboring triangles are found (\f$j_m\f$, \f$j_p\f$ and common \f$j\f$). Later, the scalar product of vectors \f$x_1=(\mathbf{i}-\mathbf{j_p})\cdot (\mathbf{i}-\mathbf{j_p})(\mathbf{i}-\mathbf{j_p})\f$, \f$x_2=(\mathbf{j}-\mathbf{j_p})\cdot  (\mathbf{j}-\mathbf{j_p})\f$  and \f$x_3=(\mathbf{j}-\mathbf{j_p})\cdot (\mathbf{i}-\mathbf{j_p})\f$  are calculated. From these three vectors the \f$c_{tp}=\frac{1}{\tan(\varphi_p)}\f$ is calculated, where \f$\varphi_p\f$ is the inner angle at vertex \f$j_p\f$. The procedure is repeated for \f$j_m\f$ instead of \f$j_p\f$ resulting in \f$c_{tn}\f$.
  *  
- \f{tikzpicture}{
+\begin{tikzpicture}{
 \coordinate[label=below:$i$] (i) at (2,0);
 \coordinate[label=left:$j_m$] (jm) at (0,3.7);
 \coordinate[label=above:$j$] (j) at (2.5,6.4);
@@ -74,7 +74,7 @@
 \draw [fill=white] (jp) circle (0.1);
 \draw [fill=white] (jm) circle (0.1);
 %\node[draw,circle,fill=white] at (i) {};
-\f}
+\end{tikzpicture}
 
  * The curvature is then calculated as \f$\mathbf{h}=\frac{1}{2}\Sigma_{k=0}^{\mathrm{neigh\_no}} c_{tp}^{(k)}+c_{tm}^{(k)} (\mathbf{j_k}-\mathbf{i})\f$, where \f$c_{tp}^{(k)}+c_{tm}^k=2\sigma^{(k)}\f$ (length in dual lattice?) and the previous equation can be written as \f$\mathbf{h}=\Sigma_{k=0}^{\mathrm{neigh\_no}}\sigma^{(k)}\cdot(\mathbf{j}-\mathbf{i})\f$ (See Kroll, p. 384, eq 70).
  *
diff --git a/src/io.c b/src/io.c
index f913762..e7461d6 100644
--- a/src/io.c
+++ b/src/io.c
@@ -15,6 +15,7 @@
 #include <sys/types.h>
 #include <dirent.h>
 #include <errno.h>
+#include <snapshot.h>
 /** DUMP STATE TO DISK DRIVE **/
 
 ts_bool dump_state(ts_vesicle *vesicle, ts_uint iteration){
@@ -824,7 +825,9 @@
 		}
 	}
 
-	fprintf(fh, "<?xml version=\"1.0\"?>\n<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" compressor=\"vtkZLibDataCompressor\">\n <UnstructuredGrid>\n");
+	fprintf(fh, "<?xml version=\"1.0\"?>\n<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" compressor=\"vtkZLibDataCompressor\">\n");
+	xml_trisurf_data(fh,vesicle);
+	fprintf(fh, " <UnstructuredGrid>\n");
     fprintf(fh, "<Piece NumberOfPoints=\"%u\" NumberOfCells=\"%u\">\n",vlist->n+monono*polyno+fonono*filno, blist->n+monono*polyno+filno*(fonono-1));
     fprintf(fh,"<PointData Scalars=\"scalars\">\n<DataArray type=\"Int64\" Name=\"scalars\" format=\"ascii\">");
    	for(i=0;i<vlist->n;i++){
diff --git a/src/snapshot.c b/src/snapshot.c
new file mode 100644
index 0000000..c845e06
--- /dev/null
+++ b/src/snapshot.c
@@ -0,0 +1,67 @@
+#include<stdio.h>
+#include<general.h>
+#include<snapshot.h>
+ts_bool xml_trisurf_data(FILE *fh, ts_vesicle *vesicle){
+	xml_trisurf_header(fh, vesicle);
+	xml_trisurf_tria(fh,vesicle->tlist);
+	xml_trisurf_tria_neigh(fh,vesicle->tlist);
+	xml_trisurf_vtx_neigh(fh,vesicle->vlist);
+	xml_trisurf_vtx_tristar(fh,vesicle->vlist);
+	xml_trisurf_footer(fh);
+	return TS_SUCCESS;
+}
+
+ts_bool xml_trisurf_header(FILE *fh, ts_vesicle *vesicle){
+	fprintf(fh, "<trisurf nvtx=\"%u\" npoly=\"%u\" nfono=\"%u\">\n", vesicle->vlist->n, vesicle->poly_list->n, vesicle->poly_list->poly[0]->vlist->n);
+	return TS_SUCCESS;
+}
+
+ts_bool xml_trisurf_footer(FILE *fh){
+	fprintf(fh, "</trisurf>\n");
+	return TS_SUCCESS;
+}
+
+ts_bool xml_trisurf_tria(FILE *fh, ts_triangle_list *tlist){
+	ts_uint i;
+	fprintf(fh,"<tria>\n");
+	for(i=0; i<tlist->n;i++){
+		fprintf(fh,"%u %u %u\n",tlist->tria[i]->vertex[0]->idx, tlist->tria[i]->vertex[1]->idx, tlist->tria[i]->vertex[2]->idx);
+	}
+	fprintf(fh,"</tria>\n");
+	return TS_SUCCESS;
+}
+
+ts_bool xml_trisurf_tria_neigh(FILE *fh, ts_triangle_list *tlist){
+	ts_uint i;
+	fprintf(fh,"<trianeigh>\n");
+	for(i=0; i<tlist->n;i++){
+		fprintf(fh,"%u %u %u\n",tlist->tria[i]->neigh[0]->idx, tlist->tria[i]->neigh[1]->idx, tlist->tria[i]->neigh[2]->idx);
+	}
+	fprintf(fh,"</trianeigh>\n");
+	return TS_SUCCESS;
+}
+
+ts_bool xml_trisurf_vtx_neigh(FILE *fh, ts_vertex_list *vlist){
+	ts_uint i,j;
+	for(i=0;i<vlist->n;i++){
+		fprintf(fh,"<vtxn idx=\"%u\">",vlist->vtx[i]->idx);
+		for(j=0;j<vlist->vtx[i]->neigh_no;j++){
+			fprintf(fh,"%u ",vlist->vtx[i]->neigh[j]->idx);
+		}
+		fprintf(fh, "</vtxn>\n");
+	}
+	return TS_SUCCESS;
+}
+
+ts_bool xml_trisurf_vtx_tristar(FILE *fh, ts_vertex_list *vlist){
+	ts_uint i,j;
+	for(i=0;i<vlist->n;i++){
+		fprintf(fh,"<tristar idx=\"%u\">",vlist->vtx[i]->idx);
+		for(j=0;j<vlist->vtx[i]->tristar_no;j++){
+			fprintf(fh,"%u ",vlist->vtx[i]->tristar[j]->idx);
+		}
+		fprintf(fh, "</tristar>\n");
+	}
+	return TS_SUCCESS;
+}
+
diff --git a/src/snapshot.h b/src/snapshot.h
new file mode 100644
index 0000000..0d1511d
--- /dev/null
+++ b/src/snapshot.h
@@ -0,0 +1,11 @@
+#ifndef _H_SNAPSHOT
+#define _H_SNAPSHOT
+
+ts_bool xml_trisurf_data(FILE *fh, ts_vesicle *vesicle);
+ts_bool xml_trisurf_header(FILE *fh, ts_vesicle *vesicle);
+ts_bool xml_trisurf_footer(FILE *fh);
+ts_bool xml_trisurf_tria(FILE *fh, ts_triangle_list *tlist);
+ts_bool xml_trisurf_tria_neigh(FILE *fh, ts_triangle_list *tlist);
+ts_bool xml_trisurf_vtx_neigh(FILE *fh, ts_vertex_list *vlist);
+ts_bool xml_trisurf_vtx_tristar(FILE *fh, ts_vertex_list *vlist);
+#endif
diff --git a/src/snapshot.o b/src/snapshot.o
new file mode 100644
index 0000000..5dbde73
--- /dev/null
+++ b/src/snapshot.o
Binary files differ
diff --git a/src/tape b/src/tape
index 9c7c574..a604c91 100644
--- a/src/tape
+++ b/src/tape
@@ -25,7 +25,7 @@
 
 ####### Polymer (brush) definitions ###########
 # npoly is a number of polymers attached to npoly distinct vertices on vesicle
-npoly=0
+npoly=10
 # nmono is a number of monomers in each polymer
 nmono=10
 # Spring constant between monomers of the polymer

--
Gitblit v1.9.3