39 #include <sys/types.h> 41 #include <Epetra_ConfigDefs.h> 44 #include <Epetra_MpiComm.h> 46 #include <Epetra_SerialComm.h> 51 #include <lifev/core/LifeV.hpp> 52 #include <lifev/bc_interface/0D/bc/BCInterface0D.hpp> 53 #include <lifev/zero_dimensional/solver/ZeroDimensionalData.hpp> 54 #include <lifev/zero_dimensional/solver/ZeroDimensionalSolver.hpp> 56 using namespace LifeV;
60 Real norm = std::abs (val - test);
64 std::cout <<
" value = " << val <<
" computed value = " << test <<
" diff = " << norm << std::endl;
74 std::shared_ptr< Epetra_Comm > comm;
77 Int numberOfProcesses (1);
81 MPI_Init ( &argc, &argv );
83 MPI_Comm_size ( MPI_COMM_WORLD, &numberOfProcesses );
84 MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
89 std::cout << std::endl;
90 std::cout <<
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl;
91 std::cout <<
" THE ZERO DIMENSIONAL SOLVER IS AN ALPHA VERSION UNDER STRONG DEVELOPMENT" << std::endl;
92 std::cout <<
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl << std::endl;
94 std::cout <<
"MPI Processes: " << numberOfProcesses << std::endl;
98 if ( numberOfProcesses > 1 )
102 std::cout <<
"test_ZeroDimensional not enabled in parallel, failing gracefully." << std::endl;
103 std::cout <<
"MPI Finalization" << std::endl;
113 std::cout <<
"MPI Epetra Initialization ... " << std::endl;
115 comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
117 std::cout <<
"SERIAL Epetra Initialization ... " << std::endl;
118 comm.reset (
new Epetra_SerialComm() );
121 bool exitFlag = EXIT_SUCCESS;
123 #if ( defined(HAVE_NOX_THYRA) && defined(HAVE_TRILINOS_RYTHMOS) ) 125 GetPot commandLine ( argc, argv );
126 const bool check = commandLine.search ( 2,
"-c",
"--check" );
127 string fileName = commandLine.follow (
"data", 2,
"-f",
"--file" );
130 GetPot dataFile ( fileName +
".dat" );
132 std::string circuitDataFile = dataFile (
"0D_Model/CircuitDataFile",
"./inputFile.dat" );
133 BCInterface0D< ZeroDimensionalBCHandler, ZeroDimensionalData > zeroDimensionalBC;
134 zeroDimensionalBC.createHandler();
135 zeroDimensionalBC.fillHandler ( circuitDataFile,
"Files" );
137 std::shared_ptr< ZeroDimensionalData > zeroDimensionalData (
new ZeroDimensionalData );
138 zeroDimensionalData->setup ( dataFile, zeroDimensionalBC.handler() );
140 std::shared_ptr< ZeroDimensionalSolver > zeroDimensionalSolver (
new ZeroDimensionalSolver ( zeroDimensionalData->unknownCounter(), comm, zeroDimensionalData->circuitData() ) );
141 zeroDimensionalSolver->setup ( zeroDimensionalData->solverData() );
143 zeroDimensionalData->showMe();
146 zeroDimensionalData->dataTime()->setInitialTime (0);
147 zeroDimensionalData->initializeSolution();
150 if ( comm->MyPID() == 0 )
152 mkdir (
"output", 0777 );
156 zeroDimensionalData->saveSolution();
158 zeroDimensionalData->dataTime()->updateTime();
159 zeroDimensionalData->dataTime()->setInitialTime (zeroDimensionalData->dataTime()->time() );
162 LifeChrono chronoTotal;
163 LifeChrono chronoSystem;
164 LifeChrono chronoIteration;
169 for ( ; zeroDimensionalData->dataTime()->canAdvance() ; zeroDimensionalData->dataTime()->updateTime(), ++count )
171 std::cout << std::endl <<
"--------- Iteration " << count <<
" time = " << zeroDimensionalData->dataTime()->time() << std::endl;
173 chronoIteration.start();
174 chronoSystem.start();
176 zeroDimensionalSolver->takeStep ( zeroDimensionalData->dataTime()->previousTime(), zeroDimensionalData->dataTime()->time() );
181 zeroDimensionalData->saveSolution();
183 chronoIteration.stop();
185 std::cout <<
" System solved in " << chronoSystem.diff() <<
" s, (total time " << chronoIteration.diff() <<
" s)." << std::endl;
189 std::cout << std::endl <<
" Simulation ended successfully in " << chronoTotal.diff() <<
" s" << std::endl;
196 ok = ok && checkValue ( 0.001329039627, zeroDimensionalData->circuitData()->Nodes()->nodeListAt (1)->voltage() );
197 ok = ok && checkValue ( 0.000787475119, zeroDimensionalData->circuitData()->Elements()->elementListAt (1)->current() );
200 std::cout <<
" Test succesful" << std::endl;
201 exitFlag = EXIT_SUCCESS;
205 std::cout <<
" Test unsuccesful" << std::endl;
206 exitFlag = EXIT_FAILURE;
210 std::cout <<
"ZeroDimensional requires configuring Trilinos with Rythmos/NOX/Thyra. Skipping test." << std::endl;
211 exitFlag = EXIT_SUCCESS;
216 std::cout <<
"End Result: TEST PASSED" << std::endl;
222 std::cout <<
"MPI Finalization" << std::endl;
int32_type Int
Generic integer data.
void updateInverseJacobian(const UInt &iQuadPt)
int main(int argc, char **argv)
double Real
Generic real data.
bool checkValue(const Real val, const Real test, const Real tol=1.e-5, const bool verbose=true)