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

Add functionality for volumetric coupling of material models #118

Draft
wants to merge 41 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
dc01332
Updates for macro-micro call
kalupaika Jan 17, 2024
6ce3ef1
Merge branch 'develop' into multiscale-update
IshaanDesai Apr 1, 2024
7e1c1b7
Reintroduce parts that seemed to be deleted unintentionally
IshaanDesai Apr 1, 2024
342df26
Formatting
IshaanDesai Apr 1, 2024
8521dfe
Merge branch 'precice:develop' into multiscale-update
kalupaika Apr 10, 2024
c70bb78
volumetric coupling update
kalupaika Apr 17, 2024
32fc350
Revert .gitignore because make clean takes care of it, and move examp…
IshaanDesai Jul 11, 2024
33d08a6
Revert to CalculiX 2.20, because the adapter only works with this ver…
IshaanDesai Jul 11, 2024
355cdd4
Revert CalculiX header file to 2.20
IshaanDesai Jul 11, 2024
f23833d
Remove unnecessary files which resulted from duplication
IshaanDesai Jul 11, 2024
6329a47
Revert files which only had size change
IshaanDesai Jul 11, 2024
a9a0127
Adding necessary definitions in Fortran part, and code formatting
IshaanDesai Jul 12, 2024
54bf8cb
Formatting .c files
IshaanDesai Jul 12, 2024
fcf72c9
Put old things back into CCXHelpers.c
IshaanDesai Aug 7, 2024
b932313
Compile with nonlingeo_precice.c and formatting
IshaanDesai Aug 7, 2024
1c3febc
Revert nonlingeo_precice.c to old state
IshaanDesai Aug 7, 2024
cde18e9
Re-add functions which read and write modal checkpoints
IshaanDesai Aug 7, 2024
0c32ca5
Apply clang-format to linstatic_precice.c
IshaanDesai Aug 7, 2024
cef5846
Revert Makefile to older state
IshaanDesai Aug 7, 2024
9552f6a
First compiling version
IshaanDesai Aug 8, 2024
06be8bb
Add call to linstatic_precice to ccx_2.20.c
IshaanDesai Aug 8, 2024
c3c8b46
Add functionality to write variables rve_id, mod_id, and ruc_size to …
IshaanDesai Aug 14, 2024
a56a7cf
Handle pointers to strain and stress data consistently in the linear …
IshaanDesai Aug 15, 2024
38fa1b8
Trying to get gauss point coorindates from the FORTRAN side
IshaanDesai Aug 19, 2024
7dc1468
Working version of the subroutine getelementgausspointcoords.f and re…
IshaanDesai Aug 22, 2024
b36a968
Working version for a linear static problem
IshaanDesai Nov 5, 2024
bfc0f58
Remove debugging print statements
IshaanDesai Nov 6, 2024
3755875
Revert to older clang-format to test things
IshaanDesai Nov 6, 2024
fdf8be0
Remove print statement at the end of freeing data, and formatting
IshaanDesai Nov 6, 2024
020c9d0
Merge branch 'develop' into multiscale-update
IshaanDesai Nov 7, 2024
55319c3
Merge branch 'develop' into multiscale-update
IshaanDesai Nov 7, 2024
9b7bdb4
Fix error in getting Gauss point coordinates for C3D8 elements
IshaanDesai Nov 18, 2024
afde186
Remove old 2D-3D mapping functions that were added by mistake
IshaanDesai Nov 18, 2024
af14bb4
Cleaning up functions which may have been remnants of resolving merge…
IshaanDesai Nov 18, 2024
6aa96aa
Further reverting of unnecesarily pushed changes
IshaanDesai Nov 18, 2024
1229dea
Add the file getgausspointscoords.f again
IshaanDesai Nov 18, 2024
49f880b
Adding back functions which were deleted unintentionally
IshaanDesai Nov 18, 2024
a5d92b8
Revert more inadvertantly done changes
IshaanDesai Nov 18, 2024
3784b38
Reverting some unnuecessary changes in the preCICE Interface functions
IshaanDesai Nov 18, 2024
6e405ea
Remove print statements for debugging
IshaanDesai Nov 19, 2024
69bbeb0
Merge branch 'develop' into multiscale-update
IshaanDesai Nov 19, 2024
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
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ LIBS = \
#CFLAGS = -g -Wall -std=c++11 -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE
#FFLAGS = -g -Wall -O0 -fopenmp $(INCLUDES)

CFLAGS = -Wall -O3 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT
CFLAGS = -Wall -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT -fbounds-check -g

# OS-specific options
UNAME_S := $(shell uname -s)
Expand All @@ -62,7 +62,7 @@ else
CC = mpicc
endif

FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS}
FFLAGS = -Wall -O0 -fopenmp $(INCLUDES) ${ADDITIONAL_FFLAGS} -fallow-argument-mismatch -fbounds-check -g
# Note for GCC 10 or newer: add -fallow-argument-mismatch in the above flags
FC = mpifort
# FC = mpif90
Expand All @@ -73,10 +73,8 @@ include $(CCX)/Makefile.inc
SCCXMAIN = ccx_$(CCX_VERSION).c

# Append additional sources
SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c
SCCXF += getflux.f getkdeltatemp.f


SCCXC += nonlingeo_precice.c dyna_precice.c CCXHelpers.c PreciceInterface.c linstatic_precice.c
SCCXF += getflux.f getkdeltatemp.f getc3d8elementgausspointcoords.f multiscale_routines.f

# Source files in this folder and in the adapter directory
$(OBJDIR)/%.o : %.c
Expand Down Expand Up @@ -104,7 +102,7 @@ OCCXC += $(OBJDIR)/ConfigReader.o $(OBJDIR)/2D3DCoupling.o $(OBJDIR)/OutputBuffe


$(OBJDIR)/ccx_preCICE: $(OBJDIR) $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a
$(FC) -fopenmp -Wall -O3 -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a $(LIBS)
$(FC) -fopenmp -Wall -O0 -g -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_$(CCX_VERSION).a $(LIBS)

$(OBJDIR)/ccx_$(CCX_VERSION).a: $(OCCXF) $(OCCXC)
ar vr $@ $?
Expand Down
54 changes: 45 additions & 9 deletions adapter/CCXHelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ void getSurfaceElementsAndFaces(ITG setID, ITG *ialset, ITG *istartset, ITG *ien
}
}

void getElementsIDs(ITG setID, ITG *ialset, ITG *istartset, ITG *iendset, ITG *elements)
{

ITG i, k = 0;

for (i = istartset[setID] - 1; i < iendset[setID]; i++) {
elements[k] = ialset[i];
k++;
}
}

