Skip to content

Commit ddafec0

Browse files
authored
Merge pull request #146 from mesnardo/fix-write-bodies
Fix output filenames of immersed bodies (and cleaning)
2 parents 6f5d0eb + 30ec3a0 commit ddafec0

File tree

93 files changed

+963
-590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+963
-590
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
---
44

5+
## Current development
6+
7+
---
8+
9+
### Added
10+
11+
* Allow to configure PetIBM against PETSc 3.12.x.
12+
13+
### Changed
14+
15+
* Default directory to output files generated by PetIBM is now the `output` folder in the current working directory. (User has the possibility to change the path of the output directory with the command-line option `-output <path of the folder>`.)
16+
* Use PETSc-3.12.2 to test PetIBM with Travis CI.
17+
* Copy `examples` folder into installation directory upon `make install`.
18+
19+
### Fixed
20+
21+
* Fix name of the file used to output the body coordinates; bug only affected simulations dealing with multiple immersed bodies with prescribed kinematics.
22+
23+
### Removed
24+
25+
* Dockerfile files and Singularity recipes. These files are now version-controlled in a separate GitHub repository: [`petibm-recipes`](https://github.com/barbagroup/petibm-recipes).
26+
27+
---
28+
529
## 0.4.2
630

731
---

Makefile.am

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ SUBDIRS = \
1010

1111
EXTRA_DIST = autogen.sh
1212

13-
EXAMPLES_DIR=$(top_builddir)/examples
14-
15-
copy-examples:
16-
@if test $(EXAMPLES_DIR) != "$(top_srcdir)/examples" ; then \
17-
echo "Copying examples folders into $(EXAMPLES_DIR)..." ; \
18-
mkdir -p $(EXAMPLES_DIR) ; \
19-
rsync -a $(top_srcdir)/examples/* $(EXAMPLES_DIR) ; \
13+
install-data-hook:
14+
@if test "$(prefix)/examples" != "$(top_srcdir)/examples" ; then \
15+
echo "Copying examples into $(prefix)..." ; \
16+
rsync -a $(top_srcdir)/examples $(prefix) ; \
17+
rm -rf $(prefix)/examples/api_examples ; \
2018
fi ;
21-
22-
.PHONY: copy-examples

Makefile.in

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ SUBDIRS = \
363363
include
364364

365365
EXTRA_DIST = autogen.sh
366-
EXAMPLES_DIR = $(top_builddir)/examples
367366
all: all-recursive
368367

369368
.SUFFIXES:
@@ -777,7 +776,8 @@ info: info-recursive
777776
info-am:
778777

779778
install-data-am:
780-
779+
@$(NORMAL_INSTALL)
780+
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
781781
install-dvi: install-dvi-recursive
782782

783783
install-dvi-am:
@@ -824,7 +824,8 @@ ps-am:
824824

825825
uninstall-am:
826826

827-
.MAKE: $(am__recursive_targets) install-am install-strip
827+
.MAKE: $(am__recursive_targets) install-am install-data-am \
828+
install-strip
828829

829830
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
830831
am--refresh check check-am clean clean-cscope clean-generic \
@@ -834,27 +835,25 @@ uninstall-am:
834835
distclean-hdr distclean-libtool distclean-tags distcleancheck \
835836
distdir distuninstallcheck dvi dvi-am html html-am info \
836837
info-am install install-am install-data install-data-am \
837-
install-dvi install-dvi-am install-exec install-exec-am \
838-
install-html install-html-am install-info install-info-am \
839-
install-man install-pdf install-pdf-am install-ps \
840-
install-ps-am install-strip installcheck installcheck-am \
841-
installdirs installdirs-am maintainer-clean \
838+
install-data-hook install-dvi install-dvi-am install-exec \
839+
install-exec-am install-html install-html-am install-info \
840+
install-info-am install-man install-pdf install-pdf-am \
841+
install-ps install-ps-am install-strip installcheck \
842+
installcheck-am installdirs installdirs-am maintainer-clean \
842843
maintainer-clean-generic mostlyclean mostlyclean-generic \
843844
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
844845
uninstall-am
845846

846847
.PRECIOUS: Makefile
847848

848849

849-
copy-examples:
850-
@if test $(EXAMPLES_DIR) != "$(top_srcdir)/examples" ; then \
851-
echo "Copying examples folders into $(EXAMPLES_DIR)..." ; \
852-
mkdir -p $(EXAMPLES_DIR) ; \
853-
rsync -a $(top_srcdir)/examples/* $(EXAMPLES_DIR) ; \
850+
install-data-hook:
851+
@if test "$(prefix)/examples" != "$(top_srcdir)/examples" ; then \
852+
echo "Copying examples into $(prefix)..." ; \
853+
rsync -a $(top_srcdir)/examples $(prefix) ; \
854+
rm -rf $(prefix)/examples/api_examples ; \
854855
fi ;
855856

856-
.PHONY: copy-examples
857-
858857
# Tell versions [3.59,3.63) of GNU make to not export all variables.
859858
# Otherwise a system limit (for SysV at least) may be exceeded.
860859
.NOEXPORT:

applications/createxdmf/main.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ int main(int argc, char **argv)
7575
if (!isSet) step = setting["parameters"]["nsave"].as<PetscInt>();
7676

7777
// u
78-
ierr = writeSingleXDMF(setting["directory"].as<std::string>(), "u",
78+
ierr = writeSingleXDMF(setting["output"].as<std::string>(), "u",
7979
mesh->dim, mesh->n[0], bg, ed, step); CHKERRQ(ierr);
8080

8181
// v
82-
ierr = writeSingleXDMF(setting["directory"].as<std::string>(), "v",
82+
ierr = writeSingleXDMF(setting["output"].as<std::string>(), "v",
8383
mesh->dim, mesh->n[1], bg, ed, step); CHKERRQ(ierr);
8484

8585
// p
86-
ierr = writeSingleXDMF(setting["directory"].as<std::string>(), "p",
86+
ierr = writeSingleXDMF(setting["output"].as<std::string>(), "p",
8787
mesh->dim, mesh->n[3], bg, ed, step); CHKERRQ(ierr);
8888

8989
// wz
@@ -92,28 +92,28 @@ int main(int argc, char **argv)
9292
wn[0] = mesh->n[4][0];
9393
wn[1] = mesh->n[4][1];
9494
wn[2] = mesh->n[3][2];
95-
ierr = writeSingleXDMF(setting["directory"].as<std::string>(), "wz",
95+
ierr = writeSingleXDMF(setting["output"].as<std::string>(), "wz",
9696
mesh->dim, wn, bg, ed, step); CHKERRQ(ierr);
9797

9898
if (mesh->dim == 3)
9999
{
100100
// w
101-
ierr = writeSingleXDMF(setting["directory"].as<std::string>(), "w",
101+
ierr = writeSingleXDMF(setting["output"].as<std::string>(), "w",
102102
mesh->dim, mesh->n[2], bg, ed, step);
103103
CHKERRQ(ierr);
104104

105105
// wx
106106
wn[0] = mesh->n[3][0];
107107
wn[1] = mesh->n[4][1];
108108
wn[2] = mesh->n[4][2];
109-
ierr = writeSingleXDMF(setting["directory"].as<std::string>(), "wx",
109+
ierr = writeSingleXDMF(setting["output"].as<std::string>(), "wx",
110110
mesh->dim, wn, bg, ed, step); CHKERRQ(ierr);
111111

112112
// wy
113113
wn[0] = mesh->n[4][0];
114114
wn[1] = mesh->n[3][1];
115115
wn[2] = mesh->n[4][2];
116-
ierr = writeSingleXDMF(setting["directory"].as<std::string>(), "wy",
116+
ierr = writeSingleXDMF(setting["output"].as<std::string>(), "wy",
117117
mesh->dim, wn, bg, ed, step); CHKERRQ(ierr);
118118
}
119119

@@ -150,7 +150,8 @@ PetscErrorCode writeSingleXDMF(const std::string &directory,
150150
ierr = PetscViewerASCIIPrintf(viewer,
151151
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" [\n");
152152
CHKERRQ(ierr);
153-
ierr = PetscViewerASCIIPrintf(viewer, "\t<!ENTITY CaseDir \"%s\">\n", "./");
153+
ierr = PetscViewerASCIIPrintf(
154+
viewer, "\t<!ENTITY CaseDir \"%s\">\n", directory.c_str());
154155
CHKERRQ(ierr);
155156

156157
// always use 3D XDMF format, so both Visit and Paraview works
@@ -247,7 +248,7 @@ PetscErrorCode writeSingleXDMF(const std::string &directory,
247248
CHKERRQ(ierr);
248249
ierr = PetscViewerASCIIPrintf(viewer,
249250
"\t\t\t\t\t"
250-
"&CaseDir;/solution/%07d.h5:/%s\n",
251+
"&CaseDir;/%07d.h5:/%s\n",
251252
t, name.c_str()); CHKERRQ(ierr);
252253
ierr = PetscViewerASCIIPrintf(viewer,
253254
"\t\t\t\t"

applications/decoupledibpm/decoupledibpm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ PetscErrorCode DecoupledIBPMSolver::init(const MPI_Comm &world,
8585

8686
// create an ASCII PetscViewer to output the body forces
8787
ierr = createPetscViewerASCII(
88-
config["directory"].as<std::string>() +
88+
config["output"].as<std::string>() +
8989
"/forces-" + std::to_string(ite) + ".txt",
9090
FILE_MODE_WRITE, forcesViewer); CHKERRQ(ierr);
9191

applications/ibpm/ibpm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ PetscErrorCode IBPMSolver::init(const MPI_Comm &world, const YAML::Node &node)
6868

6969
// create an ASCII PetscViewer to output the body forces
7070
ierr = createPetscViewerASCII(
71-
config["directory"].as<std::string>() +
71+
config["output"].as<std::string>() +
7272
"/forces-" + std::to_string(ite) + ".txt",
7373
FILE_MODE_WRITE, forcesViewer); CHKERRQ(ierr);
7474

applications/navierstokes/navierstokes.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ PetscErrorCode NavierStokesSolver::init(const MPI_Comm &world, const YAML::Node
125125
// create the Cartesian mesh
126126
ierr = petibm::mesh::createMesh(comm, config, mesh); CHKERRQ(ierr);
127127
// write the grid points into a HDF5 file
128-
std::string filePath = config["directory"].as<std::string>() + "/grid.h5";
128+
std::string filePath = config["output"].as<std::string>() + "/grid.h5";
129129
ierr = mesh->write(filePath); CHKERRQ(ierr);
130130

131131
// create the data object for the boundary conditions
@@ -167,13 +167,18 @@ PetscErrorCode NavierStokesSolver::init(const MPI_Comm &world, const YAML::Node
167167
probes.resize(config["probes"].size());
168168
for (unsigned int i = 0; i < probes.size(); ++i)
169169
{
170+
// Prepend relative path with output directory.
171+
config["probes"][i]["path"] =
172+
config["output"].as<std::string>() + "/" +
173+
config["probes"][i]["path"].as<std::string>();
174+
// Create the probe.
170175
ierr = petibm::misc::createProbe(mesh->comm, config["probes"][i],
171176
mesh, probes[i]); CHKERRQ(ierr);
172177
}
173178

174179
// create an ASCII PetscViewer to output linear solvers info
175180
ierr = createPetscViewerASCII(
176-
config["directory"].as<std::string>() +
181+
config["output"].as<std::string>() +
177182
"/iterations-" + std::to_string(ite) + ".txt",
178183
FILE_MODE_WRITE, solversViewer); CHKERRQ(ierr);
179184

applications/rigidkinematics/rigidkinematics.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,16 @@ PetscErrorCode RigidKinematicsSolver::writeBodies()
166166
PetscFunctionBeginUser;
167167

168168
std::string directory = config["output"].as<std::string>(".");
169-
std::stringstream ss;
170-
ss << std::setfill('0') << std::setw(7) << ite;
169+
std::stringstream ss_ite;
170+
ss_ite << std::setfill('0') << std::setw(7) << ite;
171171
std::string filepath;
172172
for (PetscInt i = 0; i < bodies->nBodies; ++i)
173173
{
174174
petibm::type::SingleBody &body = bodies->bodies[i];
175-
filepath = directory + "/" + body->name + "_" + ss.str();
176-
ss.str("");
177-
ss << "." << body->dim << "D";
178-
filepath = filepath + ss.str();
175+
filepath = directory + "/" + body->name + "_" + ss_ite.str();
176+
std::stringstream ss_suffix;
177+
ss_suffix << "." << body->dim << "D";
178+
filepath = filepath + ss_suffix.str();
179179
ierr = body->writeBody(filepath); CHKERRQ(ierr);
180180
}
181181

applications/vorticity/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int main(int argc, char **argv)
101101
{
102102
ierr = petibm::io::writeHDF5Vecs(
103103
PETSC_COMM_SELF,
104-
setting["directory"].as<std::string>() + "/grid.h5", wNames[i],
104+
setting["output"].as<std::string>() + "/grid.h5", wNames[i],
105105
{"x", "y", "z"}, wCoord[i], FILE_MODE_APPEND); CHKERRQ(ierr);
106106
}
107107
}

applications/writemesh/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int main(int argc, char **argv)
3838
CHKERRQ(ierr);
3939

4040
// write grid data into HDF5 file
41-
std::string filePath = config["directory"].as<std::string>() + "/grid.h5";
41+
std::string filePath = config["output"].as<std::string>() + "/grid.h5";
4242
char s[PETSC_MAX_PATH_LEN];
4343
PetscBool flag = PETSC_FALSE;
4444
ierr = PetscOptionsGetString(nullptr, nullptr, "-file", s, sizeof(s),

0 commit comments

Comments
 (0)