Skip to content

Commit

Permalink
[PL] Time dependency for the flux calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomFischer committed May 30, 2018
1 parent 3f11cb8 commit a823565
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 21 deletions.
3 changes: 2 additions & 1 deletion ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ CalculateSurfaceFlux::CalculateSurfaceFlux(

void CalculateSurfaceFlux::integrate(GlobalVector const& x,
MeshLib::PropertyVector<double>& balance,
double const t,
Process const& bulk_process)
{
DBUG("Integrate CalculateSurfaceFlux.");

GlobalExecutor::executeMemberOnDereferenced(
&CalculateSurfaceFluxLocalAssemblerInterface::integrate,
_local_assemblers, x, balance, bulk_process);
_local_assemblers, x, balance, t, bulk_process);
}

} // namespace ProcessLib
2 changes: 2 additions & 0 deletions ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class CalculateSurfaceFlux final
/// Executes for each element of the mesh the local intergration procedure.
/// @param x The global solution the intergration values will be fetched of.
/// @param balance The vector the integration results will be stored in.
/// @param t The balance will be computed at the time t.
/// @param bulk_process Stores the variable that is used for the
/// integration.
void integrate(GlobalVector const& x,
MeshLib::PropertyVector<double>& balance,
double const t,
Process const& bulk_process);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CalculateSurfaceFluxLocalAssemblerInterface
virtual void integrate(std::size_t element_id,
GlobalVector const& x,
MeshLib::PropertyVector<double>& balance,
double const t,
Process const& bulk_process) = 0;
};

