Skip to content

Commit

Permalink
Fix mapper tests with new architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
apontzen committed Sep 25, 2024
1 parent c93fe0c commit 793978d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 30 deletions.
74 changes: 47 additions & 27 deletions genetIC/src/main_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,77 @@

void usageMessage() {
using namespace std;
cout << "Usage: genetIC_mapper <paramfile1> <paramfile2> <id-file-input> <id-file-output>" << endl << endl
cout << "Usage(1): genetIC_mapper <paramfile1> <paramfile2> <id-file-input> <id-file-output>" << endl << endl
<< " Processes the geometry in paramfile1 and paramfile2, then takes a file of particle IDs from" << endl
<< " id-file-input and maps them from the geometry in paramfile1 to the geometry in paramfile2." << endl
<< " The mapped IDs are written to id-file-output." << endl;
cout << "Usage(2): genetIC_mapper <paramfile> <id-file-output>" << endl << endl
<< " Processes the geometry in paramfile and writes flagged IDs to id-file-output." << endl;
}

int main(int argc, char *argv[]) {
using namespace std;

bool useFloat = false;

if (argc<4) {
if (argc!=5 && argc!=3) {
logging::entry() << "argc = " << argc << std::endl;
usageMessage();
return -1;
}

std::string fname1(argv[1]);
std::string fname2(argv[2]);
std::string idFileInput(argv[3]);
std::string idFileOutput(argv[4]);
if(argc == 5) {

logging::entry() << "Processing geometry in " << fname1 << std::endl;
dummyic::DummyICGenerator<double> generator1;
{
logging::IndentWhileInScope temporaryIndent;
runInterpreter<ICGenerator<double>>(generator1, fname1);
}
std::string fname1(argv[1]);
std::string fname2(argv[2]);
std::string idFileInput(argv[3]);
std::string idFileOutput(argv[4]);

dummyic::DummyICGenerator<double> generator2(&generator1);
logging::entry() << "Processing geometry in " << fname2 << std::endl;
{
logging::IndentWhileInScope temporaryIndent;
runInterpreter<ICGenerator<double>>(generator2, fname2);
}
logging::entry() << "Processing geometry in " << fname1 << std::endl;
dummyic::DummyICGenerator<double> generator1;
{
logging::IndentWhileInScope temporaryIndent;
runInterpreter<ICGenerator<double>>(generator1, fname1);
}

dummyic::DummyICGenerator<double> generator2(&generator1);
logging::entry() << "Processing geometry in " << fname2 << std::endl;
{
logging::IndentWhileInScope temporaryIndent;
runInterpreter<ICGenerator<double>>(generator2, fname2);
}

logging::entry() << "Loading IDs from " << idFileInput << std::endl;
generator1.clearCellFlags();
generator2.clearCellFlags();
generator1.loadID(idFileInput);

// generator2.propagateFlagsToRefinedCells(generator1.getMultiLevelContext());
generator1.propagateFlagsToRefinedCells(generator2.getMultiLevelContext());

generator1.clearCellFlags();
generator2.clearCellFlags();

logging::entry() << "Loading IDs from " << idFileInput << std::endl;
generator1.loadID(idFileInput);

// generator2.propagateFlagsToRefinedCells(generator1.getMultiLevelContext());
generator1.propagateFlagsToRefinedCells(generator2.getMultiLevelContext());
logging::entry() << "Writing IDs to " << idFileOutput << std::endl;

logging::entry() << "Writing IDs to " << idFileOutput << std::endl;
generator2.ICGenerator<double>::dumpID(idFileOutput);

generator2.ICGenerator<double>::dumpID(idFileOutput);
logging::entry() << "Done." << std::endl;
} else {
std::string fname(argv[1]);
std::string idFileOutput(argv[2]);

logging::entry() << "Done." << std::endl;
logging::entry() << "Processing geometry in " << fname << std::endl;
dummyic::DummyICGenerator<double> generator;
{
logging::IndentWhileInScope temporaryIndent;
runInterpreter<ICGenerator<double>>(generator, fname);
}

logging::entry() << "Writing flagged IDs to " << idFileOutput << std::endl;
generator.ICGenerator<double>::dumpID(idFileOutput);

logging::entry() << "Done." << std::endl;
}


}
9 changes: 9 additions & 0 deletions genetIC/tests/mapper_test_02b_grafic_zoom_to_coarse/ID_a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
458752
458753
458754
458755
458756
458757
458758
458759
458760
1 change: 1 addition & 0 deletions genetIC/tests/mapper_test_03a_zoom_linkage/paramfile_a.txt
9 changes: 6 additions & 3 deletions genetIC/tests/run_mapper_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ function runtest {
if [ ! -f $PARAM_B ]; then
PARAM_B=paramfile.txt
fi
#if ID_a.txt exists, use it, otherwise use reference.txt
#if ID_a.txt exists, use it; otherwise, assume we just want to output flags at end of processing paramfile_a
ID_A=ID_a.txt
if [ ! -f $ID_A ]; then
ID_A=reference.txt
echo $IC_mapper $PARAM_A output.txt
$IC_mapper $PARAM_A output.txt > IC_output.txt 2>&1
else
echo $IC_mapper $PARAM_A $PARAM_B $ID_A output.txt
$IC_mapper $PARAM_A $PARAM_B $ID_A output.txt > IC_output.txt 2>&1
fi
time $IC_mapper $PARAM_A $PARAM_B $ID_A output.txt > IC_output.txt 2>&1
if [ $? -ne 0 ]
then
echo "TEST FAILED"
Expand Down

0 comments on commit 793978d

Please sign in to comment.