void getNodeCoordinates(ITG *nodes, ITG numNodes, int dim, double *co, double *v, int mt, double *coordinates)
{

Expand Down Expand Up @@ -265,7 +276,7 @@ void getXloadIndices(char const *loadType, ITG *elementIDs, ITG *faceIDs, ITG nu
char faceLabel[] = {'x', 'x', '\0'};

/* Face number is prefixed with 'S' if it is DFLUX boundary condition
* and with 'F' if it is a FILM boundary condition */
* and with 'F' if it is a FILM boundary condition */
if (strcmp(loadType, "DFLUX") == 0) {
faceLabel[0] = (char) 'S';
} else if (strcmp(loadType, "FILM") == 0) {
Expand Down Expand Up @@ -355,22 +366,22 @@ void getXforcIndices(ITG *nodes, ITG numNodes, int nforc, int *ikforc, int *ilfo
ITG i;

for (i = 0; i < numNodes; i++) {
// x-direction
//x-direction
int idof = 8 * (nodes[i] - 1) + 1; // 1 for x force DOF
int k;
FORTRAN(nident, (ikforc, &idof, &nforc, &k));
k -= 1; // Adjust because of FORTRAN indices
int m = ilforc[k] - 1; // Adjust because of FORTRAN indices
xforcIndices[3 * i] = m;

// y-direction
//y-direction
idof = 8 * (nodes[i] - 1) + 2; // 2 for y force DOF
FORTRAN(nident, (ikforc, &idof, &nforc, &k));
k -= 1; // Adjust because of FORTRAN indices
m = ilforc[k] - 1; // Adjust because of FORTRAN indices
xforcIndices[3 * i + 1] = m;

// z-direction
//z-direction
idof = 8 * (nodes[i] - 1) + 3; // 3 for z force DOF
FORTRAN(nident, (ikforc, &idof, &nforc, &k));
k -= 1; // Adjust because of FORTRAN indices
Expand All @@ -389,11 +400,11 @@ void getXforcIndices(ITG *nodes, ITG numNodes, int nforc, int *ikforc, int *ilfo
int getXloadIndexOffset(enum xloadVariable xloadVar)
{
/*
* xload is the CalculiX array where the DFLUX and FILM boundary conditions are stored
* the array has two components:
* - the first component corresponds to the flux value and the heat transfer coefficient
* - the second component corresponds to the sink temperature
* */
* xload is the CalculiX array where the DFLUX and FILM boundary conditions are stored
* the array has two components:
* - the first component corresponds to the flux value and the heat transfer coefficient
* - the second component corresponds to the sink temperature
* */
switch (xloadVar) {
case DFLUX:
return 0;
Expand All @@ -409,6 +420,20 @@ int getXloadIndexOffset(enum xloadVariable xloadVar)
}
}

void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData)
{
int i, count, idx;
// Loop through all element and respective gauss points
count = 0;
for (i = 0; i < mi[0] * nelem; i++) {
idx = i * 6 + strainIdx;
strainData[count] = eei[idx];
strainData[count + 1] = eei[idx + 1];
strainData[count + 2] = eei[idx + 2];
count = count + 3;
}
}

void setXload(double *xload, int *xloadIndices, double *values, int numValues, enum xloadVariable xloadVar)
{
ITG i;
Expand Down Expand Up @@ -512,6 +537,17 @@ bool isQuasi2D3D(const int quasi2D3D)
return quasi2D3D == 1;
}

void setDoubleArrayZero(double *values, const int length, const int dim)
{
ITG i, j;

for (i = 0; i < length; i++) {
for (j = 0; j < dim; j++) {
values[i * dim + j] = 0.0;
}
}
}

/* Errors messages */

void nodeSetNotFoundError(char const *setName)
Expand Down
48 changes: 37 additions & 11 deletions adapter/CCXHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,23 @@ enum CouplingDataType { TEMPERATURE,
DISPLACEMENTS,
DISPLACEMENTDELTAS,
VELOCITIES,
POSITIONS };

/**
* @brief Type of element used for faces mesh, where we assume only one type of element is used.
* TETRAHEDRA - C3D4 or C3D10 element
* HEXAHEDRA - C3D8 or C3D20 elment
* INVALID_ELEMENT - Anything else
*/
enum ElemType { TETRAHEDRA,
HEXAHEDRA,
INVALID_ELEMENT,
POSITIONS,
MACRO_IP_ID,
RVE_ID,
MOD_ID,
RUC_SIZE,
CONV_FLAG,
STRAIN1TO3,
STRAIN4TO6,
STRESS1TO3,
STRESS4TO6,
CMAT1,
CMAT2,
CMAT3,
CMAT4,
CMAT5,
CMAT6,
CMAT7,
};

/**
Expand Down Expand Up @@ -102,6 +108,16 @@ ITG getNumSetElements(ITG setID, ITG *istartset, ITG *iendset);
*/
void getSurfaceElementsAndFaces(ITG setID, ITG *ialset, ITG *istartset, ITG *iendset, ITG *elements, ITG *faces);

/**
* @brief Gets the element IDs given a set ID
* @param setID: input set id
* @param ialset: CalculiX variable
* @param istartset: CalculiX variable
* @param iendset: CalculiX variable
* @param elements: output element IDs
*/
void getElementsIDs(ITG setID, ITG *ialset, ITG *istartset, ITG *iendset, ITG *elements);

/**
* @brief Gets the coordinates of a list of input node IDs
* @param nodes: input node IDs
Expand Down Expand Up @@ -241,6 +257,16 @@ void getXbounIndices(ITG *nodes, ITG numNodes, int nboun, int *ikboun, int *ilbo
*/
void getXforcIndices(ITG *nodes, ITG numNodes, int nforc, int *ikforc, int *ilforc, int *xforcIndices);

/**
* @brief Gets the strain values at each Gauss point of each element
* @param strainIdx: CalculiX variable for the index of the strain values
* @param mi: CalculiX variable for the number of integration points
* @param nelem: CalculiX variable for the number of elements
* @param eei: CalculiX array for the element integration information
* @param strainData: CalculiX array for the strain values
*/
void getElementStrain(int strainIdx, int *mi, int nelem, double *eei, double *strainData);

/**
* @brief Modifies the values of a DFLUX or FILM boundary condition
* @param xload: CalculiX array for the loads
Expand Down
4 changes: 4 additions & 0 deletions adapter/ConfigReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ void ConfigReader_Read(char const *configFilename, char const *participantName,
interface.facesMeshName = strdup(config["participants"][participantName]["interfaces"][i]["mesh"].as<std::string>().c_str());
}

if (config["participants"][participantName]["interfaces"][i]["elements"]) {
interface.elementsMeshName = strdup(config["participants"][participantName]["interfaces"][i]["elements"].as<std::string>().c_str());
}

std::string patchName = config["participants"][participantName]["interfaces"][i]["patch"].as<std::string>();
std::transform(patchName.begin(), patchName.end(), patchName.begin(), toupper);
interface.patchName = strdup(patchName.c_str());
Expand Down
1 change: 1 addition & 0 deletions adapter/ConfigReader.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
typedef struct InterfaceConfig {
char * facesMeshName;
char * nodesMeshName;
char * elementsMeshName;
char * patchName;
int map;
int numWriteData;
Expand Down
Loading