Skip to content

Commit e3a2bb7

Browse files
committed
Merge branch 'ITHACA-FV:master' into cout2Info
2 parents eeae720 + cca8426 commit e3a2bb7

9 files changed

Lines changed: 66 additions & 44 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Linear and non-linear algebra operations which are not already implemented in Op
3232
* [**OpenFOAM 2312**](https://www.openfoam.com/news/main-news/openfoam-v2312) or
3333
* [**OpenFOAM 2406**](https://www.openfoam.com/news/main-news/openfoam-v2406) or
3434
* [**OpenFOAM 2412**](https://www.openfoam.com/news/main-news/openfoam-v2412) or
35-
* [**OpenFOAM 2506**](https://www.openfoam.com/news/main-news/openfoam-v2506)
35+
* [**OpenFOAM 2506**](https://www.openfoam.com/news/main-news/openfoam-v2506) or
36+
* [**OpenFOAM 2512**](https://www.openfoam.com/news/main-news/openfoam-v2512)
3637

3738

3839
### 2. Installation and usage

src/ITHACA_CORE/ITHACAstream/ITHACAstream.H

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,23 @@ Ostream& operator<< (Ostream& os, const Eigen::Transpose<Eigen::Matrix<T, -1, 1>
602602
return os;
603603
}
604604

605+
// Support for Eigen::Block (column/row views from matrices)
606+
template<typename T>
607+
Ostream& operator<< (Ostream& os, const Eigen::Block<Eigen::Matrix<T, -1, -1>, -1, 1, true>& mat)
608+
{
609+
Eigen::Matrix<T, -1, 1> evaluated = mat;
610+
os << evaluated;
611+
return os;
612+
}
613+
614+
template<typename T>
615+
Ostream& operator<< (Ostream& os, const Eigen::Block<Eigen::Matrix<T, -1, -1>, 1, -1, false>& mat)
616+
{
617+
Eigen::Matrix<T, 1, -1> evaluated = mat;
618+
os << evaluated;
619+
return os;
620+
}
621+
605622
template<typename T>
606623
Ostream& operator<< (Ostream& os, const Eigen::Tensor<T, 3>& tens)
607624
{

src/ITHACA_CORE/ITHACAstream/cnpy.H

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include<numeric>
2525
#include <regex>
2626
#include<cstring>
27+
#include "IFstream.H"
2728

2829

2930
namespace cnpy

src/ITHACA_INTERPOLATOR/Make/options

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ EXE_INC = \
1515
-I$(LIB_ITHACA_SRC)/ITHACA_INTERPOLATOR/mtbRBF \
1616
-I$(LIB_ITHACA_SRC)/ITHACA_INTERPOLATOR/splinterRBF \
1717
-I$(LIB_ITHACA_SRC)/thirdparty/mathtoolbox/include \
18-
-isystem $(LIB_ITHACA_SRC)/thirdparty/Eigen
18+
-I$(LIB_ITHACA_SRC)/thirdparty/Eigen \
19+
-std=c++17 \
20+
1921

2022
LIB_LIBS = \
2123
-L$(FOAM_USER_LIBBIN) \

src/ITHACA_MUQ/Fang2017filter/Fang2017filter.C

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ void Fang2017filter::setTime(double _startTime, double _deltaTime,
103103
deltaTime = _deltaTime;
104104
endTime = _endTime;
105105
Ntimes = (endTime - startTime) / deltaTime;
106-
Info << "startTime = " << startTime << endl;
107-
Info << "endTime = " << endTime << endl;
108-
Info << "deltaTime = " << deltaTime << endl;
109-
Info << "Ntimes = " << Ntimes << endl;
106+
Foam::Info << "startTime = " << startTime << endl;
107+
Foam::Info << "endTime = " << endTime << endl;
108+
Foam::Info << "deltaTime = " << deltaTime << endl;
109+
Foam::Info << "Ntimes = " << Ntimes << endl;
110110
timeVector = Eigen::VectorXd::LinSpaced(Ntimes + 1, startTime, endTime);
111111
}
112112

@@ -120,9 +120,9 @@ void Fang2017filter::setObservationTime(int _observationStart,
120120
M_Assert(_observationStart > 0, "First observation timestep can't be 0");
121121
observationStart = _observationStart;
122122
observationDelta = _observationDelta;
123-
Info << "First observation at time = " << timeVector(observationStart) << " s"
123+
Foam::Info << "First observation at time = " << timeVector(observationStart) << " s"
124124
<< endl;
125-
Info << "Observations taken every " << observationDelta << " timesteps" << endl;
125+
Foam::Info << "Observations taken every " << observationDelta << " timesteps" << endl;
126126
observationBoolVec = Eigen::VectorXi::Zero(timeVector.size() - 1);
127127

128128
for (int i = observationStart - 1; i < Ntimes; i += observationDelta)
@@ -274,15 +274,15 @@ void Fang2017filter::buildJointEns()
274274
void Fang2017filter::setObservationSize(int _size)
275275
{
276276
observationSize = _size;
277-
Info << "Observation size = " << observationSize << endl;
277+
Foam::Info << "Observation size = " << observationSize << Foam::endl;
278278
}
279279

280280
//--------------------------------------------------------------------------
281281
///
282282
void Fang2017filter::setStateSize(int _size)
283283
{
284284
stateSize = _size;
285-
Info << "State size = " << stateSize << endl;
285+
Foam::Info << "State size = " << stateSize << Foam::endl;
286286
}
287287

288288
//--------------------------------------------------------------------------
@@ -297,7 +297,7 @@ int Fang2017filter::getStateSize()
297297
void Fang2017filter::setParameterSize(int _size)
298298
{
299299
parameterSize = _size;
300-
Info << "Parameter size = " << parameterSize << endl;
300+
Foam::Info << "Parameter size = " << parameterSize << Foam::endl;
301301
}
302302

303303
//--------------------------------------------------------------------------
@@ -362,13 +362,13 @@ void Fang2017filter::run(int innerLoopMax, word outputFolder)
362362

363363
while (timeStepI < Ntimes)
364364
{
365-
Info << "timeStep " << timeStepI << endl;
365+
Foam::Info << "timeStep " << timeStepI << Foam::endl;
366366
innerLoopI = 0;
367367
oldStateEns.assignSamples(stateEns.getSamples());
368368

369369
while (innerLoopI < innerLoopMax)
370370
{
371-
Info << "Inner loop " << innerLoopI << endl;
371+
Foam::Info << "Inner loop " << innerLoopI << Foam::endl;
372372

373373
// Projection
374374
if (innerLoopI == 0)
@@ -385,19 +385,19 @@ void Fang2017filter::run(int innerLoopMax, word outputFolder)
385385
sampleParameterDist();
386386
}
387387

388-
Info << "\ndebug : parameterPriorMean = " <<
389-
parameterPriorMean << endl;
390-
Info << "\ndebug : parameterMean.col(" << timeStepI << ") =\n" <<
391-
parameterMean.col(timeStepI) << endl;
388+
Foam::Info << "\ndebug : parameterPriorMean = " <<
389+
parameterPriorMean << Foam::endl;
390+
Foam::Info << "\ndebug : parameterMean.col(" << timeStepI << ") =\n" <<
391+
parameterMean.col(timeStepI) << Foam::endl;
392392
}
393393
else
394394
{
395-
Info << "\ndebug : parameterMean before loop =\n" <<
396-
parameterMean.col(timeStepI) << endl;
395+
Foam::Info << "\ndebug : parameterMean before loop =\n" <<
396+
parameterMean.col(timeStepI) << Foam::endl;
397397
setParameterPriorDensity(parameterMean.col(timeStepI), parameterPriorCov);
398398
sampleParameterDist();
399-
Info << "\ndebug : parameterMean after loop =\n" <<
400-
parameterMean.col(timeStepI) << endl;
399+
Foam::Info << "\ndebug : parameterMean after loop =\n" <<
400+
parameterMean.col(timeStepI) << Foam::endl;
401401
}
402402

403403
stateProjection();
@@ -407,9 +407,9 @@ void Fang2017filter::run(int innerLoopMax, word outputFolder)
407407
{
408408
Eigen::MatrixXd measNoiseSamps = ensembleFromDensity(measNoiseDensity);
409409
observeState();
410-
Info << "\ndebug : observation =\n" <<
410+
Foam::Info << "\ndebug : observation =\n" <<
411411
observations.col(observationBoolVec.head(timeStepI + 1).sum() - 1) <<
412-
endl;
412+
Foam::endl;
413413
updateJointEns(
414414
observations.col(
415415
observationBoolVec.head(timeStepI + 1).sum() - 1));

src/ITHACA_MUQ/Fang2017filter_wDF/Fang2017filter_wDF.C

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ void Fang2017filter_wDF::setTime(double _startTime, double _deltaTime,
124124
deltaTime = _deltaTime;
125125
endTime = _endTime;
126126
Ntimes = (endTime - startTime) / deltaTime;
127-
Info << "startTime = " << startTime << endl;
128-
Info << "endTime = " << endTime << endl;
129-
Info << "deltaTime = " << deltaTime << endl;
130-
Info << "Ntimes = " << Ntimes << endl;
127+
Foam::Info << "startTime = " << startTime << Foam::endl;
128+
Foam::Info << "endTime = " << endTime << Foam::endl;
129+
Foam::Info << "deltaTime = " << deltaTime << Foam::endl;
130+
Foam::Info << "Ntimes = " << Ntimes << Foam::endl;
131131
timeVector = Eigen::VectorXd::LinSpaced(Ntimes + 1, startTime, endTime);
132132
}
133133

@@ -141,9 +141,9 @@ void Fang2017filter_wDF::setObservationTime(int _observationStart,
141141
M_Assert(_observationStart > 0, "First observation timestep can't be 0");
142142
observationStart = _observationStart;
143143
observationDelta = _observationDelta;
144-
Info << "First observation at time = " << timeVector(observationStart) << " s"
145-
<< endl;
146-
Info << "Observations taken every " << observationDelta << " timesteps" << endl;
144+
Foam::Info << "First observation at time = " << timeVector(observationStart) << " s"
145+
<< Foam::endl;
146+
Foam::Info << "Observations taken every " << observationDelta << " timesteps" << Foam::endl;
147147
observationBoolVec = Eigen::VectorXi::Zero(timeVector.size() - 1);
148148

149149
for (int i = observationStart - 1; i < Ntimes; i += observationDelta)
@@ -232,7 +232,7 @@ void Fang2017filter_wDF::setInitialStateDensity(Eigen::VectorXd _mean,
232232
/// Create initial state ensemble
233233
void Fang2017filter_wDF::sampleInitialState()
234234
{
235-
Info << "Setting initial state ensamble" << endl;
235+
Foam::Info << "Setting initial state ensamble" << Foam::endl;
236236
M_Assert(initialStateFlag == 1,
237237
"Initialize the initial state density before sampling it");
238238

@@ -257,7 +257,7 @@ void Fang2017filter_wDF::sampleInitialState()
257257
stateEns.assignSamples(ensembleFromDensity(initialStateDensity));
258258
}
259259

260-
Info << "debug: State ensamble size = " << stateEns.getSize() << endl;
260+
Foam::Info << "debug: State ensamble size = " << stateEns.getSize() << Foam::endl;
261261
}
262262

263263
//--------------------------------------------------------------------------
@@ -329,15 +329,15 @@ void Fang2017filter_wDF::buildJointEns()
329329
void Fang2017filter_wDF::setObservationSize(int _size)
330330
{
331331
observationSize = _size;
332-
Info << "Observation size = " << observationSize << endl;
332+
Foam::Info << "Observation size = " << observationSize << Foam::endl;
333333
}
334334

335335
//--------------------------------------------------------------------------
336336
///
337337
void Fang2017filter_wDF::setStateSize(int _size)
338338
{
339339
stateSize = _size;
340-
Info << "State size = " << stateSize << endl;
340+
Foam::Info << "State size = " << stateSize << Foam::endl;
341341
}
342342

343343
//--------------------------------------------------------------------------
@@ -352,7 +352,7 @@ int Fang2017filter_wDF::getStateSize()
352352
void Fang2017filter_wDF::setParameterSize(int _size)
353353
{
354354
parameterSize = _size;
355-
Info << "Parameter size = " << parameterSize << endl;
355+
Foam::Info << "Parameter size = " << parameterSize << Foam::endl;
356356
}
357357

358358
//--------------------------------------------------------------------------
@@ -426,12 +426,12 @@ void Fang2017filter_wDF::run(int innerLoopMax, word outputFolder)
426426

427427
while (timeStepI < Ntimes)
428428
{
429-
Info << "timeStep " << timeStepI << endl;
429+
Foam::Info << "timeStep " << timeStepI << Foam::endl;
430430

431431
if (timeStepI == 0)
432432
{
433433
setParameterPriorDensity(parameterPriorMean, parameterPriorCov);
434-
Info << "debugInside: parameterPriorMean = " << parameterPriorMean << endl;
434+
Foam::Info << "debugInside: parameterPriorMean = " << parameterPriorMean << Foam::endl;
435435
sampleParameterDist();
436436
}
437437
else
@@ -449,15 +449,15 @@ void Fang2017filter_wDF::run(int innerLoopMax, word outputFolder)
449449

450450
while (innerLoopI < innerLoopMax)
451451
{
452-
Info << "Inner loop " << innerLoopI << endl;
453-
Info << "debug: param mean =\n" << parameterEns.mean() << endl;
452+
Foam::Info << "Inner loop " << innerLoopI << Foam::endl;
453+
Foam::Info << "debug: param mean =\n" << parameterEns.mean() << Foam::endl;
454454

455455
if (innerLoopI > 0)
456456
{
457457
setParameterPriorDensity(parameterMean.col(timeStepI), parameterPriorCov);
458458
sampleParameterDist();
459-
Info << "\ndebug : parameterMean after loop =\n" << parameterMean.col(
460-
timeStepI) << endl;
459+
Foam::Info << "\ndebug : parameterMean after loop =\n" << parameterMean.col(
460+
timeStepI) << Foam::endl;
461461
}
462462

463463
buildJointEns();

src/thirdparty/Eigen

Submodule Eigen updated from 549bf8c to bc3b398

unitTests/libTorch/torchOperations.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ using namespace ITHACAtorch::torch2Eigen;
4141
int main()
4242
{
4343
torch::Tensor tensor = torch::randn({2, 2, 3});
44-
Info << tensor << endl;
44+
std::cout << tensor << std::endl;
4545
ITHACAtorch::save(tensor,"test.npy");
4646
torch::Tensor aloaded = ITHACAtorch::load("test.npy");
47-
Info << aloaded << endl;
47+
std::cout << aloaded << std::endl;
4848
return 0;
4949

5050
}

unitTests/pybind11/residual_of/Make/options

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ LIB_LIBS = \
7272
-lITHACA_ROMPROBLEMS \
7373
-lITHACA_FOMPROBLEMS \
7474
-lITHACA_THIRD_PARTY \
75+
-lITHACA_INTERPOLATOR \
7576
-lITHACA_CORE \
7677
-lsixDoFRigidBodyMotion \
7778
-L$(FOAM_USER_LIBBIN) \

0 commit comments

Comments
 (0)