v0.14.0
Functions | Variables
wavy_surface.cpp File Reference
#include <MoFEM.hpp>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Variables

static char help [] = "...\n\n"
 
static int debug = 1
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)
Examples
wavy_surface.cpp.

Definition at line 32 of file wavy_surface.cpp.

32  {
33 
34  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
35 
36  try {
37 
38  moab::Core mb_instance;
39  moab::Interface &moab = mb_instance;
40  int rank;
41  MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
42 
43  // Read parameters from line command
44  PetscBool flg_mesh_file = PETSC_TRUE;
45  PetscBool flg_out_file = PETSC_TRUE;
46  char mesh_file_name[255];
47  char out_file_name[255] = "out.h5m";
48 
49  double lambda = 1.0;
50  double delta = 0.01;
51  double height = 1.0;
52  int dim = 2;
53 
54  CHKERR PetscOptionsBegin(PETSC_COMM_WORLD, "", "ADD_PRISMS_LAYER", "none");
55 
56  CHKERR PetscOptionsString("-my_file", "mesh file name", "", "mesh.h5m",
57  mesh_file_name, 255, &flg_mesh_file);
58  CHKERR PetscOptionsString("-my_out_file", "out file name", "", "out.h5m",
59  out_file_name, 255, &flg_out_file);
60 
61  CHKERR PetscOptionsInt("-my_dim", "dimension (2 or 3)", "", dim, &dim,
62  PETSC_NULL);
63 
64  CHKERR PetscOptionsReal("-my_lambda", "roughness wavelength", "", lambda,
65  &lambda, PETSC_NULL);
66  CHKERR PetscOptionsReal("-my_delta", "roughness amplitude", "", delta,
67  &delta, PETSC_NULL);
68  CHKERR PetscOptionsReal("-my_height", "vertical dimension of the mesh", "",
69  height, &height, PETSC_NULL);
70 
71  int ierr = PetscOptionsEnd();
72  CHKERRG(ierr);
73 
74  if (flg_mesh_file != PETSC_TRUE) {
75  SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
76  }
77 
78  // Read mesh to MOAB
79  const char *option;
80  option = ""; //"PARALLEL=BCAST;";//;DEBUG_IO";
81  CHKERR moab.load_file(mesh_file_name, 0, option);
82  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
83  if (pcomm == NULL)
84  pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
85 
86  // Create MoFEM (Joseph) databas
87  MoFEM::Core core(moab);
88  MoFEM::Interface &m_field = core;
89 
90  Range tets, tris, nodes, all_nodes;
92  if (bit->getName().compare(0, 11, "MAT_ELASTIC") == 0) {
93  const int id = bit->getMeshsetId();
94  if (id == 1) {
95  CHKERR m_field.get_moab().get_entities_by_dimension(bit->getMeshset(),
96  3, tets, true);
97  CHKERR m_field.get_moab().get_entities_by_dimension(bit->getMeshset(),
98  2, tris, true);
99  }
100  }
101  }
102 
103  CHKERR m_field.get_moab().get_connectivity(tets, nodes);
104  all_nodes.merge(nodes);
105  nodes.clear();
106  CHKERR m_field.get_moab().get_connectivity(tris, nodes);
107  all_nodes.merge(nodes);
108 
109  double coords[3];
110  for (Range::iterator nit = all_nodes.begin(); nit != all_nodes.end();
111  nit++) {
112  CHKERR moab.get_coords(&*nit, 1, coords);
113  double x = coords[0];
114  double y = coords[1];
115  double z = coords[2];
116  double coef = (height + z) / height;
117  switch (dim) {
118  case 2:
119  coords[2] -= coef * delta * (1. - cos(2. * M_PI * x / lambda));
120  break;
121  case 3:
122  coords[2] -=
123  coef * delta *
124  (1. - cos(2. * M_PI * x / lambda) * cos(2. * M_PI * y / lambda));
125  break;
126  default:
127  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
128  "Wrong dimension = %d", dim);
129  }
130 
131  CHKERR moab.set_coords(&*nit, 1, coords);
132  }
133 
134  EntityHandle rootset = moab.get_root_set();
135  CHKERR moab.write_file(out_file_name, "MOAB", "", &rootset, 1);
136  MOFEM_LOG_C("WORLD", Sev::inform, "Write file %s\n",
137  string(out_file_name).c_str());
138  }
139  CATCH_ERRORS;
140 
142  return 0;
143 }

Variable Documentation

◆ debug

int debug = 1
static
Examples
wavy_surface.cpp.

Definition at line 30 of file wavy_surface.cpp.

◆ help

char help[] = "...\n\n"
static
Examples
wavy_surface.cpp.

Definition at line 29 of file wavy_surface.cpp.

MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:228
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
EntityHandle
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
out_file_name
char out_file_name[255]
Definition: initial_diffusion.cpp:53
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
help
static char help[]
Definition: wavy_surface.cpp:29
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
delta
static constexpr double delta
Definition: prism_elements_from_surface.cpp:18
MOFEM_LOG_C
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:22
Range
MoFEM::CoreTmp< 0 >::Initialize
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
_IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
Definition: MeshsetsManager.hpp:71
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
BLOCKSET
@ BLOCKSET
Definition: definitions.h:161
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
lambda
static double lambda
Definition: incompressible_elasticity.cpp:199
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496