Skip to content

Commit c0f663c

Browse files
committed
v1.0
1 parent 8f10441 commit c0f663c

File tree

18 files changed

+1329
-1053
lines changed

18 files changed

+1329
-1053
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Getting started with APECSS is easy. After downloading APECSS in the directory `
3434
- ````APECSS_DIR```` to the directory in which APECSS is located. Using bash, for instance, simply execute the command ````export APECSS_DIR=<path to APECSS>```` or, even better, add this command to your bash profile.
3535
- ````USRLIB_DIR```` to the directory in which libm.a or libm.dylib (the standard _math_ library) is located. This may, for instance, be ````/usr/lib64/```` on Linux systems or ````/usr/lib/```` on MacOS systems.
3636

37-
Now, navigate into the folder ````$APECSS_DIR/lib```` and execute ````./compile_lib.sh````. This shell script will compile the APECSS library using _cmake_ with the ````CMakeLists.txt```` file provided in this folder. By default, APECSS is compiled with double precision and in _Release_ mode, meaning all optimization flags are enabled. That's it, you've succesfully compiled APECSS!
37+
Now, navigate into the folder ````$APECSS_DIR/lib```` and execute ````./compile_lib.sh````. This shell script will compile the APECSS library using _cmake_ with the ````CMakeLists.txt```` file provided in this folder. By default, APECSS is compiled with double precision and in _Release_ mode, meaning all optimization flags are enabled. That's it, you've successfully compiled APECSS!
3838

3939
There are several ways in which you can use the APECSS library. You can either incorporate selected features of APECSS into your own software or you can program an interface to use APECSS as a standalone program. Some representative examples are given in the ````$APECSS_DIR/examples```` directory. Each directory contains the following:
4040
- A ````README.md```` file explaining the purpose and specificities of this/these example(s).
1.09 KB
Binary file not shown.

documentation/chapters/bubble.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ \section{The gas}
8686
& {\tt PolytropicExponent <float>} & Polytropic exponent $\Gamma_\text{g}$.\\
8787
& {\tt ReferencePressure <float>} & Reference pressure $p_\text{g,ref}$.\\
8888
& {\tt ReferenceDensity <float>} & Reference density $\rho_\text{g,ref}$.\\
89-
& {\tt HardcoreRadius <float>} & Hardcore radius $r_\text{hc}$.\\
9089
& {\tt CoVolume <float>} & Co-volume $b_\text{g}$.\\
9190
& {\tt TaitPressureConst <float>} & Pressure constant $B_\text{g}$.\\
92-
& {\tt MolecularWeight <float>} & Molecular weight $\mathcal{M}_{\text{g}}$ of the gas. \\
93-
& {\tt MolecularDiameter <float>} & Molecular kinematic diameter $\mathcal{D}_{\text{g}}$ of the gas. \\
91+
& {\tt MolecularWeight <float>} & Molecular weight $\mathcal{M}_{\text{g}}$ of the gas.\\
92+
& {\tt MolecularDiameter <float>} & Molecular kinematic diameter $\mathcal{D}_{\text{g}}$ of the gas.\\
93+
{\tt BUBBLE} & {\tt HardcoreRadius <float>} & Hardcore radius $r_\text{hc}$.\\
9494
\hline
9595
\end{tabular} \vspace{1em}
9696

documentation/chapters/using.tex

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -192,38 +192,70 @@ \subsection{Structures}
192192

193193
\subsection{Important functions}
194194

195-
Here we briefly outline how to use some of the key functions of APECSS.
196-
197195
Whenever using APECSS, at least one {\tt APECSS\_Bubble} structure has to be available and, if multiple bubbles are part of a simulation, each bubble has to be represented by a separate {\tt APECSS\_Bubble} structure. A single {\tt APECSS\_Bubble} structure is allocated and initialized as follows:
198-
\begin{lstlisting}[style=CStyle]
196+
\begin{lstlisting}[style=CStyle,numbers=none]
199197
struct APECSS_Bubble *Bubble = (struct APECSS_Bubble *) malloc(sizeof(struct APECSS_Bubble));
200198
apecss_bubble_initializestruct(Bubble);
201199
\end{lstlisting}\vspace{-0.75em}
202200
The function {\tt apecss\_bubble\_initializestruct()} ensures that all pointers (to arrays, other structures and functions) that are part of the {\tt APECSS\_Bubble} structure are initialized to {\tt NULL}. This is important because the processing of options and any checks for allocation depend on {\tt NULL} to indicate that a given pointer in not yet allocated or not in use.
203-
204-
Once a {\tt APECSS\_Bubble} structure is allocated and initialize, default values ought to be set, the {\tt *.apecss} options file is to be read and the chosen options have to be processed. In the standalone examples found in {\tt \$APECSS\_DIR/examples} this is done with the falling function calls:
205-
\begin{lstlisting}[style=CStyle]
206-
apecss_options_setdefault(Bubble);
207-
char OptionsDir[APECSS_STRINGLENGTH];
208-
sprintf(OptionsDir, "./run.apecss"); // Relative path to the options file.
209-
apecss_options_readfile(Bubble, OptionsDir);
210-
apecss_options_process(Bubble);
201+
Then, we wish to set default values for the bubble parameters and read the relevant options from the options file:
202+
\begin{lstlisting}[style=CStyle,numbers=none]
203+
apecss_bubble_setdefaultoptions(Bubble);
204+
apecss_bubble_readoptions(Bubble, OptionsDir);
205+
\end{lstlisting}\vspace{-0.75em}
206+
While setting default values is strongly advised, it is optional. The relative path to the options file may be set as
207+
\begin{lstlisting}[style=CStyle,numbers=none]
208+
char OptionsDir[APECSS_STRINGLENGTH];
209+
sprintf(OptionsDir, "./run.apecss"); // Relative path to the options file.
210+
\end{lstlisting}
211+
212+
In general, the properties of a gas ({\tt struct APECSS\_Gas}), a liquid ({\tt struct APECSS\_Liquid}) and a gas-liquid interface ({\tt struct APECSS\_Interface}), as well as the parameters for the ODE solver ({\tt struct APECSS\_NumericsODE}), have to be associated with a bubble, through the structure pointers {\tt *Gas}, {\tt *Liquid}, {\tt *Interface} and {\tt *NumericsODE} readily available in the {\tt APECSS\_Bubble} structure. In a single-bubble simulation this is obviously straightforward, we have one gas, one liquid and one interface that are associated with the bubble. In addition we have one set of solver parameters. In a multi-bubble simulation, however, we likely also have, for instance, only a single liquid (i.e.~all bubbles are situated in the same body of liquid), to which, in this case, all bubbles are associated to. Generally, the user is free in defining as many gases, liquids, interfaces and sets of solver parameters as deemed necessary, the only rule is that each bubble has to be associated with a gas, a liquid, an interface and a single set of solver parameters. Once these structures holding the fluid properties and the solver parameters are allocated, default values ought to be set, the user-defined options are read from file and the bubble(s) is/are successfully associated with its/their desired fluid properties and solver parameters. For a single-bubble simulation, this may look in a general form like:
213+
\begin{lstlisting}[style=CStyle,numbers=none]
214+
struct APECSS_Gas *Gas = (struct APECSS_Gas *) malloc(sizeof(struct APECSS_Gas));
215+
struct APECSS_Liquid *Liquid = (struct APECSS_Liquid *) malloc(sizeof(struct APECSS_Liquid));
216+
struct APECSS_Interface *Interface = (struct APECSS_Interface *) malloc(sizeof(struct APECSS_Interface));
217+
struct APECSS_NumericsODE *NumericsODE = (struct APECSS_NumericsODE *) malloc(sizeof(struct APECSS_NumericsODE));
218+
219+
apecss_gas_setdefaultoptions(Gas);
220+
apecss_liquid_setdefaultoptions(Liquid);
221+
apecss_interface_setdefaultoptions(Interface);
222+
apecss_odesolver_setdefaultoptions(NumericsODE);
223+
224+
apecss_gas_readoptions(Gas, OptionsDir);
225+
apecss_liquid_readoptions(Liquid, OptionsDir);
226+
apecss_interface_readoptions(Interface, OptionsDir);
227+
apecss_odesolver_readoptions(NumericsODE, OptionsDir);
228+
229+
Bubble->Gas = Gas;
230+
Bubble->Liquid = Liquid;
231+
Bubble->Interface = Interface;
232+
Bubble->NumericsODE = NumericsODE;
233+
\end{lstlisting}\vspace{-0.75em}
234+
Note that opening and reading the options file from disk is a relatively expensive (we are talking about a few microseconds). For some of the single-bubble examples in {\tt \$APECSS\_DIR/examples} reading the options file is the most expensive operation by some margin. Therefore, if performance is of the essence, it might be worth hard coding the options instead of reading the options file.
235+
236+
After reading the options file, the {\tt apecss\_*\_processoptions()} functions are called to process options and make the relevant modeling choices:
237+
\begin{lstlisting}[style=CStyle,numbers=none]
238+
apecss_gas_processoptions(Gas);
239+
apecss_liquid_processoptions(Liquid);
240+
apecss_interface_processoptions(Interface);
241+
apecss_odesolver_processoptions(NumericsODE);
242+
apecss_bubble_processoptions(Bubble);
211243
\end{lstlisting}\vspace{-0.75em}
212-
While setting default values is advised, for instance using the function {\tt apecss\_options\_setdefault()}, it is optional. Processing the given options correctly, however, is critical to the working of APECSS and the using the function {\tt apecss\_options\_process()} is strongly encouraged.
244+
Processing the given options correctly is critical to the working of APECSS.
213245

214-
Now that all options have been read and processed, the bubble has to be initialized based on the given options. This includes, for instance, computing the initial gas density and, if applicable hardcore radius or co-volume.
215-
\begin{lstlisting}[style=CStyle]
246+
Now that all options have been read and processed, the bubble has to be initialized based on the given options. This includes, for instance, computing the initial gas pressure inside the bubble (if it is not specified by the user) or, if applicable, the hardcore radius of the bubble.
247+
\begin{lstlisting}[style=CStyle,numbers=none]
216248
apecss_bubble_initialize(Bubble);
217-
\end{lstlisting}%\vspace{-0.75em}
249+
\end{lstlisting}
218250

219251
The heart of APECSS is, of course, the solver. The solver is split into three separate functions that (i) initialize the solver, (ii) run the solver and (iii) wrap up (i.e.~finalize) the solver:
220-
\begin{lstlisting}[style=CStyle]
252+
\begin{lstlisting}[style=CStyle,numbers=none]
221253
apecss_bubble_solver_initialize(Bubble);
222254
apecss_bubble_solver_run(tend, Bubble);
223255
apecss_bubble_solver_finalize(Bubble);
224256
\end{lstlisting}\vspace{-0.75em}
225257
The initialization of the solver with {\tt apecss\_bubble\_solver\_initialize()} makes sure all counters, the solution error variable and, if applicable, result variables are initialized correctly. The function {\tt apecss\_bubble\_solver\_run()} contains the time-stepping procedure that executes the solver until a specified end time {\tt tend}, given as the first argument of the function call. In the examples found in {\tt \$APECSS\_DIR/examples}, the function {\tt apecss\_bubble\_solver\_run()} is only called once with {\tt tend = Bubble->tEnd}, i.e.~the end of the simulation. However, the user is free to call the function {\tt apecss\_bubble\_solver\_run()} an \underline{arbitrary number of times}, with any meaningful end time. This facilitates coupling APECSS to other numerical software frameworks, where {\tt tend} then could for instance be the end of the next time-step of a fluid dynamics solver. As an example simply chopping the simulation up into five equal-sized parts would look like:
226-
\begin{lstlisting}[style=CStyle]
258+
\begin{lstlisting}[style=CStyle,numbers=none]
227259
apecss_bubble_solver_initialize(Bubble);
228260
apecss_bubble_solver_run(0.2 * tend, Bubble);
229261
apecss_bubble_solver_run(0.4 * tend, Bubble);

examples/gastemperature/run.apecss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ END
3737
ODESOLVER
3838
tolerance 1.0e-13
3939
maxtimestep 1.0e-6
40-
END
40+
END

examples/gastemperature/src/gastemperature_apecss.c

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,46 @@ int main(int argc, char **args)
7878
struct APECSS_Bubble *Bubble = (struct APECSS_Bubble *) malloc(sizeof(struct APECSS_Bubble));
7979
apecss_bubble_initializestruct(Bubble);
8080

81-
/* Allocate and set the default options for the fluids */
82-
Bubble->Gas = (struct APECSS_Gas *) malloc(sizeof(struct APECSS_Gas));
83-
apecss_gas_setdefaultoptions(Bubble->Gas);
84-
Bubble->Liquid = (struct APECSS_Liquid *) malloc(sizeof(struct APECSS_Liquid));
85-
apecss_liquid_setdefaultoptions(Bubble->Liquid);
86-
Bubble->Interface = (struct APECSS_Interface *) malloc(sizeof(struct APECSS_Interface));
87-
apecss_interface_setdefaultoptions(Bubble->Interface);
88-
89-
/* Set default options for the bubble and the fluids */
81+
/* Set default options and read the options for the bubble */
9082
apecss_bubble_setdefaultoptions(Bubble);
91-
92-
/* Read the options file */
93-
apecss_options_readfile(Bubble, OptionsDir);
83+
apecss_bubble_readoptions(Bubble, OptionsDir);
84+
85+
/* Allocate the structures for the fluid properties and ODE solver parameters */
86+
struct APECSS_Gas *Gas = (struct APECSS_Gas *) malloc(sizeof(struct APECSS_Gas));
87+
struct APECSS_Liquid *Liquid = (struct APECSS_Liquid *) malloc(sizeof(struct APECSS_Liquid));
88+
struct APECSS_Interface *Interface = (struct APECSS_Interface *) malloc(sizeof(struct APECSS_Interface));
89+
struct APECSS_NumericsODE *NumericsODE = (struct APECSS_NumericsODE *) malloc(sizeof(struct APECSS_NumericsODE));
90+
91+
/* Set the default options for the fluid properties and solver parameters */
92+
apecss_gas_setdefaultoptions(Gas);
93+
apecss_liquid_setdefaultoptions(Liquid);
94+
apecss_interface_setdefaultoptions(Interface);
95+
apecss_odesolver_setdefaultoptions(NumericsODE);
96+
97+
/* Read the options file for the fluid properties and solver parameters */
98+
apecss_gas_readoptions(Gas, OptionsDir);
99+
apecss_liquid_readoptions(Liquid, OptionsDir);
100+
apecss_interface_readoptions(Interface, OptionsDir);
101+
apecss_odesolver_readoptions(NumericsODE, OptionsDir);
102+
103+
/* Associate the bubble with the relevant fluid properties and solver parameters */
104+
Bubble->Gas = Gas;
105+
Bubble->Liquid = Liquid;
106+
Bubble->Interface = Interface;
107+
Bubble->NumericsODE = NumericsODE;
94108

95109
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
96110
// Set the case-dependent simulation parameters
97111
Bubble->tStart = 0.0;
98112
Bubble->tEnd = (APECSS_FLOAT) tEnd;
99113
Bubble->dt = APECSS_MIN(1.0e-7, Bubble->tEnd - Bubble->tStart); // Initial time-step
100-
Bubble->Excitation = (struct APECSS_Excitation *) malloc(sizeof(struct APECSS_Excitation));
101-
Bubble->Excitation->type = APECSS_EXCITATION_SIN;
102-
Bubble->Excitation->f = (APECSS_FLOAT) fa;
103-
Bubble->Excitation->dp = (APECSS_FLOAT) pa;
114+
115+
struct APECSS_Excitation *Excitation = (struct APECSS_Excitation *) malloc(sizeof(struct APECSS_Excitation));
116+
Excitation->type = APECSS_EXCITATION_SIN;
117+
Excitation->f = (APECSS_FLOAT) fa;
118+
Excitation->dp = (APECSS_FLOAT) pa;
119+
120+
Bubble->Excitation = Excitation;
104121

105122
// Set the parameters and functions for the gas energy model
106123
_cv_ = 720.0; // Isochoric heat capacity of the gas
@@ -132,9 +149,10 @@ int main(int argc, char **args)
132149
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
133150

134151
/* Process all options */
135-
apecss_gas_processoptions(Bubble->Gas);
136-
apecss_interface_processoptions(Bubble->Interface);
137-
apecss_liquid_processoptions(Bubble->Liquid);
152+
apecss_gas_processoptions(Gas);
153+
apecss_liquid_processoptions(Liquid);
154+
apecss_interface_processoptions(Interface);
155+
apecss_odesolver_processoptions(NumericsODE);
138156
apecss_bubble_processoptions(Bubble);
139157

140158
/* Initialize the bubble based on the selected options */
@@ -167,6 +185,13 @@ int main(int argc, char **args)
167185
/* Make sure all allocated memory is freed */
168186
apecss_bubble_freestruct(Bubble);
169187

188+
free(Bubble);
189+
free(Gas);
190+
free(Liquid);
191+
free(Interface);
192+
free(NumericsODE);
193+
free(Excitation);
194+
170195
return (0);
171196
}
172197

examples/rayleighcollapse/src/rayleighcollapse_apecss.c

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,33 @@ int main(int argc, char **args)
5858
struct APECSS_Bubble *Bubble = (struct APECSS_Bubble *) malloc(sizeof(struct APECSS_Bubble));
5959
apecss_bubble_initializestruct(Bubble);
6060

61-
/* Allocate and set the default options for the fluids */
62-
Bubble->Gas = (struct APECSS_Gas *) malloc(sizeof(struct APECSS_Gas));
63-
apecss_gas_setdefaultoptions(Bubble->Gas);
64-
Bubble->Liquid = (struct APECSS_Liquid *) malloc(sizeof(struct APECSS_Liquid));
65-
apecss_liquid_setdefaultoptions(Bubble->Liquid);
66-
Bubble->Interface = (struct APECSS_Interface *) malloc(sizeof(struct APECSS_Interface));
67-
apecss_interface_setdefaultoptions(Bubble->Interface);
68-
69-
/* Set default options for the bubble and the fluids */
61+
/* Set default options and read the options for the bubble */
7062
apecss_bubble_setdefaultoptions(Bubble);
71-
72-
/* Read the options file */
73-
apecss_options_readfile(Bubble, OptionsDir);
63+
apecss_bubble_readoptions(Bubble, OptionsDir);
64+
65+
/* Allocate the structures for the fluid properties and ODE solver parameters */
66+
struct APECSS_Gas *Gas = (struct APECSS_Gas *) malloc(sizeof(struct APECSS_Gas));
67+
struct APECSS_Liquid *Liquid = (struct APECSS_Liquid *) malloc(sizeof(struct APECSS_Liquid));
68+
struct APECSS_Interface *Interface = (struct APECSS_Interface *) malloc(sizeof(struct APECSS_Interface));
69+
struct APECSS_NumericsODE *NumericsODE = (struct APECSS_NumericsODE *) malloc(sizeof(struct APECSS_NumericsODE));
70+
71+
/* Set the default options for the fluid properties and solver parameters */
72+
apecss_gas_setdefaultoptions(Gas);
73+
apecss_liquid_setdefaultoptions(Liquid);
74+
apecss_interface_setdefaultoptions(Interface);
75+
apecss_odesolver_setdefaultoptions(NumericsODE);
76+
77+
/* Read the options file for the fluid properties and solver parameters */
78+
apecss_gas_readoptions(Gas, OptionsDir);
79+
apecss_liquid_readoptions(Liquid, OptionsDir);
80+
apecss_interface_readoptions(Interface, OptionsDir);
81+
apecss_odesolver_readoptions(NumericsODE, OptionsDir);
82+
83+
/* Associate the bubble with the relevant fluid properties and solver parameters */
84+
Bubble->Gas = Gas;
85+
Bubble->Liquid = Liquid;
86+
Bubble->Interface = Interface;
87+
Bubble->NumericsODE = NumericsODE;
7488

7589
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
7690
// Set the case-dependent simulation parameters
@@ -80,9 +94,10 @@ int main(int argc, char **args)
8094
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
8195

8296
/* Process all options */
83-
apecss_gas_processoptions(Bubble->Gas);
84-
apecss_interface_processoptions(Bubble->Interface);
85-
apecss_liquid_processoptions(Bubble->Liquid);
97+
apecss_gas_processoptions(Gas);
98+
apecss_liquid_processoptions(Liquid);
99+
apecss_interface_processoptions(Interface);
100+
apecss_odesolver_processoptions(NumericsODE);
86101
apecss_bubble_processoptions(Bubble);
87102

88103
/* Initialize the bubble based on the selected options */
@@ -105,5 +120,11 @@ int main(int argc, char **args)
105120
/* Make sure all allocated memory is freed */
106121
apecss_bubble_freestruct(Bubble);
107122

123+
free(Bubble);
124+
free(Gas);
125+
free(Liquid);
126+
free(Interface);
127+
free(NumericsODE);
128+
108129
return (0);
109130
}

examples/ultrasound/lipidcoated_emissions.apecss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ END
4646

4747
ODESOLVER
4848
Tolerance 1.0e-12
49-
END
49+
END

0 commit comments

Comments
 (0)