diff --git a/manual/manual.pdf b/manual/manual.pdf index ba7b45a1..ba0286cf 100644 Binary files a/manual/manual.pdf and b/manual/manual.pdf differ diff --git a/manual/src/Reference/complex.tex b/manual/src/Reference/complex.tex new file mode 100644 index 00000000..cd00aefa --- /dev/null +++ b/manual/src/Reference/complex.tex @@ -0,0 +1,50 @@ +\hypertarget{complex}{% +\section{Complex}\label{complex}} + +Morpho provides complex numbers. The keyword \texttt{im} is used to +denote the imaginary part of a complex number: + +\begin{lstlisting} +var a=1+5im +print a*a +\end{lstlisting} + +Print values on the unit circle in the complex plane: + +\begin{lstlisting} +import constants +for (phi in 0..Pi:Pi/5) print exp(im*phi) +\end{lstlisting} + +Get the real and imaginary parts of a complex number: + +\begin{lstlisting} +print real(a) +print imag(a) +\end{lstlisting} + +or alternatively: + +\begin{lstlisting} +print a.real() +print a.imag() +\end{lstlisting} + +\hypertarget{angle}{% +\section{Angle}\label{angle}} + +Returns the angle \texttt{phi} associated with the polar representation +of a complex number \texttt{r*exp(im*phi)}: + +\begin{lstlisting} +print z.angle() +\end{lstlisting} + +\hypertarget{conj}{% +\section{Conj}\label{conj}} + +Returns the complex conjugate of a number: + +\begin{lstlisting} +print z.conj() +\end{lstlisting} diff --git a/manual/src/Reference/functionals.tex b/manual/src/Reference/functionals.tex index c68efb87..98045de4 100644 --- a/manual/src/Reference/functionals.tex +++ b/manual/src/Reference/functionals.tex @@ -166,6 +166,26 @@ \section{GaussCurvature}\label{gausscurvature}} The \texttt{GaussCurvature} computes the integrated gaussian curvature over a surface. +Note that for surfaces with a boundary, the integrand is correct only +for the interior points. To compute the geodesic curvature of the +boundary in that case, you can set the optional flag \texttt{geodesic} +to \texttt{true} and compute the total on the boundary selection. Here +is an example for a 2D disk mesh. + +\begin{lstlisting} +var mesh = Mesh("disk.mesh") +mesh.addgrade(1) + +var whole = Selection(mesh, fn(x,y,z) true) +var bnd = Selection(mesh, boundary=true) +var interior = whole.difference(bnd) + +var gauss = GaussCurvature() +print gauss.total(mesh, selection=interior) // expect: 0 +gauss.geodesic = true +print gauss.total(mesh, selection=bnd) // expect: 2*Pi +\end{lstlisting} + \hypertarget{gradsq}{% \section{GradSq}\label{gradsq}} @@ -274,27 +294,35 @@ \section{AreaIntegral}\label{areaintegral}} integrand function in the order you supply them to \texttt{AreaIntegrand}. -\hypertarget{floryhuggins}{% -\section{FloryHuggins}\label{floryhuggins}} +\hypertarget{hydrogel}{% +\section{Hydrogel}\label{hydrogel}} -The \texttt{FloryHuggins} functional computes the Flory-Huggins mixing -energy over an element: +The \texttt{Hydrogel} functional computes the Flory-Rehner energy over +an element: \begin{lstlisting} -a*phi*log(phi) + b*(1-phi)+log(1-phi) + c*phi*(1-phi) +(a*phi*log(phi) + b*(1-phi)+log(1-phi) + c*phi*(1-phi))*V + +d*(log(phiref/phi)/3 - (phiref/phi)^(2/3) + 1)*V0 \end{lstlisting} -where a, b and c are parameters you can supply. The value of phi is -calculated from a reference mesh that you provide on initializing the -Functional: +The first three terms come from the Flory-Huggins mixing energy, whereas +the fourth term proportional to d comes from the Flory-Rehner elastic +energy. + +The value of phi is calculated from a reference mesh that you provide on +initializing the Functional: \begin{lstlisting} -var lfh = FloryHuggins(mref) +var lfh = Hydrogel(mref) \end{lstlisting} -Manually set the coefficients and grade to operate on: +Here, a, b, c, d and phiref are parameters you can supply (they are +\texttt{nil} by default), V is the current volume and V0 is the +reference volume of a given element. You also need to supply the initial +value of phi, labeled as phi0, which is assumed to be the same for all +the elements. Manually set the coefficients and grade to operate on: \begin{lstlisting} -lfh.a = 1; lfh.b = 1; lfh.c = 1; -lfh.grade = 2 +lfh.a = 1; lfh.b = 1; lfh.c = 1; lfh.d = 1; +lfh.grade = 2, lfh.phi0 = 0.5, lfh.phiref = 0.1 \end{lstlisting} diff --git a/manual/src/Reference/meshslice.tex b/manual/src/Reference/meshslice.tex new file mode 100644 index 00000000..61189743 --- /dev/null +++ b/manual/src/Reference/meshslice.tex @@ -0,0 +1,65 @@ +\hypertarget{meshslice}{% +\section{Meshslice}\label{meshslice}} + +The \texttt{meshslice} module is used to slice a \texttt{Mesh} object +along a given plane, yielding a new \texttt{Mesh} object of lower +dimensionality. You can also use \texttt{meshslice} to project +\texttt{Field} objects onto the new mesh. + +To use the module, begin by importing it: + +\begin{lstlisting} +import meshslice +\end{lstlisting} + +Then construct a \texttt{MeshSlicer} object, passing the mesh you want +to slice in the constructor: + +\begin{lstlisting} +var slice = MeshSlicer(mesh) +\end{lstlisting} + +You then perform a slice by calling the \texttt{slice} method, passing +the plane you want to slice through. This method returns a new +\texttt{Mesh} object comprising the slice. A plane is defined by a point +that lies on the plane \texttt{pt} and a direction normal to the plan +\texttt{dirn}: + +\begin{lstlisting} +var slc = slice.slice(pt, dirn) +\end{lstlisting} + +Having performed a slice, you can then project any associated +\texttt{Field} objects onto the sliced mesh by calling the +\texttt{slicefield} method: + +\begin{lstlisting} +var phi = Field(mesh, fn (x,y,z) x+y+z) +var sphi = slice.slicefield(phi) +\end{lstlisting} + +The new field returned by \texttt{slicefield} lives on the sliced mesh. +You can slice any number of fields. + +You can perform multiple slices with the same \texttt{MeshSlicer} simply +by calling \texttt{slice} again with a different plane. + +\hypertarget{slcempty}{% +\section{SlcEmpty}\label{slcempty}} + +This error occurs if you try to use \texttt{slicefield} on a +\texttt{MeshSlicer} without having performed a slice. For example: + +\begin{lstlisting} +var slice = MeshSlicer(mesh) +slice.slicefield(phi) // Throws SlcEmpty +slice.slice([0,0,0],[1,0,0]) +\end{lstlisting} + +To fix, call \texttt{slice} before \texttt{slicefield}: + +\begin{lstlisting} +var slice = MeshSlicer(mesh) +slice.slice([0,0,0],[1,0,0]) +slice.slicefield(phi) // Now slices correctly +\end{lstlisting} diff --git a/manual/src/Reference/meshtools.tex b/manual/src/Reference/meshtools.tex index c6987e78..4eac8f48 100644 --- a/manual/src/Reference/meshtools.tex +++ b/manual/src/Reference/meshtools.tex @@ -121,8 +121,8 @@ \section{MeshBuilder}\label{meshbuilder}} \end{lstlisting} You can then add vertices, edges, etc. one by one using -\texttt{addvertex}, \texttt{addedge} and \texttt{addtriangle}. Each of -these returns an element id: +\texttt{addvertex}, \texttt{addedge}, \texttt{addface} and +\texttt{addelement}. Each of these returns an element id: \begin{lstlisting} var id1=build.addvertex(Matrix([0,0,0])) @@ -137,6 +137,47 @@ \section{MeshBuilder}\label{meshbuilder}} var m = build.build() \end{lstlisting} +You can specify the dimension of the \texttt{Mesh} explicitly when +initializing the \texttt{MeshBuilder}: + +\begin{lstlisting} +var mb = MeshBuilder(dimension=2) +\end{lstlisting} + +or implicitly when adding the first vertex: + +\begin{lstlisting} +var mb = MeshBuilder() +mb.addvertex([0,1]) // A 2D mesh +\end{lstlisting} + +\hypertarget{mshblddimincnstnt}{% +\section{MshBldDimIncnstnt}\label{mshblddimincnstnt}} + +This error is produced if you try to add a vertex that is inconsistent +with the mesh dimension, e.g.~ + +\begin{lstlisting} +var mb = MeshBuilder(dimension=2) +mb.addvertex([1,0,0]) // Throws an error! +\end{lstlisting} + +To fix this ensure all vertices have the correct dimension. + +\hypertarget{mshblddimunknwn}{% +\section{MshBldDimUnknwn}\label{mshblddimunknwn}} + +This error is produced if you try to add an element to a +\texttt{MeshBuilder} object but haven't yet specified the dimension (at +initialization) or by adding a vertex. + +\begin{lstlisting} +var mb = MeshBuiler() +mb.addedge([0,1]) // No vertices have been added +\end{lstlisting} + +To fix this add the vertices first. + \hypertarget{meshrefiner}{% \section{MeshRefiner}\label{meshrefiner}} diff --git a/manual/src/Reference/plot.tex b/manual/src/Reference/plot.tex index 2284a643..c2387f2d 100644 --- a/manual/src/Reference/plot.tex +++ b/manual/src/Reference/plot.tex @@ -94,6 +94,6 @@ \section{Plotfield}\label{plotfield}} \texttt{default} - Color \texttt{Mesh} elements by the corresponding value of the \texttt{Field}. \item - \texttt{interpolated} - Interpolate \texttt{Field} quantities onto + \texttt{interpolate} - Interpolate \texttt{Field} quantities onto higher elements. \end{itemize} diff --git a/manual/src/Tutorial/0ExampleMesh/meshgrade0.png b/manual/src/Tutorial/0ExampleMesh/meshgrade0.png index bc8e1a71..e7a6742b 100644 Binary files a/manual/src/Tutorial/0ExampleMesh/meshgrade0.png and b/manual/src/Tutorial/0ExampleMesh/meshgrade0.png differ diff --git a/manual/src/Tutorial/0ExampleMesh/meshgrade1.png b/manual/src/Tutorial/0ExampleMesh/meshgrade1.png index 7d334b82..1b89db64 100644 Binary files a/manual/src/Tutorial/0ExampleMesh/meshgrade1.png and b/manual/src/Tutorial/0ExampleMesh/meshgrade1.png differ diff --git a/manual/src/Tutorial/0ExampleMesh/meshgrade2.png b/manual/src/Tutorial/0ExampleMesh/meshgrade2.png index 97df6c08..610a5d4a 100644 Binary files a/manual/src/Tutorial/0ExampleMesh/meshgrade2.png and b/manual/src/Tutorial/0ExampleMesh/meshgrade2.png differ diff --git a/manual/src/Tutorial/1Mesh/mesh.png b/manual/src/Tutorial/1Mesh/mesh.png index 1b9e26bc..5cfd889a 100644 Binary files a/manual/src/Tutorial/1Mesh/mesh.png and b/manual/src/Tutorial/1Mesh/mesh.png differ diff --git a/manual/src/Tutorial/2Visualize/out.png b/manual/src/Tutorial/2Visualize/out.png index 6f80fe6a..24fafdbd 100644 Binary files a/manual/src/Tutorial/2Visualize/out.png and b/manual/src/Tutorial/2Visualize/out.png differ diff --git a/manual/src/Tutorial/2Visualize/selection.png b/manual/src/Tutorial/2Visualize/selection.png index fb0e9270..f8c82864 100644 Binary files a/manual/src/Tutorial/2Visualize/selection.png and b/manual/src/Tutorial/2Visualize/selection.png differ diff --git a/manual/src/Tutorial/3Refine/out1.png b/manual/src/Tutorial/3Refine/out1.png index 7deec51e..023b1f63 100644 Binary files a/manual/src/Tutorial/3Refine/out1.png and b/manual/src/Tutorial/3Refine/out1.png differ diff --git a/manual/src/Tutorial/3Refine/out2.png b/manual/src/Tutorial/3Refine/out2.png index 17e7c523..11afa2af 100644 Binary files a/manual/src/Tutorial/3Refine/out2.png and b/manual/src/Tutorial/3Refine/out2.png differ diff --git a/manual/src/Tutorial/3Refine/out3.png b/manual/src/Tutorial/3Refine/out3.png index caaf6feb..d06f3962 100644 Binary files a/manual/src/Tutorial/3Refine/out3.png and b/manual/src/Tutorial/3Refine/out3.png differ diff --git a/manual/src/manual.lyx b/manual/src/manual.lyx index f315058f..9b7fa13a 100644 --- a/manual/src/manual.lyx +++ b/manual/src/manual.lyx @@ -164,7 +164,7 @@ figs-within-sections \begin_inset Newline newline \end_inset -Version 0.5.2 +Version 0.5.3 \end_layout \begin_layout Standard @@ -4178,6 +4178,16 @@ filename "Reference/array.tex" \end_inset +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand input +filename "Reference/complex.tex" + +\end_inset + + \end_layout \begin_layout Standard diff --git a/morpho5/build.h b/morpho5/build.h index e6d61a42..21f13a70 100644 --- a/morpho5/build.h +++ b/morpho5/build.h @@ -4,6 +4,12 @@ * @brief Define constants that choose how Morpho is built */ +/* ********************************************************************** + * Version + * ********************************************************************** */ + +#define MORPHO_VERSIONSTRING "0.5.3" + /* ********************************************************************** * Paths and file system * ********************************************************************** */ diff --git a/morpho5/docs/index.rst b/morpho5/docs/index.rst index 2ed7acc6..59b9c4fa 100644 --- a/morpho5/docs/index.rst +++ b/morpho5/docs/index.rst @@ -59,6 +59,7 @@ Morpho optimize plot povray + vtk .. toctree:: :caption: Error messages diff --git a/morpho5/interface/cli.c b/morpho5/interface/cli.c index d79f5500..403cf992 100644 --- a/morpho5/interface/cli.c +++ b/morpho5/interface/cli.c @@ -208,11 +208,11 @@ void cli_help (lineditor *edit, char *query, error *err, bool avail) { void cli(clioptions opt) { #ifdef MORPHO_LONG_BANNER printf(BLU " ___ ___ \n" RESET); - printf(BLU "(" CYN " @ " GRY"\\Y/" CYN " @ " BLU ") " RESET " | morpho 0.5.2 | \U0001F44B Type 'help' or '?' for help\n"); + printf(BLU "(" CYN " @ " GRY"\\Y/" CYN " @ " BLU ") " RESET " | morpho " MORPHO_VERSIONSTRING " | \U0001F44B Type 'help' or '?' for help\n"); printf(BLU " \\" CYN"__" GRY"+|+" CYN"__" BLU"/ " RESET " | Documentation: https://morpho-lang.readthedocs.io/en/latest/ \n"); printf(BLU" {" CYN"_" BLU "/ \\" CYN "_" BLU"} " RESET " | Code: https://github.com/Morpho-lang/morpho \n\n"); #else - printf("\U0001F98B morpho 0.5.2 | \U0001F44B Type 'help' or '?' for help\n"); + printf("\U0001F98B morpho " MORPHO_VERSIONSTRING " | \U0001F44B Type 'help' or '?' for help\n"); #endif // Original ASCII art source - https://www.asciiart.eu/animals/insects/butterflies cli_file=NULL;