Expand Down Expand Up @@ -106,6 +107,7 @@ class CalculateSurfaceFluxLocalAssembler final
void integrate(std::size_t element_id,
GlobalVector const& x,
MeshLib::PropertyVector<double>& balance,
double const t,
Process const& bulk_process) override
{
auto surface_element_normal =
Expand All @@ -126,8 +128,8 @@ class CalculateSurfaceFluxLocalAssembler final

auto const bulk_element_point = MeshLib::getBulkElementPoint(
bulk_process.getMesh(), _bulk_element_id, _bulk_face_id, wp);
auto const bulk_flux =
bulk_process.getFlux(_bulk_element_id, bulk_element_point, x);
auto const bulk_flux = bulk_process.getFlux(
_bulk_element_id, bulk_element_point, t, x);

for (int component_id(0);
component_id < balance.getNumberOfComponents();
Expand Down
9 changes: 3 additions & 6 deletions ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ class LocalAssemblerData : public GroundwaterFlowLocalAssemblerInterface

/// Computes the flux in the point \c p_local_coords that is given in local
/// coordinates using the values from \c local_x.
// TODO add time dependency
Eigen::Vector3d getFlux(
MathLib::Point3d const& p_local_coords,
std::vector<double> const& local_x) const override
Eigen::Vector3d getFlux(MathLib::Point3d const& p_local_coords,
double const t,
std::vector<double> const& local_x) const override
{
// eval dNdx and invJ at p
using FemType =
Expand All @@ -127,8 +126,6 @@ class LocalAssemblerData : public GroundwaterFlowLocalAssemblerInterface
// fetch hydraulic conductivity
SpatialPosition pos;
pos.setElementID(_element.getID());
// TODO remove follwing line if time dependency is implemented
double const t = 0.0;
auto const k = _process_data.hydraulic_conductivity(t, pos)[0];

Eigen::Vector3d flux;
Expand Down
11 changes: 6 additions & 5 deletions ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,21 @@ class GroundwaterFlowProcess final : public Process
//! @}

Eigen::Vector3d getFlux(std::size_t element_id,
MathLib::Point3d const& p,
GlobalVector const& x) const override
MathLib::Point3d const& p,
double const t,
GlobalVector const& x) const override
{
// fetch local_x from primary variable
std::vector<GlobalIndexType> indices_cache;
auto const r_c_indices = NumLib::getRowColumnIndices(
element_id, *_local_to_global_index_map, indices_cache);
std::vector<double> local_x(x.get(r_c_indices.rows));

return _local_assemblers[element_id]->getFlux(p, local_x);
return _local_assemblers[element_id]->getFlux(p, t, local_x);
}

void postTimestepConcreteProcess(GlobalVector const& x,
const double /*t*/,
const double t,
const double /*delta_t*/,
int const process_id) override
{
Expand Down Expand Up @@ -89,7 +90,7 @@ class GroundwaterFlowProcess final : public Process
_balance_mesh->getProperties()
.template getPropertyVector<double>(_balance_pv_name);

balance.integrate(x, *balance_pv, *this);
balance.integrate(x, *balance_pv, t, *this);
// post: surface_mesh has vectorial element property

// TODO output, if output classes are ready this has to be
Expand Down
4 changes: 1 addition & 3 deletions ProcessLib/HT/HTFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class HTFEM : public HTLocalAssemblerInterface

/// Computes the flux in the point \c pnt_local_coords that is given in
/// local coordinates using the values from \c local_x.
// TODO add time dependency
Eigen::Vector3d getFlux(
MathLib::Point3d const& pnt_local_coords,
double const t,
std::vector<double> const& local_x) const override
{
// eval dNdx and invJ at given point
Expand Down Expand Up @@ -123,8 +123,6 @@ class HTFEM : public HTLocalAssemblerInterface
vars[static_cast<int>(
MaterialLib::Fluid::PropertyVariableType::p)]);

// TODO remove following line if time dependency is implemented
double const t = 0.0;
auto const K =
this->_material_properties.porous_media_properties
.getIntrinsicPermeability(t, pos)
Expand Down
1 change: 1 addition & 0 deletions ProcessLib/HT/HTLocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class HTLocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,

virtual Eigen::Vector3d getFlux(
MathLib::Point3d const& pnt_local_coords,
double const t,
std::vector<double> const& local_x) const = 0;

protected:
Expand Down
5 changes: 3 additions & 2 deletions ProcessLib/HT/HTProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void HTProcess::setCoupledSolutionsOfPreviousTimeStep()

Eigen::Vector3d HTProcess::getFlux(std::size_t element_id,
MathLib::Point3d const& p,
double const t,
GlobalVector const& x) const
{
// fetch local_x from primary variable
Expand All @@ -250,7 +251,7 @@ Eigen::Vector3d HTProcess::getFlux(std::size_t element_id,
element_id, *_local_to_global_index_map, indices_cache);
std::vector<double> local_x(x.get(r_c_indices.rows));

return _local_assemblers[element_id]->getFlux(p, local_x);
return _local_assemblers[element_id]->getFlux(p, t, local_x);
}

// this is almost a copy of the implemention in the GroundwaterFlow
Expand Down Expand Up @@ -284,7 +285,7 @@ void HTProcess::postTimestepConcreteProcess(GlobalVector const& x,
getProcessVariables(process_id)[0].get().getNumberOfComponents(),
_integration_order);

balance.integrate(x, *balance_pv, *this);
balance.integrate(x, *balance_pv, t, *this);
// post: surface_mesh has scalar element property

// TODO output, if output classes are ready this has to be
Expand Down
5 changes: 3 additions & 2 deletions ProcessLib/HT/HTProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class HTProcess final : public Process
//! @}

Eigen::Vector3d getFlux(std::size_t element_id,
MathLib::Point3d const& p,
GlobalVector const& x) const override;
MathLib::Point3d const& p,
double const t,
GlobalVector const& x) const override;

void setCoupledTermForTheStaggeredSchemeToLocalAssemblers() override;

Expand Down
1 change: 1 addition & 0 deletions ProcessLib/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class LocalAssemblerInterface
/// coordinates using the values from \c local_x.
virtual Eigen::Vector3d getFlux(
MathLib::Point3d const& /*p_local_coords*/,
double const /*t*/,
std::vector<double> const& /*local_x*/) const
{
return Eigen::Vector3d{};
Expand Down
1 change: 1 addition & 0 deletions ProcessLib/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class Process

virtual Eigen::Vector3d getFlux(std::size_t /*element_id*/,
MathLib::Point3d const& /*p*/,
double const /*t*/,
GlobalVector const& /*x*/) const
{
return Eigen::Vector3d{};
Expand Down

0 comments on commit a823565

Please sign in to comment.