Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GeoMechanicsApplication] Phreatic multi line #11184

Merged
merged 35 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cf8b560
Added first implementation of phreatic multi-line
mcgicjn2 Oct 6, 2022
3ba3b05
Updated py:: namespace typo in add_custom_processes_to_python.cpp
mcgicjn2 Jan 31, 2023
1d9a4d8
Removed duplicate addition of python ApplyConstantInterpolateLinePres…
mcgicjn2 Feb 3, 2023
339f17a
Removed duplicate addition of python ApplyBoundaryPhreaticLinePressur…
mcgicjn2 Feb 3, 2023
c55254b
Added tests to phreatic multiline process
mcgicjn2 Feb 7, 2023
348907d
Removed numpy package from test
mcgicjn2 Feb 7, 2023
34c5749
Updated tests effected by changes to test_helper
mcgicjn2 Feb 7, 2023
c9ba5b3
Removed bug indicated by sonarcloud
mcgicjn2 Feb 7, 2023
c3bb406
Removed Bug with empty statement
mcgicjn2 Feb 9, 2023
5f6e4ae
Use `= default` instead of an empty functionbody for destructors
avdg81 Feb 9, 2023
499d13f
Removed some empty statements
avdg81 Feb 9, 2023
3be48d8
Merge remote-tracking branch 'origin/master' into geo/10290-phreatic-…
avdg81 Feb 10, 2023
b2b229c
Renamed several local variables in Python scripts
avdg81 Feb 10, 2023
9563e16
Removed some redundant overridden member functions
avdg81 Feb 10, 2023
840b972
Fixed nearly all remaining code smells
avdg81 Feb 10, 2023
bd145e8
Fixed remaining code smells
avdg81 Feb 14, 2023
6ce1659
Merge branch 'master' into geo/10290-phreatic-multi-line
mcgicjn2 May 25, 2023
1be5e17
Updated Node<3> → Node
mcgicjn2 May 25, 2023
d3c5ccf
Merge remote-tracking branch 'origin' into geo/10290-phreatic-multi-line
avdg81 Aug 17, 2023
51e3bfc
Merge remote-tracking branch 'origin/master' into geo/10290-phreatic-…
avdg81 Aug 23, 2023
a516571
Merge branch 'master' into geo/10290-phreatic-multi-line
rfaasse Oct 9, 2023
f2d38dc
Fix tests after merge with master
rfaasse Oct 9, 2023
6b59fc1
Cleaned up the constant phreatic multi line pressure process
rfaasse Oct 9, 2023
4a0c5af
Cleaned up the phreatic multi line pressure table process
rfaasse Oct 9, 2023
1837530
Remove unnecessary if statement for default parameter
rfaasse Oct 10, 2023
86e4309
Made new classes more consistent with already existing classes and re…
rfaasse Oct 10, 2023
066e206
Merge branch 'master' into geo/10290-phreatic-multi-line
rfaasse Oct 10, 2023
cdab328
Added the multiline processes to the new C++ class for apply scalar c…
rfaasse Oct 10, 2023
413ebde
Cleaned up the tests and reverted some test_helper functionality that…
rfaasse Oct 11, 2023
9f3ccfa
Merge branch 'master' into geo/10290-phreatic-multi-line
rfaasse Oct 13, 2023
49b268d
Removed white space from test file for codacy
mcgicjn2 Oct 18, 2023
cbf5b18
Merge branch 'geo/10290-phreatic-multi-line' of https://github.com/Kr…
mcgicjn2 Oct 18, 2023
7a445ac
Updated test_helper + test issues
mcgicjn2 Oct 18, 2023
b10242e
Removed trailing white spaces
mcgicjn2 Oct 18, 2023
7f69844
Updated test_helper to remove code smells
mcgicjn2 Oct 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
// KRATOS___
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
// // ) )
// // ___ ___
// // ____ //___) ) // ) )
// // / / // // / /
// ((____/ / ((____ ((___/ / MECHANICS
//
// License: geo_mechanics_application/license.txt
//
// Main authors: Vahid Galavi
// Jonathan Nuttall

#if !defined(KRATOS_GEO_APPLY_CONSTANT_PHREATIC_MULTI_LINE_PRESSURE_PROCESS )
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
#define KRATOS_GEO_APPLY_CONSTANT_PHREATIC_MULTI_LINE_PRESSURE_PROCESS

#include <algorithm>
#include "includes/kratos_flags.h"
#include "includes/kratos_parameters.h"
#include "processes/process.h"

#include "geo_mechanics_application_variables.h"

