Skip to content

Commit

Permalink
attempt to fix linking (happening when constructing gsMaterialMatrixL…
Browse files Browse the repository at this point in the history
…inear inside a cpp file):

- Make includes in gsMaterialMatrix-classes more uniform
- Move XML reads/writes for material matrices (gives problems!! where to put them)

Breaking change:
- Changed getMaterialMatrix to uPtr to prevent user-deletion
  • Loading branch information
hverhelst committed Nov 23, 2024
1 parent 7ddfe49 commit cd05720
Show file tree
Hide file tree
Showing 41 changed files with 1,137 additions and 2,648 deletions.
11 changes: 5 additions & 6 deletions examples/example_parametric_panel.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @file example_example_parametrix_panel.cpp
@brief Provides a simple example for multi-patch shell analysis
@brief Provides a simple example for multi-patch shell analysis
using the penalty method.
The example allows the user to set the dimensions alpha and beta
The example allows the user to set the dimensions alpha and beta
of the panel. The panel is always a square fixed on the sides, with
a distributed pressure. The following setups are available:
Testcase 0: 1p panel - for testing purposes
Expand Down Expand Up @@ -296,12 +296,12 @@ int main(int argc, char *argv[])

//! [Make assembler]
std::vector<gsFunctionSet<>*> parameters;
gsMaterialMatrixBase<real_t>* materialMatrix;
gsMaterialMatrixBase<real_t>::uPtr materialMatrix;
gsOptionList options;
// Make gsMaterialMatrix depending on the user-defined choices
if (composite)
{
materialMatrix = new gsMaterialMatrixComposite<3,real_t>(mp,Ts,Gs,Phis);
materialMatrix = gsMaterialMatrixBase<real_t>::uPtr(new gsMaterialMatrixComposite<3,real_t>(mp,Ts,Gs,Phis));
}
else
{
Expand All @@ -315,7 +315,7 @@ int main(int argc, char *argv[])

gsMaterialMatrixContainer<real_t> materialMats(mp.nPatches());
for (size_t p = 0; p!=mp.nPatches(); p++)
materialMats.add(materialMatrix);
materialMats.add(*materialMatrix);

// Construct the gsThinShellAssembler
gsThinShellAssemblerBase<real_t>* assembler;
Expand Down Expand Up @@ -461,7 +461,6 @@ int main(int argc, char *argv[])
gsInfo<<"Total ellapsed solution time (incl. assembly): \t"<<totaltime<<" s\n";

delete assembler;
delete materialMatrix;
return EXIT_SUCCESS;

}// end main
Expand Down
17 changes: 12 additions & 5 deletions examples/example_shell2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
*/

#include <gismo.h>
#include <gsKLShell/gsKLShell.h>
// #include <gsKLShell/gsKLShell.h>
#include <gsKLShell/src/gsMaterialMatrixLinear.h>
#include <gsKLShell/src/gsMaterialMatrixTFT.h>
#include <gsKLShell/src/getMaterialMatrix.h>
#include <gsKLShell/src/gsThinShellAssembler.h>

using namespace gismo;

Expand Down Expand Up @@ -339,15 +343,15 @@ int main(int argc, char *argv[])
//! [Make material functions]

//! [Make assembler]
gsMaterialMatrixBase<real_t>* materialMatrix;
gsMaterialMatrixBase<real_t>* materialMatrixTFT;
gsMaterialMatrixBase<real_t>::uPtr materialMatrix;
gsMaterialMatrixBase<real_t>::uPtr materialMatrixTFT;
gsOptionList options;
// Make gsMaterialMatrix depending on the user-defined choices
if (material==0) //Linear
{
if (composite) // Composite
{
materialMatrix = new gsMaterialMatrixComposite<2,real_t>(mp,Ts,Gs,Phis);
materialMatrix = gsMaterialMatrixBase<real_t>::uPtr(new gsMaterialMatrixComposite<2,real_t>(mp,Ts,Gs,Phis));
}
else
{
Expand All @@ -365,9 +369,12 @@ int main(int argc, char *argv[])
}

materialMatrix->options().setInt("TensionField",0);
materialMatrixTFT = new gsMaterialMatrixTFT<2,real_t,false>(materialMatrix);
// materialMatrixTFT = memory::make_unique(new gsMaterialMatrixTFT<2,real_t,false>(materialMatrix));
gsMaterialMatrixTFT<2,real_t,false> materialMatrixTFT2(materialMatrix.get());
// materialMatrixTFT->options().setReal("SlackMultiplier",1e-1);

gsMaterialMatrixLinear<2,real_t> materialMatrixLinear2(mp,t,E,nu,rho);

// Construct the gsThinShellAssembler
gsThinShellAssemblerBase<real_t>* assembler;
if (TFT)
Expand Down
7 changes: 3 additions & 4 deletions examples/example_shell3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,12 @@ int main(int argc, char *argv[])

//! [Make assembler]
std::vector<gsFunctionSet<>*> parameters;
gsMaterialMatrixBase<real_t>* materialMatrix;
gsMaterialMatrixBase<real_t>::uPtr materialMatrix;
gsOptionList options;
// Make gsMaterialMatrix depending on the user-defined choices
if (composite)
{
materialMatrix = new gsMaterialMatrixComposite<3,real_t>(mp,Ts,Gs,Phis);
materialMatrix = memory::make_unique(new gsMaterialMatrixComposite<3,real_t>(mp,Ts,Gs,Phis));
}
else
{
Expand All @@ -475,7 +475,7 @@ int main(int argc, char *argv[])

gsMaterialMatrixContainer<real_t> materialMats(mp.nPatches());
for (size_t p = 0; p!=mp.nPatches(); p++)
materialMats.add(materialMatrix);
materialMats.add(materialMatrix.get());

// Construct the gsThinShellAssembler
gsThinShellAssemblerBase<real_t>* assembler;
Expand Down Expand Up @@ -637,7 +637,6 @@ int main(int argc, char *argv[])
gsInfo<<"Total ellapsed solution time (incl. assembly): \t"<<totaltime<<" s\n";

delete assembler;
delete materialMatrix;
return EXIT_SUCCESS;

}// end main
Expand Down
3 changes: 1 addition & 2 deletions examples/example_shell3D_DWR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ int main(int argc, char *argv[])
std::vector<gsFunctionSet<>*> parameters(2);
parameters[0] = &E;
parameters[1] = &nu;
gsMaterialMatrixBase<real_t>* materialMatrix;
gsMaterialMatrixBase<real_t>::uPtr materialMatrix;
gsOptionList options;
options.addInt("Material","Material model: (0): SvK | (1): NH | (2): NH_ext | (3): MR | (4): Ogden",0);
options.addInt("Implementation","Implementation: (0): Composites | (1): Analytical | (2): Generalized | (3): Spectral",1);
Expand Down Expand Up @@ -660,7 +660,6 @@ int main(int argc, char *argv[])
}


