Skip to content

Commit 9db72e7

Browse files
authored
Merge pull request #101 from EXP-code/minorFixesAndUpdates
Minor bug fixes and updates
2 parents 1f1aa8b + 11012a6 commit 9db72e7

Some content is hidden

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

72 files changed

+4580
-841
lines changed

CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1313
# Compiler flags. Not all tested thoroughly...
1414
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1515
# using Clang
16+
message(STATUS "Clang compiler version is: ${CMAKE_CXX_COMPILER_VERSION}")
17+
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
18+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.0)
19+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
20+
endif()
21+
endif()
1622
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
1723
# using GCC
1824
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
@@ -70,6 +76,7 @@ find_package(HDF5 COMPONENTS C CXX HL REQUIRED)
7076
find_package(TIRPC) # Check for alternative Sun rpc support
7177
find_package(Eigen3 REQUIRED)
7278
find_package(PNG)
79+
find_package(Git)
7380

7481
# Check for FE
7582
include(FEENABLE)
@@ -186,15 +193,15 @@ add_compile_definitions(DATTRIB_CUDA=${CUDA_EXP_DATTRIB})
186193

187194
# Get the current working branch
188195
execute_process(
189-
COMMAND git rev-parse --abbrev-ref HEAD
196+
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
190197
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
191198
OUTPUT_VARIABLE GIT_BRANCH
192199
OUTPUT_STRIP_TRAILING_WHITESPACE
193200
)
194201

195202
# Git submodule updates
196203
execute_process(
197-
COMMAND git submodule update --init --recursive
204+
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
198205
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
199206
RESULT_VARIABLE GIT_SUBMOD_RESULT
200207
)
@@ -207,7 +214,7 @@ endif()
207214

208215
# Get the latest abbreviated commit hash of the working branch
209216
execute_process(
210-
COMMAND git rev-parse HEAD
217+
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
211218
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
212219
OUTPUT_VARIABLE GIT_COMMIT
213220
OUTPUT_STRIP_TRAILING_WHITESPACE

INSTALL.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
# Configuring and building EXP
22

3-
We are now using git submodules to provide `yaml-cpp`, which is not
4-
common in the HPC environments. So, from the top-level directory, do
5-
the following:
3+
We are now using git submodules to provide a number of packages that
4+
are not common in the HPC environments. These include
5+
6+
- `HighFive`, a C++ wrapper
7+
class to HDF5
8+
- `yaml-cpp`, a C++ class for reading and emitting YAML code
9+
- `pybind11` which is used for Python bindings to the C++ classes
10+
- `rapidxml`, used to write VTK files for rendering outside of EXP
11+
- `png++`, C++ wrappers to the png library [Note: png support is optional]
12+
13+
CMake will automatically download and configure these packages on the
14+
first call. However, if you would to do this manually, from the
15+
top-level directory, execute the following command:
616

717
```
818
git submodule update --init --recursive
919
```
1020

11-
This will install `yaml-cpp` in the `extern` directory. The png++ C++
12-
wrappers to the png library are also installed in `extern`. Note: png
13-
support is optional.
21+
This will install the source packages in the `extern` directory.
22+
1423

1524
## EXP uses CMake for building a configuration
1625

expui/BasisFactory.H

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <ParticleReader.H>
1010
#include <OrthoFunction.H>
1111
#include <Coefficients.H>
12+
#include <PseudoAccel.H>
1213
#include <YamlCheck.H>
1314
#include <localmpi.H>
1415
#include <exputils.H>
@@ -123,8 +124,22 @@ namespace BasisClasses
123124
//! Midplane escursion parameter
124125
double colh = 4.0;
125126

126-
public:
127+
//@
128+
//! Pseudo-acceleration db
129+
Eigen::VectorXd t_accel;
130+
Eigen::MatrixXd p_accel;
131+
//@}
127132

133+
//! Number of center points in acceleration estimator
134+
int Naccel = 0;
135+
136+
//! Get the current pseudo acceleration value
137+
Eigen::Vector3d currentAccel(double time);
138+
139+
public:
140+
//! The current pseudo acceleration
141+
Eigen::Vector3d pseudo {0, 0, 0};
142+
128143
//! Constructor from YAML node
129144
Basis(const YAML::Node& conf, const std::string& name="Basis");
130145

@@ -231,6 +246,19 @@ namespace BasisClasses
231246
//! Height above/below the plane for midplane search in disk scale
232247
//! lengths
233248
void setColumnHeight(double value) { colh = value; }
249+
250+
//@{
251+
//! Initialize non-inertial forces
252+
void setNonInertial(int N, Eigen::VectorXd& x, Eigen::MatrixXd& pos);
253+
void setNonInertial(int N, const std::string& orient);
254+
//@}
255+
256+
//! Set the current pseudo acceleration
257+
void setNonInertialAccel(double time)
258+
{
259+
if (Naccel > 0) pseudo = currentAccel(time);
260+
}
261+
234262
};
235263

