forked from LLNL/libROM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoke_test.C
108 lines (95 loc) · 2.58 KB
/
smoke_test.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/******************************************************************************
*
* Copyright (c) 2013-2019, Lawrence Livermore National Security, LLC
* and other libROM project developers. See the top-level COPYRIGHT
* file for details.
*
* SPDX-License-Identifier: (Apache-2.0 OR MIT)
*
*****************************************************************************/
// Description: Simple test of the incremental fast update algorithm and
// incremental sampler.
#include "IncrementalSVDBasisGenerator.h"
#include "mpi.h"
#include <stdio.h>
int
main(
int argc,
char* argv[])
{
// Initialize MPI and get the number of processors and this processor's
// rank.
MPI_Init(&argc, &argv);
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// Given the number of processors and the rank of this processor set the
// dimension of the problem.
int dim;
if (size == 1) {
dim = 6;
}
else if (size == 2) {
dim = 3;
}
else if (size == 3) {
dim = 2;
}
else if (size == 6) {
dim = 1;
}
else {
if (rank == 0) {
printf("Illegal number of procs.\n");
printf("Allowed number of procs is 1, 2, 3, or 6.\n");
}
return 1;
}
// Construct the incremental basis generator to use the fast update
// incremental algorithm and the incremental sampler.
CAROM::IncrementalSVDBasisGenerator inc_basis_generator(dim,
1.0e-2,
false,
true,
2,
1.0e-6,
2,
1.0e-2,
0.11,
"",
false,
false,
false,
CAROM::Database::HDF5,
0.1,
0.8,
5.0,
true);
// Define the values for the first sample.
double vals0[6] = {1.0, 6.0, 3.0, 8.0, 17.0, 9.0};
// Define the values for the second sample.
double vals1[6] = {2.0, 7.0, 4.0, 9.0, 18.0, 10.0};
bool status = false;
// Take the first sample.
if (inc_basis_generator.isNextSample(0.0)) {
status = inc_basis_generator.takeSample(&vals0[dim*rank], 0.0, 0.11);
if (status) {
inc_basis_generator.computeNextSampleTime(&vals0[dim*rank],
&vals0[dim*rank],
0.0);
}
}
// Take the second sample.
if (status && inc_basis_generator.isNextSample(0.11)) {
status = inc_basis_generator.takeSample(&vals1[dim*rank], 0.11, 0.11);
if (status) {
inc_basis_generator.computeNextSampleTime(&vals1[dim*rank],
&vals1[dim*rank],
0.11);
}
}
// Finalize MPI and return.
MPI_Finalize();
return !status;
}