delete materialMatrix;
return EXIT_SUCCESS;

}// end main
7 changes: 3 additions & 4 deletions examples/example_shell3D_DWR_buckling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ int main(int argc, char *argv[])
}
}
std::sort(gammas_an.begin(),gammas_an.end());

gammas_num = std::vector<real_t>{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

lambda_an = gammas_an[modeIdx] / (Load);
Expand All @@ -283,7 +283,7 @@ int main(int argc, char *argv[])
std::vector<gsFunctionSet<> *> parameters(2);
parameters[0] = &E;
parameters[1] = &nu;
gsMaterialMatrixBase<real_t> *materialMatrix;
gsMaterialMatrixBase<real_t>::uPtr materialMatrix;
gsOptionList options;
options.addInt("Material", "Material model: (0): SvK | (1): NH | (2): NH_ext | (3): MR | (4): Ogden", 0);
options.addInt("Implementation", "Implementation: (0): Composites | (1): Analytical | (2): Generalized | (3): Spectral", 1);
Expand Down Expand Up @@ -470,7 +470,7 @@ int main(int argc, char *argv[])
else if (solverH.info()==Spectra::CompInfo::NotConverging) { GISMO_ERROR("Spectra did not converge! Error code: NotConverging"); }
else if (solverH.info()==Spectra::CompInfo::NotComputed) { GISMO_ERROR("Spectra did not converge! Error code: NotComputed"); }
else { GISMO_ERROR("No error code known"); }
#else
#else
gsEigen::GeneralizedSelfAdjointEigenSolver< typename gsMatrix<>::Base > solverH;
solverH.compute(Kdiff,K_L);
#endif
Expand Down Expand Up @@ -613,7 +613,6 @@ int main(int argc, char *argv[])
gsWriteParaview<>( fieldPL, "primalL", 1000);
}

delete materialMatrix;
return EXIT_SUCCESS;

} // end main
Expand Down
2 changes: 1 addition & 1 deletion examples/example_shell3D_DWR_modal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ int main(int argc, char *argv[])
std::vector<gsFunctionSet<> *> parameters(2);
parameters[0] = &E;
parameters[1] = &nu;
gsMaterialMatrixBase<real_t> *materialMatrix;
gsMaterialMatrixBase<real_t>::uPtr materialMatrix;
gsOptionList options;
options.addInt("Material", "Material model: (0): SvK | (1): NH | (2): NH_ext | (3): MR | (4): Ogden", 0);
options.addInt("Implementation", "Implementation: (0): Composites | (1): Analytical | (2): Generalized | (3): Spectral", 1);
Expand Down
2 changes: 1 addition & 1 deletion examples/gsMaterialMatrix_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main (int argc, char** argv)
else
GISMO_ERROR("Material unknown");

gsMaterialMatrixBase<real_t>* materialMatrix;
gsMaterialMatrixBase<real_t>::uPtr materialMatrix;
gsOptionList options;
options.addInt("Material","Material model: (0): SvK | (1): NH | (2): NH_ext | (3): MR | (4): Ogden",material);
options.addSwitch("Compressibility","Compressibility: (false): Imcompressible | (true): Compressible",Compressibility);
Expand Down
Loading

0 comments on commit cd05720

Please sign in to comment.