236264
using BasisPtr = std::shared_ptr<Basis>;

expui/BasisFactory.cc

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ namespace BasisClasses
184184
else if ( !name.compare("flatdisk") ) {
185185
basis = std::make_shared<FlatDisk>(conf);
186186
}
187+
else if ( !name.compare("CBDisk") ) {
188+
basis = std::make_shared<CBDisk>(conf);
189+
}
187190
else if ( !name.compare("slabSL") ) {
188191
basis = std::make_shared<Slab>(conf);
189192
}
@@ -280,5 +283,98 @@ namespace BasisClasses
280283
return makeFromArray(time);
281284
}
282285

286+
void Basis::setNonInertial(int N, Eigen::VectorXd& t, Eigen::MatrixXd& pos)
287+
{
288+
Naccel = N;
289+
t_accel = t;
290+
p_accel = pos;
291+
}
292+
293+
void Basis::setNonInertial(int N, const std::string& orient)
294+
{
295+
std::ifstream in(orient);
296+
297+
if (not in) {
298+
throw std::runtime_error("Cannot open Orient file with centering data: " + orient);
299+
}
300+
301+
const int cbufsiz = 16384;
302+
std::unique_ptr<char[]> cbuf(new char [cbufsiz]);
303+
304+
// Look for data and write it while
305+
// accumlating data for averaging
306+
Eigen::Vector3d testread;
307+
double time, dummy;
308+
309+
std::vector<double> times;
310+
std::vector<Eigen::Vector3d> centers;
311+
312+
while (in) {
313+
314+
in.getline(cbuf.get(), cbufsiz);
315+
if (in.rdstate() & (ios::failbit | ios::eofbit)) break;
316+
317+
// Skip comment lines
318+
//
319+
if (cbuf[0] == '#') continue;
320+
321+
std::istringstream line(cbuf.get());
322+
323+
// Read until current time is reached
324+
line >> time; //
325+
line >> dummy;
326+
line >> dummy;
327+
328+
bool allRead = true;
329+
for (int i=0; i<8; i++) {
330+
if (line.eof()) allRead = false;
331+
for (int k; k<3; k++) line >> testread(k);
332+
}
333+
if (allRead) {
334+
times.push_back(time);
335+
centers.push_back(testread);
336+
}
337+
}
338+
339+
// Repack data
340+
Naccel = N;
341+
t_accel.resize(times.size());
342+
p_accel.resize(times.size(), 3);
343+
for (int i=0; i<times.size(); i++) {
344+
t_accel(i) = times[i];
345+
for (int k=0; k<3; k++) p_accel(i, k) = centers[i](k);
346+
}
347+
}
348+
349+
350+
Eigen::Vector3d Basis::currentAccel(double time)
351+
{
352+
Eigen::Vector3d ret;
353+
354+
if (time < t_accel(0) || time > t_accel(t_accel.size()-1)) {
355+
std::cout << "ERROR: " << time << " is outside of range of the non-inertial DB"
356+
<< std::endl;
357+
ret.setZero();
358+
return ret;
359+
}
360+
else {
361+
int imin = 0;
362+
int imax = std::lower_bound(t_accel.data(), t_accel.data()+t_accel.size(), time) - t_accel.data();
363+
if (imax > Naccel) imin = imax - Naccel;
364+
365+
int num = imax - imin + 1;
366+
Eigen::VectorXd t(num);
367+
Eigen::MatrixXd p(num, 3);
368+
for (int i=imin; i<=imax; i++) {
369+
t(i-imin) = t_accel(i);
370+
for (int k=0; k<3; k++) p(i-imin, k) = p_accel(i, k);
371+
}
372+
373+
for (int k=0; k<3; k++)
374+
ret(k) = 2.0*std::get<0>(QuadLS<Eigen::VectorXd>(t, p.col(k)).coefs());
375+
}
376+
return ret;
377+
}
378+
283379
}
284380
// END namespace BasisClasses

0 commit comments

Comments
 (0)