namespace Kratos
{

class ApplyConstantPhreaticMultiLinePressureProcess : public Process
{

public:

KRATOS_CLASS_POINTER_DEFINITION(ApplyConstantPhreaticMultiLinePressureProcess);

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
rfaasse marked this conversation as resolved.
Show resolved Hide resolved

/// Constructor
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
ApplyConstantPhreaticMultiLinePressureProcess(ModelPart& model_part,
Parameters rParameters
) : Process(Flags()) , mrModelPart(model_part)
{
KRATOS_TRY

//only include validation with c++11 since raw_literals do not exist in c++03
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
Parameters default_parameters( R"(
{
"model_part_name":"PLEASE_CHOOSE_MODEL_PART_NAME",
"variable_name": "PLEASE_PRESCRIBE_VARIABLE_NAME",
"is_fixed": false,
"is_seepage": false,
"gravity_direction": 1,
"out_of_plane_direction": 2,
"x_coordinates": [0.0,1.0],
"y_coordinates": [1.0,0.5],
"z_coordinates": [0.0,0.0],
"specific_weight" : 10000.0,
"pressure_tension_cut_off" : 0.0,
"table" : [0,1]
} )" );

// Some values need to be mandatorily prescribed since no meaningful default value exist. For this reason try accessing to them
// So that an error is thrown if they don't exist
rParameters["x_coordinates"];
rParameters["y_coordinates"];
rParameters["z_coordinates"];
rParameters["variable_name"];
rParameters["model_part_name"];

// Now validate agains defaults -- this also ensures no type mismatch
rParameters.ValidateAndAssignDefaults(default_parameters);

mVariableName = rParameters["variable_name"].GetString();
mIsFixed = rParameters["is_fixed"].GetBool();
mIsSeepage = rParameters["is_seepage"].GetBool();
mGravityDirection = rParameters["gravity_direction"].GetInt();
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
mOutOfPlaneDirection = rParameters["out_of_plane_direction"].GetInt();
if (GravityDirection() == OutOfPlaneDirection())
KRATOS_ERROR << "Gravity direction cannot be the same as Out-of-Plane directions"
<< rParameters
<< std::endl;

mHorizontalDirection = 0;
for (unsigned int i=0; i<N_DIM_3D; ++i)
if (i!=GravityDirection() && i != OutOfPlaneDirection()) mHorizontalDirection = i;

mXCoordinates = rParameters["x_coordinates"].GetVector();
mYCoordinates = rParameters["y_coordinates"].GetVector();
mZCoordinates = rParameters["z_coordinates"].GetVector();

if (HorizontalDirection() == 0) {
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
mHorizontalDirectionCoordinates = XCoordinates();
}
else if (HorizontalDirection() == 1)
{
mHorizontalDirectionCoordinates = YCoordinates();
}
else if (HorizontalDirection() == 2)
{
mHorizontalDirectionCoordinates = ZCoordinates();
}

if (GravityDirection() == 0) {
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
mGravityDirectionCoordinates = XCoordinates();
}
else if (GravityDirection() == 1)
{
mGravityDirectionCoordinates = YCoordinates();
}
else if (GravityDirection() == 2)
{
mGravityDirectionCoordinates = ZCoordinates();
}

if (!std::is_sorted(HorizontalDirectionCoordinates().begin(), HorizontalDirectionCoordinates().end()))
{
KRATOS_ERROR << "The Horizontal Elements Coordinates are not ordered."
<< rParameters
<< std::endl;
}

mSpecificWeight = rParameters["specific_weight"].GetDouble();
if (rParameters.Has("pressure_tension_cut_off"))
mPressureTensionCutOff = rParameters["pressure_tension_cut_off"].GetDouble();
else
mPressureTensionCutOff = 0.0;
rfaasse marked this conversation as resolved.
Show resolved Hide resolved

KRATOS_CATCH("")
}

///------------------------------------------------------------------------------------

/// Destructor
~ApplyConstantPhreaticMultiLinePressureProcess() override = default;

/// Assignment operator.
ApplyConstantPhreaticMultiLinePressureProcess& operator=(ApplyConstantPhreaticMultiLinePressureProcess const&) = delete;

/// Copy constructor.
ApplyConstantPhreaticMultiLinePressureProcess(ApplyConstantPhreaticMultiLinePressureProcess const&) = delete;

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/// this function is designed for being called at the beginning of the computations
/// right after reading the model and the groups
void ExecuteInitialize() override
{
KRATOS_TRY

if (mrModelPart.NumberOfNodes() <= 0) {
return;
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
}

const Variable<double> &var = KratosComponents< Variable<double> >::Get(VariableName());

if (IsSeepage()) {
block_for_each(mrModelPart.Nodes(), [&var, this](Node& rNode) {
const double pressure = CalculatePressure(rNode);

if ((PORE_PRESSURE_SIGN_FACTOR * pressure) < 0) {
rNode.FastGetSolutionStepValue(var) = pressure;
if (IsFixed()) rNode.Fix(var);
} else {
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
rNode.Free(var);
}
});
} else {
block_for_each(mrModelPart.Nodes(), [&var, this](Node& rNode) {
if (IsFixed()) rNode.Fix(var);
else rNode.Free(var);
const double pressure = CalculatePressure(rNode);

if ((PORE_PRESSURE_SIGN_FACTOR * pressure) < PressureTensionCutOff()) {
rNode.FastGetSolutionStepValue(var) = pressure;
} else {
rNode.FastGetSolutionStepValue(var) = PressureTensionCutOff();
}
});
}

KRATOS_CATCH("")
}

/// Turn back information as a string.
std::string Info() const override
{
return "ApplyConstantPhreaticMultiLinePressureProcess";
}

/// Print information about this object.
void PrintInfo(std::ostream& rOStream) const override
{
rOStream << "ApplyConstantPhreaticMultiLinePressureProcess";
}

const std::string& VariableName() const
{
return mVariableName;
}

bool IsFixed() const
{
return mIsFixed;
}

bool IsSeepage() const
{
return mIsSeepage;
}

unsigned int GravityDirection() const
{
return mGravityDirection;
}

double SpecificWeight() const
{
return mSpecificWeight;
}

unsigned int OutOfPlaneDirection() const
{
return mOutOfPlaneDirection;
}

unsigned int HorizontalDirection() const
{
return mHorizontalDirection;
}

const Vector& HorizontalDirectionCoordinates() const
{
return mHorizontalDirectionCoordinates;
}

const Vector& GravityDirectionCoordinates() const
{
return mGravityDirectionCoordinates;
}

const Vector& XCoordinates() const
{
return mXCoordinates;
}

const Vector& YCoordinates() const
{
return mYCoordinates;
}

const Vector& ZCoordinates() const
{
return mZCoordinates;
}

double PressureTensionCutOff() const
{
return mPressureTensionCutOff;
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

protected:

/// Member Variables
rfaasse marked this conversation as resolved.
Show resolved Hide resolved

ModelPart& mrModelPart;

int findIndex(const Node& rNode) const
{
int index = 0;
auto coords = rNode.Coordinates();
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
auto noCoordinates = static_cast<int>(HorizontalDirectionCoordinates().size());
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
for ( ; index < noCoordinates; ++index)
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
{
if (HorizontalDirectionCoordinates()[index] >= coords[HorizontalDirection()])
{
if (index == 0)
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
{
return 0;
}
else
{
return index - 1;
}
}
}
return noCoordinates - 1;

}

double CalculatePressure(const Node &rNode) const
{
double height = 0.0;
int firstPointIndex;
int secondPointIndex;
double slope;

// find nodes in horizontalDirectionCoordinates

firstPointIndex = findIndex(rNode);
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
secondPointIndex = firstPointIndex + 1;

slope = (GravityDirectionCoordinates()[secondPointIndex] - GravityDirectionCoordinates()[firstPointIndex]) /
(HorizontalDirectionCoordinates()[secondPointIndex] - HorizontalDirectionCoordinates()[firstPointIndex]);

height = slope * (rNode.Coordinates()[HorizontalDirection()] - HorizontalDirectionCoordinates()[firstPointIndex]) + GravityDirectionCoordinates()[firstPointIndex];

const double distance = height - rNode.Coordinates()[GravityDirection()];
const double pressure = - PORE_PRESSURE_SIGN_FACTOR * SpecificWeight() * distance;
rfaasse marked this conversation as resolved.
Show resolved Hide resolved
return pressure;
}

///----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

private:
std::string mVariableName;
bool mIsFixed;
bool mIsSeepage;
unsigned int mGravityDirection;
double mSpecificWeight;
unsigned int mOutOfPlaneDirection;
unsigned int mHorizontalDirection;
Vector mHorizontalDirectionCoordinates;
Vector mGravityDirectionCoordinates;
Vector mXCoordinates;
Vector mYCoordinates;
Vector mZCoordinates;
double mPressureTensionCutOff;
}; // Class ApplyConstantPhreaticMultiLinePressureProcess

/// input stream function
inline std::istream& operator >> (std::istream& rIStream,
ApplyConstantPhreaticMultiLinePressureProcess& rThis);

/// output stream function
inline std::ostream& operator << (std::ostream& rOStream,
const ApplyConstantPhreaticMultiLinePressureProcess& rThis)
{
rThis.PrintInfo(rOStream);
rOStream << std::endl;
rThis.PrintData(rOStream);

return rOStream;
}

} // namespace Kratos.

#endif /* KRATOS_GEO_APPLY_CONSTANT_PHREATIC_MULTI_LINE_PRESSURE_PROCESS defined */
Loading
Loading