-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
125 additions
and
633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright 2010-202x held jointly by participating institutions. | ||
ATS is released under the three-clause BSD License. | ||
The terms of use and "as is" disclaimer for this license are | ||
provided in the top-level COPYRIGHT file. | ||
Authors: Ethan Coon ([email protected]) | ||
*/ | ||
|
||
#include "chem_pk_helpers.hh" | ||
#include "Chemistry_PK.hh" | ||
|
||
namespace Amanzi { | ||
|
||
// ----------------------------------------------------------------------------- | ||
// Helper functions for working with Amanzi's Chemistry PK | ||
// ----------------------------------------------------------------------------- | ||
void | ||
convertConcentrationToAmanzi(const Epetra_MultiVector& mol_dens, | ||
int num_aqueous, | ||
const Epetra_MultiVector& tcc_ats, | ||
Epetra_MultiVector& tcc_amanzi) | ||
{ | ||
// convert from mole fraction [mol C / mol H20] to [mol C / L] | ||
for (int k = 0; k != num_aqueous; ++k) { | ||
for (int c = 0; c != tcc_ats.MyLength(); ++c) { | ||
// 1.e-3 converts L to m^3 | ||
tcc_amanzi[k][c] = tcc_ats[k][c] * mol_dens[0][c] * 1.e-3; | ||
} | ||
} | ||
} | ||
|
||
void | ||
convertConcentrationToATS(const Epetra_MultiVector& mol_dens, | ||
int num_aqueous, | ||
const Epetra_MultiVector& tcc_amanzi, | ||
Epetra_MultiVector& tcc_ats) | ||
{ | ||
// convert from [mol C / L] to mol fraction [mol C / mol H20] | ||
for (int k = 0; k != num_aqueous; ++k) { | ||
for (int c = 0; c != tcc_amanzi.MyLength(); ++c) { | ||
tcc_ats[k][c] = tcc_amanzi[k][c] / (mol_dens[0][c] * 1.e-3); | ||
} | ||
} | ||
} | ||
|
||
|
||
bool | ||
advanceChemistry(Teuchos::RCP<AmanziChemistry::Chemistry_PK> chem_pk, | ||
double t_old, | ||
double t_new, | ||
bool reinit, | ||
const Epetra_MultiVector& mol_dens, | ||
Teuchos::RCP<Epetra_MultiVector> tcc, | ||
Teuchos::Time& timer) | ||
{ | ||
bool fail = false; | ||
int num_aqueous = chem_pk->num_aqueous_components(); | ||
convertConcentrationToAmanzi(mol_dens, num_aqueous, *tcc, *tcc); | ||
chem_pk->set_aqueous_components(tcc); | ||
|
||
{ | ||
auto monitor = Teuchos::rcp(new Teuchos::TimeMonitor(timer)); | ||
fail = chem_pk->AdvanceStep(t_old, t_new, reinit); | ||
} | ||
if (fail) return fail; | ||
|
||
*tcc = *chem_pk->aqueous_components(); | ||
convertConcentrationToATS(mol_dens, num_aqueous, *tcc, *tcc); | ||
return fail; | ||
} | ||
|
||
|
||
} // namespace Amanzi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2010-202x held jointly by participating institutions. | ||
ATS is released under the three-clause BSD License. | ||
The terms of use and "as is" disclaimer for this license are | ||
provided in the top-level COPYRIGHT file. | ||
Authors: Ethan Coon ([email protected]) | ||
*/ | ||
|
||
//! A set of helper functions for doing common things in PKs. | ||
#pragma once | ||
|
||
#include "Teuchos_TimeMonitor.hpp" | ||
#include "Epetra_MultiVector.hpp" | ||
|
||
namespace Amanzi { | ||
|
||
namespace AmanziChemistry { | ||
class Chemistry_PK; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// Helper functions for working with Amanzi's Chemistry PK | ||
// ----------------------------------------------------------------------------- | ||
void | ||
convertConcentrationToAmanzi(const Epetra_MultiVector& mol_den, | ||
int num_aqueous, | ||
const Epetra_MultiVector& tcc_ats, | ||
Epetra_MultiVector& tcc_amanzi); | ||
|
||
void | ||
convertConcentrationToATS(const Epetra_MultiVector& mol_den, | ||
int num_aqueous, | ||
const Epetra_MultiVector& tcc_ats, | ||
Epetra_MultiVector& tcc_amanzi); | ||
|
||
bool | ||
advanceChemistry(Teuchos::RCP<AmanziChemistry::Chemistry_PK> chem_pk, | ||
double t_old, | ||
double t_new, | ||
bool reinit, | ||
const Epetra_MultiVector& mol_dens, | ||
Teuchos::RCP<Epetra_MultiVector> tcc, | ||
Teuchos::Time& timer); | ||
|
||
} // namespace Amanzi |
Oops, something went wrong.