Skip to content

Commit

Permalink
Merge pull request #2259 from chleh/mfront2
Browse files Browse the repository at this point in the history
Use Solid Material Models from MFront
  • Loading branch information
endJunction authored Nov 12, 2018
2 parents 4e854d0 + ca62b9e commit 5027ab4
Show file tree
Hide file tree
Showing 52 changed files with 3,859 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Applications/CLI/ogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ int main(int argc, char* argv[])
project_arg.getValue(), !nonfatal_arg.getValue(),
"OpenGeoSysProject");

BaseLib::setProjectDirectory(
BaseLib::extractPath(project_arg.getValue()));

ProjectData project(*project_config,
BaseLib::extractPath(project_arg.getValue()),
BaseLib::getProjectDirectory(),
outdir_arg.getValue());

#ifdef USE_INSITU
Expand Down
28 changes: 28 additions & 0 deletions BaseLib/FileTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
#include <sys/stat.h>
#include <boost/algorithm/string.hpp>

namespace
{
/// The directory where the prj file resides.
static std::string project_directory = "";

/// Whether the project directory has already been set.
static bool project_directory_is_set = false;
} // anonymous namespace

namespace BaseLib
{
/**
Expand Down Expand Up @@ -176,4 +185,23 @@ std::string joinPaths(std::string const& pathA, std::string const& pathB)
return appendPathSeparator(pathA) + pathB;
}

std::string const& getProjectDirectory()
{
if (!project_directory_is_set)
{
OGS_FATAL("The project directory has not yet been set.");
}
return project_directory;
}

void setProjectDirectory(std::string const& dir)
{
if (project_directory_is_set)
{
OGS_FATAL("The project directory has already been set.");
}
project_directory = dir;
project_directory_is_set = true;
}

} // end namespace BaseLib
6 changes: 6 additions & 0 deletions BaseLib/FileTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,10 @@ std::string appendPathSeparator(std::string const& path);
*/
std::string joinPaths(std::string const& pathA, std::string const& pathB);

/// Returns the directory where the prj file resides.
std::string const& getProjectDirectory();

/// Sets the project directory.
void setProjectDirectory(std::string const& dir);

} // end namespace BaseLib
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ option(OGS_CHECK_HEADER_COMPILATION "Check header for standalone compilation." O

option(OGS_USE_PYTHON "Interface with Python" OFF)

option(OGS_USE_MFRONT "Enable solid material models by MFront (https://tfel.sourceforge.net)" OFF)

###################
### Definitions ###
###################
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Loads a material model from a shared library that has been created by MFront
with MFront's generic interface.

See http://tfel.sourceforge.net/ https://github.com/thelfer/MFrontGenericInterfaceSupport

This requires MFront 3.2.0 or newer (because of MFront's "generic" interface).

\attention
OpenGeoSys initializes the internal state of the MFront material model to
all-zero. Furthermore, the very first iteration of OpenGeoSys is performed
already at the first load step, i.e., OpenGeoSys does not perform a stress
integration with the IC values. That differs, e.g., from the mtest executable
shipped with MFront, which, initially does a stress integration with the ICs
values. If your model needs such a stress integration step, you must make sure
that you prepend an initial, artificial load step. If you observe convergence
issues during the local stress integration in the very first iteration of
OpenGeoSys, you should consider adding such a load step, in particular if mtest
succeeds to integrate the same load path.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Specifies material properties for the MFront material model.

Each material property defined for the MFront model must be specified here,
no default values are used.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The name of the material property in MFront.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The name of the OGS parameter whose values will be used for this material
property.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sets up one material property.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Name of the behaviour to load.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Path of the shared library containing the material model.

Relative paths are interpreted relative to the project directory.
8 changes: 6 additions & 2 deletions MaterialLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ append_source_files(SOURCES PorousMedium/UnsaturatedProperty/CapillaryPressure)
append_source_files(SOURCES PorousMedium/UnsaturatedProperty/RelativePermeability)
append_source_files(SOURCES TwoPhaseModels)

add_subdirectory(SolidModels/MFront)

add_library(MaterialLib ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS MaterialLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

include(GenerateExportHeader)
generate_export_header(MaterialLib)
target_include_directories(MaterialLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(MaterialLib
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
)

target_link_libraries(MaterialLib
PUBLIC BaseLib NumLib logog # ProcessLib
PUBLIC MaterialLib_SolidModels_MFront # ProcessLib
PRIVATE MathLib MeshLib
)

Expand Down
6 changes: 6 additions & 0 deletions MaterialLib/SolidModels/CreateConstitutiveRelation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "CreateEhlers.h"
#include "CreateLinearElasticIsotropic.h"
#include "CreateLubby2.h"
#include "MFront/CreateMFront.h"

#include "MechanicsBase.h"

Expand Down Expand Up @@ -58,6 +59,11 @@ createConstitutiveRelation(
return MaterialLib::Solids::Creep::createCreepBGRa<DisplacementDim>(
parameters, config);
}
if (type == "MFront")
{
return MaterialLib::Solids::MFront::createMFront<DisplacementDim>(
parameters, config);
}
OGS_FATAL("Cannot construct constitutive relation of given type \'%s\'.",
type.c_str());
}
Expand Down
26 changes: 26 additions & 0 deletions MaterialLib/SolidModels/MFront/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(SOURCES CreateMFront.cpp CreateMFront.h)

if(OGS_USE_MFRONT)
list(APPEND SOURCES MFront.cpp MFront.h)
endif()

add_library(MaterialLib_SolidModels_MFront ${SOURCES})

if(BUILD_SHARED_LIBS)
install(TARGETS MaterialLib_SolidModels_MFront LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

target_link_libraries(MaterialLib_SolidModels_MFront
PUBLIC BaseLib NumLib logog
PRIVATE MathLib MeshLib
)

if (OGS_USE_MFRONT)
target_include_directories(MaterialLib_SolidModels_MFront
PUBLIC ${MGIS_INCLUDE_DIR}
)
target_link_libraries(MaterialLib_SolidModels_MFront
PUBLIC ${MGIS_LIBRARY}
)
target_compile_definitions(MaterialLib_SolidModels_MFront PRIVATE OGS_USE_MFRONT)
endif()
Loading

0 comments on commit 5027ab4

Please sign in to comment.