-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for source terms to cells from particles. (#520)
* particle clang-tidy cleanup * working on coupled particle solver * first draft of coupled particle solver * changed the coupling to be prestep * prototype code * added test for coupled particles * working with the api changes * adding more fields to the test * updated for vol mass matrix in FVM field * added restart test * version bump
- Loading branch information
Showing
42 changed files
with
1,248 additions
and
69 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
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 |
---|---|---|
|
@@ -8,4 +8,5 @@ target_sources(ablateLibrary | |
swarmAccessor.hpp | ||
rhsAccessor.hpp | ||
eulerianAccessor.hpp | ||
eulerianSourceAccessor.hpp | ||
) |
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
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,62 @@ | ||
#ifndef ABLATELIBRARY_EULERIANSOURCEACCESSOR_HPP | ||
#define ABLATELIBRARY_EULERIANSOURCEACCESSOR_HPP | ||
|
||
#include <petsc.h> | ||
#include <map> | ||
#include "accessor.hpp" | ||
#include "domain/subDomain.hpp" | ||
#include "particles/field.hpp" | ||
#include "swarmAccessor.hpp" | ||
#include "utilities/petscUtilities.hpp" | ||
|
||
namespace ablate::particles::accessors { | ||
/** | ||
* Allows pushing source terms to the particle source array based upon variable/component name. | ||
* The coupled solver is used to push back to the flow field ts | ||
*/ | ||
class EulerianSourceAccessor : public Accessor<PetscReal> { | ||
public: | ||
// A string to hold the coupled source terms name | ||
inline static const char CoupledSourceTermPostfix[] = "_CoupledSourceTerm"; | ||
|
||
private: | ||
//! borrowed reference to | ||
const DM& swarmDm; | ||
|
||
//! a map of fields for easy field lookup | ||
const std::map<std::string, Field>& fieldsMap; | ||
|
||
public: | ||
EulerianSourceAccessor(bool cachePointData, const DM& swarmDm, const std::map<std::string, Field>& fieldsMap) : Accessor(cachePointData), swarmDm(swarmDm), fieldsMap(fieldsMap) {} | ||
|
||
/** | ||
* Create point data from the source field in the DM | ||
* @param fieldName | ||
* @return | ||
*/ | ||
PointData CreateData(const std::string& fieldName) override { | ||
const auto& field = fieldsMap.at(fieldName + CoupledSourceTermPostfix); | ||
if (field.location == domain::FieldLocation::SOL) { | ||
throw std::invalid_argument("Eulerian Source Fields should not be SOL fields"); | ||
} else { | ||
// get the field from the dm | ||
PetscScalar* values; | ||
DMSwarmGetField(swarmDm, field.name.c_str(), nullptr, nullptr, (void**)&values) >> utilities::PetscUtilities::checkError; | ||
|
||
// Register the cleanup | ||
RegisterCleanupFunction([=]() { | ||
const std::string name = field.name; | ||
DMSwarmRestoreField(swarmDm, name.c_str(), nullptr, nullptr, (void**)&values) >> utilities::PetscUtilities::checkError; | ||
}); | ||
|
||
return {values, field}; | ||
} | ||
} | ||
|
||
/** | ||
* prevent copy of this class | ||
*/ | ||
EulerianSourceAccessor(const EulerianSourceAccessor&) = delete; | ||
}; | ||
} // namespace ablate::particles::accessors | ||
#endif // ABLATELIBRARY_EULERIANSOURCEACCESSOR_HPP |
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
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
Oops, something went wrong.